summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-11-07 05:18:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-11-07 05:18:03 +0000
commite8ee4c394f12b744f041727c5956d03879e5fc95 (patch)
tree0e0bf5e8e8cab4c739f16b7f749e708d9790f73b /java
parent2835d4c4c30c645b87887861b54bfb4a22ff524a (diff)
parent8bfef4bb84f17120eff4b0de0525dfe306910559 (diff)
Merge changes Ibaf55bde,I044861a1,Ib2d207eb,Ide61f65a
* changes: Fixed tab in packages.mk. Adding packages.mk Fixed that name mixed Hebrew is not displayed correctly at call log Show dual alphabets on the dialpad if a secondary alphabet is available.
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java3
-rw-r--r--java/com/android/dialer/dialpadview/DialpadAlphabets.java80
-rw-r--r--java/com/android/dialer/dialpadview/DialpadView.java67
-rw-r--r--java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml4
-rw-r--r--java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml4
-rw-r--r--java/com/android/dialer/dialpadview/res/values-land/styles.xml2
-rw-r--r--java/com/android/dialer/dialpadview/res/values/attrs.xml2
-rw-r--r--java/com/android/dialer/dialpadview/res/values/dimens.xml3
-rw-r--r--java/com/android/dialer/dialpadview/res/values/strings.xml13
-rw-r--r--java/com/android/dialer/dialpadview/res/values/styles.xml11
-rw-r--r--java/com/android/incallui/res/values-sw360dp/dimens.xml4
-rw-r--r--java/com/android/incallui/res/values/dimens.xml4
-rw-r--r--java/com/android/incallui/res/values/styles.xml6
13 files changed, 158 insertions, 45 deletions
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index a09bfd41f..ad931e87a 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -139,6 +139,9 @@ public class PhoneCallDetailsHelper {
views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
} else {
nameText = details.getPreferredName();
+ // "nameView" is updated from phone number to contact name after number matching.
+ // Since TextDirection remains at View.TEXT_DIRECTION_LTR, initialize it.
+ views.nameView.setTextDirection(View.TEXT_DIRECTION_INHERIT);
}
views.nameView.setText(nameText);
diff --git a/java/com/android/dialer/dialpadview/DialpadAlphabets.java b/java/com/android/dialer/dialpadview/DialpadAlphabets.java
new file mode 100644
index 000000000..f02ca4395
--- /dev/null
+++ b/java/com/android/dialer/dialpadview/DialpadAlphabets.java
@@ -0,0 +1,80 @@
+/*
+ * 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.dialpadview;
+
+import android.support.v4.util.SimpleArrayMap;
+
+/** A class containing key-letter mappings for the dialpad. */
+public class DialpadAlphabets {
+
+ // The default mapping (the Latin alphabet)
+ private static final String[] def = {
+ "+" /* 0 */,
+ "" /* 1 */,
+ "ABC" /* 2 */,
+ "DEF" /* 3 */,
+ "GHI" /* 4 */,
+ "JKL" /* 5 */,
+ "MNO" /* 6 */,
+ "PQRS" /* 7 */,
+ "TUV" /* 8 */,
+ "WXYZ" /* 9 */,
+ "" /* * */,
+ "" /* # */,
+ };
+
+ // Russian
+ private static final String[] rus = {
+ "" /* 0 */,
+ "" /* 1 */,
+ "АБВГ" /* 2 */,
+ "ДЕЖЗ" /* 3 */,
+ "ИЙКЛ" /* 4 */,
+ "МНОП" /* 5 */,
+ "РСТУ" /* 6 */,
+ "ФХЦЧ" /* 7 */,
+ "ШЩЪЫ" /* 8 */,
+ "ЬЭЮЯ" /* 9 */,
+ "" /* * */,
+ "" /* # */,
+ };
+
+ // A map in which each key is an ISO 639-2 language code and the corresponding key is an array
+ // defining key-letter mappings
+ private static final SimpleArrayMap<String, String[]> alphabets = new SimpleArrayMap<>();
+
+ static {
+ alphabets.put("rus", rus);
+ }
+
+ /**
+ * Returns the alphabet (a key-letter mapping) of the given ISO 639-2 language code or null if
+ *
+ * <ul>
+ * <li>no alphabet for the language code is defined, or
+ * <li>the language code is invalid.
+ * </ul>
+ */
+ public static String[] getAlphabetForLanguage(String languageCode) {
+ return alphabets.get(languageCode);
+ }
+
+ /** Returns the default key-letter mapping (the one that uses the Latin alphabet). */
+ public static String[] getDefaultAlphabet() {
+ return def;
+ }
+}
diff --git a/java/com/android/dialer/dialpadview/DialpadView.java b/java/com/android/dialer/dialpadview/DialpadView.java
index 5e79cb59f..38ab383a8 100644
--- a/java/com/android/dialer/dialpadview/DialpadView.java
+++ b/java/com/android/dialer/dialpadview/DialpadView.java
@@ -29,6 +29,7 @@ import android.text.Spannable;
import android.text.TextUtils;
import android.text.style.TtsSpan;
import android.util.AttributeSet;
+import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -73,38 +74,21 @@ public class DialpadView extends LinearLayout {
R.id.pound
};
- // Resource IDs for the button-letter mapping
- private static final int[] LETTER_MAPPING_IDS =
- new int[] {
- R.string.dialpad_0_letters,
- R.string.dialpad_1_letters,
- R.string.dialpad_2_letters,
- R.string.dialpad_3_letters,
- R.string.dialpad_4_letters,
- R.string.dialpad_5_letters,
- R.string.dialpad_6_letters,
- R.string.dialpad_7_letters,
- R.string.dialpad_8_letters,
- R.string.dialpad_9_letters,
- R.string.dialpad_star_letters,
- R.string.dialpad_pound_letters
- };
-
- // Whether the device is in landscape mode
- private final boolean mIsLandscape;
-
- // Whether the dialpad is shown in a right-to-left locale
- private final boolean mIsRtl;
+ private final AttributeSet mAttributeSet;
+ private final ColorStateList mRippleColor;
+ private final String[] mPrimaryLettersMapping;
+ private final String[] mSecondaryLettersMapping;
+ private final boolean mIsLandscape; // whether the device is in landscape mode
+ private final boolean mIsRtl; // whether the dialpad is shown in a right-to-left locale
+ private final int mTranslateDistance;
private EditText mDigits;
private ImageButton mDelete;
private View mOverflowMenuButton;
- private ColorStateList mRippleColor;
private ViewGroup mRateContainer;
private TextView mIldCountry;
private TextView mIldRate;
private boolean mCanDigitsBeEdited;
- private int mTranslateDistance;
public DialpadView(Context context) {
this(context, null);
@@ -116,6 +100,7 @@ public class DialpadView extends LinearLayout {
public DialpadView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mAttributeSet = attrs;
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Dialpad);
mRippleColor = a.getColorStateList(R.styleable.Dialpad_dialpad_key_button_touch_tint);
@@ -128,6 +113,10 @@ public class DialpadView extends LinearLayout {
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
mIsRtl =
TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
+
+ mPrimaryLettersMapping = DialpadAlphabets.getDefaultAlphabet();
+ mSecondaryLettersMapping =
+ DialpadAlphabets.getAlphabetForLanguage(CompatUtils.getLocale(context).getISO3Language());
}
@Override
@@ -180,7 +169,7 @@ public class DialpadView extends LinearLayout {
// The content description is used for Talkback key presses. The number is
// separated by a "," to introduce a slight delay. Convert letters into a verbatim
// span so that they are read as letters instead of as one word.
- String letters = resources.getString(LETTER_MAPPING_IDS[i]);
+ String letters = mPrimaryLettersMapping[i];
Spannable spannable =
Spannable.Factory.getInstance().newSpannable(numberString + "," + letters);
spannable.setSpan(
@@ -202,9 +191,31 @@ public class DialpadView extends LinearLayout {
dialpadKey.setContentDescription(numberContentDescription);
dialpadKey.setBackground(rippleBackground);
- TextView lettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters);
- if (lettersView != null) {
- lettersView.setText(resources.getString(LETTER_MAPPING_IDS[i]));
+ TextView primaryLettersView = (TextView) dialpadKey.findViewById(R.id.dialpad_key_letters);
+ TextView secondaryLettersView =
+ (TextView) dialpadKey.findViewById(R.id.dialpad_key_secondary_letters);
+ if (primaryLettersView != null) {
+ primaryLettersView.setText(mPrimaryLettersMapping[i]);
+ }
+ if (primaryLettersView != null && secondaryLettersView != null) {
+ if (mSecondaryLettersMapping == null) {
+ secondaryLettersView.setVisibility(View.GONE);
+ } else {
+ secondaryLettersView.setVisibility(View.VISIBLE);
+ secondaryLettersView.setText(mSecondaryLettersMapping[i]);
+
+ // Adjust the font size of the letters if a secondary alphabet is available.
+ TypedArray a =
+ getContext()
+ .getTheme()
+ .obtainStyledAttributes(mAttributeSet, R.styleable.Dialpad, 0, 0);
+ int textSize =
+ a.getDimensionPixelSize(
+ R.styleable.Dialpad_dialpad_key_letters_size_for_dual_alphabets, 0);
+ a.recycle();
+ primaryLettersView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
+ secondaryLettersView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
+ }
}
}
diff --git a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml
index 769e2d8bb..d61c636d4 100644
--- a/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml
+++ b/java/com/android/dialer/dialpadview/res/layout-land/dialpad_key.xml
@@ -42,6 +42,10 @@
<com.android.dialer.dialpadview.DialpadTextView
android:id="@+id/dialpad_key_letters"
style="@style/DialpadKeyLettersStyle"/>
+ <com.android.dialer.dialpadview.DialpadTextView
+ android:id="@+id/dialpad_key_secondary_letters"
+ style="@style/DialpadKeyLettersStyle"
+ android:layout_marginTop="2dp"/>
</LinearLayout>
<!-- A placeholder to make the width the same as other keys. -->
diff --git a/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml b/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml
index bb9ec63f6..01cbc92a0 100644
--- a/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml
+++ b/java/com/android/dialer/dialpadview/res/layout/dialpad_key.xml
@@ -34,6 +34,10 @@
<com.android.dialer.dialpadview.DialpadTextView
android:id="@+id/dialpad_key_letters"
style="@style/DialpadKeyLettersStyle"/>
+ <com.android.dialer.dialpadview.DialpadTextView
+ android:id="@+id/dialpad_key_secondary_letters"
+ style="@style/DialpadKeyLettersStyle"
+ android:layout_marginTop="2dp"/>
</LinearLayout>
</LinearLayout>
</com.android.dialer.dialpadview.DialpadKeyButton>
diff --git a/java/com/android/dialer/dialpadview/res/values-land/styles.xml b/java/com/android/dialer/dialpadview/res/values-land/styles.xml
index de9ef1fbf..abf55584b 100644
--- a/java/com/android/dialer/dialpadview/res/values-land/styles.xml
+++ b/java/com/android/dialer/dialpadview/res/values-land/styles.xml
@@ -50,7 +50,7 @@
<style name="DialpadKeyLettersStyle">
<item name="android:textColor">?attr/dialpad_text_color_secondary</item>
- <item name="android:textSize">@dimen/dialpad_key_letters_size</item>
+ <item name="android:textSize">?attr/dialpad_key_letters_size_for_single_alphabet</item>
<item name="android:fontFamily">sans-serif-regular</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
diff --git a/java/com/android/dialer/dialpadview/res/values/attrs.xml b/java/com/android/dialer/dialpadview/res/values/attrs.xml
index 972263883..61c9c208e 100644
--- a/java/com/android/dialer/dialpadview/res/values/attrs.xml
+++ b/java/com/android/dialer/dialpadview/res/values/attrs.xml
@@ -23,6 +23,8 @@
<attr format="color" name="dialpad_key_button_touch_tint"/>
<attr format="dimension" name="dialpad_digits_adjustable_text_size"/>
<attr format="dimension" name="dialpad_digits_adjustable_height"/>
+ <attr format="dimension" name="dialpad_key_letters_size_for_dual_alphabets"/>
+ <attr format="dimension" name="dialpad_key_letters_size_for_single_alphabet"/>
<attr format="dimension" name="dialpad_key_numbers_size"/>
<attr format="dimension" name="dialpad_key_number_margin_bottom"/>
</declare-styleable>
diff --git a/java/com/android/dialer/dialpadview/res/values/dimens.xml b/java/com/android/dialer/dialpadview/res/values/dimens.xml
index 797d7e839..4b386eeb5 100644
--- a/java/com/android/dialer/dialpadview/res/values/dimens.xml
+++ b/java/com/android/dialer/dialpadview/res/values/dimens.xml
@@ -17,7 +17,8 @@
<resources>
<!-- Text dimensions for dialpad keys -->
<dimen name="dialpad_key_numbers_default_size">36dp</dimen>
- <dimen name="dialpad_key_letters_size">12sp</dimen>
+ <dimen name="dialpad_key_letters_default_size_for_single_alphabet">12sp</dimen>
+ <dimen name="dialpad_key_letters_default_size_for_dual_alphabets">10sp</dimen>
<dimen name="dialpad_key_pound_size">23sp</dimen>
<dimen name="dialpad_key_star_size">36sp</dimen>
<dimen name="dialpad_key_height">64dp</dimen>
diff --git a/java/com/android/dialer/dialpadview/res/values/strings.xml b/java/com/android/dialer/dialpadview/res/values/strings.xml
index b3e92f1d9..481541677 100644
--- a/java/com/android/dialer/dialpadview/res/values/strings.xml
+++ b/java/com/android/dialer/dialpadview/res/values/strings.xml
@@ -18,19 +18,6 @@
<string name="dialpad_star_number" translatable="false">*</string>
<string name="dialpad_pound_number" translatable="false">#</string>
- <string name="dialpad_0_letters" translatable="false">+</string>
- <string name="dialpad_1_letters" translatable="false"></string>
- <string name="dialpad_2_letters" translatable="false">ABC</string>
- <string name="dialpad_3_letters" translatable="false">DEF</string>
- <string name="dialpad_4_letters" translatable="false">GHI</string>
- <string name="dialpad_5_letters" translatable="false">JKL</string>
- <string name="dialpad_6_letters" translatable="false">MNO</string>
- <string name="dialpad_7_letters" translatable="false">PQRS</string>
- <string name="dialpad_8_letters" translatable="false">TUV</string>
- <string name="dialpad_9_letters" translatable="false">WXYZ</string>
- <string name="dialpad_star_letters" translatable="false"></string>
- <string name="dialpad_pound_letters" translatable="false"></string>
-
<!-- String describing the back button in the dialpad. -->
<string name="description_dialpad_back">Navigate back</string>
diff --git a/java/com/android/dialer/dialpadview/res/values/styles.xml b/java/com/android/dialer/dialpadview/res/values/styles.xml
index 653fe484f..522e92ae9 100644
--- a/java/com/android/dialer/dialpadview/res/values/styles.xml
+++ b/java/com/android/dialer/dialpadview/res/values/styles.xml
@@ -56,7 +56,7 @@
<style name="DialpadKeyLettersStyle">
<item name="android:textColor">?attr/dialpad_text_color_secondary</item>
- <item name="android:textSize">@dimen/dialpad_key_letters_size</item>
+ <item name="android:textSize">?attr/dialpad_key_letters_size_for_single_alphabet</item>
<item name="android:fontFamily">sans-serif-regular</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
@@ -85,8 +85,15 @@
<style name="Dialpad">
<item name="dialpad_digits_adjustable_height">@dimen/dialpad_digits_height</item>
<item name="dialpad_digits_adjustable_text_size">@dimen/dialpad_digits_text_size</item>
+ <item name="dialpad_key_letters_size_for_dual_alphabets">
+ @dimen/dialpad_key_letters_default_size_for_dual_alphabets
+ </item>
+ <item name="dialpad_key_letters_size_for_single_alphabet">
+ @dimen/dialpad_key_letters_default_size_for_single_alphabet
+ </item>
<item name="dialpad_key_numbers_size">@dimen/dialpad_key_numbers_default_size</item>
- <item name="dialpad_key_number_margin_bottom">@dimen/dialpad_key_number_default_margin_bottom
+ <item name="dialpad_key_number_margin_bottom">
+ @dimen/dialpad_key_number_default_margin_bottom
</item>
<item name="dialpad_end_key_spacing">@dimen/dialpad_bottom_space_height</item>
<item name="dialpad_elevation">0dp</item>
diff --git a/java/com/android/incallui/res/values-sw360dp/dimens.xml b/java/com/android/incallui/res/values-sw360dp/dimens.xml
index bb74a0208..80b74e5e5 100644
--- a/java/com/android/incallui/res/values-sw360dp/dimens.xml
+++ b/java/com/android/incallui/res/values-sw360dp/dimens.xml
@@ -23,6 +23,10 @@
</dimen>
<dimen name="incall_dialpad_digits_adjustable_text_size">@dimen/dialpad_digits_text_size</dimen>
<dimen name="incall_dialpad_digits_adjustable_height">@dimen/dialpad_digits_height</dimen>
+ <dimen name="incall_dialpad_key_letters_size_for_dual_alphabets">9sp</dimen>
+ <dimen name="incall_dialpad_key_letters_size_for_single_alphabet">
+ @dimen/dialpad_key_letters_default_size_for_single_alphabet
+ </dimen>
<dimen name="incall_dialpad_key_numbers_size">@dimen/dialpad_key_numbers_default_size</dimen>
</resources>
diff --git a/java/com/android/incallui/res/values/dimens.xml b/java/com/android/incallui/res/values/dimens.xml
index 6e3722995..5688169ef 100644
--- a/java/com/android/incallui/res/values/dimens.xml
+++ b/java/com/android/incallui/res/values/dimens.xml
@@ -22,6 +22,10 @@
<dimen name="incall_dialpad_key_number_margin_bottom">1dp</dimen>
<dimen name="incall_dialpad_digits_adjustable_text_size">20sp</dimen>
<dimen name="incall_dialpad_digits_adjustable_height">50dp</dimen>
+ <dimen name="incall_dialpad_key_letters_size_for_dual_alphabets">9sp</dimen>
+ <dimen name="incall_dialpad_key_letters_size_for_single_alphabet">
+ @dimen/dialpad_key_letters_default_size_for_single_alphabet
+ </dimen>
<dimen name="incall_dialpad_key_numbers_size">36dp</dimen>
<!-- Dimension used to possibly down-scale high-res photo into what is suitable
diff --git a/java/com/android/incallui/res/values/styles.xml b/java/com/android/incallui/res/values/styles.xml
index 6a26e9c14..cfa4dd6f0 100644
--- a/java/com/android/incallui/res/values/styles.xml
+++ b/java/com/android/incallui/res/values/styles.xml
@@ -52,6 +52,12 @@
<item name="dialpad_digits_adjustable_height">
@dimen/incall_dialpad_digits_adjustable_height
</item>
+ <item name="dialpad_key_letters_size_for_dual_alphabets">
+ @dimen/incall_dialpad_key_letters_size_for_dual_alphabets
+ </item>
+ <item name="dialpad_key_letters_size_for_single_alphabet">
+ @dimen/incall_dialpad_key_letters_size_for_single_alphabet
+ </item>
<item name="dialpad_key_numbers_size">
@dimen/incall_dialpad_key_numbers_size
</item>