feat: 优化

pull/277/head
kunfei 5 years ago
parent 204ebe072f
commit 910646e599
  1. 1
      app/src/main/java/io/legado/app/constant/PreferKey.kt
  2. 1
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt
  5. 1
      app/src/main/res/values-zh-rHK/strings.xml
  6. 1
      app/src/main/res/values/strings.xml
  7. 132
      app/src/main/res/xml/pref_config_read.xml

@ -43,4 +43,5 @@ object PreferKey {
const val readStyleSelect = "readStyleSelect"
const val systemTypefaces = "system_typefaces"
const val readBodyToLh = "readBodyToLh"
const val textFullJustify = "textFullJustify"
}

@ -127,6 +127,7 @@ object ReadBookConfig {
}
var isScroll = pageAnim == 3
val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true)
val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true)
var bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2)
set(value) {
field = value

@ -111,6 +111,9 @@ class MoreConfigDialog : DialogFragment() {
Help.setOrientation(it)
}
}
PreferKey.textFullJustify -> {
postEvent(EventBus.UP_CONFIG, true)
}
}
}

@ -161,6 +161,10 @@ object ChapterProvider {
desiredWidth: Float
) {
var x = 0f
if (!ReadBookConfig.textFullJustify) {
addCharsToLineLast(textLine, words, textPaint, x)
return
}
val bodyIndent = ReadBookConfig.bodyIndent
val icw = StaticLayout.getDesiredWidth(bodyIndent, textPaint) / bodyIndent.length
bodyIndent.toStringArray().forEach {
@ -186,6 +190,10 @@ object ChapterProvider {
desiredWidth: Float,
startX: Float
) {
if (!ReadBookConfig.textFullJustify) {
addCharsToLineLast(textLine, words, textPaint, startX)
return
}
val gapCount: Int = words.length - 1
val d = (visibleWidth - desiredWidth) / gapCount
var x = startX

@ -691,4 +691,5 @@
<string name="hideFooter">隱藏頁脚</string>
<string name="auto_change_source">自動換源</string>
<string name="to_bottom">置底</string>
<string name="text_full_justify">文字兩端對齊</string>
</resources>

@ -693,5 +693,6 @@
<string name="night_background_color">夜间,背景色</string>
<string name="night_navbar_color">夜间,底栏色</string>
<string name="auto_change_source">自动换源</string>
<string name="text_full_justify">文字两端对齐</string>
</resources>

@ -2,79 +2,85 @@
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<io.legado.app.ui.widget.prefs.NameListPreference
android:key="@string/pk_requested_direction"
android:defaultValue="0"
android:title="@string/screen_direction"
android:entries="@array/screen_direction_title"
android:entryValues="@array/screen_direction_value"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:key="@string/pk_requested_direction"
android:defaultValue="0"
android:title="@string/screen_direction"
android:entries="@array/screen_direction_title"
android:entryValues="@array/screen_direction_value"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:key="keep_light"
android:defaultValue="0"
android:entryValues="@array/screen_time_out_value"
android:entries="@array/screen_time_out"
android:title="@string/keep_light"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.NameListPreference
android:key="keep_light"
android:defaultValue="0"
android:entryValues="@array/screen_time_out_value"
android:entries="@array/screen_time_out"
android:title="@string/keep_light"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_status_bar"
android:key="hideStatusBar"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_status_bar"
android:key="hideStatusBar"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/read_body_to_lh"
android:key="readBodyToLh"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/read_body_to_lh"
android:key="readBodyToLh"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_navigation_bar"
android:key="hideNavigationBar"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/pt_hide_navigation_bar"
android:key="hideNavigationBar"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/volume_key_page"
android:key="volumeKeyPage"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/text_full_justify"
android:key="textFullJustify"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/click_turn_page"
android:key="clickTurnPage"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/volume_key_page"
android:key="volumeKeyPage"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/click_all_next_page"
android:key="clickAllNext"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/click_turn_page"
android:key="clickTurnPage"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/volume_key_page_on_play"
android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/click_all_next_page"
android:key="clickAllNext"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/auto_change_source"
android:key="autoChangeSource"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/volume_key_page_on_play"
android:key="volumeKeyPageOnPlay"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/selectText"
android:key="selectText"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="true"
android:title="@string/auto_change_source"
android:key="autoChangeSource"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey"
android:title="@string/custom_page_key"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.SwitchPreference
android:defaultValue="false"
android:title="@string/selectText"
android:key="selectText"
app:iconSpaceReserved="false" />
<io.legado.app.ui.widget.prefs.Preference
android:key="customPageKey"
android:title="@string/custom_page_key"
app:iconSpaceReserved="false" />
</androidx.preference.PreferenceScreen>
Loading…
Cancel
Save