Merge "Add landscape support" into sc-dev
This commit is contained in:
@@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ Copyright (C) 2021 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
|
android:theme="@android:style/Theme.DeviceDefault.DayNight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@android:id/background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/people_space_tile_view_card"
|
||||||
|
android:clipToOutline="true"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="6dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/person_icon"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingEnd="4dp"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/predefined_icon"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:tint="?android:attr/textColorSecondary"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:layout_width="18dp"
|
||||||
|
android:layout_height="18dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/messages_count"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||||
|
android:textColor="?androidprv:attr/textColorOnAccent"
|
||||||
|
android:background="@drawable/people_space_messages_count_background"
|
||||||
|
android:textSize="@dimen/name_text_size_for_small"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="start|center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/name_text_size_for_small" />
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
@@ -1457,6 +1457,7 @@
|
|||||||
<dimen name="people_space_messages_count_radius">12dp</dimen>
|
<dimen name="people_space_messages_count_radius">12dp</dimen>
|
||||||
<dimen name="people_space_widget_background_padding">6dp</dimen>
|
<dimen name="people_space_widget_background_padding">6dp</dimen>
|
||||||
<dimen name="required_width_for_medium">136dp</dimen>
|
<dimen name="required_width_for_medium">136dp</dimen>
|
||||||
|
<dimen name="required_height_for_medium">80dp</dimen>
|
||||||
<dimen name="required_width_for_large">120dp</dimen>
|
<dimen name="required_width_for_large">120dp</dimen>
|
||||||
<dimen name="required_height_for_large">168dp</dimen>
|
<dimen name="required_height_for_large">168dp</dimen>
|
||||||
<dimen name="default_width">146dp</dimen>
|
<dimen name="default_width">146dp</dimen>
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ import java.util.stream.Stream;
|
|||||||
/** Utils class for People Space. */
|
/** Utils class for People Space. */
|
||||||
public class PeopleSpaceUtils {
|
public class PeopleSpaceUtils {
|
||||||
/** Turns on debugging information about People Space. */
|
/** Turns on debugging information about People Space. */
|
||||||
public static final boolean DEBUG = true;
|
public static final boolean DEBUG = false;
|
||||||
|
|
||||||
public static final String PACKAGE_NAME = "package_name";
|
public static final String PACKAGE_NAME = "package_name";
|
||||||
public static final String USER_ID = "user_id";
|
public static final String USER_ID = "user_id";
|
||||||
public static final String SHORTCUT_ID = "shortcut_id";
|
public static final String SHORTCUT_ID = "shortcut_id";
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ import java.util.stream.Collectors;
|
|||||||
/** Functions that help creating the People tile layouts. */
|
/** Functions that help creating the People tile layouts. */
|
||||||
public class PeopleTileViewHelper {
|
public class PeopleTileViewHelper {
|
||||||
/** Turns on debugging information about People Space. */
|
/** Turns on debugging information about People Space. */
|
||||||
public static final boolean DEBUG = true;
|
private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
|
||||||
private static final String TAG = "PeopleTileView";
|
private static final String TAG = "PeopleTileView";
|
||||||
|
|
||||||
private static final int DAYS_IN_A_WEEK = 7;
|
private static final int DAYS_IN_A_WEEK = 7;
|
||||||
@@ -116,8 +116,10 @@ public class PeopleTileViewHelper {
|
|||||||
private static final int MIN_MEDIUM_VERTICAL_PADDING = 4;
|
private static final int MIN_MEDIUM_VERTICAL_PADDING = 4;
|
||||||
private static final int MAX_MEDIUM_PADDING = 16;
|
private static final int MAX_MEDIUM_PADDING = 16;
|
||||||
private static final int FIXED_HEIGHT_DIMENS_FOR_MEDIUM_CONTENT_BEFORE_PADDING = 8 + 4;
|
private static final int FIXED_HEIGHT_DIMENS_FOR_MEDIUM_CONTENT_BEFORE_PADDING = 8 + 4;
|
||||||
private static final int FIXED_HEIGHT_DIMENS_FOR_SMALL = 6 + 4 + 8;
|
private static final int FIXED_HEIGHT_DIMENS_FOR_SMALL_VERTICAL = 6 + 4 + 8;
|
||||||
private static final int FIXED_WIDTH_DIMENS_FOR_SMALL = 4 + 4;
|
private static final int FIXED_WIDTH_DIMENS_FOR_SMALL_VERTICAL = 4 + 4;
|
||||||
|
private static final int FIXED_HEIGHT_DIMENS_FOR_SMALL_HORIZONTAL = 6 + 4;
|
||||||
|
private static final int FIXED_WIDTH_DIMENS_FOR_SMALL_HORIZONTAL = 8 + 8;
|
||||||
|
|
||||||
private static final int MESSAGES_COUNT_OVERFLOW = 6;
|
private static final int MESSAGES_COUNT_OVERFLOW = 6;
|
||||||
|
|
||||||
@@ -404,7 +406,8 @@ public class PeopleTileViewHelper {
|
|||||||
return LAYOUT_LARGE;
|
return LAYOUT_LARGE;
|
||||||
}
|
}
|
||||||
// Small layout used below a certain minimum mWidth with any mHeight.
|
// Small layout used below a certain minimum mWidth with any mHeight.
|
||||||
if (mWidth >= getSizeInDp(R.dimen.required_width_for_medium)) {
|
if (mHeight >= getSizeInDp(R.dimen.required_height_for_medium)
|
||||||
|
&& mWidth >= getSizeInDp(R.dimen.required_width_for_medium)) {
|
||||||
int spaceAvailableForPadding =
|
int spaceAvailableForPadding =
|
||||||
mHeight - (getSizeInDp(R.dimen.avatar_size_for_medium)
|
mHeight - (getSizeInDp(R.dimen.avatar_size_for_medium)
|
||||||
+ 4 + getLineHeightFromResource(
|
+ 4 + getLineHeightFromResource(
|
||||||
@@ -437,10 +440,15 @@ public class PeopleTileViewHelper {
|
|||||||
|
|
||||||
// Calculate adaptive avatar size for remaining layouts.
|
// Calculate adaptive avatar size for remaining layouts.
|
||||||
if (layoutId == R.layout.people_tile_small) {
|
if (layoutId == R.layout.people_tile_small) {
|
||||||
int avatarHeightSpace = mHeight - (FIXED_HEIGHT_DIMENS_FOR_SMALL + Math.max(18,
|
int avatarHeightSpace = mHeight - (FIXED_HEIGHT_DIMENS_FOR_SMALL_VERTICAL + Math.max(18,
|
||||||
getLineHeightFromResource(
|
getLineHeightFromResource(
|
||||||
R.dimen.name_text_size_for_small)));
|
R.dimen.name_text_size_for_small)));
|
||||||
int avatarWidthSpace = mWidth - FIXED_WIDTH_DIMENS_FOR_SMALL;
|
int avatarWidthSpace = mWidth - FIXED_WIDTH_DIMENS_FOR_SMALL_VERTICAL;
|
||||||
|
avatarSize = Math.min(avatarHeightSpace, avatarWidthSpace);
|
||||||
|
}
|
||||||
|
if (layoutId == R.layout.people_tile_small_horizontal) {
|
||||||
|
int avatarHeightSpace = mHeight - FIXED_HEIGHT_DIMENS_FOR_SMALL_HORIZONTAL;
|
||||||
|
int avatarWidthSpace = mWidth - FIXED_WIDTH_DIMENS_FOR_SMALL_HORIZONTAL;
|
||||||
avatarSize = Math.min(avatarHeightSpace, avatarWidthSpace);
|
avatarSize = Math.min(avatarHeightSpace, avatarWidthSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1033,7 +1041,7 @@ public class PeopleTileViewHelper {
|
|||||||
return R.layout.people_tile_large_empty;
|
return R.layout.people_tile_large_empty;
|
||||||
case LAYOUT_SMALL:
|
case LAYOUT_SMALL:
|
||||||
default:
|
default:
|
||||||
return R.layout.people_tile_small;
|
return getLayoutSmallByHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1045,7 +1053,7 @@ public class PeopleTileViewHelper {
|
|||||||
return R.layout.people_tile_large_with_notification_content;
|
return R.layout.people_tile_large_with_notification_content;
|
||||||
case LAYOUT_SMALL:
|
case LAYOUT_SMALL:
|
||||||
default:
|
default:
|
||||||
return R.layout.people_tile_small;
|
return getLayoutSmallByHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1057,8 +1065,15 @@ public class PeopleTileViewHelper {
|
|||||||
return R.layout.people_tile_large_with_status_content;
|
return R.layout.people_tile_large_with_status_content;
|
||||||
case LAYOUT_SMALL:
|
case LAYOUT_SMALL:
|
||||||
default:
|
default:
|
||||||
|
return getLayoutSmallByHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getLayoutSmallByHeight() {
|
||||||
|
if (mHeight >= getSizeInDp(R.dimen.required_height_for_medium)) {
|
||||||
return R.layout.people_tile_small;
|
return R.layout.people_tile_small;
|
||||||
}
|
}
|
||||||
|
return R.layout.people_tile_small_horizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a bitmap with the user icon and package icon. */
|
/** Returns a bitmap with the user icon and package icon. */
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ public class PeopleSpaceWidgetManager {
|
|||||||
ConversationChannel channel = mIPeopleManager.getConversation(
|
ConversationChannel channel = mIPeopleManager.getConversation(
|
||||||
key.getPackageName(), key.getUserId(), key.getShortcutId());
|
key.getPackageName(), key.getUserId(), key.getShortcutId());
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
Log.d(TAG, "Could not retrieve conversation from storage");
|
if (DEBUG) Log.d(TAG, "Could not retrieve conversation from storage");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +586,7 @@ public class PeopleSpaceWidgetManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public Optional<PeopleSpaceTile> getAugmentedTileForExistingWidget(int widgetId,
|
public Optional<PeopleSpaceTile> getAugmentedTileForExistingWidget(int widgetId,
|
||||||
Map<PeopleTileKey, Set<NotificationEntry>> notifications) {
|
Map<PeopleTileKey, Set<NotificationEntry>> notifications) {
|
||||||
Log.d(TAG, "Augmenting tile for existing widget: " + widgetId);
|
if (DEBUG) Log.d(TAG, "Augmenting tile for existing widget: " + widgetId);
|
||||||
PeopleSpaceTile tile = getTileForExistingWidget(widgetId);
|
PeopleSpaceTile tile = getTileForExistingWidget(widgetId);
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
|
|||||||
@@ -236,6 +236,21 @@ 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());
|
||||||
|
|
||||||
|
mHeight = getSizeInDp(R.dimen.required_height_for_medium) - 1;
|
||||||
|
RemoteViews smallViewHorizontal = getPeopleTileViewHelper(
|
||||||
|
tileWithLastInteraction).getViews();
|
||||||
|
View smallResultHorizontal = smallViewHorizontal.apply(mContext, null);
|
||||||
|
|
||||||
|
// Show name over predefined icon.
|
||||||
|
assertEquals(View.VISIBLE, smallResultHorizontal.findViewById(R.id.name).getVisibility());
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Shows person icon.
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.person_icon).getVisibility());
|
||||||
|
// No messages count.
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
@@ -292,6 +307,22 @@ 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());
|
||||||
|
|
||||||
|
mHeight = getSizeInDp(R.dimen.required_height_for_medium) - 1;
|
||||||
|
RemoteViews smallViewHorizontal = getPeopleTileViewHelper(
|
||||||
|
tileWithAvailabilityAndNewStory).getViews();
|
||||||
|
View smallResultHorizontal = smallViewHorizontal.apply(mContext, null);
|
||||||
|
|
||||||
|
// Show name over predefined icon.
|
||||||
|
assertEquals(View.VISIBLE, smallResultHorizontal.findViewById(R.id.name).getVisibility());
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Shows person icon.
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.person_icon).getVisibility());
|
||||||
|
// No messages count.
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(tileWithAvailabilityAndNewStory).getViews();
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithAvailabilityAndNewStory).getViews();
|
||||||
@@ -348,6 +379,22 @@ 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());
|
||||||
|
|
||||||
|
mHeight = getSizeInDp(R.dimen.required_height_for_medium) - 1;
|
||||||
|
RemoteViews smallViewHorizontal = getPeopleTileViewHelper(
|
||||||
|
tileWithStatusTemplate).getViews();
|
||||||
|
View smallResultHorizontal = smallViewHorizontal.apply(mContext, null);
|
||||||
|
|
||||||
|
// Show name over predefined icon.
|
||||||
|
assertEquals(View.GONE, smallResultHorizontal.findViewById(R.id.name).getVisibility());
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Shows person icon.
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.person_icon).getVisibility());
|
||||||
|
// No messages count.
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
@@ -407,6 +454,22 @@ 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());
|
||||||
|
|
||||||
|
mHeight = getSizeInDp(R.dimen.required_height_for_medium) - 1;
|
||||||
|
RemoteViews smallViewHorizontal = getPeopleTileViewHelper(
|
||||||
|
tileWithStatusTemplate).getViews();
|
||||||
|
View smallResultHorizontal = smallViewHorizontal.apply(mContext, null);
|
||||||
|
|
||||||
|
// Show name over predefined icon.
|
||||||
|
assertEquals(View.GONE, smallResultHorizontal.findViewById(R.id.name).getVisibility());
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.predefined_icon).getVisibility());
|
||||||
|
// Shows person icon.
|
||||||
|
assertEquals(View.VISIBLE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.person_icon).getVisibility());
|
||||||
|
// No messages count.
|
||||||
|
assertEquals(View.GONE,
|
||||||
|
smallResultHorizontal.findViewById(R.id.messages_count).getVisibility());
|
||||||
|
|
||||||
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
mWidth = getSizeInDp(R.dimen.required_width_for_large);
|
||||||
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
mHeight = getSizeInDp(R.dimen.required_height_for_large);
|
||||||
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
RemoteViews largeView = getPeopleTileViewHelper(tileWithStatusTemplate).getViews();
|
||||||
|
|||||||
Reference in New Issue
Block a user