mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
[Feature] Add setting to Truncate Video title on Player (#918)
* [Feature] Add setting to Truncate Video title on Player * add missing icons * Revert "add missing icons" This reverts commit 51c8a85ed18b5664fde21262f5b8ee3ae3a894fb. * applied PR suggestions * edit color
This commit is contained in:
parent
970a68f47b
commit
d6d4bfaa0e
6 changed files with 66 additions and 4 deletions
|
@ -545,10 +545,14 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
tvType = meta.tvType
|
tvType = meta.tvType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Get limit of characters on Video Title
|
||||||
player_episode_filler_holder?.isVisible = isFiller ?: false
|
var limitTitle = 0
|
||||||
|
context?.let {
|
||||||
player_video_title?.text = if (headerName != null) {
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
|
||||||
|
limitTitle = settingsManager.getInt(getString(R.string.prefer_limit_title_key), 0)
|
||||||
|
}
|
||||||
|
//Generate video title
|
||||||
|
var playerVideoTitle = if (headerName != null) {
|
||||||
(headerName +
|
(headerName +
|
||||||
if (tvType.isEpisodeBased() && episode != null)
|
if (tvType.isEpisodeBased() && episode != null)
|
||||||
if (season == null)
|
if (season == null)
|
||||||
|
@ -559,6 +563,15 @@ class GeneratorPlayer : FullScreenPlayer() {
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
//Truncate video title if it exceeds limit
|
||||||
|
val differenceInLength = playerVideoTitle.length - limitTitle
|
||||||
|
val margin = 3 //If the difference is smaller than or equal to this value, ignore it
|
||||||
|
if (limitTitle > 0 && differenceInLength > margin) {
|
||||||
|
playerVideoTitle = playerVideoTitle.substring(0, limitTitle-1) + "..."
|
||||||
|
}
|
||||||
|
|
||||||
|
player_episode_filler_holder?.isVisible = isFiller ?: false
|
||||||
|
player_video_title?.text = playerVideoTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
|
|
@ -705,6 +705,24 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
return@setOnPreferenceClickListener true
|
return@setOnPreferenceClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPref(R.string.prefer_limit_title_key)?.setOnPreferenceClickListener {
|
||||||
|
val prefNames = resources.getStringArray(R.array.limit_title_pref_names)
|
||||||
|
val prefValues = resources.getIntArray(R.array.limit_title_pref_values)
|
||||||
|
val current = settingsManager.getInt(getString(R.string.prefer_limit_title_key), 0)
|
||||||
|
|
||||||
|
activity?.showBottomDialog(
|
||||||
|
prefNames.toList(),
|
||||||
|
prefValues.indexOf(current),
|
||||||
|
getString(R.string.limit_title),
|
||||||
|
true,
|
||||||
|
{}) {
|
||||||
|
settingsManager.edit()
|
||||||
|
.putInt(getString(R.string.prefer_limit_title_key), prefValues[it])
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
return@setOnPreferenceClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
getPref(R.string.dns_key)?.setOnPreferenceClickListener {
|
getPref(R.string.dns_key)?.setOnPreferenceClickListener {
|
||||||
val prefNames = resources.getStringArray(R.array.dns_pref)
|
val prefNames = resources.getStringArray(R.array.dns_pref)
|
||||||
val prefValues = resources.getIntArray(R.array.dns_pref_values)
|
val prefValues = resources.getIntArray(R.array.dns_pref_values)
|
||||||
|
|
10
app/src/main/res/drawable/ic_baseline_text_format_24.xml
Normal file
10
app/src/main/res/drawable/ic_baseline_text_format_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/white">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M5,17v2h14v-2L5,17zM9.5,12.8h5l0.9,2.2h2.1L12.75,4h-1.5L6.5,15h2.1l0.9,-2.2zM12,5.98L13.87,11h-3.74L12,5.98z"/>
|
||||||
|
</vector>
|
|
@ -59,6 +59,21 @@
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
|
<array name="limit_title_pref_names">
|
||||||
|
<item>@string/none</item>
|
||||||
|
<item>16 characters</item>
|
||||||
|
<item>32 characters</item>
|
||||||
|
<item>64 characters</item>
|
||||||
|
<item>128 characters</item>
|
||||||
|
</array>
|
||||||
|
<array name="limit_title_pref_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>16</item>
|
||||||
|
<item>32</item>
|
||||||
|
<item>64</item>
|
||||||
|
<item>128</item>
|
||||||
|
</array>
|
||||||
|
|
||||||
<array name="video_buffer_length_names">
|
<array name="video_buffer_length_names">
|
||||||
<item>@string/automatic</item>
|
<item>@string/automatic</item>
|
||||||
<item>1min</item>
|
<item>1min</item>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<string name="subtitle_settings_key" translatable="false">subtitle_settings_key</string>
|
<string name="subtitle_settings_key" translatable="false">subtitle_settings_key</string>
|
||||||
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
||||||
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
||||||
|
<string name="prefer_limit_title_key" translatable="false">prefer_limit_title_key</string>
|
||||||
<string name="video_buffer_size_key" translatable="false">video_buffer_size_key</string>
|
<string name="video_buffer_size_key" translatable="false">video_buffer_size_key</string>
|
||||||
<string name="video_buffer_length_key" translatable="false">video_buffer_length_key</string>
|
<string name="video_buffer_length_key" translatable="false">video_buffer_length_key</string>
|
||||||
<string name="video_buffer_clear_key" translatable="false">video_buffer_clear_key</string>
|
<string name="video_buffer_clear_key" translatable="false">video_buffer_clear_key</string>
|
||||||
|
@ -348,6 +349,7 @@
|
||||||
<string name="dont_show_again">Don\'t show again</string>
|
<string name="dont_show_again">Don\'t show again</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
<string name="watch_quality_pref">Preferred watch quality</string>
|
||||||
|
<string name="limit_title">Limit title characters on player</string>
|
||||||
<string name="video_buffer_size_settings">Video buffer size</string>
|
<string name="video_buffer_size_settings">Video buffer size</string>
|
||||||
<string name="video_buffer_length_settings">Video buffer length</string>
|
<string name="video_buffer_length_settings">Video buffer length</string>
|
||||||
<string name="video_buffer_disk_settings">Video cache on disk</string>
|
<string name="video_buffer_disk_settings">Video cache on disk</string>
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
android:key="@string/quality_pref_key"
|
android:key="@string/quality_pref_key"
|
||||||
android:title="@string/watch_quality_pref"
|
android:title="@string/watch_quality_pref"
|
||||||
android:icon="@drawable/ic_baseline_hd_24" />
|
android:icon="@drawable/ic_baseline_hd_24" />
|
||||||
|
<Preference
|
||||||
|
android:key="@string/prefer_limit_title_key"
|
||||||
|
android:title="@string/limit_title"
|
||||||
|
android:icon="@drawable/ic_baseline_text_format_24" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
android:icon="@drawable/ic_baseline_picture_in_picture_alt_24"
|
||||||
|
|
Loading…
Reference in a new issue