summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenyi Wang <wenyiw@google.com>2015-12-15 13:10:01 -0800
committerWenyi Wang <wenyiw@google.com>2015-12-15 16:48:02 -0800
commitc24a83bcc26ff0168f2f45e8d2bf291453316027 (patch)
treeccdbf48e8850481bd9f544d6aa74a2a93ea05ffc
parentf76d293fa3cac9e7683084891ac29f0b95628ee0 (diff)
downloadpackages_apps_PhoneCommon-c24a83bcc26ff0168f2f45e8d2bf291453316027.tar.gz
packages_apps_PhoneCommon-c24a83bcc26ff0168f2f45e8d2bf291453316027.tar.bz2
packages_apps_PhoneCommon-c24a83bcc26ff0168f2f45e8d2bf291453316027.zip
Backport Context.getDrawable()
Context.getDrawable() was added in API level 21. In order to backport it, we could use ContextCompat.getDrawable(). However, the code in PhoneCommon is built as part of master in packages/services/Telephony as well and it doesn't include the support library. Simply importing ContextCompat would break master, so we handle compatibility in the class itself. Bug: 25629359 Change-Id: I98a413a1b7e0a9a94a722059e18318e22939040d
-rw-r--r--src/com/android/phone/common/dialpad/DialpadView.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/android/phone/common/dialpad/DialpadView.java b/src/com/android/phone/common/dialpad/DialpadView.java
index 1d71687..d8ee4db 100644
--- a/src/com/android/phone/common/dialpad/DialpadView.java
+++ b/src/com/android/phone/common/dialpad/DialpadView.java
@@ -22,7 +22,9 @@ 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;
@@ -187,8 +189,8 @@ public class DialpadView extends LinearLayout {
numberContentDescription = spannable;
}
- final RippleDrawable rippleBackground =
- (RippleDrawable) getContext().getDrawable(R.drawable.btn_dialpad_key);
+ final RippleDrawable rippleBackground = (RippleDrawable)
+ getDrawableCompat(getContext(), R.drawable.btn_dialpad_key);
if (mRippleColor != null) {
rippleBackground.setColor(mRippleColor);
}
@@ -213,6 +215,14 @@ public class DialpadView extends LinearLayout {
}
+ 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);
+ }
+ }
+
public void setShowVoicemailButton(boolean show) {
View view = findViewById(R.id.dialpad_key_voicemail);
if (view != null) {