Fix back button issue in ShareActivity

This commit is contained in:
maskara 2017-05-20 11:35:49 +02:00
parent 95ecfbd3c2
commit 4cb6fb86f8
4 changed files with 14 additions and 3 deletions

View file

@ -498,7 +498,7 @@ public class CategorizationFragment extends Fragment {
} }
} }
private void backButtonDialog() { public void backButtonDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("Are you sure you want to go back? The image will not have any categories saved.") builder.setMessage("Are you sure you want to go back? The image will not have any categories saved.")

View file

@ -138,6 +138,7 @@ public class ContributionsActivity
} }
requestAuthToken(); requestAuthToken();
initDrawer(); initDrawer();
setTitle(getString(R.string.title_activity_contributions));
} }
@Override @Override

View file

@ -67,6 +67,12 @@ public class NavigationBaseActivity extends BaseActivity implements HamburgerMen
}); });
} }
public void initBack() {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
private void setDrawerPaneWidth() { private void setDrawerPaneWidth() {
ViewGroup.LayoutParams params = drawerPane.getLayoutParams(); ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
// set width to lowerBound of 80% of the screen size // set width to lowerBound of 80% of the screen size

View file

@ -219,7 +219,7 @@ public class ShareActivity
uploadController = new UploadController(this); uploadController = new UploadController(this);
setContentView(R.layout.activity_share); setContentView(R.layout.activity_share);
ButterKnife.bind(this); ButterKnife.bind(this);
initDrawer(); initBack();
app = CommonsApplication.getInstance(); app = CommonsApplication.getInstance();
backgroundImageView = (SimpleDraweeView)findViewById(R.id.backgroundImage); backgroundImageView = (SimpleDraweeView)findViewById(R.id.backgroundImage);
@ -444,7 +444,11 @@ public class ShareActivity
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
NavUtils.navigateUpFromSameTask(this); if(categorizationFragment!=null && categorizationFragment.isVisible()) {
categorizationFragment.backButtonDialog();
} else {
onBackPressed();
}
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);