Merge "Handle width and height options in Tile previews" into sc-dev

This commit is contained in:
Flavio Fiszman
2021-04-19 13:16:01 +00:00
committed by Android (Google) Code Review
7 changed files with 15 additions and 15 deletions

View File

@@ -93,7 +93,7 @@ public class PeopleProvider extends ContentProvider {
: Dependency.get(NotificationEntryManager.class);
RemoteViews view = PeopleSpaceUtils.getPreview(getContext(), mPeopleManager, mLauncherApps,
mNotificationEntryManager, shortcutId, userHandle, packageName);
mNotificationEntryManager, shortcutId, userHandle, packageName, extras);
if (view == null) {
if (DEBUG) Log.d(TAG, "No preview available for shortcutId: " + shortcutId);
return null;

View File

@@ -529,7 +529,7 @@ public class PeopleSpaceUtils {
*/
public static RemoteViews getPreview(Context context, IPeopleManager peopleManager,
LauncherApps launcherApps, NotificationEntryManager notificationEntryManager,
String shortcutId, UserHandle userHandle, String packageName) {
String shortcutId, UserHandle userHandle, String packageName, Bundle options) {
peopleManager = (peopleManager != null) ? peopleManager : IPeopleManager.Stub.asInterface(
ServiceManager.getService(Context.PEOPLE_SERVICE));
launcherApps = (launcherApps != null) ? launcherApps
@@ -556,8 +556,7 @@ public class PeopleSpaceUtils {
context, tile, notificationEntryManager);
if (DEBUG) Log.i(TAG, "Returning tile preview for shortcutId: " + shortcutId);
Bundle bundle = new Bundle();
return new PeopleTileViewHelper(context, augmentedTile, 0, bundle).getViews();
return new PeopleTileViewHelper(context, augmentedTile, 0, options).getViews();
}
/** Returns the userId associated with a {@link PeopleSpaceTile} */

View File

@@ -777,12 +777,12 @@ public class PeopleSpaceWidgetManager {
* Builds a request to pin a People Tile app widget, with a preview and storing necessary
* information as the callback.
*/
public boolean requestPinAppWidget(ShortcutInfo shortcutInfo) {
public boolean requestPinAppWidget(ShortcutInfo shortcutInfo, Bundle options) {
if (DEBUG) Log.d(TAG, "Requesting pin widget, shortcutId: " + shortcutInfo.getId());
RemoteViews widgetPreview = PeopleSpaceUtils.getPreview(mContext, mIPeopleManager,
mLauncherApps, mNotificationEntryManager, shortcutInfo.getId(),
shortcutInfo.getUserHandle(), shortcutInfo.getPackage());
shortcutInfo.getUserHandle(), shortcutInfo.getPackage(), options);
if (widgetPreview == null) {
Log.w(TAG, "Skipping pinning widget: no tile for shortcutId: " + shortcutInfo.getId());
return false;

View File

@@ -44,6 +44,7 @@ import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.UserHandle;
@@ -181,7 +182,7 @@ public class NotificationConversationInfo extends LinearLayout implements
showPriorityOnboarding();
} else if (mSelectedAction == ACTION_FAVORITE && getPriority() != mSelectedAction) {
mShadeController.animateCollapsePanels();
mPeopleSpaceWidgetManager.requestPinAppWidget(mShortcutInfo);
mPeopleSpaceWidgetManager.requestPinAppWidget(mShortcutInfo, new Bundle());
}
mGutsContainer.closeControls(v, true);
};

View File

@@ -28,6 +28,7 @@ import android.graphics.PixelFormat
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.text.style.BulletSpan
import android.view.Gravity
@@ -86,7 +87,7 @@ class PriorityOnboardingDialogController @Inject constructor(
Prefs.putBoolean(context, Prefs.Key.HAS_SEEN_PRIORITY_ONBOARDING_IN_S, true)
dialog.dismiss()
shadeController.animateCollapsePanels()
peopleSpaceWidgetManager.requestPinAppWidget(shortcutInfo)
peopleSpaceWidgetManager.requestPinAppWidget(shortcutInfo, Bundle())
}
private fun settings() {

View File

@@ -1143,7 +1143,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
when(mAppWidgetManager.requestPinAppWidget(any(), any(), any())).thenReturn(true);
ShortcutInfo info = new ShortcutInfo.Builder(mMockContext, SHORTCUT_ID).build();
boolean valid = mManager.requestPinAppWidget(info);
boolean valid = mManager.requestPinAppWidget(info, new Bundle());
assertThat(valid).isTrue();
verify(mAppWidgetManager, times(1)).requestPinAppWidget(
@@ -1157,7 +1157,7 @@ public class PeopleSpaceWidgetManagerTest extends SysuiTestCase {
when(mIPeopleManager.getConversation(PACKAGE_NAME, 0, SHORTCUT_ID)).thenReturn(null);
ShortcutInfo info = new ShortcutInfo.Builder(mMockContext, SHORTCUT_ID).build();
boolean valid = mManager.requestPinAppWidget(info);
boolean valid = mManager.requestPinAppWidget(info, new Bundle());
assertThat(valid).isFalse();
verify(mAppWidgetManager, never()).requestPinAppWidget(any(), any(), any());

View File

@@ -31,7 +31,6 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.anyString;
@@ -239,7 +238,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
when(mBuilder.build()).thenReturn(mock(PriorityOnboardingDialogController.class));
when(mPeopleSpaceWidgetManager.requestPinAppWidget(any())).thenReturn(true);
when(mPeopleSpaceWidgetManager.requestPinAppWidget(any(), any())).thenReturn(true);
}
@Test
@@ -1289,7 +1288,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
mNotificationInfo.findViewById(R.id.done).performClick();
// THEN the user is presented with the People Tile pinning request
verify(mPeopleSpaceWidgetManager, times(1)).requestPinAppWidget(any());
verify(mPeopleSpaceWidgetManager, times(1)).requestPinAppWidget(any(), any());
}
@Test
@@ -1325,7 +1324,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
mNotificationInfo.findViewById(R.id.done).performClick();
// THEN the user is not presented with the People Tile pinning request
verify(mPeopleSpaceWidgetManager, never()).requestPinAppWidget(mShortcutInfo);
verify(mPeopleSpaceWidgetManager, never()).requestPinAppWidget(eq(mShortcutInfo), any());
}
@Test
@@ -1364,6 +1363,6 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
mNotificationInfo.findViewById(R.id.done).performClick();
// THEN the user is not presented with the People Tile pinning request
verify(mPeopleSpaceWidgetManager, never()).requestPinAppWidget(mShortcutInfo);
verify(mPeopleSpaceWidgetManager, never()).requestPinAppWidget(eq(mShortcutInfo), any());
}
}