mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge remote-tracking branch 'refs/remotes/commons-app/master'
This commit is contained in:
commit
f8f1f5e612
2 changed files with 27 additions and 18 deletions
|
|
@ -126,18 +126,15 @@ public class ContributionsActivity
|
|||
setContentView(R.layout.activity_contributions);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
// Activity can call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findFragmentById()
|
||||
contributionsList = (ContributionsListFragment)getSupportFragmentManager().findFragmentById(R.id.contributionsListFragment);
|
||||
// Activity can call methods in the fragment by acquiring a
|
||||
// reference to the Fragment from FragmentManager, using findFragmentById()
|
||||
contributionsList = (ContributionsListFragment)getSupportFragmentManager()
|
||||
.findFragmentById(R.id.contributionsListFragment);
|
||||
|
||||
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
||||
if (savedInstanceState != null) {
|
||||
mediaDetails = (MediaDetailPagerFragment)getSupportFragmentManager().findFragmentById(R.id.contributionsFragmentContainer);
|
||||
// onBackStackChanged uses mediaDetails.isVisible() but this returns false now.
|
||||
// Use the saved value from before pause or orientation change.
|
||||
if (mediaDetails != null && savedInstanceState.getBoolean("mediaDetailsVisible")) {
|
||||
// Feels awful that we have to reset this manually!
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
mediaDetails = (MediaDetailPagerFragment)getSupportFragmentManager()
|
||||
.findFragmentById(R.id.contributionsFragmentContainer);
|
||||
}
|
||||
requestAuthToken();
|
||||
initDrawer();
|
||||
|
|
@ -241,7 +238,10 @@ public class ContributionsActivity
|
|||
getSupportActionBar().setSubtitle(getResources()
|
||||
.getString(R.string.contributions_subtitle_zero));
|
||||
} else {
|
||||
getSupportActionBar().setSubtitle(getResources().getQuantityString(R.plurals.contributions_subtitle, cursor.getCount(), cursor.getCount()));
|
||||
getSupportActionBar().setSubtitle(getResources()
|
||||
.getQuantityString(R.plurals.contributions_subtitle,
|
||||
cursor.getCount(),
|
||||
cursor.getCount()));
|
||||
}
|
||||
|
||||
contributionsList.clearSyncMessage();
|
||||
|
|
@ -314,11 +314,7 @@ public class ContributionsActivity
|
|||
|
||||
@Override
|
||||
public void onBackStackChanged() {
|
||||
if(mediaDetails != null && mediaDetails.isVisible()) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
} else {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
initBackButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import android.os.Bundle;
|
|||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.hamburger.HamburgerMenuContainer;
|
||||
import fr.free.nrw.commons.hamburger.NavigationBaseFragment;
|
||||
|
|
@ -26,6 +26,8 @@ public class NavigationBaseActivity extends BaseActivity implements HamburgerMen
|
|||
@BindView(R.id.drawer_pane)
|
||||
RelativeLayout drawerPane;
|
||||
|
||||
private ActionBarDrawerToggle toggle;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -40,10 +42,10 @@ public class NavigationBaseActivity extends BaseActivity implements HamburgerMen
|
|||
baseFragment);
|
||||
}
|
||||
|
||||
private void initSubviews() {
|
||||
public void initSubviews() {
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,
|
||||
toggle = new ActionBarDrawerToggle(this,
|
||||
drawerLayout,
|
||||
toolbar,
|
||||
R.string.navigation_drawer_open,
|
||||
|
|
@ -54,6 +56,17 @@ public class NavigationBaseActivity extends BaseActivity implements HamburgerMen
|
|||
setDrawerPaneWidth();
|
||||
}
|
||||
|
||||
public void initBackButton() {
|
||||
int backStackEntryCount = getSupportFragmentManager().getBackStackEntryCount();
|
||||
toggle.setDrawerIndicatorEnabled(backStackEntryCount == 0);
|
||||
toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setDrawerPaneWidth() {
|
||||
ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
|
||||
// set width to lowerBound of 80% of the screen size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue