Azerty.java revision 6d44cb512239a11572ec18b850d609bacc3267be
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
17package com.android.inputmethod.keyboard.layout;
18
19import com.android.inputmethod.keyboard.KeyboardId;
20import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
21import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
22
23/**
24 * The AZERTY alphabet keyboard.
25 */
26public final class Azerty extends LayoutBase {
27    public Azerty(final LayoutCustomizer customizer) {
28        super(customizer, Symbols.class, SymbolsShifted.class);
29    }
30
31    @Override
32    public String getName() { return "azerty"; }
33
34    @Override
35    ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) {
36        final LayoutCustomizer customizer = getCustomizer();
37        final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON);
38        customizer.setAccentedLetters(builder);
39        builder.replaceKeyOfLabel(ROW3_QUOTE, key("'", joinMoreKeys(
40                customizer.getSingleQuoteMoreKeys(),
41                customizer.getSingleAngleQuoteKeys())));
42        return builder.build();
43    }
44
45    @Override
46    ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) {
47        final ExpectedKeyboardBuilder builder;
48        if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED
49                || elementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED) {
50            builder = new ExpectedKeyboardBuilder(getCommonAlphabetLayout(isPhone));
51        } else {
52            builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON);
53            getCustomizer().setAccentedLetters(builder);
54            builder.replaceKeyOfLabel(ROW3_QUOTE, "?");
55        }
56        builder.toUpperCase(getLocale());
57        return builder.build();
58    }
59
60    private static final String ROW3_QUOTE = "ROW3_QUOUTE";
61
62    private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
63            .setKeysOfRow(1,
64                    key("a", moreKey("1")),
65                    key("z", moreKey("2")),
66                    key("e", moreKey("3")),
67                    key("r", moreKey("4")),
68                    key("t", moreKey("5")),
69                    key("y", moreKey("6")),
70                    key("u", moreKey("7")),
71                    key("i", moreKey("8")),
72                    key("o", moreKey("9")),
73                    key("p", moreKey("0")))
74            .setKeysOfRow(2, "q", "s", "d", "f", "g", "h", "j", "k", "l", "m")
75            .setKeysOfRow(3, "w", "x", "c", "v", "b", "n", ROW3_QUOTE)
76            .build();
77}
78