Skip to content

Commit 3b2896a

Browse files
committed
add auto word toggle
1 parent e3e81ff commit 3b2896a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

app/src/main/kotlin/org/akanework/gramophone/ui/components/LyricsView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class LyricsView(context: Context, attrs: AttributeSet?) : FrameLayout(context,
9999
if ((key == "lyric_center" || key == "lyric_bold") && adapter != null)
100100
adapter?.onPrefsChanged()
101101
else if (key == "lyric_center" || key == "lyric_bold" || key == "lyric_no_animation" ||
102-
key == "lyric_char_scaling")
102+
key == "lyric_char_scaling" || key == "translation_auto_word")
103103
newView?.onPrefsChanged(key)
104104
else if (key == "lyric_ui" || key == "lyric_parser")
105105
createView()

app/src/main/kotlin/org/akanework/gramophone/ui/components/NewLyricsView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ class NewLyricsView(context: Context, attrs: AttributeSet?) : View(context, attr
668668
if (syncedLine?.isTranslated != true)
669669
lastNonTranslated = syncedLine
670670
val words = syncedLine?.words ?:
671-
if (syncedLine?.isTranslated == true && lastNonTranslated?.words != null)
671+
if (prefs.getBooleanStrict("translation_auto_word", false) &&
672+
syncedLine?.isTranslated == true && lastNonTranslated?.words != null)
672673
listOf(SemanticLyrics.Word(lastNonTranslated.timeRange, 0..<syncedLine.text.length,
673674
findBidirectionalBarriers(syncedLine.text).firstOrNull()?.second == true
674675
)) else null

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,4 +416,6 @@
416416
<string name="spk_encoding_pcm_16bit_offload">16-bit PCM Offload</string>
417417
<string name="spk_encoding_pcm_24bit_offload">24-bit (8.24) PCM offload</string>
418418
<string name="spk_encoding_dts_lbr">DTS Express</string>
419+
<string name="settings_translation_auto_word">Auto-animate translations</string>
420+
<string name="settings_translation_auto_word_summary">Apply linear gradient to translation lines in word-synced lyric playback if translations do not have word-sync metadata</string>
419421
</resources>

app/src/main/res/xml/settings_lyric.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,13 @@
4545
android:widgetLayout="@layout/preference_switch_widget"
4646
app:iconSpaceReserved="false" />
4747

48+
<SwitchPreferenceCompat
49+
android:defaultValue="false"
50+
android:key="translation_auto_word"
51+
android:layout="@layout/preference_switch"
52+
android:summary="@string/settings_translation_auto_word_summary"
53+
android:title="@string/settings_translation_auto_word"
54+
android:widgetLayout="@layout/preference_switch_widget"
55+
app:iconSpaceReserved="false" />
56+
4857
</PreferenceScreen>

0 commit comments

Comments
 (0)