summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/FolderCreationDialogFragment.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/dialogs/OtpImportDialogFragment.kt6
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt4
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt22
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/util/git/operation/CredentialFinder.kt4
-rw-r--r--app/src/main/res/layout/folder_dialog_fragment.xml2
-rw-r--r--app/src/main/res/layout/fragment_manual_otp_entry.xml2
-rw-r--r--app/src/main/res/layout/git_credential_layout.xml2
8 files changed, 14 insertions, 32 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/FolderCreationDialogFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/FolderCreationDialogFragment.kt
index 45dfba2b..e8111552 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/FolderCreationDialogFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/FolderCreationDialogFragment.kt
@@ -7,6 +7,7 @@ package dev.msfjarvis.aps.ui.dialogs
import android.app.Dialog
import android.content.Intent
import android.os.Bundle
+import android.view.WindowManager
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
@@ -23,7 +24,6 @@ import dev.msfjarvis.aps.ui.crypto.BasePgpActivity
import dev.msfjarvis.aps.ui.crypto.GetKeyIdsActivity
import dev.msfjarvis.aps.ui.passwords.PasswordStore
import dev.msfjarvis.aps.util.extensions.commitChange
-import dev.msfjarvis.aps.util.extensions.requestInputFocusOnView
import java.io.File
import kotlinx.coroutines.launch
import me.msfjarvis.openpgpktx.util.OpenPgpApi
@@ -67,7 +67,7 @@ class FolderCreationDialogFragment : DialogFragment() {
alertDialogBuilder.setPositiveButton(getString(R.string.button_create), null)
alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel)) { _, _ -> dismiss() }
val dialog = alertDialogBuilder.create()
- dialog.requestInputFocusOnView<TextInputEditText>(R.id.folder_name_text)
+ dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
dialog.setOnShowListener {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
createDirectory(requireArguments().getString(CURRENT_DIR_EXTRA)!!)
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/OtpImportDialogFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/OtpImportDialogFragment.kt
index 5507218b..1670d263 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/OtpImportDialogFragment.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/dialogs/OtpImportDialogFragment.kt
@@ -8,15 +8,13 @@ package dev.msfjarvis.aps.ui.dialogs
import android.app.Dialog
import android.net.Uri
import android.os.Bundle
+import android.view.WindowManager
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import com.google.android.material.dialog.MaterialAlertDialogBuilder
-import com.google.android.material.textfield.TextInputEditText
-import dev.msfjarvis.aps.R
import dev.msfjarvis.aps.databinding.FragmentManualOtpEntryBinding
import dev.msfjarvis.aps.ui.crypto.PasswordCreationActivity
-import dev.msfjarvis.aps.util.extensions.requestInputFocusOnView
class OtpImportDialogFragment : DialogFragment() {
@@ -31,7 +29,7 @@ class OtpImportDialogFragment : DialogFragment() {
)
}
val dialog = builder.create()
- dialog.requestInputFocusOnView<TextInputEditText>(R.id.secret)
+ dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
return dialog
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt
index 38c97f36..a009b701 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/passwords/PasswordStore.kt
@@ -14,6 +14,7 @@ import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.MenuItem.OnActionExpandListener
+import android.view.WindowManager
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.activity.viewModels
@@ -56,7 +57,6 @@ import dev.msfjarvis.aps.util.extensions.getString
import dev.msfjarvis.aps.util.extensions.isInsideRepository
import dev.msfjarvis.aps.util.extensions.isPermissionGranted
import dev.msfjarvis.aps.util.extensions.listFilesRecursively
-import dev.msfjarvis.aps.util.extensions.requestInputFocusOnView
import dev.msfjarvis.aps.util.extensions.sharedPrefs
import dev.msfjarvis.aps.util.settings.AuthMode
import dev.msfjarvis.aps.util.settings.PreferenceKeys
@@ -583,7 +583,7 @@ class PasswordStore : BaseGitActivity() {
.setNegativeButton(R.string.dialog_skip, null)
.create()
- dialog.requestInputFocusOnView<TextInputEditText>(R.id.folder_name_text)
+ dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
dialog.show()
}
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt b/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt
index ae175433..0ad122e6 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/extensions/AndroidExtensions.kt
@@ -15,10 +15,7 @@ import android.util.Base64
import android.util.TypedValue
import android.view.View
import android.view.autofill.AutofillManager
-import android.view.inputmethod.InputMethodManager
-import androidx.annotation.IdRes
import androidx.annotation.RequiresApi
-import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import androidx.fragment.app.FragmentActivity
@@ -33,25 +30,6 @@ import dev.msfjarvis.aps.R
import dev.msfjarvis.aps.data.repo.PasswordRepository
import dev.msfjarvis.aps.util.git.operation.GitOperation
-/**
- * Extension function for [AlertDialog] that requests focus for the view whose id is [id]. Solution
- * based on a StackOverflow answer: https://stackoverflow.com/a/13056259/297261
- */
-fun <T : View> AlertDialog.requestInputFocusOnView(@IdRes id: Int) {
- setOnShowListener {
- findViewById<T>(id)?.apply {
- setOnFocusChangeListener { v, _ ->
- v.post {
- context
- .getSystemService<InputMethodManager>()
- ?.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)
- }
- }
- requestFocus()
- }
- }
-}
-
/** Get an instance of [AutofillManager]. Only available on Android Oreo and above */
val Context.autofillManager: AutofillManager?
@RequiresApi(Build.VERSION_CODES.O) get() = getSystemService()
diff --git a/app/src/main/java/dev/msfjarvis/aps/util/git/operation/CredentialFinder.kt b/app/src/main/java/dev/msfjarvis/aps/util/git/operation/CredentialFinder.kt
index 8f9b5efc..623d69ea 100644
--- a/app/src/main/java/dev/msfjarvis/aps/util/git/operation/CredentialFinder.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/util/git/operation/CredentialFinder.kt
@@ -8,6 +8,7 @@ package dev.msfjarvis.aps.util.git.operation
import android.annotation.SuppressLint
import android.content.SharedPreferences
import android.view.LayoutInflater
+import android.view.WindowManager
import androidx.annotation.StringRes
import androidx.core.content.edit
import androidx.core.widget.doOnTextChanged
@@ -22,7 +23,6 @@ import dagger.hilt.android.EntryPointAccessors
import dagger.hilt.components.SingletonComponent
import dev.msfjarvis.aps.R
import dev.msfjarvis.aps.injection.prefs.GitPreferences
-import dev.msfjarvis.aps.util.extensions.requestInputFocusOnView
import dev.msfjarvis.aps.util.git.sshj.InteractivePasswordFinder
import dev.msfjarvis.aps.util.settings.AuthMode
import dev.msfjarvis.aps.util.settings.PreferenceKeys
@@ -100,7 +100,7 @@ class CredentialFinder(val callingActivity: FragmentActivity, val authMode: Auth
create()
}
.run {
- requestInputFocusOnView<TextInputEditText>(R.id.git_auth_credential)
+ window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
show()
}
} else {
diff --git a/app/src/main/res/layout/folder_dialog_fragment.xml b/app/src/main/res/layout/folder_dialog_fragment.xml
index 28a8287f..21d34805 100644
--- a/app/src/main/res/layout/folder_dialog_fragment.xml
+++ b/app/src/main/res/layout/folder_dialog_fragment.xml
@@ -25,6 +25,8 @@
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|textVisiblePassword" />
+ <requestFocus />
+
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.checkbox.MaterialCheckBox
diff --git a/app/src/main/res/layout/fragment_manual_otp_entry.xml b/app/src/main/res/layout/fragment_manual_otp_entry.xml
index d42028ac..ee5e5261 100644
--- a/app/src/main/res/layout/fragment_manual_otp_entry.xml
+++ b/app/src/main/res/layout/fragment_manual_otp_entry.xml
@@ -26,6 +26,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <requestFocus />
+
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
diff --git a/app/src/main/res/layout/git_credential_layout.xml b/app/src/main/res/layout/git_credential_layout.xml
index 289d713f..7935f2de 100644
--- a/app/src/main/res/layout/git_credential_layout.xml
+++ b/app/src/main/res/layout/git_credential_layout.xml
@@ -26,6 +26,8 @@
android:layout_height="wrap_content"
android:hint="@string/ssh_keygen_passphrase"
android:inputType="textPassword" />
+
+ <requestFocus />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.checkbox.MaterialCheckBox