Loading src/com/android/contacts/DynamicShortcuts.java +11 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ import java.util.List; * Currently it adds shortcuts for the top 3 contacts in the {@link Contacts#CONTENT_STREQUENT_URI} * * Usage: DynamicShortcuts.initialize should be called during Application creation. This will * schedule a Job to keep the shortcuts up-to-date so no further interations should be necessary. * schedule a Job to keep the shortcuts up-to-date so no further interactions should be necessary. */ @TargetApi(Build.VERSION_CODES.N_MR1) public class DynamicShortcuts { Loading Loading @@ -289,11 +289,21 @@ public class DynamicShortcuts { return builder; } public ShortcutInfo getQuickContactShortcutInfo(long id, String lookupKey, String displayName) { final ShortcutInfo.Builder builder = builderForContactShortcut(id, lookupKey, displayName); addIconForContact(id, lookupKey, displayName, builder); return builder.build(); } private void addIconForContact(Cursor cursor, ShortcutInfo.Builder builder) { final long id = cursor.getLong(0); final String lookupKey = cursor.getString(1); final String displayName = cursor.getString(2); addIconForContact(id, lookupKey, displayName, builder); } private void addIconForContact(long id, String lookupKey, String displayName, ShortcutInfo.Builder builder) { final Bitmap bitmap = getContactPhoto(id); if (bitmap != null) { builder.setIcon(Icon.createWithBitmap(bitmap)); Loading src/com/android/contacts/quickcontact/QuickContactActivity.java +34 −15 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.ShortcutManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading Loading @@ -74,6 +75,7 @@ import android.provider.ContactsContract.RawContacts; import android.support.v4.app.ActivityCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.res.ResourcesCompat; import android.support.v4.os.BuildCompat; import android.support.v7.graphics.Palette; import android.telecom.PhoneAccount; import android.telecom.TelecomManager; Loading Loading @@ -2645,22 +2647,32 @@ public class QuickContactActivity extends ContactsActivity { @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); } else { // Broadcast the shortcutIntent to the launcher to create a // shortcut to this contact shortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); QuickContactActivity.this.sendBroadcast(shortcutIntent); // Send a toast to give feedback to the user that a shortcut to this // contact was added to the launcher. final String displayName = shortcutIntent .getStringExtra(Intent.EXTRA_SHORTCUT_NAME); final String toastMessage = TextUtils.isEmpty(displayName) ? getString(R.string.createContactShortcutSuccessful_NoName) : getString(R.string.createContactShortcutSuccessful, displayName); : getString(R.string.createContactShortcutSuccessful, displayName); Toast.makeText(QuickContactActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); } } }); builder.createContactShortcutIntent(mContactData.getLookupUri()); } Loading @@ -2670,6 +2682,13 @@ public class QuickContactActivity extends ContactsActivity { mContactData.isDirectoryEntry()) { return false; } if (BuildCompat.isAtLeastO()) { final ShortcutManager manager = (ShortcutManager) getSystemService(Context.SHORTCUT_SERVICE); return manager.isRequestPinShortcutSupported(); } final Intent createShortcutIntent = new Intent(); createShortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); final List<ResolveInfo> receivers = getPackageManager() Loading Loading
src/com/android/contacts/DynamicShortcuts.java +11 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ import java.util.List; * Currently it adds shortcuts for the top 3 contacts in the {@link Contacts#CONTENT_STREQUENT_URI} * * Usage: DynamicShortcuts.initialize should be called during Application creation. This will * schedule a Job to keep the shortcuts up-to-date so no further interations should be necessary. * schedule a Job to keep the shortcuts up-to-date so no further interactions should be necessary. */ @TargetApi(Build.VERSION_CODES.N_MR1) public class DynamicShortcuts { Loading Loading @@ -289,11 +289,21 @@ public class DynamicShortcuts { return builder; } public ShortcutInfo getQuickContactShortcutInfo(long id, String lookupKey, String displayName) { final ShortcutInfo.Builder builder = builderForContactShortcut(id, lookupKey, displayName); addIconForContact(id, lookupKey, displayName, builder); return builder.build(); } private void addIconForContact(Cursor cursor, ShortcutInfo.Builder builder) { final long id = cursor.getLong(0); final String lookupKey = cursor.getString(1); final String displayName = cursor.getString(2); addIconForContact(id, lookupKey, displayName, builder); } private void addIconForContact(long id, String lookupKey, String displayName, ShortcutInfo.Builder builder) { final Bitmap bitmap = getContactPhoto(id); if (bitmap != null) { builder.setIcon(Icon.createWithBitmap(bitmap)); Loading
src/com/android/contacts/quickcontact/QuickContactActivity.java +34 −15 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.ShortcutManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; Loading Loading @@ -74,6 +75,7 @@ import android.provider.ContactsContract.RawContacts; import android.support.v4.app.ActivityCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.res.ResourcesCompat; import android.support.v4.os.BuildCompat; import android.support.v7.graphics.Palette; import android.telecom.PhoneAccount; import android.telecom.TelecomManager; Loading Loading @@ -2645,22 +2647,32 @@ public class QuickContactActivity extends ContactsActivity { @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); } else { // Broadcast the shortcutIntent to the launcher to create a // shortcut to this contact shortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); QuickContactActivity.this.sendBroadcast(shortcutIntent); // Send a toast to give feedback to the user that a shortcut to this // contact was added to the launcher. final String displayName = shortcutIntent .getStringExtra(Intent.EXTRA_SHORTCUT_NAME); final String toastMessage = TextUtils.isEmpty(displayName) ? getString(R.string.createContactShortcutSuccessful_NoName) : getString(R.string.createContactShortcutSuccessful, displayName); : getString(R.string.createContactShortcutSuccessful, displayName); Toast.makeText(QuickContactActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); } } }); builder.createContactShortcutIntent(mContactData.getLookupUri()); } Loading @@ -2670,6 +2682,13 @@ public class QuickContactActivity extends ContactsActivity { mContactData.isDirectoryEntry()) { return false; } if (BuildCompat.isAtLeastO()) { final ShortcutManager manager = (ShortcutManager) getSystemService(Context.SHORTCUT_SERVICE); return manager.isRequestPinShortcutSupported(); } final Intent createShortcutIntent = new Intent(); createShortcutIntent.setAction(ACTION_INSTALL_SHORTCUT); final List<ResolveInfo> receivers = getPackageManager() Loading