1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

Add help dialog to feed screen

Help to a possible confusion or simply awareness that NewPipe has both
ways to load the feed.
This commit is contained in:
Mauricio Colli 2020-03-14 00:11:30 -03:00
parent 6a9a0f1e73
commit 97f5490c13
No known key found for this signature in database
GPG Key ID: F200BFD6F29DDD85
7 changed files with 69 additions and 0 deletions

View File

@ -23,8 +23,10 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Parcelable import android.os.Parcelable
import android.view.* import android.view.*
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import androidx.preference.PreferenceManager
import icepick.State import icepick.State
import kotlinx.android.synthetic.main.error_retry.* import kotlinx.android.synthetic.main.error_retry.*
import kotlinx.android.synthetic.main.fragment_feed.* import kotlinx.android.synthetic.main.fragment_feed.*
@ -101,6 +103,38 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
activity.supportActionBar?.setTitle(R.string.fragment_feed_title) activity.supportActionBar?.setTitle(R.string.fragment_feed_title)
activity.supportActionBar?.subtitle = groupName 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() { override fun onDestroyOptionsMenu() {

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,19h-2v-2h2v2zM15.07,11.25l-0.9,0.92C13.45,12.9 13,13.5 13,15h-2v-0.5c0,-1.1 0.45,-2.1 1.17,-2.83l1.24,-1.26c0.37,-0.36 0.59,-0.86 0.59,-1.41 0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2L8,9c0,-2.21 1.79,-4 4,-4s4,1.79 4,4c0,0.88 -0.36,1.68 -0.93,2.25z"/>
</vector>

View 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">
<item
android:id="@+id/menu_item_feed_help"
android:icon="?attr/ic_help"
android:title="@string/help"
app:showAsAction="always" />
</menu>

View File

@ -80,6 +80,7 @@
<attr name="ic_telescope" format="reference"/> <attr name="ic_telescope" format="reference"/>
<attr name="ic_megaphone" format="reference"/> <attr name="ic_megaphone" format="reference"/>
<attr name="ic_sort" format="reference"/> <attr name="ic_sort" format="reference"/>
<attr name="ic_help" format="reference"/>
<attr name="progress_horizontal_drawable" format="reference"/> <attr name="progress_horizontal_drawable" format="reference"/>
<!-- Can't refer to colors directly in drawable's xml--> <!-- Can't refer to colors directly in drawable's xml-->

View File

@ -191,6 +191,7 @@
<string name="clear_search_history_summary">Deletes history of search keywords</string> <string name="clear_search_history_summary">Deletes history of search keywords</string>
<string name="delete_search_history_alert">Delete entire search history?</string> <string name="delete_search_history_alert">Delete entire search history?</string>
<string name="search_history_deleted">Search history deleted.</string> <string name="search_history_deleted">Search history deleted.</string>
<string name="help">Help</string>
<!-- error strings --> <!-- error strings -->
<string name="general_error">Error</string> <string name="general_error">Error</string>
<string name="download_to_sdcard_error_title">External storage unavailable</string> <string name="download_to_sdcard_error_title">External storage unavailable</string>
@ -640,4 +641,7 @@
<string name="feed_update_threshold_option_always_update">Always update</string> <string name="feed_update_threshold_option_always_update">Always update</string>
<string name="feed_use_dedicated_fetch_method_title">Fetch from dedicated feed when available</string> <string name="feed_use_dedicated_fetch_method_title">Fetch from dedicated feed when available</string>
<string name="feed_use_dedicated_fetch_method_summary">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).</string> <string name="feed_use_dedicated_fetch_method_summary">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).</string>
<string name="feed_use_dedicated_fetch_method_enable_button">Enable fast mode</string>
<string name="feed_use_dedicated_fetch_method_disable_button">Disable fast mode</string>
<string name="feed_use_dedicated_fetch_method_help_text">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.</string>
</resources> </resources>

View File

@ -95,6 +95,7 @@
<item name="ic_telescope">@drawable/ic_telescope_black_24dp</item> <item name="ic_telescope">@drawable/ic_telescope_black_24dp</item>
<item name="ic_megaphone">@drawable/ic_megaphone_black_24dp</item> <item name="ic_megaphone">@drawable/ic_megaphone_black_24dp</item>
<item name="ic_sort">@drawable/ic_sort_black_24dp</item> <item name="ic_sort">@drawable/ic_sort_black_24dp</item>
<item name="ic_help">@drawable/ic_help_black_24dp</item>
<item name="separator_color">@color/light_separator_color</item> <item name="separator_color">@color/light_separator_color</item>
<item name="contrast_background_color">@color/light_contrast_background_color</item> <item name="contrast_background_color">@color/light_contrast_background_color</item>
@ -200,6 +201,7 @@
<item name="ic_telescope">@drawable/ic_telescope_white_24dp</item> <item name="ic_telescope">@drawable/ic_telescope_white_24dp</item>
<item name="ic_megaphone">@drawable/ic_megaphone_white_24dp</item> <item name="ic_megaphone">@drawable/ic_megaphone_white_24dp</item>
<item name="ic_sort">@drawable/ic_sort_white_24dp</item> <item name="ic_sort">@drawable/ic_sort_white_24dp</item>
<item name="ic_help">@drawable/ic_help_white_24dp</item>
<item name="separator_color">@color/dark_separator_color</item> <item name="separator_color">@color/dark_separator_color</item>
<item name="contrast_background_color">@color/dark_contrast_background_color</item> <item name="contrast_background_color">@color/dark_contrast_background_color</item>