From c7b470553827c696465d5b6e5d9de3261177ee69 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 22 Feb 2020 10:36:10 +0100 Subject: [PATCH] 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;