mobile danmu setting dialog

pull/251/head
okjack 2 years ago
parent ca61f38445
commit 18ed56955e
  1. 5
      app/src/main/java/com/fongmi/android/tv/player/danmu/Parser.java
  2. 6
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/MainActivity.java
  3. 23
      app/src/mobile/java/com/fongmi/android/tv/ui/activity/VideoActivity.java
  4. 54
      app/src/mobile/java/com/fongmi/android/tv/ui/dialog/DanmuAlphaDialog.java
  5. 83
      app/src/mobile/java/com/fongmi/android/tv/ui/dialog/DanmuDialog.java
  6. 54
      app/src/mobile/java/com/fongmi/android/tv/ui/dialog/DanmuLineDialog.java
  7. 54
      app/src/mobile/java/com/fongmi/android/tv/ui/dialog/DanmuSizeDialog.java
  8. 104
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/SettingDanmuFragment.java
  9. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/SettingFragment.java
  10. 7
      app/src/mobile/java/com/fongmi/android/tv/ui/fragment/SettingPlayerFragment.java
  11. 13
      app/src/mobile/res/drawable/ic_control_danmu_setting.xml
  12. 179
      app/src/mobile/res/layout/dialog_danmu.xml
  13. 20
      app/src/mobile/res/layout/dialog_danmu_alpha.xml
  14. 20
      app/src/mobile/res/layout/dialog_danmu_line.xml
  15. 20
      app/src/mobile/res/layout/dialog_danmu_size.xml
  16. 17
      app/src/mobile/res/layout/fragment_setting.xml
  17. 210
      app/src/mobile/res/layout/fragment_setting_danmu.xml
  18. 27
      app/src/mobile/res/layout/fragment_setting_player.xml
  19. 39
      app/src/mobile/res/layout/view_control_vod.xml

@ -3,7 +3,6 @@ package com.fongmi.android.tv.player.danmu;
import android.graphics.Color;
import android.text.TextUtils;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.bean.Danmu;
import com.github.catvod.net.OkHttp;
import com.github.catvod.utils.Path;
@ -25,7 +24,6 @@ import master.flame.danmaku.danmaku.util.DanmakuUtils;
public class Parser extends BaseDanmakuParser {
private final Danmu danmu;
private final float dSize;
private BaseDanmaku item;
private float scaleX;
private float scaleY;
@ -33,7 +31,6 @@ public class Parser extends BaseDanmakuParser {
public Parser(String path) {
this.danmu = Danmu.fromXml(getContent(path));
this.dSize = Setting.getDanmuSize();
}
private String getContent(String path) {
@ -73,7 +70,7 @@ public class Parser extends BaseDanmakuParser {
item = mContext.mDanmakuFactory.createDanmaku(type, mContext);
item.setTime(time);
item.setTimer(mTimer);
item.textSize = size * dSize;
item.textSize = size;
item.textColor = color;
item.textShadowColor = color <= Color.BLACK ? Color.WHITE : Color.BLACK;
item.flags = mContext.mGlobalFlagValues;

@ -34,7 +34,6 @@ import com.fongmi.android.tv.server.Server;
import com.fongmi.android.tv.ui.base.BaseActivity;
import com.fongmi.android.tv.ui.custom.FragmentStateManager;
import com.fongmi.android.tv.ui.fragment.SettingCustomFragment;
import com.fongmi.android.tv.ui.fragment.SettingDanmuFragment;
import com.fongmi.android.tv.ui.fragment.SettingFragment;
import com.fongmi.android.tv.ui.fragment.SettingPlayerFragment;
import com.fongmi.android.tv.ui.fragment.VodFragment;
@ -97,8 +96,7 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt
if (position == 0) return VodFragment.newInstance();
if (position == 1) return SettingFragment.newInstance();
if (position == 2) return SettingPlayerFragment.newInstance();
if (position == 3) return SettingDanmuFragment.newInstance();
if (position == 4) return SettingCustomFragment.newInstance();
if (position == 3) return SettingCustomFragment.newInstance();
return null;
}
};
@ -212,8 +210,6 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt
protected void onBackPress() {
if (!mBinding.navigation.getMenu().findItem(R.id.vod).isVisible()) {
setNavigation();
} else if (mManager.isVisible(4)) {
change(1);
} else if (mManager.isVisible(3)) {
change(1);
} else if (mManager.isVisible(2)) {

@ -82,6 +82,7 @@ import com.fongmi.android.tv.ui.custom.CustomMovement;
import com.fongmi.android.tv.ui.custom.SpaceItemDecoration;
import com.fongmi.android.tv.ui.dialog.CastDialog;
import com.fongmi.android.tv.ui.dialog.ControlDialog;
import com.fongmi.android.tv.ui.dialog.DanmuDialog;
import com.fongmi.android.tv.ui.dialog.EpisodeGridDialog;
import com.fongmi.android.tv.ui.dialog.EpisodeListDialog;
import com.fongmi.android.tv.ui.dialog.InfoDialog;
@ -340,6 +341,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mBinding.control.full.setOnClickListener(view -> onFull());
mBinding.control.keep.setOnClickListener(view -> onKeep());
mBinding.control.danmu.setOnClickListener(view -> onDanmu());
mBinding.control.danmuSetting.setOnClickListener(view -> onDanmuSetting());
mBinding.control.play.setOnClickListener(view -> checkPlay());
mBinding.control.next.setOnClickListener(view -> checkNext());
mBinding.control.prev.setOnClickListener(view -> checkPrev());
@ -413,18 +415,24 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
setSubtitle(14);
}
private void setDanmuView() {
public void setDanmuViewSettings() {
int maxLine = Setting.getDanmuLine(2);
mPlayers.setDanmuView(mBinding.danmaku);
float[] range = {2.4f, 1.8f, 1.2f, 0.8f};
float speed = range[Setting.getDanmuSpeed()];
float alpha = Setting.getDanmuAlpha() / 100.0f;
float sizeScale = Setting.getDanmuSize();
HashMap<Integer, Integer> maxLines = new HashMap<>();
maxLines.put(BaseDanmaku.TYPE_FIX_TOP, maxLine);
maxLines.put(BaseDanmaku.TYPE_SCROLL_RL, maxLine);
maxLines.put(BaseDanmaku.TYPE_SCROLL_LR, maxLine);
maxLines.put(BaseDanmaku.TYPE_FIX_BOTTOM, maxLine);
mDanmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setMaximumLines(maxLines).setScrollSpeedFactor(speed).setDanmakuTransparency(alpha).setDanmakuMargin(8).setScaleTextSize(0.8f);
mDanmakuContext.setMaximumLines(maxLines).setScrollSpeedFactor(speed).setDanmakuTransparency(alpha).setScaleTextSize(sizeScale);
}
private void setDanmuView() {
mPlayers.setDanmuView(mBinding.danmaku);
setDanmuViewSettings();
mDanmakuContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDanmakuMargin(8);
checkDanmuImg();
}
@ -744,6 +752,10 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
showDanmu();
}
private void onDanmuSetting() {
DanmuDialog.create().show(this);
}
private void showDanmu() {
if (Setting.isDanmu()) mBinding.danmaku.show();
else mBinding.danmaku.hide();
@ -952,7 +964,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
App.post(() -> mBinding.video.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)), 50);
setRequestedOrientation(mPlayers.isPortrait() ? ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
mBinding.control.full.setVisibility(View.GONE);
mDanmakuContext.setScaleTextSize(1.0f);
mDanmakuContext.setScaleTextSize(1.0f * Setting.getDanmuSize());
setRotate(mPlayers.isPortrait(), true);
setSubtitle(Setting.getSubtitle());
Util.hideSystemUI(this);
@ -966,7 +978,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
mBinding.episode.scrollToPosition(mEpisodeAdapter.getPosition());
mBinding.control.full.setVisibility(View.VISIBLE);
mBinding.video.setLayoutParams(mFrameParams);
mDanmakuContext.setScaleTextSize(0.8f);
mDanmakuContext.setScaleTextSize(0.8f * Setting.getDanmuSize());
setRotate(false, false);
App.post(mR3, 2000);
setSubtitle(14);
@ -1011,6 +1023,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
private void showControl() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInPictureInPictureMode()) return;
mBinding.control.danmu.setVisibility(isLock() || !mBinding.danmaku.isPrepared() ? View.GONE : View.VISIBLE);
mBinding.control.danmuSetting.setVisibility(isLock() || !Setting.isDanmuLoad() ? View.GONE : View.VISIBLE);
mBinding.control.setting.setVisibility(mHistory == null || isFullscreen() ? View.GONE : View.VISIBLE);
mBinding.control.right.rotate.setVisibility(isFullscreen() && !isLock() ? View.VISIBLE : View.GONE);
mBinding.control.keep.setVisibility(mHistory == null || isFullscreen() ? View.GONE : View.VISIBLE);

@ -1,54 +0,0 @@
package com.fongmi.android.tv.ui.dialog;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.databinding.DialogDanmuAlphaBinding;
import com.fongmi.android.tv.impl.DanmuAlphaCallback;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class DanmuAlphaDialog {
private final DialogDanmuAlphaBinding binding;
private final DanmuAlphaCallback callback;
private int value;
public static DanmuAlphaDialog create(Fragment fragment) {
return new DanmuAlphaDialog(fragment);
}
public DanmuAlphaDialog(Fragment fragment) {
this.callback = (DanmuAlphaCallback) fragment;
this.binding = DialogDanmuAlphaBinding.inflate(LayoutInflater.from(fragment.getContext()));
}
public void show() {
initDialog();
initView();
}
private void initDialog() {
AlertDialog dialog = new MaterialAlertDialogBuilder(binding.getRoot().getContext()).setTitle(R.string.player_danmu_alpha).setView(binding.getRoot()).setPositiveButton(R.string.dialog_positive, this::onPositive).setNegativeButton(R.string.dialog_negative, this::onNegative).create();
dialog.getWindow().setDimAmount(0);
dialog.show();
}
private void initView() {
binding.slider.setValue(value = Setting.getDanmuAlpha());
}
private void onPositive(DialogInterface dialog, int which) {
callback.setDanmuAlpha((int) binding.slider.getValue());
dialog.dismiss();
}
private void onNegative(DialogInterface dialog, int which) {
callback.setDanmuAlpha(value);
dialog.dismiss();
}
}

@ -0,0 +1,83 @@
package com.fongmi.android.tv.ui.dialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewbinding.ViewBinding;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.databinding.DialogDanmuBinding;
import com.fongmi.android.tv.ui.activity.VideoActivity;
import com.fongmi.android.tv.utils.ResUtil;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.slider.Slider;
public class DanmuDialog extends BaseDialog {
private DialogDanmuBinding binding;
private String[] danmuSpeed;
private int speed;
private VideoActivity activity;
public static DanmuDialog create() {
return new DanmuDialog();
}
public DanmuDialog() {
}
public DanmuDialog show(FragmentActivity activity) {
for (Fragment f : activity.getSupportFragmentManager().getFragments()) if (f instanceof BottomSheetDialogFragment) return this;
show(activity.getSupportFragmentManager(), null);
this.activity = (VideoActivity) activity;
return this;
}
@Override
protected ViewBinding getBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
return binding = DialogDanmuBinding.inflate(inflater, container, false);
}
@Override
protected void initView() {
binding.list.setVisibility(View.VISIBLE);
binding.speed.setValue(speed = Setting.getDanmuSpeed());
binding.size.setValue(Setting.getDanmuSize());
binding.line.setValue(Setting.getDanmuLine(2));
binding.alpha.setValue(Setting.getDanmuAlpha());
binding.speedText.setText((danmuSpeed = ResUtil.getStringArray(R.array.select_danmu_speed))[speed]);
}
@Override
protected void initEvent() {
binding.speed.addOnChangeListener((@NonNull Slider slider, float value, boolean fromUser) -> {
int val = (int) slider.getValue();
binding.speedText.setText(danmuSpeed[val]);
Setting.putDanmuSpeed(val);
this.activity.setDanmuViewSettings();
});
binding.size.addOnChangeListener((@NonNull Slider slider, float value, boolean fromUser) -> {
Setting.putDanmuSize(slider.getValue());
this.activity.setDanmuViewSettings();
});
binding.line.addOnChangeListener((@NonNull Slider slider, float value, boolean fromUser) -> {
Setting.putDanmuLine((int) slider.getValue());
this.activity.setDanmuViewSettings();
});
binding.alpha.addOnChangeListener((@NonNull Slider slider, float value, boolean fromUser) -> {
Setting.putDanmuAlpha((int) slider.getValue());
this.activity.setDanmuViewSettings();
});
}
@Override
public void dismiss() {
super.dismiss();
}
}

@ -1,54 +0,0 @@
package com.fongmi.android.tv.ui.dialog;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.databinding.DialogDanmuLineBinding;
import com.fongmi.android.tv.impl.DanmuLineCallback;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class DanmuLineDialog {
private final DialogDanmuLineBinding binding;
private final DanmuLineCallback callback;
private int value;
public static DanmuLineDialog create(Fragment fragment) {
return new DanmuLineDialog(fragment);
}
public DanmuLineDialog(Fragment fragment) {
this.callback = (DanmuLineCallback) fragment;
this.binding = DialogDanmuLineBinding.inflate(LayoutInflater.from(fragment.getContext()));
}
public void show() {
initDialog();
initView();
}
private void initDialog() {
AlertDialog dialog = new MaterialAlertDialogBuilder(binding.getRoot().getContext()).setTitle(R.string.player_danmu_line).setView(binding.getRoot()).setPositiveButton(R.string.dialog_positive, this::onPositive).setNegativeButton(R.string.dialog_negative, this::onNegative).create();
dialog.getWindow().setDimAmount(0);
dialog.show();
}
private void initView() {
binding.slider.setValue(value = Setting.getDanmuLine(2));
}
private void onPositive(DialogInterface dialog, int which) {
callback.setDanmuLine((int) binding.slider.getValue());
dialog.dismiss();
}
private void onNegative(DialogInterface dialog, int which) {
callback.setDanmuLine(value);
dialog.dismiss();
}
}

@ -1,54 +0,0 @@
package com.fongmi.android.tv.ui.dialog;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.databinding.DialogDanmuSizeBinding;
import com.fongmi.android.tv.impl.DanmuSizeCallback;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class DanmuSizeDialog {
private final DialogDanmuSizeBinding binding;
private final DanmuSizeCallback callback;
private float value;
public static DanmuSizeDialog create(Fragment fragment) {
return new DanmuSizeDialog(fragment);
}
public DanmuSizeDialog(Fragment fragment) {
this.callback = (DanmuSizeCallback) fragment;
this.binding = DialogDanmuSizeBinding.inflate(LayoutInflater.from(fragment.getContext()));
}
public void show() {
initDialog();
initView();
}
private void initDialog() {
AlertDialog dialog = new MaterialAlertDialogBuilder(binding.getRoot().getContext()).setTitle(R.string.player_danmu_size).setView(binding.getRoot()).setPositiveButton(R.string.dialog_positive, this::onPositive).setNegativeButton(R.string.dialog_negative, this::onNegative).create();
dialog.getWindow().setDimAmount(0);
dialog.show();
}
private void initView() {
binding.slider.setValue(value = Setting.getDanmuSize());
}
private void onPositive(DialogInterface dialog, int which) {
callback.setDanmuSize(binding.slider.getValue());
dialog.dismiss();
}
private void onNegative(DialogInterface dialog, int which) {
callback.setDanmuSize(value);
dialog.dismiss();
}
}

@ -1,104 +0,0 @@
package com.fongmi.android.tv.ui.fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewbinding.ViewBinding;
import com.fongmi.android.tv.R;
import com.fongmi.android.tv.Setting;
import com.fongmi.android.tv.databinding.FragmentSettingDanmuBinding;
import com.fongmi.android.tv.impl.DanmuAlphaCallback;
import com.fongmi.android.tv.impl.DanmuLineCallback;
import com.fongmi.android.tv.impl.DanmuSizeCallback;
import com.fongmi.android.tv.ui.base.BaseFragment;
import com.fongmi.android.tv.ui.dialog.DanmuAlphaDialog;
import com.fongmi.android.tv.ui.dialog.DanmuLineDialog;
import com.fongmi.android.tv.ui.dialog.DanmuSizeDialog;
import com.fongmi.android.tv.utils.ResUtil;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
public class SettingDanmuFragment extends BaseFragment implements DanmuLineCallback, DanmuSizeCallback, DanmuAlphaCallback {
private FragmentSettingDanmuBinding mBinding;
private String[] danmuSpeed;
public static SettingDanmuFragment newInstance() {
return new SettingDanmuFragment();
}
private String getSwitch(boolean value) {
return getString(value ? R.string.setting_on : R.string.setting_off);
}
@Override
protected ViewBinding getBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
return mBinding = FragmentSettingDanmuBinding.inflate(inflater, container, false);
}
@Override
protected void initView() {
mBinding.danmuLoadText.setText(getSwitch(Setting.isDanmuLoad()));
mBinding.danmuSizeText.setText(String.valueOf(Setting.getDanmuSize()));
mBinding.danmuLineText.setText(String.valueOf(Setting.getDanmuLine(2)));
mBinding.danmuAlphaText.setText(String.valueOf(Setting.getDanmuAlpha()));
mBinding.danmuSpeedText.setText((danmuSpeed = ResUtil.getStringArray(R.array.select_danmu_speed))[Setting.getDanmuSpeed()]);
}
@Override
protected void initEvent() {
mBinding.danmuSize.setOnClickListener(this::onDanmuSize);
mBinding.danmuLine.setOnClickListener(this::onDanmuLine);
mBinding.danmuLoad.setOnClickListener(this::setDanmuLoad);
mBinding.danmuAlpha.setOnClickListener(this::onDanmuAlpha);
mBinding.danmuSpeed.setOnClickListener(this::onDanmuSpeed);
}
private void onDanmuSize(View view) {
DanmuSizeDialog.create(this).show();
}
@Override
public void setDanmuSize(float size) {
mBinding.danmuSizeText.setText(String.valueOf(size));
Setting.putDanmuSize(size);
}
private void onDanmuLine(View view) {
DanmuLineDialog.create(this).show();
}
@Override
public void setDanmuLine(int line) {
mBinding.danmuLineText.setText(String.valueOf(line));
Setting.putDanmuLine(line);
}
private void setDanmuLoad(View view) {
Setting.putDanmuLoad(!Setting.isDanmuLoad());
mBinding.danmuLoadText.setText(getSwitch(Setting.isDanmuLoad()));
}
private void onDanmuAlpha(View view) {
DanmuAlphaDialog.create(this).show();
}
@Override
public void setDanmuAlpha(int alpha) {
mBinding.danmuAlphaText.setText(String.valueOf(alpha));
Setting.putDanmuAlpha(alpha);
}
private void onDanmuSpeed(View view) {
new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.player_danmu_speed).setNegativeButton(R.string.dialog_negative, null).setSingleChoiceItems(danmuSpeed, Setting.getDanmuSpeed(), (dialog, which) -> {
mBinding.danmuSpeedText.setText(danmuSpeed[which]);
Setting.putDanmuSpeed(which);
dialog.dismiss();
}).show();
}
}

@ -122,7 +122,6 @@ public class SettingFragment extends BaseFragment implements ConfigCallback, Sit
mBinding.wallDefault.setOnClickListener(this::setWallDefault);
mBinding.wallRefresh.setOnClickListener(this::setWallRefresh);
mBinding.doh.setOnClickListener(this::setDoh);
mBinding.danmu.setOnClickListener(this::onDanmu);
mBinding.custom.setOnClickListener(this::onCustom);
}
@ -257,12 +256,8 @@ public class SettingFragment extends BaseFragment implements ConfigCallback, Sit
getRoot().change(2);
}
private void onDanmu(View view) {
getRoot().change(3);
}
private void onCustom(View view) {
getRoot().change(4);
getRoot().change(3);
}
private void onVersion(View view) {

@ -57,6 +57,7 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
mBinding.captionText.setText(getSwitch(Setting.isCaption()));
mBinding.bufferText.setText(String.valueOf(Setting.getBuffer()));
mBinding.subtitleText.setText(String.valueOf(Setting.getSubtitle()));
mBinding.danmuLoadText.setText(getSwitch(Setting.isDanmuLoad()));
mBinding.flagText.setText((flag = ResUtil.getStringArray(R.array.select_flag))[Setting.getFlag()]);
mBinding.httpText.setText((http = ResUtil.getStringArray(R.array.select_exo_http))[Setting.getHttp()]);
mBinding.scaleText.setText((scale = ResUtil.getStringArray(R.array.select_scale))[Setting.getScale()]);
@ -79,6 +80,7 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
mBinding.caption.setOnClickListener(this::setCaption);
mBinding.subtitle.setOnClickListener(this::onSubtitle);
mBinding.caption.setOnLongClickListener(this::onCaption);
mBinding.danmuLoad.setOnClickListener(this::setDanmuLoad);
mBinding.background.setOnClickListener(this::onBackground);
}
@ -167,6 +169,11 @@ public class SettingPlayerFragment extends BaseFragment implements UaCallback, B
mBinding.subtitleText.setText(String.valueOf(size));
}
private void setDanmuLoad(View view) {
Setting.putDanmuLoad(!Setting.isDanmuLoad());
mBinding.danmuLoadText.setText(getSwitch(Setting.isDanmuLoad()));
}
private void onBackground(View view) {
new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.player_background).setNegativeButton(R.string.dialog_negative, null).setSingleChoiceItems(background, Setting.getBackground(), (dialog, which) -> {
mBinding.backgroundText.setText(background[which]);

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:fillType="evenOdd"
android:pathData="m15.645 4.881 1.06-1.473a.998.998 0 1 0-1.622-1.166L13.22 4.835a110.67 110.67 0 0 0-1.1-.007h-.131c-.47 0-.975.004-1.515.012L8.783 2.3A.998.998 0 0 0 7.12 3.408l.988 1.484c-.688.019-1.418.042-2.188.069a4.013 4.013 0 0 0-3.83 3.44c-.165 1.15-.245 2.545-.245 4.185 0 1.965.115 3.67.35 5.116a4.012 4.012 0 0 0 3.763 3.363c1.903.094 3.317.141 5.513.141a.988.988 0 0 0 0-1.975 97.58 97.58 0 0 1-5.416-.139 2.037 2.037 0 0 1-1.91-1.708c-.216-1.324-.325-2.924-.325-4.798 0-1.563.076-2.864.225-3.904.14-.977.96-1.713 1.945-1.747 2.444-.087 4.465-.13 6.063-.131 1.598 0 3.62.044 6.064.13.96.034 1.71.81 1.855 1.814.075.524.113 1.962.141 3.065v.002c.005.183.01.07.014-.038.004-.096.008-.189.011-.081a.987.987 0 1 0 1.974-.069c-.004-.105-.007-.009-.011.09-.002.056-.004.112-.007.135l-.002.01a.574.574 0 0 1-.005-.091v-.027c-.03-1.118-.073-2.663-.16-3.276-.273-1.906-1.783-3.438-3.74-3.507-.905-.032-1.752-.058-2.543-.079Zm-3.113 4.703h-1.307v4.643h2.2v.04l.651-1.234c.113-.215.281-.389.482-.509v-.11h.235c.137-.049.283-.074.433-.074h1.553V9.584h-1.264a8.5 8.5 0 0 0 .741-1.405l-1.078-.381c-.24.631-.501 1.23-.806 1.786h-1.503l.686-.305c-.228-.501-.5-.959-.806-1.394l-1.034.348c.294.392.566.839.817 1.35Zm-1.7 5.502h2.16l-.564 1.068h-1.595v-1.068Zm-2.498-1.863.152-1.561h1.96V8.289H7.277v.969h2.048v1.435h-1.84l-.306 3.51h2.254c0 1.155-.043 1.906-.12 2.255-.076.348-.38.523-.925.523-.305 0-.61-.022-.893-.055l.294 1.056.061.005c.282.02.546.039.81.039.991-.065 1.547-.414 1.677-1.046.11-.631.175-1.883.175-3.757H8.334Zm5.09-.8v.85h-1.188v-.85h1.187Zm-1.188-.955h1.187v-.893h-1.187v.893Zm2.322.007v-.893h1.241v.893h-1.241Zm.528 2.757a1.26 1.26 0 0 1 1.087-.627l4.003-.009a1.26 1.26 0 0 1 1.094.63l1.721 2.982c.226.39.225.872-.001 1.263l-1.743 3a1.26 1.26 0 0 1-1.086.628l-4.003.009a1.26 1.26 0 0 1-1.094-.63l-1.722-2.982a1.26 1.26 0 0 1 .002-1.263l1.742-3Zm1.967.858a1.26 1.26 0 0 0-1.08.614l-.903 1.513a1.26 1.26 0 0 0-.002 1.289l.885 1.492c.227.384.64.62 1.086.618l2.192-.005a1.26 1.26 0 0 0 1.08-.615l.904-1.518a1.26 1.26 0 0 0 .001-1.288l-.884-1.489a1.26 1.26 0 0 0-1.086-.616l-2.193.005Zm2.517 2.76a1.4 1.4 0 1 1-2.8 0 1.4 1.4 0 0 1 2.8 0Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="@string/play_danmu"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp"
android:visibility="gone"
tools:visibility="visible">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/player_danmu_speed"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center_vertical|left"
android:textSize="16sp" />
<com.google.android.material.slider.Slider
android:id="@+id/speed"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:gravity="center_vertical|center"
android:stepSize="1"
android:valueFrom="0"
android:valueTo="3"
app:trackColorInactive="@color/blue_50" />
<TextView
android:id="@+id/speedText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="适中"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/player_danmu_size"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center_vertical|left"
android:textSize="16sp" />
<com.google.android.material.slider.Slider
android:id="@+id/size"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:gravity="center_vertical|center"
android:stepSize="0.2"
android:valueFrom="0.6"
android:valueTo="2"
app:trackColorInactive="@color/blue_50" />
<TextView
android:id="@+id/sizeText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="@string/times"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/player_danmu_line"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center_vertical|left"
android:textSize="16sp" />
<com.google.android.material.slider.Slider
android:id="@+id/line"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:gravity="center_vertical|center"
android:stepSize="1"
android:valueFrom="1"
android:valueTo="15"
app:trackColorInactive="@color/blue_50" />
<TextView
android:id="@+id/lineText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="@string/lines"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/player_danmu_alpha"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center_vertical|left"
android:textSize="16sp" />
<com.google.android.material.slider.Slider
android:id="@+id/alpha"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:gravity="center_vertical|center"
android:stepSize="5"
android:valueFrom="10"
android:valueTo="100"
app:trackColorInactive="@color/blue_50" />
<TextView
android:id="@+id/alphaText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="%"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingEnd="24dp">
<com.google.android.material.slider.Slider
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="5"
android:valueFrom="10"
android:valueTo="100"
app:trackColorInactive="@color/blue_50" />
</LinearLayout>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingEnd="24dp">
<com.google.android.material.slider.Slider
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="1"
android:valueFrom="1"
android:valueTo="15"
app:trackColorInactive="@color/blue_50" />
</LinearLayout>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="24dp"
android:paddingTop="16dp"
android:paddingEnd="24dp">
<com.google.android.material.slider.Slider
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="0.2"
android:valueFrom="0.6"
android:valueTo="2"
app:trackColorInactive="@color/blue_50" />
</LinearLayout>

@ -230,23 +230,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/danmu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setting_danmu"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/custom"
android:layout_width="match_parent"

@ -1,210 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:elevation="0dp"
app:elevation="0dp"
app:liftOnScrollColor="@color/transparent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:text="@string/setting_danmu"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_scrollFlags="scroll|enterAlways" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="never"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:paddingBottom="16dp">
<LinearLayout
android:id="@+id/danmuLoad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_load"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuLoadText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="開" />
</LinearLayout>
<LinearLayout
android:id="@+id/danmuSpeed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_speed"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuSpeedText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="慢" />
</LinearLayout>
<LinearLayout
android:id="@+id/danmuSize"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_size"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuSizeText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="@string/times"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/danmuLine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_line"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuLineText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="@string/lines"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/danmuAlpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_alpha"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuAlphaText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:text="%"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

@ -183,6 +183,33 @@
</LinearLayout>
<LinearLayout
android:id="@+id/danmuLoad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_item"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/player_danmu_load"
android:textColor="@color/white"
android:textSize="16sp" />
<TextView
android:id="@+id/danmuLoadText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end"
android:textColor="@color/white"
android:textSize="16sp"
tools:text="開" />
</LinearLayout>
<LinearLayout
android:id="@+id/background"
android:layout_width="match_parent"

@ -141,18 +141,37 @@
</FrameLayout>
</LinearLayout>
<ImageView
android:id="@+id/danmu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<LinearLayout
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="8dp"
android:visibility="gone"
tools:src="@drawable/ic_control_danmu_off"
tools:visibility="visible" />
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/danmu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="8dp"
android:visibility="gone"
tools:src="@drawable/ic_control_danmu_off"
tools:visibility="visible" />
<ImageView
android:id="@+id/danmuSetting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="8dp"
android:visibility="gone"
android:src="@drawable/ic_control_danmu_setting"
tools:visibility="visible" />
</LinearLayout>
<include
android:id="@+id/right"

Loading…
Cancel
Save