1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.inputmethod.latin.utils;
18 
19 import android.view.inputmethod.InputMethodSubtype;
20 
21 public final class SpacebarLanguageUtils {
SpacebarLanguageUtils()22     private SpacebarLanguageUtils() {
23         // Intentional empty constructor for utility class.
24     }
25 
26     // InputMethodSubtype's display name for spacebar text in its locale.
27     //        isAdditionalSubtype (T=true, F=false)
28     // locale layout  |  Middle      Full
29     // ------ ------- - --------- ----------------------
30     //  en_US qwerty  F  English   English (US)           exception
31     //  en_GB qwerty  F  English   English (UK)           exception
32     //  es_US spanish F  Español   Español (EE.UU.)       exception
33     //  fr    azerty  F  Français  Français
34     //  fr_CA qwerty  F  Français  Français (Canada)
35     //  fr_CH swiss   F  Français  Français (Suisse)
36     //  de    qwertz  F  Deutsch   Deutsch
37     //  de_CH swiss   T  Deutsch   Deutsch (Schweiz)
38     //  zz    qwerty  F  QWERTY    QWERTY
39     //  fr    qwertz  T  Français  Français
40     //  de    qwerty  T  Deutsch   Deutsch
41     //  en_US azerty  T  English   English (US)
42     //  zz    azerty  T  AZERTY    AZERTY
43     // Get InputMethodSubtype's full display name in its locale.
getFullDisplayName(final InputMethodSubtype subtype)44     public static String getFullDisplayName(final InputMethodSubtype subtype) {
45         if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
46             return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype);
47         }
48         return SubtypeLocaleUtils.getSubtypeLocaleDisplayName(subtype.getLocale());
49     }
50 
51     // Get InputMethodSubtype's middle display name in its locale.
getMiddleDisplayName(final InputMethodSubtype subtype)52     public static String getMiddleDisplayName(final InputMethodSubtype subtype) {
53         if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
54             return SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype);
55         }
56         return SubtypeLocaleUtils.getSubtypeLanguageDisplayName(subtype.getLocale());
57     }
58 }
59