Skip to content

Commit 1bc0b78

Browse files
committed
Fix which menu items get displayed at which state
Only show actions that are applicable to each state. Also clarify that 'abort' actually only 'deleted' failed uploads. We have no way to abort an in-progress upload yet Change-Id: I2c18273e603e3ca6b1e03f83b7404e96b6d8bad0
1 parent b7c1f44 commit 1bc0b78

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

commons/res/menu/fragment_image_detail.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<item android:id="@+id/menu_retry_current_image"
2020
android:showAsAction="ifRoom|withText"
2121
android:icon="@android:drawable/ic_menu_revert"
22-
android:title="@string/menu_retry"
22+
android:title="@string/menu_retry_upload"
2323
android:visible="false"
2424
android:enabled="false"
2525
/>
26-
<item android:id="@+id/menu_abort_current_image"
26+
<item android:id="@+id/menu_cancel_current_image"
2727
android:showAsAction="never"
2828
android:icon="@android:drawable/ic_menu_delete"
29-
android:title="@string/menu_abort"
29+
android:title="@string/menu_cancel_upload"
3030
android:visible="false"
3131
android:enabled="false"
3232
/>

commons/res/values-qq/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
<string name="menu_feedback">Menu item text that prompts user to send feedback to WMF via email</string>
7474
<string name="waiting_first_sync">Message shown on contributions list during first sync.</string>
7575
<string name="no_uploads_yet">Message shown on contribution list during non-first sync if no uploads present.</string>
76-
<string name="menu_retry">Menu item text prompting user to retry a failed upload.
76+
<string name="menu_retry_upload">Menu item text prompting user to retry a failed upload.
7777
{{Identical|Retry}}</string>
78-
<string name="menu_abort">Menu item text prompting user to abort and delete a failed upload.</string>
78+
<string name="menu_cancel_upload">Menu item text prompting user to cancel and delete a failed upload.</string>
7979
<string name="share_license_summary">Text label telling user the license of the current upload in progress. %1$s refers to appropriate display text for the chosen CC license</string>
8080
<string name="menu_download">Menu item text prompting user to download a selected photo or media file locally.
8181
{{Identical|Download}}</string>

commons/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
<string name="waiting_first_sync">Waiting for first sync...</string>
8686
<string name="no_uploads_yet">You have not yet uploaded any photos.</string>
8787

88-
<string name="menu_retry">Retry</string>
89-
<string name="menu_abort">Abort</string>
88+
<string name="menu_retry_upload">Retry</string>
89+
<string name="menu_cancel_upload">Cancel</string>
9090

9191
<string name="share_license_summary">This image will be licensed under %1$s</string>
9292

commons/src/main/java/org/wikimedia/commons/media/MediaDetailPagerFragment.java

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
142142
((ContributionsActivity)getActivity()).retryUpload(pager.getCurrentItem());
143143
getSherlockActivity().getSupportFragmentManager().popBackStack();
144144
return true;
145-
case R.id.menu_abort_current_image:
145+
case R.id.menu_cancel_current_image:
146146
// todo: delete image
147147
((ContributionsActivity)getActivity()).deleteUpload(pager.getCurrentItem());
148148
getSherlockActivity().getSupportFragmentManager().popBackStack();
@@ -228,13 +228,37 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
228228
if(pager != null) {
229229
MediaDetailProvider provider = (MediaDetailProvider)getSherlockActivity();
230230
Media m = provider.getMediaAtPosition(pager.getCurrentItem());
231-
if(m != null && !m.getFilename().startsWith("File:")) {
232-
// Crude way of checking if the file has been successfully saved!
233-
menu.findItem(R.id.menu_browser_current_image).setEnabled(false).setVisible(false);
234-
menu.findItem(R.id.menu_share_current_image).setEnabled(false).setVisible(false);
235-
menu.findItem(R.id.menu_download_current_image).setEnabled(false).setVisible(false);
236-
menu.findItem(R.id.menu_retry_current_image).setEnabled(true).setVisible(true);
237-
menu.findItem(R.id.menu_abort_current_image).setEnabled(true).setVisible(true);
231+
if(m != null) {
232+
// Enable default set of actions, then re-enable different set of actions only if it is a failed contrib
233+
234+
if(m instanceof Contribution) {
235+
Contribution c = (Contribution)m;
236+
switch(c.getState()) {
237+
case Contribution.STATE_FAILED:
238+
menu.findItem(R.id.menu_retry_current_image).setEnabled(true).setVisible(true);
239+
menu.findItem(R.id.menu_cancel_current_image).setEnabled(true).setVisible(true);
240+
menu.findItem(R.id.menu_browser_current_image).setEnabled(false).setVisible(false);
241+
menu.findItem(R.id.menu_share_current_image).setEnabled(false).setVisible(false);
242+
menu.findItem(R.id.menu_download_current_image).setEnabled(false).setVisible(false);
243+
break;
244+
case Contribution.STATE_IN_PROGRESS:
245+
case Contribution.STATE_QUEUED:
246+
menu.findItem(R.id.menu_retry_current_image).setEnabled(false).setVisible(false);
247+
menu.findItem(R.id.menu_cancel_current_image).setEnabled(false).setVisible(false);
248+
menu.findItem(R.id.menu_browser_current_image).setEnabled(false).setVisible(false);
249+
menu.findItem(R.id.menu_share_current_image).setEnabled(false).setVisible(false);
250+
menu.findItem(R.id.menu_download_current_image).setEnabled(false).setVisible(false);
251+
break;
252+
case Contribution.STATE_COMPLETED:
253+
menu.findItem(R.id.menu_retry_current_image).setEnabled(false).setVisible(false);
254+
menu.findItem(R.id.menu_cancel_current_image).setEnabled(false).setVisible(false);
255+
menu.findItem(R.id.menu_browser_current_image).setEnabled(true).setVisible(true);
256+
menu.findItem(R.id.menu_share_current_image).setEnabled(true).setVisible(true);
257+
menu.findItem(R.id.menu_download_current_image).setEnabled(true).setVisible(true);
258+
break;
259+
}
260+
261+
}
238262
return;
239263
}
240264
}

0 commit comments

Comments
 (0)