Skip to content

Commit 75cbd0a

Browse files
authored
Merge pull request commons-app#638 from maskaravivek/shareBack
Fix back button issue in ShareActivity
2 parents 95ecfbd + 4cb6fb8 commit 75cbd0a

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
498498
}
499499
}
500500

501-
private void backButtonDialog() {
501+
public void backButtonDialog() {
502502
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
503503

504504
builder.setMessage("Are you sure you want to go back? The image will not have any categories saved.")

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ protected void onCreate(Bundle savedInstanceState) {
138138
}
139139
requestAuthToken();
140140
initDrawer();
141+
setTitle(getString(R.string.title_activity_contributions));
141142
}
142143

143144
@Override

app/src/main/java/fr/free/nrw/commons/theme/NavigationBaseActivity.java

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ public void onClick(View v) {
6767
});
6868
}
6969

70+
public void initBack() {
71+
setSupportActionBar(toolbar);
72+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
73+
getSupportActionBar().setDisplayShowHomeEnabled(true);
74+
}
75+
7076
private void setDrawerPaneWidth() {
7177
ViewGroup.LayoutParams params = drawerPane.getLayoutParams();
7278
// set width to lowerBound of 80% of the screen size

app/src/main/java/fr/free/nrw/commons/upload/ShareActivity.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void onCreate(Bundle savedInstanceState) {
219219
uploadController = new UploadController(this);
220220
setContentView(R.layout.activity_share);
221221
ButterKnife.bind(this);
222-
initDrawer();
222+
initBack();
223223
app = CommonsApplication.getInstance();
224224
backgroundImageView = (SimpleDraweeView)findViewById(R.id.backgroundImage);
225225

@@ -444,7 +444,11 @@ protected void onDestroy() {
444444
public boolean onOptionsItemSelected(MenuItem item) {
445445
switch (item.getItemId()) {
446446
case android.R.id.home:
447-
NavUtils.navigateUpFromSameTask(this);
447+
if(categorizationFragment!=null && categorizationFragment.isVisible()) {
448+
categorizationFragment.backButtonDialog();
449+
} else {
450+
onBackPressed();
451+
}
448452
return true;
449453
}
450454
return super.onOptionsItemSelected(item);

0 commit comments

Comments
 (0)