From 97f5490c13f0a9c927fec4fd7d5b801381a00e5c Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sat, 14 Mar 2020 00:11:30 -0300 Subject: [PATCH] Add help dialog to feed screen Help to a possible confusion or simply awareness that NewPipe has both ways to load the feed. --- .../schabi/newpipe/local/feed/FeedFragment.kt | 34 +++++++++++++++++++ .../main/res/drawable/ic_help_black_24dp.xml | 9 +++++ .../main/res/drawable/ic_help_white_24dp.xml | 9 +++++ app/src/main/res/menu/menu_feed_fragment.xml | 10 ++++++ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/strings.xml | 4 +++ app/src/main/res/values/styles.xml | 2 ++ 7 files changed, 69 insertions(+) create mode 100644 app/src/main/res/drawable/ic_help_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_help_white_24dp.xml create mode 100644 app/src/main/res/menu/menu_feed_fragment.xml diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index b16a9dfb7..64020d14c 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -23,8 +23,10 @@ import android.content.Intent import android.os.Bundle import android.os.Parcelable import android.view.* +import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders +import androidx.preference.PreferenceManager import icepick.State import kotlinx.android.synthetic.main.error_retry.* import kotlinx.android.synthetic.main.fragment_feed.* @@ -101,6 +103,38 @@ class FeedFragment : BaseListFragment() { super.onCreateOptionsMenu(menu, inflater) activity.supportActionBar?.setTitle(R.string.fragment_feed_title) activity.supportActionBar?.subtitle = groupName + + inflater.inflate(R.menu.menu_feed_fragment, menu) + + if (useAsFrontPage) { + menu.findItem(R.id.menu_item_feed_help).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + } + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == R.id.menu_item_feed_help) { + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) + + val usingDedicatedMethod = sharedPreferences.getBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), false) + val enableDisableButtonText = when { + usingDedicatedMethod -> R.string.feed_use_dedicated_fetch_method_disable_button + else -> R.string.feed_use_dedicated_fetch_method_enable_button + } + + AlertDialog.Builder(requireContext()) + .setMessage(R.string.feed_use_dedicated_fetch_method_help_text) + .setNeutralButton(enableDisableButtonText) { _, _ -> + sharedPreferences.edit() + .putBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), !usingDedicatedMethod) + .apply() + } + .setPositiveButton(android.R.string.ok, null) + .create() + .show() + return true + } + + return super.onOptionsItemSelected(item) } override fun onDestroyOptionsMenu() { diff --git a/app/src/main/res/drawable/ic_help_black_24dp.xml b/app/src/main/res/drawable/ic_help_black_24dp.xml new file mode 100644 index 000000000..1517747d0 --- /dev/null +++ b/app/src/main/res/drawable/ic_help_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_help_white_24dp.xml b/app/src/main/res/drawable/ic_help_white_24dp.xml new file mode 100644 index 000000000..d813b72b8 --- /dev/null +++ b/app/src/main/res/drawable/ic_help_white_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/menu_feed_fragment.xml b/app/src/main/res/menu/menu_feed_fragment.xml new file mode 100644 index 000000000..3519875eb --- /dev/null +++ b/app/src/main/res/menu/menu_feed_fragment.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index f05471cd4..4cda52a99 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -80,6 +80,7 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f4303ca74..edc4c5a27 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -191,6 +191,7 @@ Deletes history of search keywords Delete entire search history? Search history deleted. + Help Error External storage unavailable @@ -640,4 +641,7 @@ Always update Fetch from dedicated feed when available Available in some services, it is usually much faster but may return a limited amount of items and often incomplete information (e.g. no duration, item type, no live status). + Enable fast mode + Disable fast mode + Do you think feed loading is too slow? If so, try enabling fast loading (you can change it in settings or by pressing the button below).\n\nNewPipe offers two feed loading strategies:\n• Fetching the whole subscription channel, which is slow but complete.\n• Using a dedicated service endpoint, which is fast but usually not complete.\n\nThe difference between the two is that the fast one usually lacks some information, like the item\'s duration or type (can\'t distinguish between live videos and normal ones) and it may return less items.\n\nYouTube is an example of a service that offers this fast method with its RSS feed.\n\nSo the choice boils down to what you prefer: speed or precise information. \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4c668b825..f7d09ef9c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -95,6 +95,7 @@ @drawable/ic_telescope_black_24dp @drawable/ic_megaphone_black_24dp @drawable/ic_sort_black_24dp + @drawable/ic_help_black_24dp @color/light_separator_color @color/light_contrast_background_color @@ -200,6 +201,7 @@ @drawable/ic_telescope_white_24dp @drawable/ic_megaphone_white_24dp @drawable/ic_sort_white_24dp + @drawable/ic_help_white_24dp @color/dark_separator_color @color/dark_contrast_background_color