summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/smartdial
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-12-22 18:44:31 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-12-22 18:44:31 +0000
commit88518503c1351ba86f503ebd8742d6b292928ddd (patch)
tree97c6b6429cd3a0276ece3bba0ce022e4c6b92866 /java/com/android/dialer/smartdial
parente2da6ef8a56bd9f7eedfa1c6d89e968590e0c09b (diff)
parent1e8275f3e6f57f285900ce35946064e0550b174a (diff)
Merge changes I66342431,I5e579f11,I927711aa,Idd4cc115,If8cdbdfa, ...
* changes: Automated rollback of changelist 179615699 Automated rollback of changelist 179847039 Differentiate read/unread voicemails in the NUI Voicemail by bolding. Use CHAR_TO_KEY_MAPS in DialpadCharMappings in SmartDialMaps. Reorganize classes related to smart dial. Use the orientation obtained in onFinishInflate as the truth in DialpadView. Added context menu for favorite contacts in new speed dial. Update assisted dialing extras in preparation for platform implementation. Quick fix for bugs on simulator voice call. Fixed crash in UiListener when launching activity with screen off. Handle contacts which have been disassociated with a number in Cp2PhoneLookup. Fixed crash in PinnedShortcuts. Bug: 70402588 Added copySubMessage method to PhoneLookup interface. Bubble v2 changes. Always have hardware acceration enabled for InCallActivity Include inserted calls for consideration in PhoneLookupDataSource. Don't use phone number in spam call notifications Register content observer when voicemail table changes. Add SmartDialMaps for the Bulgarian alphabet and the Ukrainian alphabet. Remove voicemail from UI only after delete request. Bubble v2 RTL language fixes. Implemented SpeedDialEntry Room Database.
Diffstat (limited to 'java/com/android/dialer/smartdial')
-rw-r--r--java/com/android/dialer/smartdial/RussianSmartDialMap.java94
-rw-r--r--java/com/android/dialer/smartdial/SmartDialCursorLoader.java182
-rw-r--r--java/com/android/dialer/smartdial/map/BulgarianSmartDialMap.java49
-rw-r--r--java/com/android/dialer/smartdial/map/CompositeSmartDialMap.java (renamed from java/com/android/dialer/smartdial/CompositeSmartDialMap.java)16
-rw-r--r--java/com/android/dialer/smartdial/map/LatinSmartDialMap.java (renamed from java/com/android/dialer/smartdial/LatinSmartDialMap.java)43
-rw-r--r--java/com/android/dialer/smartdial/map/RussianSmartDialMap.java49
-rw-r--r--java/com/android/dialer/smartdial/map/SmartDialMap.java (renamed from java/com/android/dialer/smartdial/SmartDialMap.java)2
-rw-r--r--java/com/android/dialer/smartdial/map/UkrainianSmartDialMap.java48
-rw-r--r--java/com/android/dialer/smartdial/util/SmartDialMatchPosition.java (renamed from java/com/android/dialer/smartdial/SmartDialMatchPosition.java)6
-rw-r--r--java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java (renamed from java/com/android/dialer/smartdial/SmartDialNameMatcher.java)5
-rw-r--r--java/com/android/dialer/smartdial/util/SmartDialPrefix.java (renamed from java/com/android/dialer/smartdial/SmartDialPrefix.java)3
11 files changed, 349 insertions, 148 deletions
diff --git a/java/com/android/dialer/smartdial/RussianSmartDialMap.java b/java/com/android/dialer/smartdial/RussianSmartDialMap.java
deleted file mode 100644
index ada9182e1..000000000
--- a/java/com/android/dialer/smartdial/RussianSmartDialMap.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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 Russian alphabet. */
-@SuppressWarnings("Guava")
-final class RussianSmartDialMap extends SmartDialMap {
- private static final SimpleArrayMap<Character, Character> CHAR_TO_KEY_MAP =
- new SimpleArrayMap<>();
-
- // Reference: https://en.wikipedia.org/wiki/Russian_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('з', '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('п', '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('ъ', '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 RussianSmartDialMap instance;
-
- static RussianSmartDialMap getInstance() {
- if (instance == null) {
- instance = new RussianSmartDialMap();
- }
-
- return instance;
- }
-
- private RussianSmartDialMap() {}
-
- @Override
- Optional<Character> normalizeCharacter(char ch) {
- ch = Character.toLowerCase(ch);
- return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent();
- }
-
- @Override
- SimpleArrayMap<Character, Character> getCharToKeyMap() {
- return CHAR_TO_KEY_MAP;
- }
-}
diff --git a/java/com/android/dialer/smartdial/SmartDialCursorLoader.java b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java
new file mode 100644
index 000000000..f6bc9325a
--- /dev/null
+++ b/java/com/android/dialer/smartdial/SmartDialCursorLoader.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2013 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.content.AsyncTaskLoader;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import com.android.contacts.common.list.PhoneNumberListAdapter.PhoneQuery;
+import com.android.dialer.common.LogUtil;
+import com.android.dialer.database.Database;
+import com.android.dialer.database.DialerDatabaseHelper;
+import com.android.dialer.database.DialerDatabaseHelper.ContactNumber;
+import com.android.dialer.smartdial.util.SmartDialNameMatcher;
+import com.android.dialer.util.PermissionsUtil;
+import java.util.ArrayList;
+
+/** Implements a Loader<Cursor> class to asynchronously load SmartDial search results. */
+public class SmartDialCursorLoader extends AsyncTaskLoader<Cursor> {
+
+ private static final String TAG = "SmartDialCursorLoader";
+ private static final boolean DEBUG = false;
+
+ private final Context mContext;
+
+ private Cursor mCursor;
+
+ private String mQuery;
+ private SmartDialNameMatcher mNameMatcher;
+
+ private boolean mShowEmptyListForNullQuery = true;
+
+ public SmartDialCursorLoader(Context context) {
+ super(context);
+ mContext = context;
+ }
+
+ /**
+ * Configures the query string to be used to find SmartDial matches.
+ *
+ * @param query The query string user typed.
+ */
+ public void configureQuery(String query) {
+ if (DEBUG) {
+ LogUtil.v(TAG, "Configure new query to be " + query);
+ }
+ mQuery = SmartDialNameMatcher.normalizeNumber(mContext, query);
+
+ /** Constructs a name matcher object for matching names. */
+ mNameMatcher = new SmartDialNameMatcher(mQuery);
+ mNameMatcher.setShouldMatchEmptyQuery(!mShowEmptyListForNullQuery);
+ }
+
+ /**
+ * Queries the SmartDial database and loads results in background.
+ *
+ * @return Cursor of contacts that matches the SmartDial query.
+ */
+ @Override
+ public Cursor loadInBackground() {
+ if (DEBUG) {
+ LogUtil.v(TAG, "Load in background " + mQuery);
+ }
+
+ if (!PermissionsUtil.hasContactsReadPermissions(mContext)) {
+ return new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
+ }
+
+ /** Loads results from the database helper. */
+ final DialerDatabaseHelper dialerDatabaseHelper =
+ Database.get(mContext).getDatabaseHelper(mContext);
+ final ArrayList<ContactNumber> allMatches =
+ dialerDatabaseHelper.getLooseMatches(mQuery, mNameMatcher);
+
+ if (DEBUG) {
+ LogUtil.v(TAG, "Loaded matches " + allMatches.size());
+ }
+
+ /** Constructs a cursor for the returned array of results. */
+ final MatrixCursor cursor = new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
+ Object[] row = new Object[PhoneQuery.PROJECTION_PRIMARY.length];
+ for (ContactNumber contact : allMatches) {
+ row[PhoneQuery.PHONE_ID] = contact.dataId;
+ row[PhoneQuery.PHONE_NUMBER] = contact.phoneNumber;
+ row[PhoneQuery.CONTACT_ID] = contact.id;
+ row[PhoneQuery.LOOKUP_KEY] = contact.lookupKey;
+ row[PhoneQuery.PHOTO_ID] = contact.photoId;
+ row[PhoneQuery.DISPLAY_NAME] = contact.displayName;
+ row[PhoneQuery.CARRIER_PRESENCE] = contact.carrierPresence;
+ cursor.addRow(row);
+ }
+ return cursor;
+ }
+
+ @Override
+ public void deliverResult(Cursor cursor) {
+ if (isReset()) {
+ /** The Loader has been reset; ignore the result and invalidate the data. */
+ releaseResources(cursor);
+ return;
+ }
+
+ /** Hold a reference to the old data so it doesn't get garbage collected. */
+ Cursor oldCursor = mCursor;
+ mCursor = cursor;
+
+ if (isStarted()) {
+ /** If the Loader is in a started state, deliver the results to the client. */
+ super.deliverResult(cursor);
+ }
+
+ /** Invalidate the old data as we don't need it any more. */
+ if (oldCursor != null && oldCursor != cursor) {
+ releaseResources(oldCursor);
+ }
+ }
+
+ @Override
+ protected void onStartLoading() {
+ if (mCursor != null) {
+ /** Deliver any previously loaded data immediately. */
+ deliverResult(mCursor);
+ }
+ if (mCursor == null) {
+ /** Force loads every time as our results change with queries. */
+ forceLoad();
+ }
+ }
+
+ @Override
+ protected void onStopLoading() {
+ /** The Loader is in a stopped state, so we should attempt to cancel the current load. */
+ cancelLoad();
+ }
+
+ @Override
+ protected void onReset() {
+ /** Ensure the loader has been stopped. */
+ onStopLoading();
+
+ /** Release all previously saved query results. */
+ if (mCursor != null) {
+ releaseResources(mCursor);
+ mCursor = null;
+ }
+ }
+
+ @Override
+ public void onCanceled(Cursor cursor) {
+ super.onCanceled(cursor);
+
+ /** The load has been canceled, so we should release the resources associated with 'data'. */
+ releaseResources(cursor);
+ }
+
+ private void releaseResources(Cursor cursor) {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+
+ public void setShowEmptyListForNullQuery(boolean show) {
+ mShowEmptyListForNullQuery = show;
+ if (mNameMatcher != null) {
+ mNameMatcher.setShouldMatchEmptyQuery(!show);
+ }
+ }
+}
diff --git a/java/com/android/dialer/smartdial/map/BulgarianSmartDialMap.java b/java/com/android/dialer/smartdial/map/BulgarianSmartDialMap.java
new file mode 100644
index 000000000..5be9761a1
--- /dev/null
+++ b/java/com/android/dialer/smartdial/map/BulgarianSmartDialMap.java
@@ -0,0 +1,49 @@
+/*
+ * 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.map;
+
+import android.support.v4.util.SimpleArrayMap;
+import com.android.dialer.dialpadview.DialpadCharMappings;
+import com.google.common.base.Optional;
+
+/** A {@link SmartDialMap} for the Bulgarian alphabet. */
+@SuppressWarnings("Guava")
+final class BulgarianSmartDialMap extends SmartDialMap {
+
+ private static BulgarianSmartDialMap instance;
+
+ static BulgarianSmartDialMap getInstance() {
+ if (instance == null) {
+ instance = new BulgarianSmartDialMap();
+ }
+
+ return instance;
+ }
+
+ private BulgarianSmartDialMap() {}
+
+ @Override
+ Optional<Character> normalizeCharacter(char ch) {
+ ch = Character.toLowerCase(ch);
+ return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent();
+ }
+
+ @Override
+ SimpleArrayMap<Character, Character> getCharToKeyMap() {
+ return DialpadCharMappings.getCharToKeyMap("bul");
+ }
+}
diff --git a/java/com/android/dialer/smartdial/CompositeSmartDialMap.java b/java/com/android/dialer/smartdial/map/CompositeSmartDialMap.java
index d51e46f76..df32d4ce7 100644
--- a/java/com/android/dialer/smartdial/CompositeSmartDialMap.java
+++ b/java/com/android/dialer/smartdial/map/CompositeSmartDialMap.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.map;
import android.content.Context;
import android.support.annotation.VisibleForTesting;
@@ -45,7 +45,9 @@ public class CompositeSmartDialMap {
private static final SimpleArrayMap<String, SmartDialMap> 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() {}
@@ -56,7 +58,7 @@ public class CompositeSmartDialMap {
* <p>The provided character is expected to be a normalized character. See {@link
* SmartDialMap#normalizeCharacter(char)} for details.
*/
- static boolean isValidDialpadCharacter(Context context, char ch) {
+ public static boolean isValidDialpadCharacter(Context context, char ch) {
if (DEFAULT_MAP.isValidDialpadCharacter(ch)) {
return true;
}
@@ -71,7 +73,7 @@ public class CompositeSmartDialMap {
* <p>The provided character is expected to be a normalized character. See {@link
* SmartDialMap#normalizeCharacter(char)} for details.
*/
- static boolean isValidDialpadAlphabeticChar(Context context, char ch) {
+ public static boolean isValidDialpadAlphabeticChar(Context context, char ch) {
if (DEFAULT_MAP.isValidDialpadAlphabeticChar(ch)) {
return true;
}
@@ -83,7 +85,7 @@ public class CompositeSmartDialMap {
/**
* Returns true if the provided character is a digit, and can be mapped to a key on the dialpad.
*/
- static boolean isValidDialpadNumericChar(Context context, char ch) {
+ public static boolean isValidDialpadNumericChar(Context context, char ch) {
if (DEFAULT_MAP.isValidDialpadNumericChar(ch)) {
return true;
}
@@ -100,7 +102,7 @@ public class CompositeSmartDialMap {
*
* <p>If the provided character can't be mapped to a key on the dialpad, return -1.
*/
- static byte getDialpadIndex(Context context, char ch) {
+ public static byte getDialpadIndex(Context context, char ch) {
Optional<Byte> dialpadIndex = DEFAULT_MAP.getDialpadIndex(ch);
if (dialpadIndex.isPresent()) {
return dialpadIndex.get();
@@ -122,7 +124,7 @@ public class CompositeSmartDialMap {
*
* <p>If the provided character can't be mapped to a key on the dialpad, return the character.
*/
- static char getDialpadNumericCharacter(Context context, char ch) {
+ public static char getDialpadNumericCharacter(Context context, char ch) {
Optional<Character> dialpadNumericChar = DEFAULT_MAP.getDialpadNumericCharacter(ch);
if (dialpadNumericChar.isPresent()) {
return dialpadNumericChar.get();
@@ -142,7 +144,7 @@ public class CompositeSmartDialMap {
*
* <p>If the provided character can't be mapped to a key on the dialpad, return the character.
*/
- static char normalizeCharacter(Context context, char ch) {
+ public static char normalizeCharacter(Context context, char ch) {
Optional<Character> normalizedChar = DEFAULT_MAP.normalizeCharacter(ch);
if (normalizedChar.isPresent()) {
return normalizedChar.get();
diff --git a/java/com/android/dialer/smartdial/LatinSmartDialMap.java b/java/com/android/dialer/smartdial/map/LatinSmartDialMap.java
index b67901bbe..b8ef951c5 100644
--- a/java/com/android/dialer/smartdial/LatinSmartDialMap.java
+++ b/java/com/android/dialer/smartdial/map/LatinSmartDialMap.java
@@ -14,52 +14,15 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.map;
import android.support.v4.util.SimpleArrayMap;
+import com.android.dialer.dialpadview.DialpadCharMappings;
import com.google.common.base.Optional;
/** A {@link SmartDialMap} for the Latin alphabet, which is for T9 dialpad searching. */
@SuppressWarnings("Guava")
final class LatinSmartDialMap extends SmartDialMap {
- private static final SimpleArrayMap<Character, Character> CHAR_TO_KEY_MAP =
- new SimpleArrayMap<>();
-
- static {
- CHAR_TO_KEY_MAP.put('a', '2');
- CHAR_TO_KEY_MAP.put('b', '2');
- CHAR_TO_KEY_MAP.put('c', '2');
-
- CHAR_TO_KEY_MAP.put('d', '3');
- CHAR_TO_KEY_MAP.put('e', '3');
- CHAR_TO_KEY_MAP.put('f', '3');
-
- CHAR_TO_KEY_MAP.put('g', '4');
- CHAR_TO_KEY_MAP.put('h', '4');
- CHAR_TO_KEY_MAP.put('i', '4');
-
- CHAR_TO_KEY_MAP.put('j', '5');
- CHAR_TO_KEY_MAP.put('k', '5');
- CHAR_TO_KEY_MAP.put('l', '5');
-
- CHAR_TO_KEY_MAP.put('m', '6');
- CHAR_TO_KEY_MAP.put('n', '6');
- CHAR_TO_KEY_MAP.put('o', '6');
-
- CHAR_TO_KEY_MAP.put('p', '7');
- CHAR_TO_KEY_MAP.put('q', '7');
- CHAR_TO_KEY_MAP.put('r', '7');
- CHAR_TO_KEY_MAP.put('s', '7');
-
- CHAR_TO_KEY_MAP.put('t', '8');
- CHAR_TO_KEY_MAP.put('u', '8');
- CHAR_TO_KEY_MAP.put('v', '8');
-
- CHAR_TO_KEY_MAP.put('w', '9');
- CHAR_TO_KEY_MAP.put('x', '9');
- CHAR_TO_KEY_MAP.put('y', '9');
- CHAR_TO_KEY_MAP.put('z', '9');
- }
private static LatinSmartDialMap instance;
@@ -780,6 +743,6 @@ final class LatinSmartDialMap extends SmartDialMap {
@Override
SimpleArrayMap<Character, Character> getCharToKeyMap() {
- return CHAR_TO_KEY_MAP;
+ return DialpadCharMappings.getDefaultCharToKeyMap();
}
}
diff --git a/java/com/android/dialer/smartdial/map/RussianSmartDialMap.java b/java/com/android/dialer/smartdial/map/RussianSmartDialMap.java
new file mode 100644
index 000000000..c10bbb0ce
--- /dev/null
+++ b/java/com/android/dialer/smartdial/map/RussianSmartDialMap.java
@@ -0,0 +1,49 @@
+/*
+ * 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.map;
+
+import android.support.v4.util.SimpleArrayMap;
+import com.android.dialer.dialpadview.DialpadCharMappings;
+import com.google.common.base.Optional;
+
+/** A {@link SmartDialMap} for the Russian alphabet. */
+@SuppressWarnings("Guava")
+final class RussianSmartDialMap extends SmartDialMap {
+
+ private static RussianSmartDialMap instance;
+
+ static RussianSmartDialMap getInstance() {
+ if (instance == null) {
+ instance = new RussianSmartDialMap();
+ }
+
+ return instance;
+ }
+
+ private RussianSmartDialMap() {}
+
+ @Override
+ Optional<Character> normalizeCharacter(char ch) {
+ ch = Character.toLowerCase(ch);
+ return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent();
+ }
+
+ @Override
+ SimpleArrayMap<Character, Character> getCharToKeyMap() {
+ return DialpadCharMappings.getCharToKeyMap("rus");
+ }
+}
diff --git a/java/com/android/dialer/smartdial/SmartDialMap.java b/java/com/android/dialer/smartdial/map/SmartDialMap.java
index bc5c9ea72..c74dd2893 100644
--- a/java/com/android/dialer/smartdial/SmartDialMap.java
+++ b/java/com/android/dialer/smartdial/map/SmartDialMap.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.map;
import android.support.v4.util.SimpleArrayMap;
import com.google.common.base.Optional;
diff --git a/java/com/android/dialer/smartdial/map/UkrainianSmartDialMap.java b/java/com/android/dialer/smartdial/map/UkrainianSmartDialMap.java
new file mode 100644
index 000000000..844732c32
--- /dev/null
+++ b/java/com/android/dialer/smartdial/map/UkrainianSmartDialMap.java
@@ -0,0 +1,48 @@
+/*
+ * 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.map;
+
+import android.support.v4.util.SimpleArrayMap;
+import com.android.dialer.dialpadview.DialpadCharMappings;
+import com.google.common.base.Optional;
+
+/** A {@link SmartDialMap} for the Ukrainian alphabet. */
+final class UkrainianSmartDialMap extends SmartDialMap {
+
+ private static UkrainianSmartDialMap instance;
+
+ static UkrainianSmartDialMap getInstance() {
+ if (instance == null) {
+ instance = new UkrainianSmartDialMap();
+ }
+
+ return instance;
+ }
+
+ private UkrainianSmartDialMap() {}
+
+ @Override
+ Optional<Character> normalizeCharacter(char ch) {
+ ch = Character.toLowerCase(ch);
+ return isValidDialpadAlphabeticChar(ch) ? Optional.of(ch) : Optional.absent();
+ }
+
+ @Override
+ SimpleArrayMap<Character, Character> getCharToKeyMap() {
+ return DialpadCharMappings.getCharToKeyMap("ukr");
+ }
+}
diff --git a/java/com/android/dialer/smartdial/SmartDialMatchPosition.java b/java/com/android/dialer/smartdial/util/SmartDialMatchPosition.java
index 8056ad723..db317ae6b 100644
--- a/java/com/android/dialer/smartdial/SmartDialMatchPosition.java
+++ b/java/com/android/dialer/smartdial/util/SmartDialMatchPosition.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.util;
-import android.util.Log;
+import com.android.dialer.common.LogUtil;
import java.util.ArrayList;
/**
@@ -59,7 +59,7 @@ public class SmartDialMatchPosition {
public static void print(ArrayList<SmartDialMatchPosition> list) {
for (int i = 0; i < list.size(); i++) {
SmartDialMatchPosition m = list.get(i);
- Log.d(TAG, "[" + m.start + "," + m.end + "]");
+ LogUtil.d(TAG, "[" + m.start + "," + m.end + "]");
}
}
diff --git a/java/com/android/dialer/smartdial/SmartDialNameMatcher.java b/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java
index 4e3e0cc3f..725c88c57 100644
--- a/java/com/android/dialer/smartdial/SmartDialNameMatcher.java
+++ b/java/com/android/dialer/smartdial/util/SmartDialNameMatcher.java
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.util;
import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
-import com.android.dialer.smartdial.SmartDialPrefix.PhoneNumberTokens;
+import com.android.dialer.smartdial.map.CompositeSmartDialMap;
+import com.android.dialer.smartdial.util.SmartDialPrefix.PhoneNumberTokens;
import java.util.ArrayList;
/**
diff --git a/java/com/android/dialer/smartdial/SmartDialPrefix.java b/java/com/android/dialer/smartdial/util/SmartDialPrefix.java
index b9c1f8c11..9af411913 100644
--- a/java/com/android/dialer/smartdial/SmartDialPrefix.java
+++ b/java/com/android/dialer/smartdial/util/SmartDialPrefix.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.dialer.smartdial;
+package com.android.dialer.smartdial.util;
import android.content.Context;
import android.content.SharedPreferences;
@@ -22,6 +22,7 @@ import android.preference.PreferenceManager;
import android.support.annotation.VisibleForTesting;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
+import com.android.dialer.smartdial.map.CompositeSmartDialMap;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;