summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/dialpadview
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2017-11-17 17:13:47 -0800
committerzachh <zachh@google.com>2017-11-18 07:36:32 +0000
commit7f1076d08b39467ac8c550f60a7fbbad604ab4fa (patch)
treec9bb61716fc202d23c4966a1d2407cfa09744791 /java/com/android/dialer/dialpadview
parent57b093b4815afd2d169403c56be1702fae25ad51 (diff)
DialpadView cleanup.
Changes: 1. Rewrote the logic to pick a NumberFormat. 2. Deleted dead method setShowVoicemailButton(boolean) and field mCanDigitsBeEdited. 3. Deleted the redundant SDK version check when getting a Drawable. Test: DialpadFragmentIntegrationTest PiperOrigin-RevId: 176181808 Change-Id: Iee4e3db8535ebbea3d4c63c8d8c1d3eb342b538e
Diffstat (limited to 'java/com/android/dialer/dialpadview')
-rw-r--r--java/com/android/dialer/dialpadview/DialpadView.java48
1 files changed, 11 insertions, 37 deletions
diff --git a/java/com/android/dialer/dialpadview/DialpadView.java b/java/com/android/dialer/dialpadview/DialpadView.java
index 4cbf42f2e..1d48066ad 100644
--- a/java/com/android/dialer/dialpadview/DialpadView.java
+++ b/java/com/android/dialer/dialpadview/DialpadView.java
@@ -22,9 +22,7 @@ import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
-import android.os.Build;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.style.TtsSpan;
@@ -33,7 +31,6 @@ import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.view.ViewPropertyAnimator;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.view.accessibility.AccessibilityManager;
@@ -90,7 +87,6 @@ public class DialpadView extends LinearLayout {
private ViewGroup mRateContainer;
private TextView mIldCountry;
private TextView mIldRate;
- private boolean mCanDigitsBeEdited;
public DialpadView(Context context) {
this(context, null);
@@ -154,16 +150,7 @@ public class DialpadView extends LinearLayout {
private void setupKeypad() {
final Resources resources = getContext().getResources();
-
- final Locale currentLocale = resources.getConfiguration().locale;
- final NumberFormat nf;
- // We translate dialpad numbers only for "fa" and not any other locale
- // ("ar" anybody ?).
- if ("fa".equals(currentLocale.getLanguage())) {
- nf = DecimalFormat.getInstance(CompatUtils.getLocale(getContext()));
- } else {
- nf = DecimalFormat.getInstance(Locale.ENGLISH);
- }
+ final NumberFormat numberFormat = getNumberFormat();
for (int i = 0; i < BUTTON_IDS.length; i++) {
DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(BUTTON_IDS[i]);
@@ -178,7 +165,7 @@ public class DialpadView extends LinearLayout {
numberString = resources.getString(R.string.dialpad_star_number);
numberContentDescription = numberString;
} else {
- numberString = nf.format(i);
+ numberString = numberFormat.format(i);
// 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.
@@ -194,7 +181,7 @@ public class DialpadView extends LinearLayout {
}
final RippleDrawable rippleBackground =
- (RippleDrawable) getDrawableCompat(getContext(), R.drawable.btn_dialpad_key);
+ (RippleDrawable) getContext().getDrawable(R.drawable.btn_dialpad_key);
if (mRippleColor != null) {
rippleBackground.setColor(mRippleColor);
}
@@ -239,26 +226,19 @@ public class DialpadView extends LinearLayout {
zero.setLongHoverContentDescription(resources.getText(R.string.description_image_button_plus));
}
- private Drawable getDrawableCompat(Context context, int id) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- return context.getDrawable(id);
- } else {
- return context.getResources().getDrawable(id);
- }
- }
+ private NumberFormat getNumberFormat() {
+ Locale locale = CompatUtils.getLocale(getContext());
- public void setShowVoicemailButton(boolean show) {
- View view = findViewById(R.id.dialpad_key_voicemail);
- if (view != null) {
- view.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
- }
+ // Return the Persian number format if the current language is Persian.
+ return "fas".equals(locale.getISO3Language())
+ ? DecimalFormat.getInstance(locale)
+ : DecimalFormat.getInstance(Locale.ENGLISH);
}
/**
- * Whether or not the digits above the dialer can be edited.
+ * Configure whether or not the digits above the dialpad can be edited.
*
- * @param canBeEdited If true, the backspace button will be shown and the digits EditText will be
- * configured to allow text manipulation.
+ * <p>If we allow editing digits, the backspace button will be shown.
*/
public void setCanDigitsBeEdited(boolean canBeEdited) {
View deleteButton = findViewById(R.id.deleteButton);
@@ -271,8 +251,6 @@ public class DialpadView extends LinearLayout {
digits.setLongClickable(canBeEdited);
digits.setFocusableInTouchMode(canBeEdited);
digits.setCursorVisible(false);
-
- mCanDigitsBeEdited = canBeEdited;
}
public void setCallRateInformation(String countryName, String displayRate) {
@@ -285,10 +263,6 @@ public class DialpadView extends LinearLayout {
mIldRate.setText(displayRate);
}
- public boolean canDigitsBeEdited() {
- return mCanDigitsBeEdited;
- }
-
/**
* Always returns true for onHoverEvent callbacks, to fix problems with accessibility due to the
* dialpad overlaying other fragments.