Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds auto keyboard popup to dialogs #4667

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.PopupMenu
import androidx.activity.viewModels
import androidx.annotation.StringRes
Expand Down Expand Up @@ -136,11 +137,14 @@ class ListsActivity : BaseActivity() {
.setNegativeButton(android.R.string.cancel, null)
.show()

dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

binding.nameText.let { editText ->
editText.doOnTextChanged { s, _, _, _ ->
dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled = s?.isNotBlank() == true
}
editText.setText(list?.title)
editText.requestFocus()
editText.text?.let { editText.setSelection(it.length) }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.keylesspalace.tusky
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AlertDialog
Expand Down Expand Up @@ -267,6 +268,7 @@ class TabPreferenceActivity : BaseActivity(), ItemInteractionListener, ListSelec

dialog.show()
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = validateHashtag(editText.text)
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
editText.requestFocus()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.view.LayoutInflater
import android.view.WindowManager
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.textfield.TextInputEditText
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.databinding.DialogAddPollBinding
import com.keylesspalace.tusky.entity.NewPoll
Expand Down Expand Up @@ -106,6 +107,14 @@ fun showAddPollDialog(

dialog.show()

dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
binding.pollChoices.post {
val firstItemView = binding.pollChoices.layoutManager?.findViewByPosition(0)
val editText = firstItemView?.findViewById<TextInputEditText>(R.id.optionEditText)
editText?.requestFocus()
editText?.setSelection(editText.length())
}

// make the dialog focusable so the keyboard does not stay behind it
dialog.window?.clearFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class CaptionDialog : DialogFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val imageView = binding.imageDescriptionView
imageView.maxZoom = 6f
val imageDescriptionText = binding.imageDescriptionText
imageDescriptionText.post {
imageDescriptionText.requestFocus()
imageDescriptionText.setSelection(imageDescriptionText.length())
}

binding.imageDescriptionText.hint = resources.getQuantityString(
R.plurals.hint_describe_for_visually_impaired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.keylesspalace.tusky.components.filters
import android.content.Context
import android.content.DialogInterface.BUTTON_POSITIVE
import android.os.Bundle
import android.view.WindowManager
import android.widget.AdapterView
import androidx.activity.viewModels
import androidx.core.view.size
Expand Down Expand Up @@ -211,7 +212,7 @@ class EditFilterActivity : BaseActivity() {
private fun showAddKeywordDialog() {
val binding = DialogFilterBinding.inflate(layoutInflater)
binding.phraseWholeWord.isChecked = true
MaterialAlertDialogBuilder(this)
val dialog = MaterialAlertDialogBuilder(this)
.setTitle(R.string.filter_keyword_addition_title)
.setView(binding.root)
.setPositiveButton(android.R.string.ok) { _, _ ->
Expand All @@ -225,14 +226,20 @@ class EditFilterActivity : BaseActivity() {
}
.setNegativeButton(android.R.string.cancel, null)
.show()

dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

val editText = binding.phraseEditText
editText.requestFocus()
editText.setSelection(editText.length())
}

private fun showEditKeywordDialog(keyword: FilterKeyword) {
val binding = DialogFilterBinding.inflate(layoutInflater)
binding.phraseEditText.setText(keyword.keyword)
binding.phraseWholeWord.isChecked = keyword.wholeWord

MaterialAlertDialogBuilder(this)
val dialog = MaterialAlertDialogBuilder(this)
.setTitle(R.string.filter_edit_keyword_title)
.setView(binding.root)
.setPositiveButton(R.string.filter_dialog_update_button) { _, _ ->
Expand All @@ -246,6 +253,12 @@ class EditFilterActivity : BaseActivity() {
}
.setNegativeButton(android.R.string.cancel, null)
.show()

dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

val editText = binding.phraseEditText
editText.requestFocus()
editText.setSelection(editText.length())
}

private fun validateSaveButton() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.DialogInterface
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
import android.view.WindowManager
import android.widget.AutoCompleteTextView
import androidx.activity.viewModels
import androidx.fragment.app.DialogFragment
Expand Down Expand Up @@ -194,6 +195,8 @@ class FollowedTagsActivity :
showBotBadge = false
)
)
autoCompleteTextView.requestFocus()
autoCompleteTextView.setSelection(autoCompleteTextView.length())

return MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.dialog_follow_hashtag_title)
Expand All @@ -207,6 +210,11 @@ class FollowedTagsActivity :
.create()
}

override fun onStart() {
super.onStart()
dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
}

companion object {
fun newInstance(): FollowTagDialog = FollowTagDialog()
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,5 @@
<string name="pref_default_reply_privacy_explanation">محرمانگی پیش‌گزیده به فرسته‌ای که به آن پاسخ می‌دهید بستگی خواهد داشت.</string>
<string name="post_privacy_direct">مستقیم</string>
<string name="pref_match_default_post_privacy">تطبیق با محرمانگی پیش‌گزیدهٔ فرسته</string>
<string name="label_expires_after">انقضا پس از</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,4 @@
<string name="error_unmuting_hashtag_format">Kesalahan mengaktifkan #%1$s</string>
<string name="error_status_source_load">Gagal memuat sumber status dari server.</string>
<string name="title_public_trending_hashtags">Hashtag yang sedang tren</string>
</resources>
</resources>
9 changes: 5 additions & 4 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
<string name="pref_title_alway_show_sensitive_media">Mostra sempre i contenuti sensibili</string>
<string name="title_media">Media</string>
<string name="replying_to">Rispondendo a @%1$s</string>
<string name="load_more_placeholder_text">carica altro</string>
<string name="load_more_placeholder_text">Carica altro</string>
<string name="pref_title_public_filter_keywords">Timeline pubbliche</string>
<string name="pref_title_thread_filter_keywords">Conversazioni</string>
<string name="filter_addition_title">Aggiungi filtro</string>
Expand All @@ -267,9 +267,9 @@
<string name="error_create_list">Non è stato possibile creare la lista</string>
<string name="error_rename_list">Non è stato possibile aggiornare la lista</string>
<string name="error_delete_list">Non è stato possibile eliminare la lista</string>
<string name="action_create_list">Crea una lista</string>
<string name="action_rename_list">Aggiorna la lista</string>
<string name="action_delete_list">Elimina la lista</string>
<string name="action_create_list">Crea lista</string>
<string name="action_rename_list">Aggiorna lista</string>
<string name="action_delete_list">Elimina lista</string>
<string name="hint_search_people_list">Cerca tra le persone che segui</string>
<string name="action_add_to_list">Aggiungi un account alla lista</string>
<string name="action_remove_from_list">Rimuovi un account dalla lista</string>
Expand Down Expand Up @@ -738,4 +738,5 @@
<string name="pref_default_reply_privacy_explanation">La privacy preselezionata dipenderà dal post a cui stai rispondendo.</string>
<string name="pref_match_default_post_privacy">Stessa privacy predefinita del post</string>
<string name="post_privacy_direct">Diretto</string>
<string name="label_expires_after">Scade dopo</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-ml/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@
<string name="post_media_video">വിഡിയോ</string>
<string name="action_mention">സൂചിപ്പിക്കുക</string>
<string name="filter_dialog_remove_button">നീക്കം ചെയ്യുക</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@
<string name="filter_dialog_remove_button">Odstrániť</string>
<string name="notification_favourite_name">Obľúbené</string>
<string name="pref_title_post_tabs">Panely</string>
</resources>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
<string name="filter_addition_title">Додати фільтр</string>
<string name="pref_title_thread_filter_keywords">Розмови</string>
<string name="pref_title_public_filter_keywords">Загальнодоступні стрічки</string>
<string name="load_more_placeholder_text">завантажити ще</string>
<string name="load_more_placeholder_text">Завантажити ще</string>
<string name="replying_to">Відповідь для @%1$s</string>
<string name="pref_title_alway_open_spoiler">Завжди розгортати допис, з попередженнями про вміст</string>
<string name="follows_you">Підписники</string>
Expand Down Expand Up @@ -738,4 +738,5 @@
<string name="pref_match_default_post_privacy">Відповідає типовим параметрам приватності дописів</string>
<string name="pref_default_reply_privacy_explanation">Попередньо вибрана приватність буде залежати від допису, на який ви відповідаєте.</string>
<string name="post_privacy_direct">Особисті</string>
<string name="label_expires_after">Завершується після</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,5 @@
<string name="pref_default_reply_privacy_explanation">预选隐私将取决于你回复的嘟文。</string>
<string name="pref_match_default_post_privacy">匹配默认嘟文发布隐私</string>
<string name="post_privacy_direct">私信</string>
<string name="label_expires_after">多久过期</string>
</resources>
Loading