- 字幕黑边 (by okjack)

- 云盘字幕不能加载的bug修复 (by okjack)
pull/68/head
okjackcaptain 3 years ago
parent dff7367240
commit dd110ccfef
  1. 2
      app/src/main/java/com/github/tvbox/osc/subtitle/SubtitleLoader.java
  2. 65
      app/src/main/java/com/github/tvbox/osc/subtitle/widget/SimpleSubtitleView.java
  3. 2
      app/src/main/java/com/github/tvbox/osc/ui/activity/PlayActivity.java
  4. 2
      app/src/main/java/com/github/tvbox/osc/ui/fragment/PlayFragment.java
  5. 4
      app/src/main/res/layout/player_vod_control_view.xml

@ -160,7 +160,7 @@ public class SubtitleLoader {
throws IOException, FatalParsingException, Exception {
Log.d(TAG, "parseRemote: remoteSubtitlePath = " + remoteSubtitlePath);
String referer = "";
if (remoteSubtitlePath.contains("alicloud")) {
if (remoteSubtitlePath.contains("alicloud") || remoteSubtitlePath.contains("aliyundrive")) {
referer = "https://www.aliyundrive.com/";
} else if (remoteSubtitlePath.contains("assrt.net")) {
referer = "https://secure.assrt.net/";

@ -28,8 +28,15 @@ package com.github.tvbox.osc.subtitle.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import androidx.annotation.Nullable;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.Html;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.TextView;
import com.github.tvbox.osc.cache.CacheManager;
@ -59,19 +66,24 @@ public class SimpleSubtitleView extends TextView
public boolean hasInternal = false;
private TextView backGroundText = null;//用于描边的TextView
public SimpleSubtitleView(final Context context) {
super(context);
backGroundText = new TextView(context);
init();
}
public SimpleSubtitleView(final Context context, final AttributeSet attrs) {
super(context, attrs);
backGroundText = new TextView(context, attrs);
init();
}
public SimpleSubtitleView(final Context context, final AttributeSet attrs,
final int defStyleAttr) {
super(context, attrs, defStyleAttr);
backGroundText = new TextView(context, attrs, defStyleAttr);
init();
}
@ -176,4 +188,57 @@ public class SimpleSubtitleView extends TextView
destroy();
super.onDetachedFromWindow();
}
@Override
public void setLayoutParams(ViewGroup.LayoutParams params) {
//同步布局参数
backGroundText.setLayoutParams(params);
super.setLayoutParams(params);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
CharSequence tt = backGroundText.getText();
//两个TextView上的文字必须一致
if (TextUtils.isEmpty(tt) || !tt.equals(this.getText())) {
backGroundText.setText(getText());
this.postInvalidate();
}
backGroundText.measure(widthMeasureSpec, heightMeasureSpec);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
if (backGroundText != null) {
backGroundText.setText(text);
}
super.onTextChanged(text, start, lengthBefore, lengthAfter);
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
backGroundText.layout(left, top, right, bottom);
super.onLayout(changed, left, top, right, bottom);
}
@Override
protected void onDraw(Canvas canvas) {
//其他地方,backGroundText和super的先后顺序影响不会很大,但是此处必须要先绘制backGroundText,
drawBackGroundText();
backGroundText.draw(canvas);
super.onDraw(canvas);
}
private void drawBackGroundText() {
TextPaint tp = backGroundText.getPaint();
//设置描边宽度
tp.setStrokeWidth(10);
//背景描边并填充全部
tp.setStyle(Paint.Style.FILL_AND_STROKE);
//设置描边颜色
backGroundText.setTextColor(Color.BLACK);
//将背景的文字对齐方式做同步
backGroundText.setGravity(getGravity());
}
}

@ -340,10 +340,8 @@ public class PlayActivity extends BaseActivity {
void setSubtitleViewTextStyle(int style) {
if (style == 0) {
mController.mSubtitleView.setTextColor(getBaseContext().getResources().getColorStateList(R.color.color_FFFFFF));
mController.mSubtitleView.setShadowLayer(3, 2, 2, R.color.color_CC000000);
} else if (style == 1) {
mController.mSubtitleView.setTextColor(getBaseContext().getResources().getColorStateList(R.color.color_FFB6C1));
mController.mSubtitleView.setShadowLayer(3, 2, 2, R.color.color_FFFFFF);
}
}

@ -340,10 +340,8 @@ public class PlayFragment extends BaseLazyFragment {
void setSubtitleViewTextStyle(int style) {
if (style == 0) {
mController.mSubtitleView.setTextColor(getContext().getResources().getColorStateList(R.color.color_FFFFFF));
mController.mSubtitleView.setShadowLayer(3, 2, 2, R.color.color_CC000000);
} else if (style == 1) {
mController.mSubtitleView.setTextColor(getContext().getResources().getColorStateList(R.color.color_FFB6C1));
mController.mSubtitleView.setShadowLayer(3, 2, 2, R.color.color_FFFFFF);
}
}

@ -97,10 +97,6 @@
android:paddingRight="@dimen/vs_20"
android:paddingBottom="@dimen/vs_15"
android:text=""
android:shadowColor="@color/color_CC000000"
android:shadowRadius="3"
android:shadowDx="2"
android:shadowDy="2"
android:textColor="#ffffff"
android:textSize="16sp"
android:textStyle="bold"/>

Loading…
Cancel
Save