From f1d3cd3b8d55b98ebad54eebfab7be26b31c8e48 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Sat, 8 Jul 2023 18:05:01 -0500 Subject: [PATCH] NumberDialog: Use text input on Samsung devices Fixes #1719 --- .../uhabits/activities/common/dialogs/NumberDialog.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/dialogs/NumberDialog.kt b/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/dialogs/NumberDialog.kt index 38c0a5756..423e90958 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/dialogs/NumberDialog.kt +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/dialogs/NumberDialog.kt @@ -2,11 +2,13 @@ package org.isoron.uhabits.activities.common.dialogs import android.app.Dialog import android.os.Bundle +import android.provider.Settings import android.text.method.DigitsKeyListener import android.view.KeyEvent import android.view.LayoutInflater import android.view.MotionEvent import android.view.View +import android.view.inputmethod.EditorInfo import androidx.appcompat.app.AppCompatDialogFragment import org.isoron.uhabits.HabitsApplication import org.isoron.uhabits.R @@ -86,6 +88,15 @@ class NumberDialog : AppCompatDialogFragment() { // https://stackoverflow.com/a/34256139 val separator = DecimalFormatSymbols.getInstance().decimalSeparator view.value.keyListener = DigitsKeyListener.getInstance("0123456789$separator") + + // https://github.com/flutter/flutter/issues/61175 + val currKeyboard = Settings.Secure.getString( + requireContext().contentResolver, + Settings.Secure.DEFAULT_INPUT_METHOD + ) + if (currKeyboard.contains("swiftkey") || currKeyboard.contains("samsung")) { + view.value.inputType = EditorInfo.TYPE_CLASS_TEXT + } } fun save() {