Add preference to hide description tab in video details
This commit is contained in:
parent
d043a4f410
commit
750c4ffbd3
|
@ -130,8 +130,6 @@ public final class VideoDetailFragment
|
|||
OnKeyDownListener {
|
||||
public static final String KEY_SWITCHING_PLAYERS = "switching_players";
|
||||
|
||||
private static final int RELATED_STREAMS_UPDATE_FLAG = 0x1;
|
||||
private static final int COMMENTS_UPDATE_FLAG = 0x2;
|
||||
private static final float MAX_OVERLAY_ALPHA = 0.9f;
|
||||
private static final float MAX_PLAYER_HEIGHT = 0.7f;
|
||||
|
||||
|
@ -151,12 +149,12 @@ public final class VideoDetailFragment
|
|||
private static final String DESCRIPTION_TAB_TAG = "DESCRIPTION TAB";
|
||||
|
||||
// tabs
|
||||
private boolean showRelatedStreams;
|
||||
private boolean showComments;
|
||||
private boolean showRelatedStreams;
|
||||
private boolean showDescription;
|
||||
private String selectedTabTag;
|
||||
@AttrRes @NonNull final List<Integer> tabIcons = new ArrayList<>();
|
||||
|
||||
private int updateFlags = 0;
|
||||
private boolean tabSettingsChanged = false;
|
||||
|
||||
@State
|
||||
protected int serviceId = Constants.NO_SERVICE_ID;
|
||||
|
@ -275,17 +273,13 @@ public final class VideoDetailFragment
|
|||
public void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
showRelatedStreams = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.getBoolean(getString(R.string.show_next_video_key), true);
|
||||
|
||||
showComments = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.getBoolean(getString(R.string.show_comments_key), true);
|
||||
|
||||
selectedTabTag = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.getString(getString(R.string.stream_info_selected_tab_key), COMMENTS_TAB_TAG);
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
showComments = prefs.getBoolean(getString(R.string.show_comments_key), true);
|
||||
showRelatedStreams = prefs.getBoolean(getString(R.string.show_next_video_key), true);
|
||||
showDescription = prefs.getBoolean(getString(R.string.show_description_key), true);
|
||||
selectedTabTag = prefs.getString(
|
||||
getString(R.string.stream_info_selected_tab_key), COMMENTS_TAB_TAG);
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
setupBroadcastReceiver();
|
||||
|
||||
|
@ -330,17 +324,12 @@ public final class VideoDetailFragment
|
|||
|
||||
setupBrightness();
|
||||
|
||||
if (updateFlags != 0) {
|
||||
if (!isLoading.get() && currentInfo != null) {
|
||||
if ((updateFlags & RELATED_STREAMS_UPDATE_FLAG) != 0) {
|
||||
startLoading(false);
|
||||
}
|
||||
if ((updateFlags & COMMENTS_UPDATE_FLAG) != 0) {
|
||||
startLoading(false);
|
||||
}
|
||||
if (tabSettingsChanged) {
|
||||
tabSettingsChanged = false;
|
||||
initTabs();
|
||||
if (currentInfo != null) {
|
||||
updateTabs(currentInfo);
|
||||
}
|
||||
|
||||
updateFlags = 0;
|
||||
}
|
||||
|
||||
// Check if it was loading when the fragment was stopped/paused
|
||||
|
@ -415,12 +404,15 @@ public final class VideoDetailFragment
|
|||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
|
||||
final String key) {
|
||||
if (key.equals(getString(R.string.show_next_video_key))) {
|
||||
showRelatedStreams = sharedPreferences.getBoolean(key, true);
|
||||
updateFlags |= RELATED_STREAMS_UPDATE_FLAG;
|
||||
} else if (key.equals(getString(R.string.show_comments_key))) {
|
||||
if (key.equals(getString(R.string.show_comments_key))) {
|
||||
showComments = sharedPreferences.getBoolean(key, true);
|
||||
updateFlags |= COMMENTS_UPDATE_FLAG;
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_next_video_key))) {
|
||||
showRelatedStreams = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_description_key))) {
|
||||
showComments = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -926,9 +918,11 @@ public final class VideoDetailFragment
|
|||
tabIcons.add(R.drawable.ic_art_track_white_24dp);
|
||||
}
|
||||
|
||||
// temp empty fragment. will be updated in handleResult
|
||||
pageAdapter.addFragment(new Fragment(), DESCRIPTION_TAB_TAG);
|
||||
tabIcons.add(R.drawable.ic_description_white_24dp);
|
||||
if (showDescription) {
|
||||
// temp empty fragment. will be updated in handleResult
|
||||
pageAdapter.addFragment(new Fragment(), DESCRIPTION_TAB_TAG);
|
||||
tabIcons.add(R.drawable.ic_description_white_24dp);
|
||||
}
|
||||
pageAdapter.notifyDataSetUpdate();
|
||||
|
||||
if (pageAdapter.getCount() < 2) {
|
||||
|
@ -972,8 +966,11 @@ public final class VideoDetailFragment
|
|||
}
|
||||
}
|
||||
|
||||
pageAdapter.updateItem(DESCRIPTION_TAB_TAG,
|
||||
new DescriptionFragment(info));
|
||||
if (showDescription) {
|
||||
pageAdapter.updateItem(DESCRIPTION_TAB_TAG,
|
||||
new DescriptionFragment(info));
|
||||
}
|
||||
|
||||
pageAdapter.notifyDataSetUpdate();
|
||||
updateTabIcons();
|
||||
}
|
||||
|
|
|
@ -197,8 +197,9 @@
|
|||
<!-- Content & History -->
|
||||
<string name="show_search_suggestions_key" translatable="false">show_search_suggestions</string>
|
||||
<string name="show_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
|
||||
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
||||
<string name="show_comments_key" translatable="false">show_comments</string>
|
||||
<string name="show_next_video_key" translatable="false">show_next_video</string>
|
||||
<string name="show_description_key" translatable="false">show_description</string>
|
||||
<string name="show_meta_info_key" translatable="false">show_meta_info</string>
|
||||
<string name="stream_info_selected_tab_key" translatable="false">stream_info_selected_tab</string>
|
||||
<string name="show_hold_to_append_key" translatable="false">show_hold_to_append</string>
|
||||
|
|
|
@ -91,9 +91,12 @@
|
|||
<string name="clear_queue_confirmation_summary">Switching from one player to another may replace your queue</string>
|
||||
<string name="clear_queue_confirmation_description">The active player queue will be replaced</string>
|
||||
<string name="download_thumbnail_title">Load thumbnails</string>
|
||||
<string name="download_thumbnail_summary">Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache.</string>
|
||||
<string name="show_comments_title">Show comments</string>
|
||||
<string name="show_comments_summary">Turn off to hide comments</string>
|
||||
<string name="download_thumbnail_summary">Turn off to prevent loading thumbnails, saving data and memory usage. Changes clear both in-memory and on-disk image cache.</string>
|
||||
<string name="show_next_and_similar_title">Show \'Next\' and \'Similar\' videos</string>
|
||||
<string name="show_description_title">Show description</string>
|
||||
<string name="show_description_summary">Turn off to hide video description and additional information</string>
|
||||
<string name="show_meta_info_title">Show meta info</string>
|
||||
<string name="show_meta_info_summary">Turn off to hide meta info boxes with additional information about the stream creator, stream content or a search request.</string>
|
||||
<string name="thumbnail_cache_wipe_complete_notice">Image cache wiped</string>
|
||||
|
@ -124,7 +127,6 @@
|
|||
<string name="resume_on_audio_focus_gain_summary">Continue playing after interruptions (e.g. phonecalls)</string>
|
||||
<string name="download_dialog_title">Download</string>
|
||||
<string name="autoplay_title">Autoplay</string>
|
||||
<string name="show_next_and_similar_title">Show \'Next\' and \'Similar\' videos</string>
|
||||
<string name="show_hold_to_append_title">Show \"Hold to append\" tip</string>
|
||||
<string name="show_hold_to_append_summary">Show tip when pressing the background or the popup button in video \"Details:\"</string>
|
||||
<string name="unsupported_url">Unsupported URL</string>
|
||||
|
|
|
@ -72,6 +72,13 @@
|
|||
android:title="@string/download_thumbnail_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/show_comments_key"
|
||||
android:summary="@string/show_comments_summary"
|
||||
android:title="@string/show_comments_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/show_next_video_key"
|
||||
|
@ -80,9 +87,9 @@
|
|||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="@string/show_comments_key"
|
||||
android:summary="@string/show_comments_summary"
|
||||
android:title="@string/show_comments_title"
|
||||
android:key="@string/show_description_key"
|
||||
android:summary="@string/show_description_summary"
|
||||
android:title="@string/show_description_title"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
|
|
Loading…
Reference in New Issue