Loading core/java/android/provider/ContactsContract.java +54 −32 Original line number Diff line number Diff line Loading @@ -7658,6 +7658,54 @@ public final class ContactsContract { */ public static final int MODE_LARGE = 3; /** * Constructs the QuickContacts intent with a view's rect. * @hide */ public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes) { // Find location and bounds of target view, adjusting based on the // assumed local density. final float appScale = context.getResources().getCompatibilityInfo().applicationScale; final int[] pos = new int[2]; target.getLocationOnScreen(pos); final Rect rect = new Rect(); rect.left = (int) (pos[0] * appScale + 0.5f); rect.top = (int) (pos[1] * appScale + 0.5f); rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); } /** * Constructs the QuickContacts intent. * @hide */ public static Intent composeQuickContactsIntent(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes) { // When launching from an Activiy, we don't want to start a new task, but otherwise // we *must* start a new task. (Otherwise startActivity() would crash.) Context actualContext = context; while ((actualContext instanceof ContextWrapper) && !(actualContext instanceof Activity)) { actualContext = ((ContextWrapper) actualContext).getBaseContext(); } final int intentFlags = (actualContext instanceof Activity) ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; // Launch pivot dialog through intent for now final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); intent.setData(lookupUri); intent.setSourceBounds(target); intent.putExtra(EXTRA_MODE, mode); intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); return intent; } /** * Trigger a dialog that lists the various methods of interacting with * the requested {@link Contacts} entry. This may be based on available Loading @@ -7683,20 +7731,10 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes) { // Find location and bounds of target view, adjusting based on the // assumed local density. final float appScale = context.getResources().getCompatibilityInfo().applicationScale; final int[] pos = new int[2]; target.getLocationOnScreen(pos); final Rect rect = new Rect(); rect.left = (int) (pos[0] * appScale + 0.5f); rect.top = (int) (pos[1] * appScale + 0.5f); rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); // Trigger with obtained rectangle showQuickContact(context, rect, lookupUri, mode, excludeMimes); Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, excludeMimes); context.startActivity(intent); } /** Loading Loading @@ -7727,25 +7765,9 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes) { // When launching from an Activiy, we don't want to start a new task, but otherwise // we *must* start a new task. (Otherwise startActivity() would crash.) Context actualContext = context; while ((actualContext instanceof ContextWrapper) && !(actualContext instanceof Activity)) { actualContext = ((ContextWrapper) actualContext).getBaseContext(); } final int intentFlags = (actualContext instanceof Activity) ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; // Launch pivot dialog through intent for now final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); intent.setData(lookupUri); intent.setSourceBounds(target); intent.putExtra(EXTRA_MODE, mode); intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); context.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, excludeMimes); context.startActivity(intent); } } Loading Loading
core/java/android/provider/ContactsContract.java +54 −32 Original line number Diff line number Diff line Loading @@ -7658,6 +7658,54 @@ public final class ContactsContract { */ public static final int MODE_LARGE = 3; /** * Constructs the QuickContacts intent with a view's rect. * @hide */ public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes) { // Find location and bounds of target view, adjusting based on the // assumed local density. final float appScale = context.getResources().getCompatibilityInfo().applicationScale; final int[] pos = new int[2]; target.getLocationOnScreen(pos); final Rect rect = new Rect(); rect.left = (int) (pos[0] * appScale + 0.5f); rect.top = (int) (pos[1] * appScale + 0.5f); rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes); } /** * Constructs the QuickContacts intent. * @hide */ public static Intent composeQuickContactsIntent(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes) { // When launching from an Activiy, we don't want to start a new task, but otherwise // we *must* start a new task. (Otherwise startActivity() would crash.) Context actualContext = context; while ((actualContext instanceof ContextWrapper) && !(actualContext instanceof Activity)) { actualContext = ((ContextWrapper) actualContext).getBaseContext(); } final int intentFlags = (actualContext instanceof Activity) ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; // Launch pivot dialog through intent for now final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); intent.setData(lookupUri); intent.setSourceBounds(target); intent.putExtra(EXTRA_MODE, mode); intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); return intent; } /** * Trigger a dialog that lists the various methods of interacting with * the requested {@link Contacts} entry. This may be based on available Loading @@ -7683,20 +7731,10 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, View target, Uri lookupUri, int mode, String[] excludeMimes) { // Find location and bounds of target view, adjusting based on the // assumed local density. final float appScale = context.getResources().getCompatibilityInfo().applicationScale; final int[] pos = new int[2]; target.getLocationOnScreen(pos); final Rect rect = new Rect(); rect.left = (int) (pos[0] * appScale + 0.5f); rect.top = (int) (pos[1] * appScale + 0.5f); rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f); rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f); // Trigger with obtained rectangle showQuickContact(context, rect, lookupUri, mode, excludeMimes); Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, excludeMimes); context.startActivity(intent); } /** Loading Loading @@ -7727,25 +7765,9 @@ public final class ContactsContract { */ public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode, String[] excludeMimes) { // When launching from an Activiy, we don't want to start a new task, but otherwise // we *must* start a new task. (Otherwise startActivity() would crash.) Context actualContext = context; while ((actualContext instanceof ContextWrapper) && !(actualContext instanceof Activity)) { actualContext = ((ContextWrapper) actualContext).getBaseContext(); } final int intentFlags = (actualContext instanceof Activity) ? Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK; // Launch pivot dialog through intent for now final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags); intent.setData(lookupUri); intent.setSourceBounds(target); intent.putExtra(EXTRA_MODE, mode); intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes); context.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode, excludeMimes); context.startActivity(intent); } } Loading