parent
c99355e504
commit
39ed24d4dc
@ -1,91 +0,0 @@ |
||||
package io.legado.app.ui.book.read.config |
||||
|
||||
import android.content.DialogInterface |
||||
import android.os.Bundle |
||||
import android.util.DisplayMetrics |
||||
import android.view.LayoutInflater |
||||
import android.view.View |
||||
import android.view.ViewGroup |
||||
import io.legado.app.R |
||||
import io.legado.app.base.BaseDialogFragment |
||||
import io.legado.app.constant.EventBus |
||||
import io.legado.app.help.ReadBookConfig |
||||
import io.legado.app.ui.book.read.Help |
||||
import io.legado.app.utils.postEvent |
||||
import kotlinx.android.synthetic.main.dialog_read_type.* |
||||
|
||||
class ReadTypeDialog : BaseDialogFragment() { |
||||
|
||||
override fun onStart() { |
||||
super.onStart() |
||||
val dm = DisplayMetrics() |
||||
activity?.let { |
||||
Help.upSystemUiVisibility(it) |
||||
it.windowManager?.defaultDisplay?.getMetrics(dm) |
||||
} |
||||
dialog?.window?.let { |
||||
val attr = it.attributes |
||||
attr.dimAmount = 0.0f |
||||
it.attributes = attr |
||||
it.setLayout((dm.widthPixels * 0.9).toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) |
||||
} |
||||
} |
||||
|
||||
override fun onCreateView( |
||||
inflater: LayoutInflater, |
||||
container: ViewGroup?, |
||||
savedInstanceState: Bundle? |
||||
): View? { |
||||
return inflater.inflate(R.layout.dialog_read_type, container) |
||||
} |
||||
|
||||
override fun onDismiss(dialog: DialogInterface) { |
||||
super.onDismiss(dialog) |
||||
ReadBookConfig.save() |
||||
} |
||||
|
||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
||||
initView() |
||||
initViewEvent() |
||||
upStyle() |
||||
} |
||||
|
||||
private fun initView() { |
||||
dsb_text_size.valueFormat = { |
||||
(it + 5).toString() |
||||
} |
||||
dsb_text_letter_spacing.valueFormat = { |
||||
((it - 50) / 100f).toString() |
||||
} |
||||
dsb_line_size.valueFormat = { ((it - 10) / 10f).toString() } |
||||
dsb_paragraph_spacing.valueFormat = { (it / 10f).toString() } |
||||
} |
||||
|
||||
private fun initViewEvent() { |
||||
dsb_text_size.onChanged = { |
||||
ReadBookConfig.textSize = it + 5 |
||||
postEvent(EventBus.UP_CONFIG, true) |
||||
} |
||||
dsb_text_letter_spacing.onChanged = { |
||||
ReadBookConfig.letterSpacing = (it - 50) / 100f |
||||
postEvent(EventBus.UP_CONFIG, true) |
||||
} |
||||
dsb_line_size.onChanged = { |
||||
ReadBookConfig.lineSpacingExtra = it |
||||
postEvent(EventBus.UP_CONFIG, true) |
||||
} |
||||
dsb_paragraph_spacing.onChanged = { |
||||
ReadBookConfig.paragraphSpacing = it |
||||
postEvent(EventBus.UP_CONFIG, true) |
||||
} |
||||
} |
||||
|
||||
private fun upStyle() { |
||||
ReadBookConfig.let { |
||||
dsb_text_size.progress = it.textSize - 5 |
||||
dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 |
||||
dsb_line_size.progress = it.lineSpacingExtra |
||||
dsb_paragraph_spacing.progress = it.paragraphSpacing |
||||
} |
||||
} |
||||
} |
@ -1,12 +0,0 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:height="24dp" |
||||
android:viewportHeight="16" |
||||
android:viewportWidth="16" |
||||
android:width="24dp"> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,2h15C15.8,2 16,2.2 16,2.5l0,0C16,2.8 15.8,3 15.5,3h-15C0.2,3 0,2.8 0,2.5l0,0C0,2.2 0.2,2 0.5,2z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,13h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,14 0,13.8 0,13.5l0,0C0,13.2 0.2,13 0.5,13z" /> |
||||
</vector> |
@ -1,15 +0,0 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:height="24dp" |
||||
android:viewportHeight="16" |
||||
android:viewportWidth="16" |
||||
android:width="24dp"> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,2h15C15.8,2 16,2.2 16,2.5l0,0C16,2.8 15.8,3 15.5,3h-15C0.2,3 0,2.8 0,2.5l0,0C0,2.2 0.2,2 0.5,2z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,7.4h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,8.4 0,8.2 0,7.9l0,0C0,7.7 0.2,7.4 0.5,7.4z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,13h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,14 0,13.8 0,13.5l0,0C0,13.2 0.2,13 0.5,13z" /> |
||||
</vector> |
@ -1,18 +0,0 @@ |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:height="24dp" |
||||
android:viewportHeight="16" |
||||
android:viewportWidth="16" |
||||
android:width="24dp"> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,2h15C15.8,2 16,2.2 16,2.5l0,0C16,2.8 15.8,3 15.5,3h-15C0.2,3 0,2.8 0,2.5l0,0C0,2.2 0.2,2 0.5,2z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,5.7h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,6.7 0,6.5 0,6.2l0,0C0,5.9 0.2,5.7 0.5,5.7z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,9.3h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,10.3 0,10.1 0,9.8l0,0C0,9.5 0.2,9.3 0.5,9.3z" /> |
||||
<path |
||||
android:fillColor="#3C3F43" |
||||
android:pathData="M0.5,13h15c0.3,0 0.5,0.2 0.5,0.5l0,0c0,0.3 -0.2,0.5 -0.5,0.5h-15C0.2,14 0,13.8 0,13.5l0,0C0,13.2 0.2,13 0.5,13z" /> |
||||
</vector> |
@ -1,45 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
android:orientation="vertical"> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_text_size" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_marginTop="10dp" |
||||
android:paddingLeft="10dp" |
||||
android:paddingRight="10dp" |
||||
app:max="45" |
||||
app:title="@string/text_size" /> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_text_letter_spacing" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:paddingLeft="10dp" |
||||
android:paddingRight="10dp" |
||||
app:max="100" |
||||
app:title="@string/text_letter_spacing" /> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_line_size" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:paddingLeft="10dp" |
||||
android:paddingRight="10dp" |
||||
app:max="20" |
||||
app:title="@string/line_size" /> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_paragraph_spacing" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:paddingLeft="10dp" |
||||
android:paddingRight="10dp" |
||||
app:max="20" |
||||
app:title="@string/paragraph_size" /> |
||||
|
||||
</LinearLayout> |
@ -0,0 +1,51 @@ |
||||
<?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="match_parent" |
||||
android:orientation="vertical" |
||||
android:padding="10dp"> |
||||
|
||||
<RadioGroup |
||||
android:id="@+id/rg_title_mode" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:orientation="horizontal"> |
||||
|
||||
<RadioButton |
||||
android:id="@+id/rb_title_mode1" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:padding="3dp" |
||||
android:text="@string/title_left" /> |
||||
|
||||
<RadioButton |
||||
android:id="@+id/rb_title_mode2" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:padding="3dp" |
||||
android:text="@string/title_center" /> |
||||
|
||||
<RadioButton |
||||
android:id="@+id/rb_title_mode3" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="wrap_content" |
||||
android:padding="3dp" |
||||
android:text="@string/title_hide" /> |
||||
</RadioGroup> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_title_top" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:padding="3dp" |
||||
app:title="上间距" /> |
||||
|
||||
<io.legado.app.ui.widget.DetailSeekBar |
||||
android:id="@+id/dsb_title_bottom" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:padding="3dp" |
||||
app:title="下间距" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue