mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fixed #4836 & #4840 Added the functionality of cancel upload and also solved the small bug of pausing upload (#4843)
* Fixed #4836 & #4840 * Added Pausing PopUp * Closing Pausing PopUp exactly when pause button disappears * Managed to display the Pausing Upload * Added the Pausing Dialog Using Progress Bar * Added the Pausing Dialog Using Progress Bar * Added Required Changes * Added Required Changes-wording change * Added Required Changes-wording change
This commit is contained in:
parent
f1169eaff9
commit
9431e3770c
5 changed files with 62 additions and 9 deletions
|
|
@ -18,6 +18,7 @@ import android.os.Build;
|
|||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.multidex.BuildConfig;
|
||||
import androidx.multidex.MultiDexApplication;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.imagepipeline.core.ImagePipeline;
|
||||
|
|
@ -135,7 +136,7 @@ public class CommonsApplication extends MultiDexApplication {
|
|||
ContributionDao contributionDao;
|
||||
|
||||
/**
|
||||
* In memory list of contributios whose uploads ahve been paused by the user
|
||||
* In-memory list of contributions whose uploads have been paused by the user
|
||||
*/
|
||||
public static Map<String, Boolean> pauseUploads = new HashMap<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import android.widget.ProgressBar;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AlertDialog.Builder;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
|
@ -54,13 +56,23 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
private final CompositeDisposable compositeDisposable = new CompositeDisposable();
|
||||
private final MediaClient mediaClient;
|
||||
private boolean isWikipediaButtonDisplayed;
|
||||
private AlertDialog pausingPopUp;
|
||||
private View parent;
|
||||
|
||||
ContributionViewHolder(final View parent, final Callback callback,
|
||||
final MediaClient mediaClient) {
|
||||
super(parent);
|
||||
this.parent = parent;
|
||||
this.mediaClient = mediaClient;
|
||||
ButterKnife.bind(this, parent);
|
||||
this.callback = callback;
|
||||
|
||||
/* Set a dialog indicating that the upload is being paused. This is needed because pausing
|
||||
an upload might take a dozen seconds. */
|
||||
AlertDialog.Builder builder = new Builder(parent.getContext());
|
||||
builder.setCancelable(false);
|
||||
builder.setView(R.layout.progress_dialog);
|
||||
pausingPopUp = builder.create();
|
||||
}
|
||||
|
||||
public void init(final int position, final Contribution contribution) {
|
||||
|
|
@ -105,8 +117,8 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
break;
|
||||
case Contribution.STATE_QUEUED:
|
||||
case Contribution.STATE_QUEUED_LIMITED_CONNECTION_MODE:
|
||||
stateView.setVisibility(View.VISIBLE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
stateView.setVisibility(View.VISIBLE);
|
||||
stateView.setText(R.string.contribution_state_queued);
|
||||
imageOptions.setVisibility(View.GONE);
|
||||
break;
|
||||
|
|
@ -128,14 +140,17 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
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();
|
||||
if(pausingPopUp.isShowing()){
|
||||
pausingPopUp.hide();
|
||||
}
|
||||
break;
|
||||
case Contribution.STATE_FAILED:
|
||||
stateView.setVisibility(View.VISIBLE);
|
||||
|
|
@ -245,6 +260,7 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
|
||||
private void pause() {
|
||||
pausingPopUp.show();
|
||||
callback.pauseUpload(contribution);
|
||||
setResume();
|
||||
}
|
||||
|
|
@ -254,7 +270,7 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
*/
|
||||
private void setPaused() {
|
||||
pauseResumeButton.setImageResource(R.drawable.pause_icon);
|
||||
pauseResumeButton.setTag(R.string.pause);
|
||||
pauseResumeButton.setTag(parent.getContext().getString(R.string.pause));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -262,6 +278,6 @@ public class ContributionViewHolder extends RecyclerView.ViewHolder {
|
|||
*/
|
||||
private void setResume() {
|
||||
pauseResumeButton.setImageResource(R.drawable.play_icon);
|
||||
pauseResumeButton.setTag(R.string.resume);
|
||||
pauseResumeButton.setTag(parent.getContext().getString(R.string.resume));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
private int contributionsSize;
|
||||
String userName;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable @org.jetbrains.annotations.Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
@ -389,7 +388,18 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
|
||||
@Override
|
||||
public void deleteUpload(final Contribution contribution) {
|
||||
DialogUtil.showAlertDialog(getActivity(),
|
||||
String.format(getString(R.string.cancelling_upload),
|
||||
Locale.getDefault().getDisplayLanguage()),
|
||||
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
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
23
app/src/main/res/layout/progress_dialog.xml
Normal file
23
app/src/main/res/layout/progress_dialog.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:paddingVertical="20dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="0.6" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pausing_upload"
|
||||
android:layout_weight="1.5"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -330,6 +330,7 @@
|
|||
<string name="error_fetching_nearby_monuments">Error fetching nearby monuments.</string>
|
||||
<string name="no_recent_searches">No recent searches</string>
|
||||
<string name="delete_recent_searches_dialog">Are you sure you want to clear your search history?</string>
|
||||
<string name="cancel_upload_dialog">Are you sure you want to cancel this upload?</string>
|
||||
<string name="delete_search_dialog">Do you want to delete this search?</string>
|
||||
<string name="search_history_deleted">Search history deleted</string>
|
||||
|
||||
|
|
@ -625,6 +626,8 @@ Upload your first media by tapping on the add button.</string>
|
|||
<string name="quality_images_info">Quality images are diagrams or photographs that meet certain quality standards (which are mostly technical in nature) and are valuable for Wikimedia projects</string>
|
||||
<string name="resuming_upload">Resuming upload…</string>
|
||||
<string name="pausing_upload">Pausing upload…</string>
|
||||
<string name="cancelling_upload">Cancelling upload…</string>
|
||||
<string name="cancel_upload">Cancel Upload</string>
|
||||
<string name="limited_connection_explanation">You have enabled limited connection mode. All uploads are paused and will resume once you disable this mode.</string>
|
||||
<string name="limited_connection_is_on">Limited connection mode is on.</string>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue