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