mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +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
				
			
		|  | @ -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) { | ||||
|         contributionsListPresenter.deleteUpload(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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Arin Modi
						Arin Modi