kopia lustrzana https://github.com/TeamNewPipe/NewPipe
-Added settings for managing caption font size.
rodzic
f506fc0478
commit
59f8583895
|
@ -51,6 +51,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
|
import com.google.android.exoplayer2.ui.SubtitleView;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
|
@ -337,8 +338,24 @@ public final class MainVideoPlayer extends Activity {
|
||||||
channelTextView.setSelected(true);
|
channelTextView.setSelected(true);
|
||||||
|
|
||||||
getRootView().setKeepScreenOn(true);
|
getRootView().setKeepScreenOn(true);
|
||||||
getSubtitleView().setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
|
}
|
||||||
getCaptionSizePx(context));
|
|
||||||
|
@Override
|
||||||
|
protected void setupSubtitleView(@NonNull SubtitleView view,
|
||||||
|
@NonNull String captionSizeKey) {
|
||||||
|
final float captionRatio;
|
||||||
|
if (captionSizeKey.equals(getString(R.string.smaller_caption_size_key))) {
|
||||||
|
captionRatio = 22f;
|
||||||
|
} else if (captionSizeKey.equals(getString(R.string.larger_caption_size_key))) {
|
||||||
|
captionRatio = 18f;
|
||||||
|
} else {
|
||||||
|
captionRatio = 20f;
|
||||||
|
}
|
||||||
|
|
||||||
|
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||||
|
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
|
||||||
|
view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
|
||||||
|
(float) minimumLength / captionRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -768,12 +785,6 @@ public final class MainVideoPlayer extends Activity {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getCaptionSizePx(@NonNull Context context) {
|
|
||||||
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
|
||||||
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
|
|
||||||
// todo: expose size control to users
|
|
||||||
return (float) minimumLength / 20f;
|
|
||||||
}
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Getters
|
// Getters
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -53,6 +53,7 @@ import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.PlaybackParameters;
|
import com.google.android.exoplayer2.PlaybackParameters;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
|
import com.google.android.exoplayer2.ui.SubtitleView;
|
||||||
|
|
||||||
import org.schabi.newpipe.BuildConfig;
|
import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
@ -391,6 +392,18 @@ public final class PopupVideoPlayer extends Service {
|
||||||
rootView.addOnLayoutChangeListener(this);
|
rootView.addOnLayoutChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupSubtitleView(@NonNull SubtitleView view,
|
||||||
|
@NonNull String captionSizeKey) {
|
||||||
|
float captionRatio = SubtitleView.DEFAULT_TEXT_SIZE_FRACTION;
|
||||||
|
if (captionSizeKey.equals(getString(R.string.smaller_caption_size_key))) {
|
||||||
|
captionRatio *= 0.9;
|
||||||
|
} else if (captionSizeKey.equals(getString(R.string.larger_caption_size_key))) {
|
||||||
|
captionRatio *= 1.1;
|
||||||
|
}
|
||||||
|
view.setFractionalTextSize(captionRatio);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutChange(final View view, int left, int top, int right, int bottom,
|
public void onLayoutChange(final View view, int left, int top, int right, int bottom,
|
||||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
@ -183,7 +184,12 @@ public abstract class VideoPlayer extends BasePlayer
|
||||||
this.bottomControlsRoot = rootView.findViewById(R.id.bottomControls);
|
this.bottomControlsRoot = rootView.findViewById(R.id.bottomControls);
|
||||||
this.topControlsRoot = rootView.findViewById(R.id.topControls);
|
this.topControlsRoot = rootView.findViewById(R.id.topControls);
|
||||||
this.qualityTextView = rootView.findViewById(R.id.qualityTextView);
|
this.qualityTextView = rootView.findViewById(R.id.qualityTextView);
|
||||||
|
|
||||||
this.subtitleView = rootView.findViewById(R.id.subtitleView);
|
this.subtitleView = rootView.findViewById(R.id.subtitleView);
|
||||||
|
final String captionSizeKey = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
.getString(context.getString(R.string.caption_size_key),
|
||||||
|
context.getString(R.string.caption_size_default));
|
||||||
|
setupSubtitleView(subtitleView, captionSizeKey);
|
||||||
|
|
||||||
this.resizeView = rootView.findViewById(R.id.resizeTextView);
|
this.resizeView = rootView.findViewById(R.id.resizeTextView);
|
||||||
resizeView.setText(PlayerHelper.resizeTypeOf(context, aspectRatioFrameLayout.getResizeMode()));
|
resizeView.setText(PlayerHelper.resizeTypeOf(context, aspectRatioFrameLayout.getResizeMode()));
|
||||||
|
@ -204,6 +210,9 @@ public abstract class VideoPlayer extends BasePlayer
|
||||||
.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
|
.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract void setupSubtitleView(@NonNull SubtitleView view,
|
||||||
|
@NonNull String captionSizeKey);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initListeners() {
|
public void initListeners() {
|
||||||
super.initListeners();
|
super.initListeners();
|
||||||
|
|
|
@ -100,6 +100,25 @@
|
||||||
<item>@string/black_theme_title</item>
|
<item>@string/black_theme_title</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Caption Size -->
|
||||||
|
<string name="caption_size_key" translatable="false">caption_size_key</string>
|
||||||
|
<string name="caption_size_default" translatable="false">@string/normal_caption_size_key</string>
|
||||||
|
|
||||||
|
<string name="smaller_caption_size_key" translatable="false">smaller_caption_size</string>
|
||||||
|
<string name="normal_caption_size_key" translatable="false">normal_caption_size</string>
|
||||||
|
<string name="larger_caption_size_key" translatable="false">larger_caption_size</string>
|
||||||
|
|
||||||
|
<string-array name="caption_size_descriptions_list" translatable="false">
|
||||||
|
<item>@string/smaller_caption_font_size</item>
|
||||||
|
<item>@string/normal_caption_font_size</item>
|
||||||
|
<item>@string/larger_caption_font_size</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="caption_size_values_list" translatable="false">
|
||||||
|
<item>@string/smaller_caption_size_key</item>
|
||||||
|
<item>@string/normal_caption_size_key</item>
|
||||||
|
<item>@string/larger_caption_size_key</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<!-- Content & History -->
|
<!-- Content & History -->
|
||||||
<string name="show_search_suggestions_key" translatable="false">show_search_suggestions</string>
|
<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_play_with_kodi_key" translatable="false">show_play_with_kodi</string>
|
||||||
|
|
|
@ -403,4 +403,9 @@
|
||||||
<string name="resize_fill">FILL</string>
|
<string name="resize_fill">FILL</string>
|
||||||
<string name="resize_zoom">ZOOM</string>
|
<string name="resize_zoom">ZOOM</string>
|
||||||
|
|
||||||
|
<string name="caption_font_size_settings_title">Caption Font Size</string>
|
||||||
|
<string name="smaller_caption_font_size">Smaller Font</string>
|
||||||
|
<string name="normal_caption_font_size">Normal Font</string>
|
||||||
|
<string name="larger_caption_font_size">Larger Font</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -21,4 +21,12 @@
|
||||||
android:key="@string/show_hold_to_append_key"
|
android:key="@string/show_hold_to_append_key"
|
||||||
android:title="@string/show_hold_to_append_title"
|
android:title="@string/show_hold_to_append_title"
|
||||||
android:summary="@string/show_hold_to_append_summary"/>
|
android:summary="@string/show_hold_to_append_summary"/>
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/caption_size_default"
|
||||||
|
android:entries="@array/caption_size_descriptions_list"
|
||||||
|
android:entryValues="@array/caption_size_values_list"
|
||||||
|
android:key="@string/caption_size_key"
|
||||||
|
android:summary="%s"
|
||||||
|
android:title="@string/caption_font_size_settings_title"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Ładowanie…
Reference in New Issue