pull/48/head
parent
b5399c4041
commit
8e1af9cc16
@ -0,0 +1,45 @@ |
||||
package io.legado.app.ui.book.read.config |
||||
|
||||
import android.app.Dialog |
||||
import android.content.Context |
||||
import android.view.KeyEvent |
||||
import io.legado.app.R |
||||
import io.legado.app.constant.PreferKey |
||||
import io.legado.app.utils.hideSoftInput |
||||
import io.legado.app.utils.putPrefInt |
||||
import kotlinx.android.synthetic.main.dialog_page_key.* |
||||
import org.jetbrains.anko.sdk27.listeners.onClick |
||||
|
||||
|
||||
class PageKeyDialog(context: Context) : Dialog(context, R.style.AppTheme_AlertDialog) { |
||||
|
||||
init { |
||||
setContentView(R.layout.dialog_page_key) |
||||
tv_ok.onClick { |
||||
et_prev.text?.let { |
||||
context.putPrefInt(PreferKey.prevKey, it.toString().toInt()) |
||||
} |
||||
et_next.text?.let { |
||||
context.putPrefInt(PreferKey.nextKey, it.toString().toInt()) |
||||
} |
||||
dismiss() |
||||
} |
||||
} |
||||
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { |
||||
if (keyCode != KeyEvent.KEYCODE_BACK) { |
||||
if (et_prev.hasFocus()) { |
||||
et_prev.setText(keyCode.toString()) |
||||
} else if (et_next.hasFocus()) { |
||||
et_next.setText(keyCode.toString()) |
||||
} |
||||
} |
||||
return super.onKeyDown(keyCode, event) |
||||
} |
||||
|
||||
override fun dismiss() { |
||||
super.dismiss() |
||||
currentFocus?.hideSoftInput() |
||||
} |
||||
|
||||
} |
@ -0,0 +1,44 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<TextView |
||||
android:id="@+id/tv_title" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="5dp" /> |
||||
|
||||
<io.legado.app.lib.theme.view.ATEEditText |
||||
android:id="@+id/et_prev" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="5dp" |
||||
android:completionThreshold="0" |
||||
android:inputType="number" |
||||
android:singleLine="true" /> |
||||
|
||||
<io.legado.app.lib.theme.view.ATEEditText |
||||
android:id="@+id/et_next" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="5dp" |
||||
android:completionThreshold="0" |
||||
android:inputType="number" |
||||
android:singleLine="true" /> |
||||
|
||||
<TextView |
||||
android:id="@+id/tv_ok" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="wrap_content" |
||||
android:layout_margin="5dp" |
||||
android:background="@drawable/selector_fillet_btn_bg" |
||||
android:clickable="true" |
||||
android:focusable="true" |
||||
android:gravity="center" |
||||
android:paddingTop="5dp" |
||||
android:paddingBottom="5dp" |
||||
android:text="@string/ok" |
||||
android:textColor="@color/tv_text_default" /> |
||||
</LinearLayout> |
Loading…
Reference in new issue