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