-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixed #4836 & #4840 Added the functionality of cancel upload and also solved the small bug of pausing upload #4843
Changes from 2 commits
45c5edd
3a5fd20
d14ef22
93f26fe
04ba8e1
6707bec
d4cd2c3
b75dc81
f151111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,14 +128,14 @@ public void init(final int position, final Contribution contribution) { | |
} | ||
break; | ||
case Contribution.STATE_PAUSED: | ||
progressView.setVisibility(View.GONE); | ||
stateView.setVisibility(View.VISIBLE); | ||
stateView.setText(R.string.paused); | ||
setResume(); | ||
progressView.setVisibility(View.GONE); | ||
cancelButton.setVisibility(View.GONE); | ||
cancelButton.setVisibility(View.VISIBLE); | ||
retryButton.setVisibility(View.GONE); | ||
pauseResumeButton.setVisibility(View.VISIBLE); | ||
imageOptions.setVisibility(View.VISIBLE); | ||
setResume(); | ||
break; | ||
case Contribution.STATE_FAILED: | ||
stateView.setVisibility(View.VISIBLE); | ||
|
@@ -254,14 +254,14 @@ private void pause() { | |
*/ | ||
private void setPaused() { | ||
pauseResumeButton.setImageResource(R.drawable.pause_icon); | ||
pauseResumeButton.setTag(R.string.pause); | ||
pauseResumeButton.setTag("pause"); | ||
4D17Y4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/** | ||
* Update pause/resume button to show resume state | ||
*/ | ||
private void setResume() { | ||
pauseResumeButton.setImageResource(R.drawable.play_icon); | ||
pauseResumeButton.setTag(R.string.resume); | ||
pauseResumeButton.setTag("resume"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really needed? |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import static android.view.View.VISIBLE; | ||
import static fr.free.nrw.commons.di.NetworkingModule.NAMED_LANGUAGE_WIKI_PEDIA_WIKI_SITE; | ||
|
||
import android.app.ProgressDialog; | ||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
import android.net.Uri; | ||
|
@@ -115,6 +116,8 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl | |
private int contributionsSize; | ||
String userName; | ||
|
||
private ProgressDialog pausingPopUp; | ||
|
||
|
||
@Override | ||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) { | ||
|
@@ -138,6 +141,10 @@ public View onCreateView( | |
ButterKnife.bind(this, view); | ||
contributionsListPresenter.onAttachView(this); | ||
|
||
// setting the pausingPopUp properties | ||
pausingPopUp = new ProgressDialog(getContext()); | ||
pausingPopUp.setMessage(getString(R.string.pausing_upload)); | ||
|
||
if (Objects.equals(sessionManager.getUserName(), userName)) { | ||
tvContributionsOfUser.setVisibility(GONE); | ||
fab_layout.setVisibility(VISIBLE); | ||
|
@@ -220,6 +227,10 @@ public void onItemRangeChanged(final int positionStart, final int itemCount) { | |
if (callback != null) { | ||
callback.viewPagerNotifyDataSetChanged(); | ||
} | ||
// check for the pausingPopUp if it's visible then hide | ||
if(pausingPopUp.isShowing()){ | ||
pausingPopUp.hide(); | ||
} | ||
} | ||
}); | ||
|
||
|
@@ -389,7 +400,17 @@ public void retryUpload(final Contribution contribution) { | |
|
||
@Override | ||
public void deleteUpload(final Contribution contribution) { | ||
contributionsListPresenter.deleteUpload(contribution); | ||
DialogUtil.showAlertDialog(getActivity(), | ||
"Cancel Upload", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind reminding me what this string is used for, and why is does not need localization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this string is the title of dialog util, And I forgot to do localization |
||
String.format(getString(R.string.cancel_upload_dialog), | ||
Locale.getDefault().getDisplayLanguage()), | ||
"YES", "NO", | ||
() -> { | ||
ViewUtil.showShortToast(getContext(), R.string.cancelling_upload); | ||
contributionsListPresenter.deleteUpload(contribution); | ||
}, () -> { | ||
///do nothing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
} | ||
|
||
@Override | ||
|
@@ -424,6 +445,7 @@ public void addImageToWikipedia(Contribution contribution) { | |
*/ | ||
@Override | ||
public void pauseUpload(Contribution contribution) { | ||
pausingPopUp.show(); | ||
ViewUtil.showShortToast(getContext(), R.string.pausing_upload); | ||
callback.pauseUpload(contribution); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for the future: Thanks for fixing these! Please do not hesitate to make such changes in a separate pull request, so that this pull request does not contain unrelated changes :-)
By the way:
In memory -> In-memory
contribution -> contributions