mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 05:39:10 +00:00
display "<language> (<layout>)" also for custom layouts
This commit is contained in:
parent
9bd2136ebe
commit
3754b2be82
6 changed files with 21 additions and 7 deletions
|
@ -24,6 +24,7 @@ import helium314.keyboard.latin.common.LocaleUtils
|
|||
import helium314.keyboard.latin.utils.DeviceProtectedUtils
|
||||
import helium314.keyboard.latin.utils.SubtypeLocaleUtils
|
||||
import helium314.keyboard.latin.utils.addEnabledSubtype
|
||||
import helium314.keyboard.latin.utils.displayName
|
||||
import helium314.keyboard.latin.utils.isAdditionalSubtype
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.latin.utils.removeEnabledSubtype
|
||||
|
@ -89,7 +90,7 @@ private class LanguageAdapter(list: List<MutableList<SubtypeInfo>> = listOf(), c
|
|||
var start = true
|
||||
infos.forEach {
|
||||
val string = SpannableString(SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(it.subtype)
|
||||
?: SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(it.subtype))
|
||||
?: it.subtype.displayName(context))
|
||||
if (it.isEnabled)
|
||||
string.setSpan(StyleSpan(Typeface.BOLD), 0, string.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
if (!start) {
|
||||
|
|
|
@ -141,7 +141,7 @@ class LanguageSettingsDialog(
|
|||
if (layoutSetName?.startsWith(CUSTOM_LAYOUT_PREFIX) == false // don't allow copying custom layout (at least for now)
|
||||
&& !layoutSetName.endsWith("+")) { // don't allow copying layouts only defined via extra keys
|
||||
layouts.add(layoutSetName)
|
||||
displayNames.add(SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(it.subtype))
|
||||
displayNames.add(it.subtype.displayName(context).toString())
|
||||
}
|
||||
}
|
||||
if (infos.first().subtype.isAsciiCapable) {
|
||||
|
@ -171,7 +171,7 @@ class LanguageSettingsDialog(
|
|||
val layoutSetName = subtype.subtype.getExtraValueOf(KEYBOARD_LAYOUT_SET) ?: "qwerty"
|
||||
row.findViewById<TextView>(R.id.language_name).text =
|
||||
SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype.subtype)
|
||||
?: SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(subtype.subtype)
|
||||
?: subtype.subtype.displayName(context)
|
||||
if (layoutSetName.startsWith(CUSTOM_LAYOUT_PREFIX)) {
|
||||
row.findViewById<TextView>(R.id.language_details).setText(R.string.edit_layout)
|
||||
row.findViewById<View>(R.id.language_text).setOnClickListener { editCustomLayout(layoutSetName, context) }
|
||||
|
|
|
@ -30,6 +30,7 @@ import helium314.keyboard.latin.utils.DictionaryUtilsKt;
|
|||
import helium314.keyboard.latin.utils.ExecutorUtils;
|
||||
import helium314.keyboard.latin.utils.JniUtils;
|
||||
import helium314.keyboard.latin.utils.SubtypeSettingsKt;
|
||||
import helium314.keyboard.latin.utils.SubtypeUtilsKt;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.BufferedOutputStream;
|
||||
|
@ -89,7 +90,7 @@ public final class SettingsFragment extends PreferenceFragmentCompat {
|
|||
for (final InputMethodSubtype subtype : subtypes) {
|
||||
if (sb.length() > 0)
|
||||
sb.append(", ");
|
||||
sb.append(subtype.getDisplayName(getActivity(), requireContext().getPackageName(), requireContext().getApplicationInfo()));
|
||||
sb.append(SubtypeUtilsKt.displayName(subtype, requireContext()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -43,9 +43,9 @@ fun createInputMethodPickerDialog(latinIme: LatinIME, richImm: RichInputMethodMa
|
|||
for (imiAndSubtype in enabledSubtypes) {
|
||||
val (imi, subtype) = imiAndSubtype
|
||||
|
||||
val title = SpannableString(subtype?.getDisplayName(latinIme, imi.packageName, imi.serviceInfo.applicationInfo)
|
||||
?.ifBlank { imi.loadLabel(pm) }
|
||||
?: imi.loadLabel(pm))
|
||||
val subtypeName = if (imi == thisImi) subtype?.displayName(latinIme)
|
||||
else subtype?.getDisplayName(latinIme, imi.packageName, imi.serviceInfo.applicationInfo)
|
||||
val title = SpannableString(subtypeName?.ifBlank { imi.loadLabel(pm) } ?: imi.loadLabel(pm))
|
||||
val subtitle = SpannableString(if (subtype == null) "" else "\n${imi.loadLabel(pm)}")
|
||||
title.setSpan(
|
||||
RelativeSizeSpan(0.9f), 0, title.length,
|
||||
|
|
|
@ -29,6 +29,7 @@ import androidx.annotation.Nullable;
|
|||
* A helper class to deal with subtype locales.
|
||||
*/
|
||||
// TODO: consolidate this into RichInputMethodSubtype
|
||||
// todo (later): see whether this complicated mess can be simplified
|
||||
public final class SubtypeLocaleUtils {
|
||||
static final String TAG = SubtypeLocaleUtils.class.getSimpleName();
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package helium314.keyboard.latin.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.view.inputmethod.InputMethodSubtype
|
||||
import helium314.keyboard.latin.common.LocaleUtils
|
||||
import helium314.keyboard.latin.common.LocaleUtils.constructLocale
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -12,3 +14,12 @@ fun InputMethodSubtype.locale(): Locale {
|
|||
}
|
||||
@Suppress("deprecation") return locale.constructLocale()
|
||||
}
|
||||
|
||||
/** Workaround for SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale ignoring custom layout names */
|
||||
// todo (later): this should be done properly and in SubtypeLocaleUtils
|
||||
fun InputMethodSubtype.displayName(context: Context): CharSequence {
|
||||
val layoutName = SubtypeLocaleUtils.getKeyboardLayoutSetName(this)
|
||||
if (layoutName.startsWith(CUSTOM_LAYOUT_PREFIX))
|
||||
return "${LocaleUtils.getLocaleDisplayNameInSystemLocale(locale(), context)} (${getLayoutDisplayName(layoutName)})"
|
||||
return SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(this)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue