Loading src/com/android/contacts/DynamicShortcuts.java +4 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ public class DynamicShortcuts { final ShortcutInfo.Builder builder = new ShortcutInfo.Builder(mContext, id) .setIntent(action) .setIcon(icon) .setExtras(extras) .setDisabledMessage(mContext.getString(R.string.dynamic_shortcut_disabled_message)); setLabel(builder, label); Loading @@ -305,6 +306,9 @@ public class DynamicShortcuts { public ShortcutInfo getQuickContactShortcutInfo(long id, String lookupKey, String displayName) { final ShortcutInfo.Builder builder = builderForContactShortcut(id, lookupKey, displayName); if (builder == null) { return null; } addIconForContact(id, lookupKey, displayName, builder); return builder.build(); } Loading src/com/android/contacts/ShortcutIntentBuilder.java +9 −5 Original line number Diff line number Diff line Loading @@ -276,6 +276,9 @@ public class ShortcutIntentBuilder { private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Intent intent = null; if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (BuildCompat.isAtLeastO()) { final long contactId = ContentUris.parseId(contactUri); final ShortcutManager sm = (ShortcutManager) Loading @@ -283,12 +286,11 @@ public class ShortcutIntentBuilder { final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getQuickContactShortcutInfo( contactId, lookupKey, displayName); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Intent shortcutIntent = ImplicitIntentsUtil.getIntentForQuickContactLauncherShortcut( mContext, contactUri); Loading Loading @@ -346,8 +348,10 @@ public class ShortcutIntentBuilder { final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getActionShortcutInfo( id, displayName, shortcutIntent, compatAdaptiveIcon.toIcon()); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } intent = intent == null ? new Intent() : intent; // This will be non-null in O and above. Loading src/com/android/contacts/quickcontact/QuickContactActivity.java +23 −17 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.content.IntentFilter; import android.content.Loader; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.res.Resources; import android.graphics.Bitmap; Loading Loading @@ -2697,21 +2698,26 @@ public class QuickContactActivity extends ContactsActivity { * Creates a launcher shortcut with the current contact. */ private void createLauncherShortcutWithContact() { final ShortcutIntentBuilder builder = new ShortcutIntentBuilder(this, new OnShortcutIntentCreatedListener() { @Override public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) { if (BuildCompat.isAtLeastO()) { final ShortcutManager shortcutManager = (ShortcutManager) getSystemService(SHORTCUT_SERVICE); final DynamicShortcuts shortcuts = new DynamicShortcuts(QuickContactActivity.this); shortcutManager.requestPinShortcut( shortcuts.getQuickContactShortcutInfo( mContactData.getId(), mContactData.getLookupKey(), mContactData.getDisplayName()), null); String displayName = mContactData.getDisplayName(); if (displayName == null) { displayName = getString(R.string.missing_name); } final ShortcutInfo shortcutInfo = shortcuts.getQuickContactShortcutInfo( mContactData.getId(), mContactData.getLookupKey(), displayName); if (shortcutInfo != null) { shortcutManager.requestPinShortcut(shortcutInfo, null); } } else { final ShortcutIntentBuilder builder = new ShortcutIntentBuilder(this, new OnShortcutIntentCreatedListener() { @Override public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) { // Broadcast the shortcutIntent to the launcher to create a // shortcut to this contact shortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); Loading @@ -2727,10 +2733,10 @@ public class QuickContactActivity extends ContactsActivity { Toast.makeText(QuickContactActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); } } }); builder.createContactShortcutIntent(mContactData.getLookupUri()); } } private boolean isShortcutCreatable() { if (mContactData == null || mContactData.isUserProfile() || Loading Loading
src/com/android/contacts/DynamicShortcuts.java +4 −0 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ public class DynamicShortcuts { final ShortcutInfo.Builder builder = new ShortcutInfo.Builder(mContext, id) .setIntent(action) .setIcon(icon) .setExtras(extras) .setDisabledMessage(mContext.getString(R.string.dynamic_shortcut_disabled_message)); setLabel(builder, label); Loading @@ -305,6 +306,9 @@ public class DynamicShortcuts { public ShortcutInfo getQuickContactShortcutInfo(long id, String lookupKey, String displayName) { final ShortcutInfo.Builder builder = builderForContactShortcut(id, lookupKey, displayName); if (builder == null) { return null; } addIconForContact(id, lookupKey, displayName, builder); return builder.build(); } Loading
src/com/android/contacts/ShortcutIntentBuilder.java +9 −5 Original line number Diff line number Diff line Loading @@ -276,6 +276,9 @@ public class ShortcutIntentBuilder { private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName, String lookupKey, byte[] bitmapData) { Intent intent = null; if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } if (BuildCompat.isAtLeastO()) { final long contactId = ContentUris.parseId(contactUri); final ShortcutManager sm = (ShortcutManager) Loading @@ -283,12 +286,11 @@ public class ShortcutIntentBuilder { final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getQuickContactShortcutInfo( contactId, lookupKey, displayName); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); if (TextUtils.isEmpty(displayName)) { displayName = mContext.getResources().getString(R.string.missing_name); } final Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey); final Intent shortcutIntent = ImplicitIntentsUtil.getIntentForQuickContactLauncherShortcut( mContext, contactUri); Loading Loading @@ -346,8 +348,10 @@ public class ShortcutIntentBuilder { final DynamicShortcuts dynamicShortcuts = new DynamicShortcuts(mContext); final ShortcutInfo shortcutInfo = dynamicShortcuts.getActionShortcutInfo( id, displayName, shortcutIntent, compatAdaptiveIcon.toIcon()); if (shortcutInfo != null) { intent = sm.createShortcutResultIntent(shortcutInfo); } } intent = intent == null ? new Intent() : intent; // This will be non-null in O and above. Loading
src/com/android/contacts/quickcontact/QuickContactActivity.java +23 −17 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.content.IntentFilter; import android.content.Loader; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.res.Resources; import android.graphics.Bitmap; Loading Loading @@ -2697,21 +2698,26 @@ public class QuickContactActivity extends ContactsActivity { * Creates a launcher shortcut with the current contact. */ private void createLauncherShortcutWithContact() { final ShortcutIntentBuilder builder = new ShortcutIntentBuilder(this, new OnShortcutIntentCreatedListener() { @Override public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) { if (BuildCompat.isAtLeastO()) { final ShortcutManager shortcutManager = (ShortcutManager) getSystemService(SHORTCUT_SERVICE); final DynamicShortcuts shortcuts = new DynamicShortcuts(QuickContactActivity.this); shortcutManager.requestPinShortcut( shortcuts.getQuickContactShortcutInfo( mContactData.getId(), mContactData.getLookupKey(), mContactData.getDisplayName()), null); String displayName = mContactData.getDisplayName(); if (displayName == null) { displayName = getString(R.string.missing_name); } final ShortcutInfo shortcutInfo = shortcuts.getQuickContactShortcutInfo( mContactData.getId(), mContactData.getLookupKey(), displayName); if (shortcutInfo != null) { shortcutManager.requestPinShortcut(shortcutInfo, null); } } else { final ShortcutIntentBuilder builder = new ShortcutIntentBuilder(this, new OnShortcutIntentCreatedListener() { @Override public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) { // Broadcast the shortcutIntent to the launcher to create a // shortcut to this contact shortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); Loading @@ -2727,10 +2733,10 @@ public class QuickContactActivity extends ContactsActivity { Toast.makeText(QuickContactActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); } } }); builder.createContactShortcutIntent(mContactData.getLookupUri()); } } private boolean isShortcutCreatable() { if (mContactData == null || mContactData.isUserProfile() || Loading