Merge "Create RemoteViews for all supported app widget sizes" into sc-dev
This commit is contained in:
@@ -29,6 +29,7 @@ import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT;
|
|||||||
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH;
|
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH;
|
||||||
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT;
|
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT;
|
||||||
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH;
|
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH;
|
||||||
|
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_SIZES;
|
||||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||||
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
||||||
|
|
||||||
@@ -43,7 +44,6 @@ import android.app.people.ConversationStatus;
|
|||||||
import android.app.people.PeopleSpaceTile;
|
import android.app.people.PeopleSpaceTile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrix;
|
||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
@@ -59,6 +59,7 @@ import android.text.TextUtils;
|
|||||||
import android.util.IconDrawableFactory;
|
import android.util.IconDrawableFactory;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.util.SizeF;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -85,8 +86,10 @@ import java.util.Arrays;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -173,28 +176,64 @@ public class PeopleTileViewHelper {
|
|||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
private NumberFormat mIntegerFormat;
|
private NumberFormat mIntegerFormat;
|
||||||
|
|
||||||
public PeopleTileViewHelper(Context context, @Nullable PeopleSpaceTile tile,
|
PeopleTileViewHelper(Context context, @Nullable PeopleSpaceTile tile,
|
||||||
int appWidgetId, Bundle options, PeopleTileKey key) {
|
int appWidgetId, int width, int height, PeopleTileKey key) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mTile = tile;
|
mTile = tile;
|
||||||
mKey = key;
|
mKey = key;
|
||||||
mAppWidgetId = appWidgetId;
|
mAppWidgetId = appWidgetId;
|
||||||
mDensity = mContext.getResources().getDisplayMetrics().density;
|
mDensity = mContext.getResources().getDisplayMetrics().density;
|
||||||
int display = mContext.getResources().getConfiguration().orientation;
|
mWidth = width;
|
||||||
mWidth = display == Configuration.ORIENTATION_PORTRAIT
|
mHeight = height;
|
||||||
? options.getInt(OPTION_APPWIDGET_MIN_WIDTH,
|
|
||||||
getSizeInDp(R.dimen.default_width)) : options.getInt(
|
|
||||||
OPTION_APPWIDGET_MAX_WIDTH,
|
|
||||||
getSizeInDp(R.dimen.default_width));
|
|
||||||
mHeight = display == Configuration.ORIENTATION_PORTRAIT ? options.getInt(
|
|
||||||
OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.default_height))
|
|
||||||
: options.getInt(OPTION_APPWIDGET_MIN_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.default_height));
|
|
||||||
mLayoutSize = getLayoutSize();
|
mLayoutSize = getLayoutSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteViews getViews() {
|
/**
|
||||||
|
* Creates a {@link RemoteViews} for the specified arguments. The RemoteViews will support all
|
||||||
|
* the sizes present in {@code options.}.
|
||||||
|
*/
|
||||||
|
public static RemoteViews createRemoteViews(Context context, @Nullable PeopleSpaceTile tile,
|
||||||
|
int appWidgetId, Bundle options, PeopleTileKey key) {
|
||||||
|
List<SizeF> widgetSizes = getWidgetSizes(context, options);
|
||||||
|
Map<SizeF, RemoteViews> sizeToRemoteView =
|
||||||
|
widgetSizes
|
||||||
|
.stream()
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
Function.identity(),
|
||||||
|
size -> new PeopleTileViewHelper(
|
||||||
|
context, tile, appWidgetId,
|
||||||
|
(int) size.getWidth(),
|
||||||
|
(int) size.getHeight(),
|
||||||
|
key)
|
||||||
|
.getViews()));
|
||||||
|
return new RemoteViews(sizeToRemoteView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<SizeF> getWidgetSizes(Context context, Bundle options) {
|
||||||
|
float density = context.getResources().getDisplayMetrics().density;
|
||||||
|
List<SizeF> widgetSizes = options.getParcelableArrayList(OPTION_APPWIDGET_SIZES);
|
||||||
|
// If the full list of sizes was provided in the options bundle, use that.
|
||||||
|
if (widgetSizes != null && !widgetSizes.isEmpty()) return widgetSizes;
|
||||||
|
|
||||||
|
// Otherwise, create a list using the portrait/landscape sizes.
|
||||||
|
int defaultWidth = getSizeInDp(context, R.dimen.default_width, density);
|
||||||
|
int defaultHeight = getSizeInDp(context, R.dimen.default_height, density);
|
||||||
|
widgetSizes = new ArrayList<>(2);
|
||||||
|
|
||||||
|
int portraitWidth = options.getInt(OPTION_APPWIDGET_MIN_WIDTH, defaultWidth);
|
||||||
|
int portraitHeight = options.getInt(OPTION_APPWIDGET_MAX_HEIGHT, defaultHeight);
|
||||||
|
widgetSizes.add(new SizeF(portraitWidth, portraitHeight));
|
||||||
|
|
||||||
|
int landscapeWidth = options.getInt(OPTION_APPWIDGET_MAX_WIDTH, defaultWidth);
|
||||||
|
int landscapeHeight = options.getInt(OPTION_APPWIDGET_MIN_HEIGHT, defaultHeight);
|
||||||
|
widgetSizes.add(new SizeF(landscapeWidth, landscapeHeight));
|
||||||
|
|
||||||
|
return widgetSizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
RemoteViews getViews() {
|
||||||
RemoteViews viewsForTile = getViewForTile();
|
RemoteViews viewsForTile = getViewForTile();
|
||||||
int maxAvatarSize = getMaxAvatarSize(viewsForTile);
|
int maxAvatarSize = getMaxAvatarSize(viewsForTile);
|
||||||
RemoteViews views = setCommonRemoteViewsFields(viewsForTile, maxAvatarSize);
|
RemoteViews views = setCommonRemoteViewsFields(viewsForTile, maxAvatarSize);
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ public class PeopleSpaceWidgetManager {
|
|||||||
Log.e(TAG, "Cannot update invalid widget");
|
Log.e(TAG, "Cannot update invalid widget");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RemoteViews views = new PeopleTileViewHelper(mContext, tile, appWidgetId,
|
RemoteViews views = PeopleTileViewHelper.createRemoteViews(mContext, tile, appWidgetId,
|
||||||
options, key).getViews();
|
options, key);
|
||||||
|
|
||||||
// Tell the AppWidgetManager to perform an update on the current app widget.
|
// Tell the AppWidgetManager to perform an update on the current app widget.
|
||||||
mAppWidgetManager.updateAppWidget(appWidgetId, views);
|
mAppWidgetManager.updateAppWidget(appWidgetId, views);
|
||||||
@@ -1031,8 +1031,8 @@ public class PeopleSpaceWidgetManager {
|
|||||||
Optional.empty());
|
Optional.empty());
|
||||||
|
|
||||||
if (DEBUG) Log.i(TAG, "Returning tile preview for shortcutId: " + shortcutId);
|
if (DEBUG) Log.i(TAG, "Returning tile preview for shortcutId: " + shortcutId);
|
||||||
return new PeopleTileViewHelper(mContext, augmentedTile, 0, options,
|
return PeopleTileViewHelper.createRemoteViews(mContext, augmentedTile, 0, options,
|
||||||
new PeopleTileKey(augmentedTile)).getViews();
|
new PeopleTileKey(augmentedTile));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final BroadcastReceiver mBaseBroadcastReceiver = new BroadcastReceiver() {
|
protected final BroadcastReceiver mBaseBroadcastReceiver = new BroadcastReceiver() {
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ import static android.app.people.PeopleSpaceTile.BLOCK_CONVERSATIONS;
|
|||||||
import static android.app.people.PeopleSpaceTile.SHOW_CONTACTS;
|
import static android.app.people.PeopleSpaceTile.SHOW_CONTACTS;
|
||||||
import static android.app.people.PeopleSpaceTile.SHOW_IMPORTANT_CONVERSATIONS;
|
import static android.app.people.PeopleSpaceTile.SHOW_IMPORTANT_CONVERSATIONS;
|
||||||
import static android.app.people.PeopleSpaceTile.SHOW_STARRED_CONTACTS;
|
import static android.app.people.PeopleSpaceTile.SHOW_STARRED_CONTACTS;
|
||||||
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT;
|
|
||||||
import static android.appwidget.AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH;
|
|
||||||
|
|
||||||
import static com.android.systemui.people.PeopleSpaceUtils.STARRED_CONTACT;
|
import static com.android.systemui.people.PeopleSpaceUtils.STARRED_CONTACT;
|
||||||
import static com.android.systemui.people.PeopleSpaceUtils.VALID_CONTACT;
|
import static com.android.systemui.people.PeopleSpaceUtils.VALID_CONTACT;
|
||||||
@@ -48,7 +46,6 @@ import android.content.res.Configuration;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -136,15 +133,14 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private PackageManager mPackageManager;
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
private Bundle mOptions;
|
private int mWidth;
|
||||||
|
private int mHeight;
|
||||||
private PeopleTileViewHelper mPeopleTileViewHelper;
|
private PeopleTileViewHelper mPeopleTileViewHelper;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mOptions = new Bundle();
|
|
||||||
|
|
||||||
when(mMockContext.getString(R.string.birthday_status)).thenReturn(
|
when(mMockContext.getString(R.string.birthday_status)).thenReturn(
|
||||||
mContext.getString(R.string.birthday_status));
|
mContext.getString(R.string.birthday_status));
|
||||||
when(mMockContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mMockContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
@@ -159,25 +155,24 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
TextView textView = mock(TextView.class);
|
TextView textView = mock(TextView.class);
|
||||||
when(textView.getLineHeight()).thenReturn(16);
|
when(textView.getLineHeight()).thenReturn(16);
|
||||||
when(mPackageManager.getApplicationIcon(anyString())).thenReturn(null);
|
when(mPackageManager.getApplicationIcon(anyString())).thenReturn(null);
|
||||||
mPeopleTileViewHelper = getPeopleTileViewHelper(
|
|
||||||
PERSON_TILE, mOptions);
|
mWidth = getSizeInDp(R.dimen.default_width);
|
||||||
|
mHeight = getSizeInDp(R.dimen.default_height);
|
||||||
|
mPeopleTileViewHelper = getPeopleTileViewHelper(PERSON_TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateRemoteViewsWithLastInteractionTimeUnderOneDayHidden() {
|
public void testCreateRemoteViewsWithLastInteractionTimeUnderOneDayHidden() {
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(PERSON_TILE_WITHOUT_NOTIFICATION).getViews();
|
||||||
PERSON_TILE_WITHOUT_NOTIFICATION, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
// Not showing last interaction.
|
// Not showing last interaction.
|
||||||
assertEquals(View.GONE, result.findViewById(R.id.last_interaction).getVisibility());
|
assertEquals(View.GONE, result.findViewById(R.id.last_interaction).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
RemoteViews largeView = getPeopleTileViewHelper(
|
||||||
PERSON_TILE_WITHOUT_NOTIFICATION, mOptions).getViews();
|
PERSON_TILE_WITHOUT_NOTIFICATION).getViews();
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
// Not showing last interaction.
|
// Not showing last interaction.
|
||||||
@@ -213,8 +208,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
PeopleSpaceTile tileWithLastInteraction =
|
PeopleSpaceTile tileWithLastInteraction =
|
||||||
PERSON_TILE_WITHOUT_NOTIFICATION.toBuilder().setLastInteractionTimestamp(
|
PERSON_TILE_WITHOUT_NOTIFICATION.toBuilder().setLastInteractionTimestamp(
|
||||||
123445L).build();
|
123445L).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithLastInteraction).getViews();
|
||||||
tileWithLastInteraction, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -230,10 +224,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No status.
|
// No status.
|
||||||
assertThat((View) result.findViewById(R.id.text_content)).isNull();
|
assertThat((View) result.findViewById(R.id.text_content)).isNull();
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
RemoteViews smallView = getPeopleTileViewHelper(tileWithLastInteraction).getViews();
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
|
||||||
tileWithLastInteraction, mOptions).getViews();
|
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show name over predefined icon.
|
// Show name over predefined icon.
|
||||||
@@ -245,12 +237,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
RemoteViews largeView = getPeopleTileViewHelper(
|
||||||
tileWithLastInteraction, mOptions).getViews();
|
tileWithLastInteraction).getViews();
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -275,8 +265,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
new ConversationStatus.Builder(
|
new ConversationStatus.Builder(
|
||||||
PERSON_TILE_WITHOUT_NOTIFICATION.getId(),
|
PERSON_TILE_WITHOUT_NOTIFICATION.getId(),
|
||||||
ACTIVITY_GAME).build())).build();
|
ACTIVITY_GAME).build())).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithAvailabilityAndNewStory).getViews();
|
||||||
tileWithAvailabilityAndNewStory, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -290,10 +279,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No status.
|
// No status.
|
||||||
assertThat((View) result.findViewById(R.id.text_content)).isNull();
|
assertThat((View) result.findViewById(R.id.text_content)).isNull();
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
RemoteViews smallView = getPeopleTileViewHelper(tileWithAvailabilityAndNewStory).getViews();
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
|
||||||
tileWithAvailabilityAndNewStory, mOptions).getViews();
|
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show name rather than game type.
|
// Show name rather than game type.
|
||||||
@@ -305,12 +292,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No messages count.
|
// No messages count.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithAvailabilityAndNewStory).getViews();
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
|
||||||
tileWithAvailabilityAndNewStory, mOptions).getViews();
|
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -333,8 +317,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
NEW_STORY_WITH_AVAILABILITY, new ConversationStatus.Builder(
|
NEW_STORY_WITH_AVAILABILITY, new ConversationStatus.Builder(
|
||||||
PERSON_TILE_WITHOUT_NOTIFICATION.getId(),
|
PERSON_TILE_WITHOUT_NOTIFICATION.getId(),
|
||||||
ACTIVITY_BIRTHDAY).build())).build();
|
ACTIVITY_BIRTHDAY).build())).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -351,10 +334,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(statusContent.getText(), mContext.getString(R.string.birthday_status));
|
assertEquals(statusContent.getText(), mContext.getString(R.string.birthday_status));
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
RemoteViews smallView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -367,12 +348,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No messages count.
|
// No messages count.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -397,8 +375,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
PERSON_TILE_WITHOUT_NOTIFICATION.toBuilder().setStatuses(
|
PERSON_TILE_WITHOUT_NOTIFICATION.toBuilder().setStatuses(
|
||||||
Arrays.asList(GAME_STATUS,
|
Arrays.asList(GAME_STATUS,
|
||||||
NEW_STORY_WITH_AVAILABILITY)).build();
|
NEW_STORY_WITH_AVAILABILITY)).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -416,10 +393,8 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(statusContent.getText(), GAME_DESCRIPTION);
|
assertEquals(statusContent.getText(), GAME_DESCRIPTION);
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
RemoteViews smallView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -432,12 +407,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No messages count.
|
// No messages count.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
|
||||||
tileWithStatusTemplate, mOptions).getViews();
|
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -466,7 +438,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
ACTIVITY_ANNIVERSARY).setDescription("Anniversary").setAvailability(
|
ACTIVITY_ANNIVERSARY).setDescription("Anniversary").setAvailability(
|
||||||
AVAILABILITY_AVAILABLE).setIcon(mIcon).build())).build();
|
AVAILABILITY_AVAILABLE).setIcon(mIcon).build())).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(
|
||||||
tileWithIconInStatusTemplate, mOptions).getViews();
|
tileWithIconInStatusTemplate).getViews();
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
|
assertEquals(View.GONE, result.findViewById(R.id.subtext).getVisibility());
|
||||||
@@ -482,12 +454,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(statusContent.getText(), "Anniversary");
|
assertEquals(statusContent.getText(), "Anniversary");
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(1);
|
assertThat(statusContent.getMaxLines()).isEqualTo(1);
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithIconInStatusTemplate).getViews();
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
|
||||||
tileWithIconInStatusTemplate, mOptions).getViews();
|
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
|
assertEquals(View.GONE, largeResult.findViewById(R.id.subtext).getVisibility());
|
||||||
@@ -512,8 +481,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
PeopleSpaceTile tile = PERSON_TILE.toBuilder()
|
PeopleSpaceTile tile = PERSON_TILE.toBuilder()
|
||||||
.setIsPackageSuspended(true)
|
.setIsPackageSuspended(true)
|
||||||
.build();
|
.build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tile).getViews();
|
||||||
tile, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
|
assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_suppressed_layout);
|
||||||
@@ -524,8 +492,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
PeopleSpaceTile tile = PERSON_TILE.toBuilder()
|
PeopleSpaceTile tile = PERSON_TILE.toBuilder()
|
||||||
.setIsUserQuieted(true)
|
.setIsUserQuieted(true)
|
||||||
.build();
|
.build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tile).getViews();
|
||||||
tile, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_work_profile_quiet_layout);
|
assertEquals(result.getSourceLayoutResId(), R.layout.people_tile_work_profile_quiet_layout);
|
||||||
@@ -536,8 +503,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
PeopleSpaceTile tileWithDndBlocking = PERSON_TILE.toBuilder()
|
PeopleSpaceTile tileWithDndBlocking = PERSON_TILE.toBuilder()
|
||||||
.setNotificationPolicyState(BLOCK_CONVERSATIONS)
|
.setNotificationPolicyState(BLOCK_CONVERSATIONS)
|
||||||
.build();
|
.build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesEqual(
|
assertResourcesEqual(
|
||||||
@@ -548,8 +514,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(BLOCK_CONVERSATIONS)
|
.setNotificationPolicyState(BLOCK_CONVERSATIONS)
|
||||||
.setCanBypassDnd(true)
|
.setCanBypassDnd(true)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesNotEqual(
|
assertResourcesNotEqual(
|
||||||
@@ -559,8 +524,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
tileWithDndBlocking = PERSON_TILE.toBuilder()
|
tileWithDndBlocking = PERSON_TILE.toBuilder()
|
||||||
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
|
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesEqual(
|
assertResourcesEqual(
|
||||||
@@ -571,8 +535,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
|
.setNotificationPolicyState(SHOW_IMPORTANT_CONVERSATIONS)
|
||||||
.setIsImportantConversation(true)
|
.setIsImportantConversation(true)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesNotEqual(
|
assertResourcesNotEqual(
|
||||||
@@ -583,8 +546,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
|
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
|
||||||
.setContactAffinity(VALID_CONTACT)
|
.setContactAffinity(VALID_CONTACT)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesEqual(
|
assertResourcesEqual(
|
||||||
@@ -595,8 +557,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
|
.setNotificationPolicyState(SHOW_STARRED_CONTACTS)
|
||||||
.setContactAffinity(STARRED_CONTACT)
|
.setContactAffinity(STARRED_CONTACT)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesNotEqual(
|
assertResourcesNotEqual(
|
||||||
@@ -607,8 +568,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(SHOW_CONTACTS)
|
.setNotificationPolicyState(SHOW_CONTACTS)
|
||||||
.setContactAffinity(STARRED_CONTACT)
|
.setContactAffinity(STARRED_CONTACT)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesNotEqual(
|
assertResourcesNotEqual(
|
||||||
@@ -619,8 +579,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationPolicyState(SHOW_CONTACTS)
|
.setNotificationPolicyState(SHOW_CONTACTS)
|
||||||
.setContactAffinity(VALID_CONTACT)
|
.setContactAffinity(VALID_CONTACT)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesNotEqual(
|
assertResourcesNotEqual(
|
||||||
@@ -630,8 +589,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
tileWithDndBlocking = PERSON_TILE.toBuilder()
|
tileWithDndBlocking = PERSON_TILE.toBuilder()
|
||||||
.setNotificationPolicyState(SHOW_CONTACTS)
|
.setNotificationPolicyState(SHOW_CONTACTS)
|
||||||
.build();
|
.build();
|
||||||
views = getPeopleTileViewHelper(
|
views = getPeopleTileViewHelper(tileWithDndBlocking).getViews();
|
||||||
tileWithDndBlocking, mOptions).getViews();
|
|
||||||
result = views.apply(mContext, null);
|
result = views.apply(mContext, null);
|
||||||
|
|
||||||
assertResourcesEqual(
|
assertResourcesEqual(
|
||||||
@@ -648,8 +606,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setNotificationCategory(CATEGORY_MISSED_CALL)
|
.setNotificationCategory(CATEGORY_MISSED_CALL)
|
||||||
.setNotificationContent(MISSED_CALL)
|
.setNotificationContent(MISSED_CALL)
|
||||||
.build();
|
.build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(tileWithMissedCallNotification).getViews();
|
||||||
tileWithMissedCallNotification, mOptions).getViews();
|
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -666,10 +623,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
assertEquals(statusContent.getText(), MISSED_CALL);
|
assertEquals(statusContent.getText(), MISSED_CALL);
|
||||||
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
assertThat(statusContent.getMaxLines()).isEqualTo(2);
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
RemoteViews smallView = getPeopleTileViewHelper(
|
||||||
tileWithMissedCallNotification, mOptions).getViews();
|
tileWithMissedCallNotification).getViews();
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -681,12 +637,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// No messages count.
|
// No messages count.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithMissedCallNotification).getViews();
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
|
||||||
tileWithMissedCallNotification, mOptions).getViews();
|
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -712,7 +665,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setStatuses(Arrays.asList(GAME_STATUS,
|
.setStatuses(Arrays.asList(GAME_STATUS,
|
||||||
NEW_STORY_WITH_AVAILABILITY)).build();
|
NEW_STORY_WITH_AVAILABILITY)).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -733,10 +686,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has a single message, no count shown.
|
// Has a single message, no count shown.
|
||||||
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
RemoteViews smallView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -750,12 +702,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has a single message, no count shown.
|
// Has a single message, no count shown.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
RemoteViews largeView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -786,7 +736,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
.setStatuses(Arrays.asList(GAME_STATUS,
|
.setStatuses(Arrays.asList(GAME_STATUS,
|
||||||
NEW_STORY_WITH_AVAILABILITY)).build();
|
NEW_STORY_WITH_AVAILABILITY)).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -810,10 +760,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has a single message, no count shown.
|
// Has a single message, no count shown.
|
||||||
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
RemoteViews smallView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -827,12 +776,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has a single message, no count shown.
|
// Has a single message, no count shown.
|
||||||
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.GONE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
RemoteViews largeView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -867,7 +814,7 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
NEW_STORY_WITH_AVAILABILITY))
|
NEW_STORY_WITH_AVAILABILITY))
|
||||||
.setMessagesCount(2).build();
|
.setMessagesCount(2).build();
|
||||||
RemoteViews views = getPeopleTileViewHelper(
|
RemoteViews views = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View result = views.apply(mContext, null);
|
View result = views.apply(mContext, null);
|
||||||
|
|
||||||
TextView name = (TextView) result.findViewById(R.id.name);
|
TextView name = (TextView) result.findViewById(R.id.name);
|
||||||
@@ -887,10 +834,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has two messages, show count.
|
// Has two messages, show count.
|
||||||
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.VISIBLE, result.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_medium) - 1;
|
||||||
getSizeInDp(R.dimen.required_width_for_medium) - 1);
|
|
||||||
RemoteViews smallView = getPeopleTileViewHelper(
|
RemoteViews smallView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View smallResult = smallView.apply(mContext, null);
|
View smallResult = smallView.apply(mContext, null);
|
||||||
|
|
||||||
// Show icon instead of name.
|
// Show icon instead of name.
|
||||||
@@ -904,12 +850,10 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
// Has two messages, show count.
|
// Has two messages, show count.
|
||||||
assertEquals(View.VISIBLE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
assertEquals(View.VISIBLE, smallResult.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MIN_WIDTH,
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
getSizeInDp(R.dimen.required_width_for_large));
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
mOptions.putInt(OPTION_APPWIDGET_MAX_HEIGHT,
|
|
||||||
getSizeInDp(R.dimen.required_height_for_large));
|
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(
|
RemoteViews largeView = getPeopleTileViewHelper(
|
||||||
tileWithStatusAndNotification, mOptions).getViews();
|
tileWithStatusAndNotification).getViews();
|
||||||
View largeResult = largeView.apply(mContext, null);
|
View largeResult = largeView.apply(mContext, null);
|
||||||
|
|
||||||
name = (TextView) largeResult.findViewById(R.id.name);
|
name = (TextView) largeResult.findViewById(R.id.name);
|
||||||
@@ -1083,8 +1027,9 @@ public class PeopleTileViewHelperTest extends SysuiTestCase {
|
|||||||
/ mContext.getResources().getDisplayMetrics().density);
|
/ mContext.getResources().getDisplayMetrics().density);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PeopleTileViewHelper getPeopleTileViewHelper(PeopleSpaceTile tile, Bundle options) {
|
private PeopleTileViewHelper getPeopleTileViewHelper(
|
||||||
return new PeopleTileViewHelper(mContext, tile, 0, options,
|
PeopleSpaceTile tile) {
|
||||||
|
return new PeopleTileViewHelper(mContext, tile, 0, mWidth, mHeight,
|
||||||
new PeopleTileKey(tile.getId(), 0, tile.getPackageName()));
|
new PeopleTileKey(tile.getId(), 0, tile.getPackageName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user