Skip to content

Fix back button issue in ShareActivity #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
}
}

private void backButtonDialog() {
public void backButtonDialog() {
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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
requestAuthToken();
initDrawer();
setTitle(getString(R.string.title_activity_contributions));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public void onClick(View v) {
});
}

public void initBack() {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}

private void setDrawerPaneWidth() {
ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
// set width to lowerBound of 80% of the screen size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void onCreate(Bundle savedInstanceState) {
uploadController = new UploadController(this);
setContentView(R.layout.activity_share);
ButterKnife.bind(this);
initDrawer();
initBack();
app = CommonsApplication.getInstance();
backgroundImageView = (SimpleDraweeView)findViewById(R.id.backgroundImage);

Expand Down Expand Up @@ -444,7 +444,11 @@ protected void onDestroy() {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
if(categorizationFragment!=null && categorizationFragment.isVisible()) {
categorizationFragment.backButtonDialog();
} else {
onBackPressed();
}
return true;
}
return super.onOptionsItemSelected(item);
Expand Down