From 2bf7d229b18ffdc6ebbc2f07ec3eaa685731e703 Mon Sep 17 00:00:00 2001 From: linyuh Date: Tue, 19 Dec 2017 16:39:31 -0800 Subject: Add SmartDialMaps for the Bulgarian alphabet and the Ukrainian alphabet. Bug: 30215380,70633239 Test: BulgarianSmartDialMapTest, UkrainianSmartDialMapTest PiperOrigin-RevId: 179621038 Change-Id: I1a5ad97ba7cd4e9e0edffb3cb39f40c4c5d137a1 --- .../dialer/smartdial/BulgarianSmartDialMap.java | 91 +++++++++++++++++++++ .../dialer/smartdial/CompositeSmartDialMap.java | 2 + .../dialer/smartdial/UkrainianSmartDialMap.java | 93 ++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 java/com/android/dialer/smartdial/BulgarianSmartDialMap.java create mode 100644 java/com/android/dialer/smartdial/UkrainianSmartDialMap.java (limited to 'java/com/android/dialer/smartdial') diff --git a/java/com/android/dialer/smartdial/BulgarianSmartDialMap.java b/java/com/android/dialer/smartdial/BulgarianSmartDialMap.java new file mode 100644 index 000000000..a16d15919 --- /dev/null +++ b/java/com/android/dialer/smartdial/BulgarianSmartDialMap.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dialer.smartdial; + +import android.support.v4.util.SimpleArrayMap; +import com.google.common.base.Optional; + +/** A {@link SmartDialMap} for the Bulgarian alphabet. */ +@SuppressWarnings("Guava") +final class BulgarianSmartDialMap extends SmartDialMap { + private static final SimpleArrayMap CHAR_TO_KEY_MAP = + new SimpleArrayMap<>(); + + // Reference: https://en.wikipedia.org/wiki/Bulgarian_alphabet + static { + CHAR_TO_KEY_MAP.put('а', '2'); + CHAR_TO_KEY_MAP.put('б', '2'); + CHAR_TO_KEY_MAP.put('в', '2'); + CHAR_TO_KEY_MAP.put('г', '2'); + + CHAR_TO_KEY_MAP.put('д', '3'); + CHAR_TO_KEY_MAP.put('е', '3'); + CHAR_TO_KEY_MAP.put('ж', '3'); + CHAR_TO_KEY_MAP.put('з', '3'); + + CHAR_TO_KEY_MAP.put('и', '4'); + CHAR_TO_KEY_MAP.put('й', '4'); + CHAR_TO_KEY_MAP.put('к', '4'); + CHAR_TO_KEY_MAP.put('л', '4'); + + CHAR_TO_KEY_MAP.put('м', '5'); + CHAR_TO_KEY_MAP.put('н', '5'); + CHAR_TO_KEY_MAP.put('о', '5'); + + CHAR_TO_KEY_MAP.put('п', '6'); + CHAR_TO_KEY_MAP.put('р', '6'); + CHAR_TO_KEY_MAP.put('с', '6'); + + CHAR_TO_KEY_MAP.put('т', '7'); + CHAR_TO_KEY_MAP.put('у', '7'); + CHAR_TO_KEY_MAP.put('ф', '7'); + CHAR_TO_KEY_MAP.put('х', '7'); + + CHAR_TO_KEY_MAP.put('ц', '8'); + CHAR_TO_KEY_MAP.put('ч', '8'); + CHAR_TO_KEY_MAP.put('ш', '8'); + CHAR_TO_KEY_MAP.put('щ', '8'); + + CHAR_TO_KEY_MAP.put('ъ', '9'); + CHAR_TO_KEY_MAP.put('ь', '9'); + CHAR_TO_KEY_MAP.put('ю', '9'); + CHAR_TO_KEY_MAP.put('я', '9'); + } + + private static BulgarianSmartDialMap instance; + + static BulgarianSmartDialMap getInstance() { + if (instance == null) { + instance = new BulgarianSmartDialMap(); + } + + return instance; + } + + private BulgarianSmartDialMap() {} + + @Override + Optional normalizeCharacter(char ch) { + ch = Character.toLowerCase(ch); + return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent(); + } + + @Override + SimpleArrayMap getCharToKeyMap() { + return CHAR_TO_KEY_MAP; + } +} diff --git a/java/com/android/dialer/smartdial/CompositeSmartDialMap.java b/java/com/android/dialer/smartdial/CompositeSmartDialMap.java index d51e46f76..e9f237f01 100644 --- a/java/com/android/dialer/smartdial/CompositeSmartDialMap.java +++ b/java/com/android/dialer/smartdial/CompositeSmartDialMap.java @@ -45,7 +45,9 @@ public class CompositeSmartDialMap { private static final SimpleArrayMap EXTRA_MAPS = new SimpleArrayMap<>(); static { + EXTRA_MAPS.put("bul", BulgarianSmartDialMap.getInstance()); EXTRA_MAPS.put("rus", RussianSmartDialMap.getInstance()); + EXTRA_MAPS.put("ukr", UkrainianSmartDialMap.getInstance()); } private CompositeSmartDialMap() {} diff --git a/java/com/android/dialer/smartdial/UkrainianSmartDialMap.java b/java/com/android/dialer/smartdial/UkrainianSmartDialMap.java new file mode 100644 index 000000000..8ba53c45f --- /dev/null +++ b/java/com/android/dialer/smartdial/UkrainianSmartDialMap.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.dialer.smartdial; + +import android.support.v4.util.SimpleArrayMap; +import com.google.common.base.Optional; + +/** A {@link SmartDialMap} for the Ukrainian alphabet. */ +final class UkrainianSmartDialMap extends SmartDialMap { + private static final SimpleArrayMap CHAR_TO_KEY_MAP = + new SimpleArrayMap<>(); + + // Reference: https://en.wikipedia.org/wiki/Ukrainian_alphabet + static { + CHAR_TO_KEY_MAP.put('а', '2'); + CHAR_TO_KEY_MAP.put('б', '2'); + CHAR_TO_KEY_MAP.put('в', '2'); + CHAR_TO_KEY_MAP.put('г', '2'); + CHAR_TO_KEY_MAP.put('ґ', '2'); + + CHAR_TO_KEY_MAP.put('д', '3'); + CHAR_TO_KEY_MAP.put('е', '3'); + CHAR_TO_KEY_MAP.put('є', '3'); + CHAR_TO_KEY_MAP.put('ж', '3'); + CHAR_TO_KEY_MAP.put('з', '3'); + + CHAR_TO_KEY_MAP.put('и', '4'); + CHAR_TO_KEY_MAP.put('і', '4'); + CHAR_TO_KEY_MAP.put('ї', '4'); + CHAR_TO_KEY_MAP.put('й', '4'); + CHAR_TO_KEY_MAP.put('к', '4'); + CHAR_TO_KEY_MAP.put('л', '4'); + + CHAR_TO_KEY_MAP.put('м', '5'); + CHAR_TO_KEY_MAP.put('н', '5'); + CHAR_TO_KEY_MAP.put('о', '5'); + CHAR_TO_KEY_MAP.put('п', '5'); + + CHAR_TO_KEY_MAP.put('р', '6'); + CHAR_TO_KEY_MAP.put('с', '6'); + CHAR_TO_KEY_MAP.put('т', '6'); + CHAR_TO_KEY_MAP.put('у', '6'); + + CHAR_TO_KEY_MAP.put('ф', '7'); + CHAR_TO_KEY_MAP.put('х', '7'); + CHAR_TO_KEY_MAP.put('ц', '7'); + CHAR_TO_KEY_MAP.put('ч', '7'); + + CHAR_TO_KEY_MAP.put('ш', '8'); + CHAR_TO_KEY_MAP.put('щ', '8'); + + CHAR_TO_KEY_MAP.put('ь', '9'); + CHAR_TO_KEY_MAP.put('ю', '9'); + CHAR_TO_KEY_MAP.put('я', '9'); + } + + private static UkrainianSmartDialMap instance; + + static UkrainianSmartDialMap getInstance() { + if (instance == null) { + instance = new UkrainianSmartDialMap(); + } + + return instance; + } + + private UkrainianSmartDialMap() {} + + @Override + Optional normalizeCharacter(char ch) { + ch = Character.toLowerCase(ch); + return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent(); + } + + @Override + SimpleArrayMap getCharToKeyMap() { + return CHAR_TO_KEY_MAP; + } +} -- cgit v1.2.3