Add scroll gap for danmaku setting

fongmi
FongMi 2 weeks ago
parent 9eedcc2ac4
commit a0d096f77f
  1. 36
      app/src/leanback/res/layout/view_danmaku_density.xml
  2. 16
      app/src/main/java/com/fongmi/android/tv/setting/DanmakuSetting.java
  3. 1
      app/src/main/java/com/fongmi/android/tv/ui/dialog/DanmakuSettingPanel.java
  4. 5
      app/src/main/res/values-zh-rCN/strings.xml
  5. 5
      app/src/main/res/values-zh-rTW/strings.xml
  6. 3
      app/src/main/res/values/strings.xml
  7. 34
      app/src/mobile/res/layout/view_danmaku_density.xml

@ -78,6 +78,42 @@
android:valueTo="1.0"
app:tickVisible="false" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="24dp"
android:paddingTop="4dp">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/danmaku_scroll_gap_ratio"
android:textAppearance="?attr/textAppearanceBodyLarge" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/scrollGapValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorPrimary" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.slider.Slider
android:id="@+id/scrollGapSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:stepSize="0.1"
android:valueFrom="0"
android:valueTo="5.0"
app:tickVisible="false" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"

@ -154,7 +154,7 @@ public class DanmakuSetting {
}
public static float getScrollAreaRatio() {
return Prefers.getFloat("danmaku_scroll_area_ratio", 0.75f);
return Prefers.getFloat("danmaku_scroll_area_ratio", 0.5f);
}
public static void putScrollAreaRatio(float value) {
@ -193,6 +193,14 @@ public class DanmakuSetting {
Prefers.put("danmaku_line_spacing", value);
}
public static float getScrollGapRatio() {
return Prefers.getFloat("danmaku_scroll_gap_ratio", 0f);
}
public static void putScrollGapRatio(float value) {
Prefers.put("danmaku_scroll_gap_ratio", value);
}
public static boolean isShowScroll() {
return Prefers.getBoolean("danmaku_show_scroll", true);
}
@ -280,10 +288,11 @@ public class DanmakuSetting {
DanmakuConfig config = DanmakuConfig.DEFAULT;
putMaxOnScreen(config.maxOnScreen);
putScrollAreaRatio(config.scrollAreaRatio);
putScrollGapRatio(config.scrollGapRatio);
putLineSpacing(config.lineSpacing);
putMaxScrollLines(config.maxScrollLines);
putMaxTopLines(config.maxTopLines);
putMaxBottomLines(config.maxBottomLines);
putLineSpacing(config.lineSpacing);
}
public static void resetDisplay() {
@ -314,10 +323,11 @@ public class DanmakuSetting {
.setTimeOffsetMs(getTimeOffsetMs())
.setMaxOnScreen(getMaxOnScreen())
.setScrollAreaRatio(getScrollAreaRatio())
.setScrollGapRatio(getScrollGapRatio())
.setLineSpacing(getLineSpacing())
.setMaxScrollLines(getMaxScrollLines())
.setMaxTopLines(getMaxTopLines())
.setMaxBottomLines(getMaxBottomLines())
.setLineSpacing(getLineSpacing())
.setShowScroll(isShowScroll())
.setShowTop(isShowTop())
.setShowBottom(isShowBottom())

@ -72,6 +72,7 @@ final class DanmakuSettingPanel {
var density = binding.density;
setupInt(density.maxOnScreenSlider, density.maxOnScreenValue, DanmakuSetting.getMaxOnScreen(), String::valueOf, DanmakuSetting::putMaxOnScreen);
setupFloat(density.scrollAreaSlider, density.scrollAreaValue, DanmakuSetting.getScrollAreaRatio(), "%.2f", DanmakuSetting::putScrollAreaRatio);
setupFloat(density.scrollGapSlider, density.scrollGapValue, DanmakuSetting.getScrollGapRatio(), "%.1f", DanmakuSetting::putScrollGapRatio);
setupFloat(density.lineSpacingSlider, density.lineSpacingValue, DanmakuSetting.getLineSpacing(), "%.1f", DanmakuSetting::putLineSpacing);
setupInt(density.maxScrollLinesSlider, density.maxScrollLinesValue, DanmakuSetting.getMaxScrollLines(), this::linesText, DanmakuSetting::putMaxScrollLines);
setupInt(density.maxTopLinesSlider, density.maxTopLinesValue, DanmakuSetting.getMaxTopLines(), this::linesText, DanmakuSetting::putMaxTopLines);

@ -84,11 +84,12 @@
<string name="danmaku_fixed_duration">固定显示时间</string>
<string name="danmaku_time_offset">时间偏移</string>
<string name="danmaku_max_on_screen">最多同时显示</string>
<string name="danmaku_scroll_area_ratio">滚动区域比例</string>
<string name="danmaku_scroll_area_ratio">滚动区域</string>
<string name="danmaku_max_scroll_lines">最大滚动行数</string>
<string name="danmaku_max_top_lines">最大顶部行数</string>
<string name="danmaku_max_bottom_lines">最大底部行数</string>
<string name="danmaku_line_spacing">行距倍率</string>
<string name="danmaku_line_spacing">垂直间距</string>
<string name="danmaku_scroll_gap_ratio">水平间距</string>
<string name="danmaku_show_scroll">滚动弹幕</string>
<string name="danmaku_show_top">顶部固定</string>
<string name="danmaku_show_bottom">底部固定</string>

@ -84,11 +84,12 @@
<string name="danmaku_fixed_duration">固定顯示時間</string>
<string name="danmaku_time_offset">時間偏移</string>
<string name="danmaku_max_on_screen">最多同時顯示</string>
<string name="danmaku_scroll_area_ratio">滾動區域比例</string>
<string name="danmaku_scroll_area_ratio">滾動區域</string>
<string name="danmaku_max_scroll_lines">最大滾動行數</string>
<string name="danmaku_max_top_lines">最大頂部行數</string>
<string name="danmaku_max_bottom_lines">最大底部行數</string>
<string name="danmaku_line_spacing">行距倍率</string>
<string name="danmaku_line_spacing">垂直間距</string>
<string name="danmaku_scroll_gap_ratio">水平間距</string>
<string name="danmaku_show_scroll">滾動彈幕</string>
<string name="danmaku_show_top">頂部固定</string>
<string name="danmaku_show_bottom">底部固定</string>

@ -88,7 +88,8 @@
<string name="danmaku_max_scroll_lines">Max scroll rows</string>
<string name="danmaku_max_top_lines">Max top rows</string>
<string name="danmaku_max_bottom_lines">Max bottom rows</string>
<string name="danmaku_line_spacing">Line spacing</string>
<string name="danmaku_line_spacing">Line gap</string>
<string name="danmaku_scroll_gap_ratio">Row gap</string>
<string name="danmaku_show_scroll">Scrolling</string>
<string name="danmaku_show_top">Top pinned</string>
<string name="danmaku_show_bottom">Bottom pinned</string>

@ -73,6 +73,40 @@
android:valueTo="1.0"
app:tickVisible="false" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingHorizontal="24dp"
android:paddingTop="4dp">
<com.google.android.material.textview.MaterialTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/danmaku_scroll_gap_ratio"
android:textAppearance="?attr/textAppearanceBodyLarge" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/scrollGapValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorPrimary" />
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.slider.Slider
android:id="@+id/scrollGapSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:stepSize="0.1"
android:valueFrom="0"
android:valueTo="5.0"
app:tickVisible="false" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"

Loading…
Cancel
Save