summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/shortcuts
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2017-06-30 15:26:17 -0700
committerEric Erfanian <erfanian@google.com>2017-07-01 03:17:31 +0000
commitd538e0b42004524abe36ac17606d3915a14f5dae (patch)
tree04638b64ff49c88d13ca3471eea44c30681489dd /java/com/android/dialer/shortcuts
parent842a9777de13bebb1c82f9d57222c52f9ddec558 (diff)
Update AOSP Dialer source from internal google3 repository at
cl/160679286. Test: make, treehugger This CL updates the AOSP Dialer source with all the changes that have gone into the private google3 repository. This includes all the changes from cl/159771812 (6/22/2017) to 160679286 (6/30/2017). These changes track the dialer V11 release. This goal of these drops is to keep the AOSP source in sync with the internal google3 repository. Currently these sync are done by hand with very minor modifications to the internal source code. See the Android.mk file for list of modifications. Change-Id: I7e7b41ce472b85a9d5a6728d5c8b3c045c09e095 Merged-In: Ie2eb735a92c577b5ae5a5e8b7efa2d699fc964bc
Diffstat (limited to 'java/com/android/dialer/shortcuts')
-rw-r--r--java/com/android/dialer/shortcuts/IconFactory.java37
-rw-r--r--java/com/android/dialer/shortcuts/res/drawable-anydpi-v26/ic_shortcut_add_contact.xml21
-rw-r--r--java/com/android/dialer/shortcuts/res/drawable/ic_add_contact_foreground.xml23
-rw-r--r--java/com/android/dialer/shortcuts/res/values/dimens.xml1
4 files changed, 82 insertions, 0 deletions
diff --git a/java/com/android/dialer/shortcuts/IconFactory.java b/java/com/android/dialer/shortcuts/IconFactory.java
index a8c4ada4e..4ec964c7b 100644
--- a/java/com/android/dialer/shortcuts/IconFactory.java
+++ b/java/com/android/dialer/shortcuts/IconFactory.java
@@ -20,11 +20,16 @@ import android.content.Context;
import android.content.pm.ShortcutInfo;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.net.Uri;
+import android.os.Build.VERSION;
+import android.os.Build.VERSION_CODES;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.annotation.RequiresApi;
import android.support.annotation.WorkerThread;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
@@ -83,6 +88,38 @@ class IconFactory {
ContactsContract.Contacts.openContactPhotoInputStream(
context.getContentResolver(), lookupUri, false /* preferHighres */);
+ return VERSION.SDK_INT >= VERSION_CODES.O
+ ? createAdaptiveIcon(displayName, lookupKey, inputStream)
+ : createFlatIcon(displayName, lookupKey, inputStream);
+ }
+
+ @RequiresApi(VERSION_CODES.O)
+ private Icon createAdaptiveIcon(
+ @NonNull String displayName, @NonNull String lookupKey, @Nullable InputStream inputStream) {
+ if (inputStream == null) {
+ LetterTileDrawable letterTileDrawable = new LetterTileDrawable(context.getResources());
+ // The adaptive icons clip the drawable to a safe area inside the drawable. Scale the letter
+ // so it fits inside the safe area.
+ letterTileDrawable.setScale(1f / (1f + AdaptiveIconDrawable.getExtraInsetFraction()));
+ letterTileDrawable.setCanonicalDialerLetterTileDetails(
+ displayName,
+ lookupKey,
+ LetterTileDrawable.SHAPE_RECTANGLE,
+ LetterTileDrawable.TYPE_DEFAULT);
+
+ int iconSize =
+ context
+ .getResources()
+ .getDimensionPixelSize(R.dimen.launcher_shortcut_adaptive_icon_size);
+ return Icon.createWithAdaptiveBitmap(
+ DrawableConverter.drawableToBitmap(letterTileDrawable, iconSize, iconSize));
+ }
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ return Icon.createWithAdaptiveBitmap(bitmap);
+ }
+
+ private Icon createFlatIcon(
+ @NonNull String displayName, @NonNull String lookupKey, @Nullable InputStream inputStream) {
Drawable drawable;
if (inputStream == null) {
// No photo for contact; use a letter tile.
diff --git a/java/com/android/dialer/shortcuts/res/drawable-anydpi-v26/ic_shortcut_add_contact.xml b/java/com/android/dialer/shortcuts/res/drawable-anydpi-v26/ic_shortcut_add_contact.xml
new file mode 100644
index 000000000..07ed17226
--- /dev/null
+++ b/java/com/android/dialer/shortcuts/res/drawable-anydpi-v26/ic_shortcut_add_contact.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/shortcut_add_contact_background_color"/>
+
+ <foreground android:drawable="@drawable/ic_add_contact_foreground"/>
+</adaptive-icon>
diff --git a/java/com/android/dialer/shortcuts/res/drawable/ic_add_contact_foreground.xml b/java/com/android/dialer/shortcuts/res/drawable/ic_add_contact_foreground.xml
new file mode 100644
index 000000000..6bc172767
--- /dev/null
+++ b/java/com/android/dialer/shortcuts/res/drawable/ic_add_contact_foreground.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ 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
+ -->
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:gravity="center"
+ android:src="@drawable/quantum_ic_person_add_white_24"
+ android:tint="@color/shortcut_add_contact_foreground_color">
+
+</bitmap>
diff --git a/java/com/android/dialer/shortcuts/res/values/dimens.xml b/java/com/android/dialer/shortcuts/res/values/dimens.xml
index 232125653..369d38c15 100644
--- a/java/com/android/dialer/shortcuts/res/values/dimens.xml
+++ b/java/com/android/dialer/shortcuts/res/values/dimens.xml
@@ -16,4 +16,5 @@
-->
<resources>
<dimen name="launcher_shortcut_icon_size">48dp</dimen>
+ <dimen name="launcher_shortcut_adaptive_icon_size">108dp</dimen>
</resources>