Commit 5a658d7c authored by Nicolas Pomepuy's avatar Nicolas Pomepuy

Convert align mode setting to proper ellipsize setting

parent 8d41cc47
......@@ -11,10 +11,6 @@
<import type="org.videolan.medialibrary.media.MediaLibraryItem" />
<variable
name="alignMode"
type="int" />
<variable
name="item"
......@@ -93,23 +89,23 @@
vlc:layout_constraintRight_toRightOf="@+id/media_cover" />
<TextView
android:id="@+id/title"
style="@style/VLC.TextViewTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
tools:text="Title"
vlc:alignMode="@{alignMode}"
vlc:asyncText="@{item.title}"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintStart_toStartOf="parent"
vlc:layout_constraintTop_toBottomOf="@id/media_cover"
vlc:placeholder="@{item}" />
android:id="@+id/title"
style="@style/VLC.TextViewTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:gravity="center_vertical"
android:maxLines="1"
android:singleLine="true"
tools:text="Title"
vlc:ellipsizeMode="@{true}"
vlc:asyncText="@{item.title}"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintStart_toStartOf="parent"
vlc:layout_constraintTop_toBottomOf="@id/media_cover"
vlc:placeholder="@{item}"/>
<TextView
android:id="@+id/subtitle"
......
......@@ -10,9 +10,6 @@
<import type="org.videolan.medialibrary.media.MediaLibraryItem" />
<variable
name="alignMode"
type="int" />
<variable
......@@ -80,22 +77,24 @@
<!-- TextView must be set to singleLine
see https://code.google.com/p/android/issues/detail?id=33868 -->
<TextView
android:id="@+id/title"
style="@style/VLC.TextViewTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:gravity="center_vertical"
vlc:alignMode="@{alignMode}"
vlc:asyncText="@{item.title}"
vlc:layout_constraintBottom_toTopOf="@+id/subtitle"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintStart_toEndOf="@+id/media_cover"
vlc:layout_constraintTop_toTopOf="parent"
vlc:layout_constraintVertical_chainStyle="packed"
vlc:layout_goneMarginEnd="@dimen/default_margin_plus_audio_margin"
vlc:layout_goneMarginStart="@dimen/default_margin_plus_audio_margin"
vlc:placeholder="@{item}" />
android:id="@+id/title"
style="@style/VLC.TextViewTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:gravity="center_vertical"
vlc:asyncText="@{item.title}"
android:maxLines="2"
android:singleLine="false"
android:ellipsize="end"
vlc:layout_constraintBottom_toTopOf="@+id/subtitle"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintStart_toEndOf="@+id/media_cover"
vlc:layout_constraintTop_toTopOf="parent"
vlc:layout_constraintVertical_chainStyle="packed"
vlc:layout_goneMarginEnd="@dimen/default_margin_plus_audio_margin"
vlc:layout_goneMarginStart="@dimen/default_margin_plus_audio_margin"
vlc:placeholder="@{item}"/>
<TextView
android:id="@+id/subtitle"
......
......@@ -99,25 +99,26 @@
app:layout_constraintTop_toTopOf="@+id/item_icon" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:ellipsize="marquee"
android:marqueeRepeatLimit="1"
android:scrollHorizontally="true"
android:lineSpacingMultiplier="1.1"
android:singleLine="true"
android:text="@{filename ?? item.title}"
android:textColor="?attr/list_title"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toStartOf="@+id/item_more"
app:layout_constraintStart_toEndOf="@+id/item_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_goneMarginBottom="2dp" />
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_margin"
android:layout_marginLeft="@dimen/default_margin"
android:ellipsize="marquee"
android:marqueeRepeatLimit="1"
android:scrollHorizontally="true"
android:lineSpacingMultiplier="1.1"
android:singleLine="true"
android:text="@{filename ?? item.title}"
android:textColor="?attr/list_title"
android:textSize="16sp"
app:ellipsizeMode="@{true}"
app:layout_constraintBottom_toTopOf="@+id/text"
app:layout_constraintEnd_toStartOf="@+id/item_more"
app:layout_constraintStart_toEndOf="@+id/item_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_goneMarginBottom="2dp"/>
<TextView
android:id="@+id/text"
......
......@@ -36,22 +36,22 @@
android:src="@{cover}" />
<TextView
android:id="@+id/folder_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/folder_desc"
app:layout_constraintEnd_toStartOf="@+id/folder_more"
app:layout_constraintStart_toEndOf="@+id/folder_image"
app:layout_constraintTop_toTopOf="@+id/folder_image"
app:layout_constraintVertical_chainStyle="packed"
android:text="@{folder.title}"
android:ellipsize="end"
android:singleLine="true"
android:maxLines="1"
android:textColor="?attr/list_title"
android:textSize="16sp"
android:lineSpacingMultiplier="1.1" />
android:id="@+id/folder_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toTopOf="@+id/folder_desc"
app:layout_constraintEnd_toStartOf="@+id/folder_more"
app:layout_constraintStart_toEndOf="@+id/folder_image"
app:layout_constraintTop_toTopOf="@+id/folder_image"
app:layout_constraintVertical_chainStyle="packed"
android:text="@{folder.title}"
app:ellipsizeMode="@{true}"
android:singleLine="true"
android:maxLines="1"
android:textColor="?attr/list_title"
android:textSize="16sp"
android:lineSpacingMultiplier="1.1"/>
<TextView
android:id="@+id/folder_desc"
......
......@@ -90,19 +90,19 @@
vlc:layout_constraintTop_toTopOf="@+id/ml_item_thumbnail" />
<TextView
android:id="@+id/ml_item_title"
android:layout_width="0dp"
android:layout_height="0dp"
vlc:layout_constraintTop_toTopOf="parent"
vlc:layout_constraintStart_toEndOf="@+id/ml_item_thumbnail"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintBottom_toTopOf="@+id/ml_item_time"
android:ellipsize="end"
android:gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:text="@{showFilename ? media.fileName : media.title}"
style="@style/VLC.TextViewTitle" />
android:id="@+id/ml_item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
vlc:layout_constraintTop_toTopOf="parent"
vlc:layout_constraintStart_toEndOf="@+id/ml_item_thumbnail"
vlc:layout_constraintEnd_toStartOf="@+id/item_more"
vlc:layout_constraintBottom_toTopOf="@+id/ml_item_time"
android:ellipsize="end"
android:gravity="center_vertical"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:text="@{showFilename ? media.fileName : media.title}"
style="@style/VLC.TextViewTitle"/>
<ImageView
android:id="@+id/item_more"
......
......@@ -246,17 +246,19 @@
<item>102</item>
</string-array>
<string-array name="audio_title_alignment_list">
<item>@string/audio_title_alignment_default</item>
<item>@string/audio_title_alignment_left</item>
<item>@string/audio_title_alignment_right</item>
<item>@string/audio_title_alignment_marquee</item>
</string-array>
<string-array name="audio_title_alignment_values" translatable="false">
<string-array name="list_title_ellipsize_list">
<item>@string/list_title_ellipsize_default</item>
<item>@string/list_title_ellipsize_left</item>
<item>@string/list_title_ellipsize_right</item>
<item>@string/list_title_ellipsize_middle</item>
<item>@string/list_title_ellipsize_marquee</item>
</string-array>
<string-array name="list_title_ellipsize_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</string-array>
<string-array name="video_min_group_length_list" translatable="false">
......
......@@ -368,12 +368,13 @@
<string name="lockscreen_cover_summary">When available, set the current media cover art as lockscreen wallpaper</string>
<string name="playlist_animate_scroll_title">Animate current playlist auto-scrolling</string>
<string name="playlist_animate_scroll_summary">Animate scrolling on media transition</string>
<string name="audio_title_alignment">Audio title alignment</string>
<string name="audio_title_alignment_default">Default</string>
<string name="audio_title_alignment_left">Left</string>
<string name="audio_title_alignment_centre">Centre</string>
<string name="audio_title_alignment_right">Right</string>
<string name="audio_title_alignment_marquee">Marquee</string>
<string name="list_title_ellipsize">Single line list title ellipsize</string>
<string name="list_title_ellipsize_default">Default</string>
<string name="list_title_ellipsize_left">Left</string>
<string name="list_title_alignment_centre">Centre</string>
<string name="list_title_ellipsize_right">Right</string>
<string name="list_title_ellipsize_middle">Middle</string>
<string name="list_title_ellipsize_marquee">Marquee</string>
<string name="audio_save_repeat_title">Save repeat mode</string>
<string name="audio_save_repeat_summary">Remember repeat mode when loading audio playlists</string>
<string name="audio_boost_title">Audio-boost</string>
......
......@@ -31,6 +31,15 @@
android:summary="@string/browser_show_all_summary"
android:title="@string/browser_show_all_title"/>
<ListPreference
android:defaultValue="0"
android:entries="@array/list_title_ellipsize_list"
android:entryValues="@array/list_title_ellipsize_values"
android:key="list_title_ellipsize"
android:persistent="true"
android:title="@string/list_title_ellipsize"
android:summary="%s"/>
<PreferenceCategory
android:title="@string/video"
android:key="ui_video_category">
......@@ -99,12 +108,5 @@
android:key="artists_show_all"
android:summary="@string/artists_show_all_summary"
android:title="@string/artists_show_all_title"/>
<ListPreference
android:defaultValue="0"
android:entries="@array/audio_title_alignment_list"
android:entryValues="@array/audio_title_alignment_values"
android:key="audio_title_alignment"
android:persistent="true"
android:title="@string/audio_title_alignment"/>
</PreferenceCategory>
</androidx.preference.PreferenceScreen>
......@@ -29,7 +29,6 @@ import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.media.MediaRouter
......@@ -597,19 +596,22 @@ object UiTools {
* mode from preferences.
*
*
* See @array/audio_title_alignment_values
* See @array/list_title_alignment_values
*
* @param alignMode Align mode as read from preferences
* @param t Reference to the textview
*/
@BindingAdapter("alignMode")
fun setAlignModeByPref(t: TextView, alignMode: Int) {
when (alignMode) {
@BindingAdapter("ellipsizeMode")
fun setEllipsizeModeByPref(t: TextView, activated: Boolean) {
if (!activated) return
when (Settings.listTitleEllipsize) {
0 -> {
}
1 -> t.ellipsize = TextUtils.TruncateAt.END
2 -> t.ellipsize = TextUtils.TruncateAt.START
3 -> {
1 -> t.ellipsize = TextUtils.TruncateAt.START
2 -> t.ellipsize = TextUtils.TruncateAt.END
3 -> t.ellipsize = TextUtils.TruncateAt.MIDDLE
4 -> {
t.ellipsize = TextUtils.TruncateAt.MARQUEE
t.marqueeRepeatLimit = -1
t.isSelected = true
......
......@@ -104,6 +104,10 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
}
"browser_show_all_files" -> (activity as PreferencesActivity).setRestart()
KEY_APP_THEME -> (activity as PreferencesActivity).exitAndRescan()
LIST_TITLE_ELLIPSIZE -> {
Settings.listTitleEllipsize = sharedPreferences.getString(LIST_TITLE_ELLIPSIZE, "0").toInt()
(activity as PreferencesActivity).setRestart()
}
}
}
......
......@@ -16,10 +16,12 @@ object Settings : SingletonHolder<SharedPreferences, Context>({ PreferenceManage
var showVideoThumbs = true
var tvUI = false
var listTitleEllipsize = 0
fun init(prefs: SharedPreferences) {
showVideoThumbs = prefs.getBoolean(SHOW_VIDEO_THUMBNAILS, true)
tvUI = prefs.getBoolean(PREF_TV_UI, false)
listTitleEllipsize = prefs.getString(LIST_TITLE_ELLIPSIZE, "0").toInt()
}
val showTvUi : Boolean
......@@ -35,6 +37,10 @@ const val KEY_DAYNIGHT = "daynight"
const val SHOW_VIDEO_THUMBNAILS = "show_video_thumbnails"
const val FORCE_LIST_PORTRAIT = "force_list_portrait"
//UI
const val LIST_TITLE_ELLIPSIZE = "list_title_ellipsize"
// AudioPlayer
const val PREF_PLAYLIST_TIPS_SHOWN = "playlist_tips_shown"
const val PREF_AUDIOPLAYER_TIPS_SHOWN = "audioplayer_tips_shown"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment