From 27e054e02313e6077354f03d055f731605d9fddd Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Thu, 17 Aug 2023 20:00:58 +0300 Subject: [PATCH] migrate remaining inflated layouts to viewbinding --- .../keyboard/dialogs/KeyboardRadioGroupDialog.kt | 4 ++-- .../com/simplemobiletools/keyboard/extensions/Context.kt | 4 ++-- .../com/simplemobiletools/keyboard/views/MyKeyboardView.kt | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/KeyboardRadioGroupDialog.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/KeyboardRadioGroupDialog.kt index 40ee1e5..182229a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/KeyboardRadioGroupDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/dialogs/KeyboardRadioGroupDialog.kt @@ -4,10 +4,10 @@ import android.view.ContextThemeWrapper import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.RadioButton import android.widget.RadioGroup import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.databinding.DialogRadioGroupBinding +import com.simplemobiletools.commons.databinding.RadioButtonBinding import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.keyboard.R @@ -34,7 +34,7 @@ class KeyboardRadioGroupDialog( val binding = DialogRadioGroupBinding.inflate(layoutInflater) binding.dialogRadioGroup.apply { for (i in 0 until items.size) { - val radioButton = (layoutInflater.inflate(R.layout.radio_button, null) as RadioButton).apply { + val radioButton = RadioButtonBinding.inflate(layoutInflater).dialogRadioButton.apply { text = items[i].title isChecked = items[i].id == checkedItemId id = i diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt index f23a678..eb29b1f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/extensions/Context.kt @@ -11,6 +11,7 @@ import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.core.content.res.ResourcesCompat import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.simplemobiletools.commons.databinding.DialogTitleBinding import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.commons.models.RadioItem @@ -120,8 +121,7 @@ fun Context.setupKeyboardDialogStuff( } else { var title: TextView? = null if (titleId != 0 || titleText.isNotEmpty()) { - title = LayoutInflater.from(this).inflate(R.layout.dialog_title, null) as TextView - title.apply { + title = DialogTitleBinding.inflate(LayoutInflater.from(this)).dialogTitleTextview.apply { if (titleText.isNotEmpty()) { text = titleText } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt index 4ad01dc..db67102 100644 --- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt @@ -37,6 +37,7 @@ import com.simplemobiletools.keyboard.activities.ManageClipboardItemsActivity import com.simplemobiletools.keyboard.activities.SettingsActivity import com.simplemobiletools.keyboard.adapters.ClipsKeyboardAdapter import com.simplemobiletools.keyboard.adapters.EmojisAdapter +import com.simplemobiletools.keyboard.databinding.KeyboardKeyPreviewBinding import com.simplemobiletools.keyboard.databinding.KeyboardPopupKeyboardBinding import com.simplemobiletools.keyboard.databinding.KeyboardViewKeyboardBinding import com.simplemobiletools.keyboard.dialogs.ChangeLanguagePopup @@ -206,7 +207,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut } mPreviewPopup = PopupWindow(context) - mPreviewText = inflater.inflate(resources.getLayout(R.layout.keyboard_key_preview), null) as TextView + mPreviewText = KeyboardKeyPreviewBinding.inflate(inflater).root mPreviewTextSizeLarge = context.resources.getDimension(R.dimen.preview_text_size).toInt() mPreviewPopup.contentView = mPreviewText mPreviewPopup.setBackgroundDrawable(null)