diff options
author | Raj Yengisetty <raj@cyngn.com> | 2016-01-28 15:28:59 -0800 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2016-04-08 10:42:50 -0700 |
commit | 969c8f4ef904a235e0760ed6c9628910a731ca77 (patch) | |
tree | 957278a99ec15f681d7b760743d6f2fea9e08d4f | |
parent | 22fef9c20c52c127c95a50e357324ed921332647 (diff) | |
download | packages_apps_PhoneCommon-969c8f4ef904a235e0760ed6c9628910a731ca77.tar.gz packages_apps_PhoneCommon-969c8f4ef904a235e0760ed6c9628910a731ca77.tar.bz2 packages_apps_PhoneCommon-969c8f4ef904a235e0760ed6c9628910a731ca77.zip |
InCall: clean up logs and add ImageUtils
Change-Id: I235715af94f96f9ce8bde01643d1c1ed140a8ef3
-rw-r--r-- | src-ambient/incall/CallMethodHelper.java | 4 | ||||
-rw-r--r-- | src/com/android/phone/common/util/ImageUtils.java | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src-ambient/incall/CallMethodHelper.java b/src-ambient/incall/CallMethodHelper.java index c1219cb..bcdf143 100644 --- a/src-ambient/incall/CallMethodHelper.java +++ b/src-ambient/incall/CallMethodHelper.java @@ -97,7 +97,7 @@ public class CallMethodHelper { private static int callbackCount = 0; private static final String TAG = CallMethodHelper.class.getSimpleName(); - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; public interface CallMethodReceiver { void onChanged(HashMap<ComponentName, CallMethodInfo> callMethodInfos); @@ -115,7 +115,7 @@ public class CallMethodHelper { } if (DEBUG) { for (CallMethodInfo cmi : mCallMethodInfos.values()) { - Log.v("BIRD", "Broadcast: " + cmi.mName); + Log.v(TAG, "Broadcast: " + cmi.mName); } } dataHasBeenBroadcastPreviously = true; diff --git a/src/com/android/phone/common/util/ImageUtils.java b/src/com/android/phone/common/util/ImageUtils.java new file mode 100644 index 0000000..533e080 --- /dev/null +++ b/src/com/android/phone/common/util/ImageUtils.java @@ -0,0 +1,36 @@ +package com.android.phone.common.util; + +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; + +/** + * Utility class around Image loading and Bitmap effects + */ +public class ImageUtils { + + /** + * Used to convert a drawable into a bitmap. + * + * Drawables that don't have intrinsic dimensions are excluded from this conversion. This + * includes drawables such as ColorDrawables + */ + public static Bitmap drawableToBitmap (Drawable drawable) { + if (drawable instanceof BitmapDrawable) { + return ((BitmapDrawable)drawable).getBitmap(); + } + + if (drawable.getIntrinsicHeight() <= 0 || drawable.getIntrinsicWidth() <= 0) { + return null; + } + + Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), + drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + drawable.draw(canvas); + + return bitmap; + } +} |