tweaking the edit dialog with Material theme
This commit is contained in:
parent
2233150e25
commit
a9b409a5aa
3 changed files with 36 additions and 6 deletions
|
@ -65,7 +65,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:c070dff787'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:15387bc4a3'
|
||||
|
||||
kapt 'androidx.room:room-compiler:2.4.2'
|
||||
implementation 'androidx.room:room-runtime:2.4.2'
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
package com.simplemobiletools.keyboard.dialogs
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.AppCompatEditText
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.keyboard.R
|
||||
import com.simplemobiletools.keyboard.helpers.ClipsHelper
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
import kotlinx.android.synthetic.main.dialog_add_or_edit_clip.view.*
|
||||
|
||||
class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Clip?, val callback: () -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_add_or_edit_clip, null).apply {
|
||||
val layoutId = if (activity.baseConfig.isUsingSystemTheme) {
|
||||
R.layout.dialog_add_or_edit_clip_material
|
||||
} else {
|
||||
R.layout.dialog_add_or_edit_clip
|
||||
}
|
||||
|
||||
val view = activity.layoutInflater.inflate(layoutId, null).apply {
|
||||
if (originalClip != null) {
|
||||
add_clip_value.setText(originalClip.value)
|
||||
findViewById<AppCompatEditText>(R.id.add_clip_value).setText(originalClip.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,9 +28,9 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl
|
|||
.setNegativeButton(R.string.cancel, null)
|
||||
.apply {
|
||||
activity.setupDialogStuff(view, this) { alertDialog ->
|
||||
alertDialog.showKeyboard(view.add_clip_value)
|
||||
alertDialog.showKeyboard(view.findViewById(R.id.add_clip_value))
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val clipValue = view.add_clip_value.value
|
||||
val clipValue = view.findViewById<AppCompatEditText>(R.id.add_clip_value).value
|
||||
if (clipValue.isEmpty()) {
|
||||
activity.toast(R.string.value_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
|
|
24
app/src/main/res/layout/dialog_add_or_edit_clip_material.xml
Normal file
24
app/src/main/res/layout/dialog_add_or_edit_clip_material.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/add_clip_hint"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginEnd="@dimen/activity_margin"
|
||||
android:hint="@string/clip_text">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/add_clip_value"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:textSize="@dimen/bigger_text_size" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue