mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	Add confirmation button before deleting all files.
Co-authored-by: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com>
This commit is contained in:
		| @@ -192,14 +192,7 @@ public class MissionsFragment extends Fragment { | |||||||
|                 updateList(); |                 updateList(); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.clear_list: |             case R.id.clear_list: | ||||||
|                 AlertDialog.Builder prompt = new AlertDialog.Builder(mContext); |                 showClearDownloadHistoryPrompt(); | ||||||
|                 prompt.setTitle(R.string.clear_download_history); |  | ||||||
|                 prompt.setMessage(R.string.confirm_prompt); |  | ||||||
|                 // Intentionally misusing button's purpose in order to achieve good order |  | ||||||
|                 prompt.setNegativeButton(R.string.clear_download_history, (dialog, which) -> mAdapter.clearFinishedDownloads(false)); |  | ||||||
|                 prompt.setPositiveButton(R.string.delete_downloaded_files, (dialog, which) -> mAdapter.clearFinishedDownloads(true)); |  | ||||||
|                 prompt.setNeutralButton(R.string.cancel, null); |  | ||||||
|                 prompt.create().show(); |  | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.start_downloads: |             case R.id.start_downloads: | ||||||
|                 mBinder.getDownloadManager().startAllMissions(); |                 mBinder.getDownloadManager().startAllMissions(); | ||||||
| @@ -212,6 +205,32 @@ public class MissionsFragment extends Fragment { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public void showClearDownloadHistoryPrompt() { | ||||||
|  |         // ask the user whether he wants to just clear history or instead delete files on disk | ||||||
|  |         new AlertDialog.Builder(mContext) | ||||||
|  |                 .setTitle(R.string.clear_download_history) | ||||||
|  |                 .setMessage(R.string.confirm_prompt) | ||||||
|  |                 // Intentionally misusing buttons' purpose in order to achieve good order | ||||||
|  |                 .setNegativeButton(R.string.clear_download_history, | ||||||
|  |                         (dialog, which) -> mAdapter.clearFinishedDownloads(false)) | ||||||
|  |                 .setNeutralButton(R.string.cancel, null) | ||||||
|  |                 .setPositiveButton(R.string.delete_downloaded_files, | ||||||
|  |                         (dialog, which) -> showDeleteDownloadedFilesConfirmationPrompt()) | ||||||
|  |                 .create() | ||||||
|  |                 .show(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void showDeleteDownloadedFilesConfirmationPrompt() { | ||||||
|  |         // make sure the user confirms once more before deleting files on disk | ||||||
|  |         new AlertDialog.Builder(mContext) | ||||||
|  |                 .setTitle(R.string.delete_downloaded_files_confirm) | ||||||
|  |                 .setNegativeButton(R.string.cancel, null) | ||||||
|  |                 .setPositiveButton(R.string.ok, | ||||||
|  |                         (dialog, which) -> mAdapter.clearFinishedDownloads(true)) | ||||||
|  |                 .create() | ||||||
|  |                 .show(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     private void updateList() { |     private void updateList() { | ||||||
|         if (mLinear) { |         if (mLinear) { | ||||||
|             mList.setLayoutManager(mLinearManager); |             mList.setLayoutManager(mLinearManager); | ||||||
|   | |||||||
| @@ -580,6 +580,7 @@ | |||||||
|     <string name="clear_download_history">Clear download history</string> |     <string name="clear_download_history">Clear download history</string> | ||||||
|     <string name="confirm_prompt">Do you want to clear your download history or delete all downloaded files?</string> |     <string name="confirm_prompt">Do you want to clear your download history or delete all downloaded files?</string> | ||||||
|     <string name="delete_downloaded_files">Delete downloaded files</string> |     <string name="delete_downloaded_files">Delete downloaded files</string> | ||||||
|  |     <string name="delete_downloaded_files_confirm">Erase all downloaded files from disk?</string> | ||||||
|     <plurals name="deleted_downloads_toast"> |     <plurals name="deleted_downloads_toast"> | ||||||
|         <item quantity="one">Deleted %1$s download</item> |         <item quantity="one">Deleted %1$s download</item> | ||||||
|         <item quantity="other">Deleted %1$s downloads</item> |         <item quantity="other">Deleted %1$s downloads</item> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Spinhit
					Spinhit