Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 234bf612 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Use "No language (QWERTY)" for language agnostic QWERTY keyboard name"

parents e0d06fa7 3bf57a56
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -156,22 +156,20 @@
    <string-array name="subtype_locale_exception_keys">
        <item>en_US</item>
        <item>en_GB</item>
        <item>de_QY</item>
        <item>zz_QY</item>
        <item>*_QY</item>
        <item>QY</item>
    </string-array>
    <string-array name="subtype_locale_exception_values">
        <item>English (US)</item>
        <item>English (UK)</item>
        <item>@string/subtype_generic_qwerty</item>
        <item>@string/subtype_qwerty</item>
        <item>QWERTY</item>
    </string-array>

    <!-- Generic subtype label -->
    <string name="subtype_generic">%s</string>
    <!-- Description for generic QWERTY keyboard subtype -->
    <string name="subtype_generic_qwerty">%s (QWERTY)</string>
    <!-- Description for language agnostic QWERTY keyboard subtype -->
    <string name="subtype_qwerty">QWERTY</string>

    <!-- dictionary pack package name /settings activity (for shared prefs and settings) -->
    <string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string>
+2 −0
Original line number Diff line number Diff line
@@ -252,6 +252,8 @@
    <string name="subtype_en_GB">English (UK)</string>
    <!-- Description for English (United States) keyboard subtype [CHAR LIMIT=22] -->
    <string name="subtype_en_US">English (US)</string>
    <!-- Description for language agnostic QWERTY keyboard subtype [CHAR LIMIT=22] -->
    <string name="subtype_no_language_qwerty">No language (QWERTY)</string>

    <!-- Title of an option for usability study mode -->
    <string name="prefs_usability_study_mode">Usability study mode</string>
+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@
            android:imeSubtypeExtraValue="AsciiCapable"
    />
    <subtype android:icon="@drawable/ic_subtype_keyboard"
            android:label="@string/subtype_qwerty"
            android:label="@string/subtype_no_language_qwerty"
            android:imeSubtypeLocale="zz_QY"
            android:imeSubtypeMode="keyboard"
            android:imeSubtypeExtraValue="AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable"
+4 −4
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ import com.android.inputmethod.latin.LatinImeLogger;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.ResearchLogger;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
import com.android.inputmethod.latin.StringUtils;
import com.android.inputmethod.latin.SubtypeLocale;
import com.android.inputmethod.latin.SubtypeUtils;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.Utils.UsabilityStudyLogUtils;
@@ -926,7 +926,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
        paint.setTextAlign(Align.CENTER);
        paint.setTypeface(Typeface.DEFAULT);
        // Estimate appropriate language name text size to fit in maxTextWidth.
        String language = StringUtils.getFullDisplayName(locale, true);
        String language = SubtypeLocale.getFullDisplayName(locale);
        int textWidth = getTextWidth(paint, language, origTextSize);
        // Assuming text width and text size are proportional to each other.
        float textSize = origTextSize * Math.min(width / textWidth, 1.0f);
@@ -938,7 +938,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke

        final boolean useShortName;
        if (useMiddleName) {
            language = StringUtils.getMiddleDisplayLanguage(locale);
            language = SubtypeLocale.getMiddleDisplayName(locale);
            textWidth = getTextWidth(paint, language, origTextSize);
            textSize = origTextSize * Math.min(width / textWidth, 1.0f);
            useShortName = (textSize / origTextSize < MINIMUM_SCALE_OF_LANGUAGE_NAME)
@@ -948,7 +948,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
        }

        if (useShortName) {
            language = StringUtils.getShortDisplayLanguage(locale);
            language = SubtypeLocale.getShortDisplayName(locale);
            textWidth = getTextWidth(paint, language, origTextSize);
            textSize = origTextSize * Math.min(width / textWidth, 1.0f);
        }
+0 −38
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.Keyboard;

import java.util.ArrayList;
import java.util.Locale;

public class StringUtils {
    private StringUtils() {
@@ -150,41 +149,4 @@ public class StringUtils {
            i++;
        }
    }

    public static String getFullDisplayName(Locale locale, boolean returnsNameInThisLocale) {
        if (returnsNameInThisLocale) {
            return toTitleCase(SubtypeLocale.getFullDisplayName(locale), locale);
        } else {
            return toTitleCase(locale.getDisplayName(), locale);
        }
    }

    public static String getDisplayLanguage(Locale locale) {
        return toTitleCase(SubtypeLocale.getFullDisplayName(locale), locale);
    }

    public static String getMiddleDisplayLanguage(Locale locale) {
        return toTitleCase((LocaleUtils.constructLocaleFromString(
                locale.getLanguage()).getDisplayLanguage(locale)), locale);
    }

    public static String getShortDisplayLanguage(Locale locale) {
        return toTitleCase(locale.getLanguage(), locale);
    }

    public static String toTitleCase(String s, Locale locale) {
        if (s.length() <= 1) {
            // TODO: is this really correct? Shouldn't this be s.toUpperCase()?
            return s;
        }
        // TODO: fix the bugs below
        // - This does not work for Greek, because it returns upper case instead of title case.
        // - It does not work for Serbian, because it fails to account for the "lj" character,
        // which should be "Lj" in title case and "LJ" in upper case.
        // - It does not work for Dutch, because it fails to account for the "ij" digraph, which
        // are two different characters but both should be capitalized as "IJ" as if they were
        // a single letter.
        // - It also does not work with unicode surrogate code points.
        return s.toUpperCase(locale).charAt(0) + s.substring(1);
    }
}
Loading