mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 23:03:00 +00:00 
			
		
		
		
	Moved the 'Remove Watched' button to the three dot menu button.
This commit is contained in:
		| @@ -8,6 +8,9 @@ import android.os.Parcelable; | ||||
| import android.text.TextUtils; | ||||
| import android.util.Log; | ||||
| import android.view.LayoutInflater; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuInflater; | ||||
| import android.view.MenuItem; | ||||
| import android.view.View; | ||||
| import android.view.ViewGroup; | ||||
| import android.widget.EditText; | ||||
| @@ -76,7 +79,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|     private View headerPlayAllButton; | ||||
|     private View headerPopupButton; | ||||
|     private View headerBackgroundButton; | ||||
|     private View headerRemoveWatchedButton; | ||||
|  | ||||
|     private ItemTouchHelper itemTouchHelper; | ||||
|  | ||||
| @@ -153,7 +155,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|         headerPlayAllButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_all_button); | ||||
|         headerPopupButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_popup_button); | ||||
|         headerBackgroundButton = headerRootLayout.findViewById(R.id.playlist_ctrl_play_bg_button); | ||||
|         headerRemoveWatchedButton = headerRootLayout.findViewById(R.id.playlist_ctrl_remove_watched_button); | ||||
|  | ||||
|         return headerRootLayout; | ||||
|     } | ||||
| @@ -252,6 +253,14 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|         saveImmediate(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | ||||
|         if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + | ||||
|                 "], inflater = [" + inflater + "]"); | ||||
|         super.onCreateOptionsMenu(menu, inflater); | ||||
|         inflater.inflate(R.menu.menu_local_playlist, menu); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onDestroyView() { | ||||
|         super.onDestroyView(); | ||||
| @@ -268,9 +277,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|         if (headerPopupButton != null) { | ||||
|             headerPopupButton.setOnClickListener(null); | ||||
|         } | ||||
|         if (headerRemoveWatchedButton != null) { | ||||
|             headerRemoveWatchedButton.setOnClickListener(null); | ||||
|         } | ||||
|  | ||||
|         if (databaseSubscription != null) { | ||||
|             databaseSubscription.cancel(); | ||||
| @@ -342,6 +348,20 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         switch (item.getItemId()) { | ||||
|             case R.id.menu_item_removeWatched: | ||||
|                 //Solution, Scorched Earth, Copy non duplicates, clear playlist, then copy back over | ||||
|                 //Other options didn't work as intended, or crashed. Like deleteItem(playlist_item) crashes when called in this function. | ||||
|                 new RemoveWatchedStreams().execute(); | ||||
|                 break; | ||||
|             default: | ||||
|                 return super.onOptionsItemSelected(item); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleResult(@NonNull final List<PlaylistStreamEntry> result) { | ||||
|         super.handleResult(result); | ||||
| @@ -369,13 +389,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|                 NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(), false)); | ||||
|         headerBackgroundButton.setOnClickListener(view -> | ||||
|                 NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue(), false)); | ||||
|         headerRemoveWatchedButton.setOnClickListener( | ||||
|                 view -> { | ||||
|                     //Solution, Scorched Earth, Copy non duplicates, clear playlist, then copy back over | ||||
|                     //Other options didn't work as intended, or crashed. Like deleteItem(playlist_item) crashes when called in this function. | ||||
|                     new RemoveWatchedStreams().execute(); | ||||
|                 } | ||||
|         ); | ||||
|  | ||||
|         headerPopupButton.setOnLongClickListener(view -> { | ||||
|             NavigationHelper.enqueueOnPopupPlayer(activity, getPlayQueue(), true); | ||||
| @@ -706,7 +719,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|     private class RemoveWatchedStreams extends AsyncTask<String, Long, Long> { | ||||
|         List<PlaylistStreamEntry> localItems = new ArrayList<>(); | ||||
|         Long RemovedItemCount = 0l; | ||||
|         boolean thumbNailVideoRemoved = false; | ||||
|         boolean thumbnailVideoRemoved = false; | ||||
|  | ||||
|         @Override | ||||
|         protected void onPreExecute() { | ||||
| @@ -749,7 +762,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|                     RemovedItemCount++; | ||||
|                     if(playlistManager.getPlaylistThumbnail(playlistId).equals(playlist_item.thumbnailUrl)) | ||||
|                     { | ||||
|                         thumbNailVideoRemoved = true; | ||||
|                         thumbnailVideoRemoved = true; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
| @@ -762,13 +775,17 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt | ||||
|             itemListAdapter.addItems(localItems); | ||||
|             localItems.clear(); | ||||
|  | ||||
|             if (thumbNailVideoRemoved) | ||||
|             if (thumbnailVideoRemoved) | ||||
|                 updateThumbnailUrl(); | ||||
|  | ||||
|             setVideoCount(itemListAdapter.getItemsList().size()); | ||||
|             int amountOfVideos = itemListAdapter.getItemsList().size(); | ||||
|             setVideoCount(amountOfVideos); | ||||
|  | ||||
|             saveChanges(); | ||||
|             hideLoading(); | ||||
|  | ||||
|             if(amountOfVideos == 0) | ||||
|                 showEmptyState(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,7 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
|  | ||||
|  | ||||
|  | ||||
| <LinearLayout | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="wrap_content" | ||||
| @@ -30,6 +32,7 @@ | ||||
|             android:drawableStart="?attr/audio"/> | ||||
|     </LinearLayout> | ||||
|  | ||||
|  | ||||
|     <View android:id="@+id/anchorLeft" | ||||
|         android:layout_width="1dp" | ||||
|         android:layout_height="match_parent" | ||||
| @@ -56,7 +59,7 @@ | ||||
|             android:textColor="?attr/colorAccent"/> | ||||
|     </LinearLayout> | ||||
|  | ||||
|     <View android:id="@+id/anchorMiddle" | ||||
|     <View android:id="@+id/anchorRight" | ||||
|         android:layout_width="1dp" | ||||
|         android:layout_height="match_parent" | ||||
|         android:clickable="false" | ||||
| @@ -84,32 +87,4 @@ | ||||
|             android:drawableLeft="?attr/popup" | ||||
|             android:drawableStart="?attr/popup"/> | ||||
|     </LinearLayout> | ||||
|  | ||||
|     <View android:id="@+id/anchorRight" | ||||
|         android:layout_width="1dp" | ||||
|         android:layout_height="match_parent" | ||||
|         android:clickable="false" | ||||
|         android:layout_marginBottom="@dimen/playlist_ctrl_seperator_margin" | ||||
|         android:layout_marginTop="@dimen/playlist_ctrl_seperator_margin" | ||||
|         android:background="?attr/colorAccent"/> | ||||
|  | ||||
|     <LinearLayout | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="match_parent" | ||||
|         android:layout_weight="1.2" | ||||
|         android:gravity="center" | ||||
|         android:clickable="true" | ||||
|         android:focusable="true" | ||||
|         android:background="?attr/selectableItemBackground" | ||||
|         android:id="@+id/playlist_ctrl_remove_watched_button"> | ||||
|  | ||||
|         <TextView | ||||
|             android:layout_width="wrap_content" | ||||
|             android:layout_height="wrap_content" | ||||
|             android:paddingLeft="15px" | ||||
|             android:gravity="center_vertical" | ||||
|             android:text="@string/remove_watched" | ||||
|             android:textColor="?attr/colorAccent" | ||||
|             android:textSize="@dimen/channel_rss_title_size" /> | ||||
|     </LinearLayout> | ||||
| </LinearLayout> | ||||
|   | ||||
							
								
								
									
										10
									
								
								app/src/main/res/menu/menu_local_playlist.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/src/main/res/menu/menu_local_playlist.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     xmlns:tools="http://schemas.android.com/tools"> | ||||
|  | ||||
|     <item | ||||
|         android:id="@+id/menu_item_removeWatched" | ||||
|         android:title="@string/remove_watched" | ||||
|         app:showAsAction="never"/> | ||||
| </menu> | ||||
		Reference in New Issue
	
	Block a user
	 Grady Clark
					Grady Clark