From 065faf31b65b2ea5fbb901ab05d3c9cda5f3fd59 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 10:23:01 +0100 Subject: [PATCH 1/5] Add settings button back in dot menu --- app/src/main/res/menu/download_menu.xml | 3 +++ app/src/main/res/menu/menu_channel.xml | 17 ++++++++++++----- app/src/main/res/menu/menu_play_queue.xml | 9 +++++++-- app/src/main/res/menu/menu_playlist.xml | 17 ++++++++++++----- app/src/main/res/menu/video_detail_menu.xml | 7 +++++++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/app/src/main/res/menu/download_menu.xml b/app/src/main/res/menu/download_menu.xml index 27d9bfe29..c74dc804a 100644 --- a/app/src/main/res/menu/download_menu.xml +++ b/app/src/main/res/menu/download_menu.xml @@ -27,4 +27,7 @@ android:title="@string/clear_download_history" app:showAsAction="ifRoom" /> + diff --git a/app/src/main/res/menu/menu_channel.xml b/app/src/main/res/menu/menu_channel.xml index cc6a9ed71..f8449d8b5 100644 --- a/app/src/main/res/menu/menu_channel.xml +++ b/app/src/main/res/menu/menu_channel.xml @@ -4,11 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" tools:context=".fragments.list.impl.ChannelFragment"> - - + + + + diff --git a/app/src/main/res/menu/menu_play_queue.xml b/app/src/main/res/menu/menu_play_queue.xml index 5413794be..be6cea46c 100644 --- a/app/src/main/res/menu/menu_play_queue.xml +++ b/app/src/main/res/menu/menu_play_queue.xml @@ -10,13 +10,18 @@ android:visible="true" app:showAsAction="ifRoom"/> + + diff --git a/app/src/main/res/menu/menu_playlist.xml b/app/src/main/res/menu/menu_playlist.xml index 4583ff719..5e62d40a3 100644 --- a/app/src/main/res/menu/menu_playlist.xml +++ b/app/src/main/res/menu/menu_playlist.xml @@ -3,11 +3,6 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> - - + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/video_detail_menu.xml b/app/src/main/res/menu/video_detail_menu.xml index fd44c7860..65e7bc4da 100644 --- a/app/src/main/res/menu/video_detail_menu.xml +++ b/app/src/main/res/menu/video_detail_menu.xml @@ -14,8 +14,15 @@ android:title="@string/share" app:showAsAction="ifRoom"/> + + From c7b470553827c696465d5b6e5d9de3261177ee69 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 10:36:10 +0100 Subject: [PATCH 2/5] Implement Settings buttons --- .../schabi/newpipe/download/DownloadActivity.java | 8 +++++--- .../fragments/detail/VideoDetailFragment.java | 15 ++++++++++----- .../fragments/list/channel/ChannelFragment.java | 7 +++++-- .../fragments/list/playlist/PlaylistFragment.java | 7 +++++-- .../newpipe/player/ServicePlayerActivity.java | 3 +++ 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java index 00dd45ac9..2c54f75cf 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java @@ -12,6 +12,7 @@ import android.view.MenuItem; import android.view.ViewTreeObserver; import org.schabi.newpipe.R; +import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; import us.shandian.giga.service.DownloadManagerService; @@ -76,11 +77,12 @@ public class DownloadActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: { + case android.R.id.home: onBackPressed(); return true; - } - + case R.id.action_settings: + NavigationHelper.openSettings(this); + return true; default: return super.onOptionsItemSelected(item); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 7dd98003a..b28c71d72 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -600,22 +600,27 @@ public class VideoDetailFragment @Override public boolean onOptionsItemSelected(MenuItem item) { - if (isLoading.get()) { - // if is still loading block menu + int id = item.getItemId(); + if (id == R.id.action_settings) { + NavigationHelper.openSettings(requireContext()); + return true; + } + + if (isLoading.get()) { + // if still loading, block menu buttons related to video info return true; } - int id = item.getItemId(); switch (id) { case R.id.menu_item_share: { if (currentInfo != null) { - ShareUtils.shareUrl(this.getContext(), currentInfo.getName(), currentInfo.getOriginalUrl()); + ShareUtils.shareUrl(requireContext(), currentInfo.getName(), currentInfo.getOriginalUrl()); } return true; } case R.id.menu_item_openInBrowser: { if (currentInfo != null) { - ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl()); + ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl()); } return true; } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 7b7a08a48..4742fcca1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -175,17 +175,20 @@ public class ChannelFragment extends BaseListInfoFragment { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case R.id.action_settings: + NavigationHelper.openSettings(requireContext()); + break; case R.id.menu_item_rss: openRssFeed(); break; case R.id.menu_item_openInBrowser: if (currentInfo != null) { - ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl()); + ShareUtils.openUrlInBrowser(requireContext(), currentInfo.getOriginalUrl()); } break; case R.id.menu_item_share: if (currentInfo != null) { - ShareUtils.shareUrl(this.getContext(), name, currentInfo.getOriginalUrl()); + ShareUtils.shareUrl(requireContext(), name, currentInfo.getOriginalUrl()); } break; default: diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index 6941741af..a992cd7ba 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -222,11 +222,14 @@ public class PlaylistFragment extends BaseListInfoFragment { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case R.id.action_settings: + NavigationHelper.openSettings(requireContext()); + break; case R.id.menu_item_openInBrowser: - ShareUtils.openUrlInBrowser(this.getContext(), url); + ShareUtils.openUrlInBrowser(requireContext(), url); break; case R.id.menu_item_share: - ShareUtils.shareUrl(this.getContext(), name, url); + ShareUtils.shareUrl(requireContext(), name, url); break; case R.id.menu_item_bookmark: onBookmarkClicked(); diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 669d1c16c..aeba763be 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -156,6 +156,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity case android.R.id.home: finish(); return true; + case R.id.action_settings: + NavigationHelper.openSettings(this); + return true; case R.id.action_append_playlist: appendAllToPlaylist(); return true; From 8754cbb38ffac180ffe42543eb114da42e9c5c6f Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 11:12:22 +0100 Subject: [PATCH 3/5] Remove Settings button from download activity --- .../java/org/schabi/newpipe/download/DownloadActivity.java | 3 --- app/src/main/res/menu/download_menu.xml | 4 ---- 2 files changed, 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java index 2c54f75cf..de3df3527 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java @@ -80,9 +80,6 @@ public class DownloadActivity extends AppCompatActivity { case android.R.id.home: onBackPressed(); return true; - case R.id.action_settings: - NavigationHelper.openSettings(this); - return true; default: return super.onOptionsItemSelected(item); } diff --git a/app/src/main/res/menu/download_menu.xml b/app/src/main/res/menu/download_menu.xml index c74dc804a..d41434711 100644 --- a/app/src/main/res/menu/download_menu.xml +++ b/app/src/main/res/menu/download_menu.xml @@ -26,8 +26,4 @@ android:icon="?attr/ic_delete" android:title="@string/clear_download_history" app:showAsAction="ifRoom" /> - - From 6968dd266a6f8c0de34d9890efc3449f698d9f79 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 11:30:57 +0100 Subject: [PATCH 4/5] Remove empty about menu --- .../main/java/org/schabi/newpipe/about/AboutActivity.java | 7 ------- app/src/main/res/menu/menu_about.xml | 6 ------ 2 files changed, 13 deletions(-) delete mode 100644 app/src/main/res/menu/menu_about.xml diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index edfc54375..7fab44f8f 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -88,13 +88,6 @@ public class AboutActivity extends AppCompatActivity { } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_about, menu); - return true; - } - @Override public boolean onOptionsItemSelected(MenuItem item) { diff --git a/app/src/main/res/menu/menu_about.xml b/app/src/main/res/menu/menu_about.xml deleted file mode 100644 index dbe91a04f..000000000 --- a/app/src/main/res/menu/menu_about.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - From d65b8d7d18a953b98f11a7cdf9938d2516d96ed1 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 11:34:08 +0100 Subject: [PATCH 5/5] Address @mauriciocolli suggestions in #2960 Simplify code to enable history button --- .../main/java/org/schabi/newpipe/MainActivity.java | 12 +++--------- .../main/java/org/schabi/newpipe/util/Constants.java | 2 -- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 7cd620faa..29dde41c1 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -453,15 +453,9 @@ public class MainActivity extends AppCompatActivity { NavigationHelper.openMainActivity(this); } - if (sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) { - if (DEBUG) Log.d(TAG, "do not show History-menu as its disabled in settings"); - drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(true); - } - - if (!sharedPreferences.getBoolean(Constants.KEY_ENABLE_WATCH_HISTORY, true)) { - if (DEBUG) Log.d(TAG, "show History-menu as its enabled in settings"); - drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(false); - } + final boolean isHistoryEnabled = sharedPreferences.getBoolean( + getString(R.string.enable_watch_history_key), true); + drawerItems.getMenu().findItem(ITEM_ID_HISTORY).setVisible(isHistoryEnabled); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/util/Constants.java b/app/src/main/java/org/schabi/newpipe/util/Constants.java index 50350651d..b01b6df6a 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Constants.java +++ b/app/src/main/java/org/schabi/newpipe/util/Constants.java @@ -11,7 +11,5 @@ public class Constants { public static final String KEY_THEME_CHANGE = "key_theme_change"; public static final String KEY_MAIN_PAGE_CHANGE = "key_main_page_change"; - public static final String KEY_ENABLE_WATCH_HISTORY = "enable_watch_history"; - public static final int NO_SERVICE_ID = -1; }