Skip to content

Commit

Permalink
Configurable subtitle bold style
Browse files Browse the repository at this point in the history
  • Loading branch information
moneytoo committed Sep 30, 2023
1 parent 8279b84 commit 97a3351
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
applicationId "com.brouken.player"
minSdkVersion 21
targetSdkVersion 34
versionCode 151
versionCode 152
versionName "0.${versionCode}"
archivesBaseName = "Just.Player.v${versionName}"
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/brouken/player/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
} else if (requestCode == REQUEST_SETTINGS) {
mPrefs.loadUserPreferences();
updateSubtitleStyle(this);
} else {
super.onActivityResult(requestCode, resultCode, data);
}
Expand Down Expand Up @@ -1945,7 +1946,8 @@ void updateSubtitleStyle(final Context context) {
userStyle.hasWindowColor() ? userStyleCompat.windowColor : Color.TRANSPARENT,
userStyle.hasEdgeType() ? userStyleCompat.edgeType : CaptionStyleCompat.EDGE_TYPE_OUTLINE,
userStyle.hasEdgeColor() ? userStyleCompat.edgeColor : Color.BLACK,
userStyleCompat.typeface != null ? userStyleCompat.typeface : Typeface.DEFAULT_BOLD);
Typeface.create(userStyleCompat.typeface != null ? userStyleCompat.typeface : Typeface.DEFAULT,
mPrefs.subtitleStyleBold ? Typeface.BOLD : Typeface.NORMAL));
subtitleView.setStyle(captionStyle);
subtitleView.setApplyEmbeddedStyles(mPrefs.subtitleStyleEmbedded);
subtitleView.setBottomPaddingFraction(SubtitleView.DEFAULT_BOTTOM_PADDING_FRACTION * 2f / 3f);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/brouken/player/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Prefs {
private static final String PREF_KEY_MAP_DV7 = "mapDV7ToHevc";
private static final String PREF_KEY_LANGUAGE_AUDIO = "languageAudio";
private static final String PREF_KEY_SUBTITLE_STYLE_EMBEDDED = "subtitleStyleEmbedded";
private static final String PREF_KEY_SUBTITLE_STYLE_BOLD = "subtitleStyleBold";

public static final String TRACK_DEFAULT = "default";
public static final String TRACK_DEVICE = "device";
Expand Down Expand Up @@ -79,6 +80,7 @@ class Prefs {
public boolean mapDV7ToHevc = false;
public String languageAudio = TRACK_DEVICE;
public boolean subtitleStyleEmbedded = true;
public boolean subtitleStyleBold = false;

private LinkedHashMap positions;

Expand Down Expand Up @@ -127,6 +129,7 @@ public void loadUserPreferences() {
mapDV7ToHevc = mSharedPreferences.getBoolean(PREF_KEY_MAP_DV7, mapDV7ToHevc);
languageAudio = mSharedPreferences.getString(PREF_KEY_LANGUAGE_AUDIO, languageAudio);
subtitleStyleEmbedded = mSharedPreferences.getBoolean(PREF_KEY_SUBTITLE_STYLE_EMBEDDED, subtitleStyleEmbedded);
subtitleStyleBold = mSharedPreferences.getBoolean(PREF_KEY_SUBTITLE_STYLE_BOLD, subtitleStyleBold);
}

public void updateMedia(final Context context, final Uri uri, final String type) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@
<string name="pref_subtitle_style_embedded">Styly v titulcích</string>
<string name="pref_subtitle_style_embedded_on">Aplikovat styly definované v titulcích</string>
<string name="pref_subtitle_style_embedded_off">Neaplikovat styly definované v titulcích</string>
<string name="pref_subtitle_style_bold">Tučné písmo</string>
<string name="pref_subtitle_style_bold_on">Použít tučný styl písma</string>
<string name="pref_subtitle_style_bold_off">Použít výchozí styl písma</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@
<string name="pref_subtitle_style_embedded">Embedded styles</string>
<string name="pref_subtitle_style_embedded_on">Apply embedded subtitle styles</string>
<string name="pref_subtitle_style_embedded_off">Do not apply embedded subtitle styles</string>
<string name="pref_subtitle_style_bold">Bold style</string>
<string name="pref_subtitle_style_bold_on">Use bold typeface as regular</string>
<string name="pref_subtitle_style_bold_off">Use default regular typeface</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
android:summaryOff="@string/pref_subtitle_style_embedded_off"
app:title="@string/pref_subtitle_style_embedded" />

<SwitchPreferenceCompat
app:key="subtitleStyleBold"
app:defaultValue="false"
android:summaryOn="@string/pref_subtitle_style_bold_on"
android:summaryOff="@string/pref_subtitle_style_bold_off"
app:title="@string/pref_subtitle_style_bold" />

<Preference
app:title="@string/pref_captioning_preferences">
<intent android:action="android.settings.CAPTIONING_SETTINGS" />
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.1'
classpath 'com.android.tools.build:gradle:8.1.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 97a3351

Please sign in to comment.