Change People Tile config activity layout
Change-Id: I7df41980e1d9fe6b14a91be9ff68fad0c1c7185f Test: manual Bug: 183721209
This commit is contained in:
@@ -583,7 +583,7 @@
|
||||
android:label="@string/people_tile_title"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.Material.NoActionBar">
|
||||
android:theme="@style/Theme.PeopleTileConfigActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE"/>
|
||||
</intent-filter>
|
||||
|
||||
@@ -14,6 +14,5 @@
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="?android:attr/colorAccent" />
|
||||
<corners android:radius="@dimen/people_space_widget_radius" />
|
||||
<solid android:color="?android:attr/colorBackgroundFloating" />
|
||||
</shape>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?android:attr/colorBackgroundFloating" />
|
||||
<corners android:radius="40dp" />
|
||||
</shape>
|
||||
@@ -13,42 +13,101 @@
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/scroll"
|
||||
android:id="@+id/top_level"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
<TextView
|
||||
android:id="@+id/select_conversation_title"
|
||||
android:text="@string/select_conversation_title"
|
||||
android:gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/people_space_layout"
|
||||
<TextView
|
||||
android:id="@+id/select_conversation"
|
||||
android:text="@string/select_conversation_text"
|
||||
android:gravity="center"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
android:padding="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_conversation_title"
|
||||
android:gravity="center"
|
||||
android:text="@string/select_conversation_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textSize="24sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_conversation"
|
||||
android:gravity="center"
|
||||
android:text="@string/select_conversation_text"
|
||||
<LinearLayout
|
||||
android:id="@+id/scroll_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textSize="16sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="24dp" />
|
||||
android:layout_marginTop="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
<LinearLayout
|
||||
android:id="@+id/priority"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="35dp">
|
||||
<TextView
|
||||
android:id="@+id/priority_header"
|
||||
android:text="@string/priority_conversations"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/colorAccent"
|
||||
android:textSize="14sp"
|
||||
android:paddingStart="16dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/priority_tiles"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/rounded_bg_full_large_radius"
|
||||
android:clipToOutline="true">
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/recent"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/recent_header"
|
||||
android:gravity="start"
|
||||
android:text="@string/recent_conversations"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/colorAccent"
|
||||
android:textSize="14sp"
|
||||
android:paddingStart="16dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/recent_tiles"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/rounded_bg_full_large_radius"
|
||||
android:clipToOutline="true">
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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.
|
||||
-->
|
||||
<View
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="?android:attr/colorBackground" />
|
||||
@@ -0,0 +1,78 @@
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/top_level"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="24dp"
|
||||
android:clipToOutline="true">
|
||||
<TextView
|
||||
android:id="@+id/select_conversation_title"
|
||||
android:gravity="center"
|
||||
android:text="@string/select_conversation_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="24sp"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_conversation"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_conversations_text"
|
||||
android:layout_width="match_parent"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="16sp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:padding="24dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:layout_below="@id/select_conversation_title"/>
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/okay_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/rounded_bg_full_large_radius"
|
||||
android:onClick="dismissActivity"
|
||||
android:text="@string/okay"
|
||||
android:layout_marginBottom="60dp"
|
||||
android:layout_alignParentBottom="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/okay_button"
|
||||
android:layout_below="@id/select_conversation"
|
||||
android:layout_centerInParent="true"
|
||||
android:clipToOutline="true">
|
||||
<LinearLayout
|
||||
android:id="@+id/widget_initial_layout"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/rounded_bg_full_large_radius"
|
||||
android:layout_above="@id/okay_button">
|
||||
<include layout="@layout/people_space_placeholder_layout" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
@@ -24,7 +24,6 @@
|
||||
android:background="@drawable/people_space_activity_card"
|
||||
android:padding="12dp"
|
||||
android:elevation="4dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@@ -43,12 +42,14 @@
|
||||
android:id="@+id/tile_view_package_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_marginStart="-8dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:layout_height="16dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tile_view_name"
|
||||
@@ -56,16 +57,8 @@
|
||||
android:paddingHorizontal="16dp"
|
||||
android:textSize="22sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tile_view_status"
|
||||
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.ListItem"
|
||||
android:paddingVertical="4dp"
|
||||
android:textSize="12sp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end" />
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -2848,6 +2848,14 @@
|
||||
<string name="select_conversation_title">Conversation widgets</string>
|
||||
<!--Text explaining to tap a conversation to select it show in their Conversation widget [CHAR LIMIT=180] -->
|
||||
<string name="select_conversation_text">Tap a conversation to add it to your Home screen</string>
|
||||
<!--Text explaining there are no existing conversations to show in their Conversation widget [CHAR LIMIT=100] -->
|
||||
<string name="no_conversations_text">Check back here once you get some messages</string>
|
||||
<!--Text header for priority conversation tiles available to be added to the home screen [CHAR LIMIT=100] -->
|
||||
<string name="priority_conversations">Priority conversations</string>
|
||||
<!--Text header for recent conversation tiles available to be added to the home screen [CHAR LIMIT=100] -->
|
||||
<string name="recent_conversations">Recent conversations</string>
|
||||
<!-- Text for button dismissing configuration activity with no conversations [CHAR LIMIT=20] -->
|
||||
<string name="okay">Okay</string>
|
||||
<!-- Timestamp for notification with exact time [CHAR LIMIT=25] -->
|
||||
<string name="timestamp"><xliff:g id="duration" example="5 hours">%1$s</xliff:g> ago</string>
|
||||
<!-- Timestamp for notification when less than a certain time window [CHAR LIMIT=25] -->
|
||||
|
||||
@@ -669,6 +669,11 @@
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.PeopleTileConfigActivity" parent="@style/Theme.SystemUI">
|
||||
<item name="android:windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Control">
|
||||
<item name="android:fontFamily">@*android:string/config_bodyFontFamily</item>
|
||||
</style>
|
||||
|
||||
@@ -27,28 +27,33 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.ServiceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.people.widget.PeopleSpaceWidgetManager;
|
||||
import com.android.systemui.statusbar.notification.NotificationEntryManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Shows the user their tiles for their priority People (go/live-status).
|
||||
*/
|
||||
/** People Tile Widget configuration activity that shows the user their conversation tiles. */
|
||||
public class PeopleSpaceActivity extends Activity {
|
||||
|
||||
private static final String TAG = "PeopleSpaceActivity";
|
||||
private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
|
||||
|
||||
private ViewGroup mPeopleSpaceLayout;
|
||||
private IPeopleManager mPeopleManager;
|
||||
private PeopleSpaceWidgetManager mPeopleSpaceWidgetManager;
|
||||
private INotificationManager mNotificationManager;
|
||||
@@ -70,8 +75,6 @@ public class PeopleSpaceActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.people_space_activity);
|
||||
mPeopleSpaceLayout = findViewById(R.id.people_space_layout);
|
||||
mContext = getApplicationContext();
|
||||
mNotificationManager = INotificationManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
|
||||
@@ -79,38 +82,74 @@ public class PeopleSpaceActivity extends Activity {
|
||||
mPeopleManager = IPeopleManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.PEOPLE_SERVICE));
|
||||
mLauncherApps = mContext.getSystemService(LauncherApps.class);
|
||||
setTileViewsWithPriorityConversations();
|
||||
mAppWidgetId = getIntent().getIntExtra(EXTRA_APPWIDGET_ID,
|
||||
INVALID_APPWIDGET_ID);
|
||||
setResult(RESULT_CANCELED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all priority conversations and sets a {@link PeopleSpaceTileView}s for each
|
||||
* priority conversation.
|
||||
*/
|
||||
private void setTileViewsWithPriorityConversations() {
|
||||
/** Builds the conversation selection activity. */
|
||||
private void buildActivity() {
|
||||
List<PeopleSpaceTile> priorityTiles = new ArrayList<>();
|
||||
List<PeopleSpaceTile> recentTiles = new ArrayList<>();
|
||||
try {
|
||||
List<PeopleSpaceTile> tiles = PeopleSpaceUtils.getTiles(mContext, mNotificationManager,
|
||||
priorityTiles = PeopleSpaceUtils.getPriorityTiles(mContext, mNotificationManager,
|
||||
mPeopleManager, mLauncherApps, mNotificationEntryManager);
|
||||
recentTiles = PeopleSpaceUtils.getRecentTiles(mContext, mNotificationManager,
|
||||
mPeopleManager, mLauncherApps, mNotificationEntryManager);
|
||||
for (PeopleSpaceTile tile : tiles) {
|
||||
PeopleSpaceTileView tileView = new PeopleSpaceTileView(mContext, mPeopleSpaceLayout,
|
||||
tile.getId());
|
||||
setTileView(tileView, tile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Couldn't retrieve conversations", e);
|
||||
}
|
||||
|
||||
// If no conversations, render activity without conversations
|
||||
if (recentTiles.isEmpty() && priorityTiles.isEmpty()) {
|
||||
setContentView(R.layout.people_space_activity_no_conversations);
|
||||
|
||||
// The Tile preview has colorBackground as its background. Change it so it's different
|
||||
// than the activity's background.
|
||||
LinearLayout item = findViewById(R.id.item);
|
||||
GradientDrawable shape = (GradientDrawable) item.getBackground();
|
||||
final TypedArray ta = mContext.obtainStyledAttributes(
|
||||
new int[] {android.R.attr.colorBackgroundFloating});
|
||||
shape.setColor(ta.getColor(0, Color.WHITE));
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.people_space_activity);
|
||||
setTileViews(R.id.priority, R.id.priority_tiles, priorityTiles);
|
||||
setTileViews(R.id.recent, R.id.recent_tiles, recentTiles);
|
||||
}
|
||||
|
||||
private ViewOutlineProvider mViewOutlineProvider = new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(),
|
||||
mContext.getResources().getDimension(R.dimen.people_space_widget_radius));
|
||||
}
|
||||
};
|
||||
|
||||
/** Sets a {@link PeopleSpaceTileView}s for each conversation. */
|
||||
private void setTileViews(int viewId, int tilesId, List<PeopleSpaceTile> tiles) {
|
||||
if (tiles.isEmpty()) {
|
||||
LinearLayout view = findViewById(viewId);
|
||||
view.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
ViewGroup layout = findViewById(tilesId);
|
||||
layout.setClipToOutline(true);
|
||||
layout.setOutlineProvider(mViewOutlineProvider);
|
||||
for (int i = 0; i < tiles.size(); ++i) {
|
||||
PeopleSpaceTile tile = tiles.get(i);
|
||||
PeopleSpaceTileView tileView = new PeopleSpaceTileView(mContext,
|
||||
layout, tile.getId(), i == (tiles.size() - 1));
|
||||
setTileView(tileView, tile);
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets {@code tileView} with the data in {@code conversation}. */
|
||||
private void setTileView(PeopleSpaceTileView tileView, PeopleSpaceTile tile) {
|
||||
try {
|
||||
String pkg = tile.getPackageName();
|
||||
String status =
|
||||
PeopleSpaceUtils.getLastInteractionString(mContext,
|
||||
tile.getLastInteractionTimestamp());
|
||||
tileView.setStatus(status);
|
||||
|
||||
tileView.setName(tile.getUserName().toString());
|
||||
tileView.setPackageIcon(mPackageManager.getApplicationIcon(pkg));
|
||||
@@ -141,6 +180,12 @@ public class PeopleSpaceActivity extends Activity {
|
||||
finish();
|
||||
}
|
||||
|
||||
/** Finish activity without choosing a widget. */
|
||||
public void dismissActivity(View v) {
|
||||
if (DEBUG) Log.d(TAG, "Activity dismissed with no widgets added!");
|
||||
finish();
|
||||
}
|
||||
|
||||
private void setActivityResult(int result) {
|
||||
Intent resultValue = new Intent();
|
||||
resultValue.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId);
|
||||
@@ -151,6 +196,12 @@ public class PeopleSpaceActivity extends Activity {
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
// Refresh tile views to sync new conversations.
|
||||
setTileViewsWithPriorityConversations();
|
||||
buildActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,10 @@ public class PeopleSpaceTileView extends LinearLayout {
|
||||
|
||||
private View mTileView;
|
||||
private TextView mNameView;
|
||||
private TextView mStatusView;
|
||||
private ImageView mPackageIconView;
|
||||
private ImageView mPersonIconView;
|
||||
|
||||
public PeopleSpaceTileView(Context context, ViewGroup view, String shortcutId) {
|
||||
public PeopleSpaceTileView(Context context, ViewGroup view, String shortcutId, boolean isLast) {
|
||||
super(context);
|
||||
mTileView = view.findViewWithTag(shortcutId);
|
||||
if (mTileView == null) {
|
||||
@@ -50,9 +49,13 @@ public class PeopleSpaceTileView extends LinearLayout {
|
||||
view.addView(mTileView, LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.MATCH_PARENT);
|
||||
mTileView.setTag(shortcutId);
|
||||
|
||||
// If it's not the last conversation in this section, add a divider.
|
||||
if (!isLast) {
|
||||
inflater.inflate(R.layout.people_space_activity_list_divider, view, true);
|
||||
}
|
||||
}
|
||||
mNameView = mTileView.findViewById(R.id.tile_view_name);
|
||||
mStatusView = mTileView.findViewById(R.id.tile_view_status);
|
||||
mPackageIconView = mTileView.findViewById(R.id.tile_view_package_icon);
|
||||
mPersonIconView = mTileView.findViewById(R.id.tile_view_person_icon);
|
||||
}
|
||||
@@ -62,11 +65,6 @@ public class PeopleSpaceTileView extends LinearLayout {
|
||||
mNameView.setText(name);
|
||||
}
|
||||
|
||||
/** Sets the status text on the tile. */
|
||||
public void setStatus(String status) {
|
||||
mStatusView.setText(status);
|
||||
}
|
||||
|
||||
/** Sets the package drawable on the tile. */
|
||||
public void setPackageIcon(Drawable drawable) {
|
||||
mPackageIconView.setImageDrawable(drawable);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.people;
|
||||
import static android.app.Notification.CATEGORY_MISSED_CALL;
|
||||
import static android.app.Notification.EXTRA_MESSAGES;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.INotificationManager;
|
||||
import android.app.Notification;
|
||||
import android.app.people.ConversationChannel;
|
||||
@@ -126,8 +127,9 @@ public class PeopleSpaceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a list of map entries corresponding to user's conversations. */
|
||||
public static List<PeopleSpaceTile> getTiles(
|
||||
/** Returns a list of map entries corresponding to user's priority conversations. */
|
||||
@NonNull
|
||||
public static List<PeopleSpaceTile> getPriorityTiles(
|
||||
Context context, INotificationManager notificationManager, IPeopleManager peopleManager,
|
||||
LauncherApps launcherApps, NotificationEntryManager notificationEntryManager)
|
||||
throws Exception {
|
||||
@@ -139,11 +141,23 @@ public class PeopleSpaceUtils {
|
||||
.filter(c -> c.getNotificationChannel() != null
|
||||
&& c.getNotificationChannel().isImportantConversation())
|
||||
.map(c -> c.getShortcutInfo());
|
||||
List<PeopleSpaceTile> tiles = getSortedTiles(peopleManager, launcherApps,
|
||||
List<PeopleSpaceTile> priorityTiles = getSortedTiles(peopleManager, launcherApps,
|
||||
priorityConversations);
|
||||
priorityTiles = augmentTilesFromVisibleNotifications(
|
||||
context, priorityTiles, notificationEntryManager);
|
||||
return priorityTiles;
|
||||
}
|
||||
|
||||
// Sort and then add recent and non priority conversations to tiles list.
|
||||
/** Returns a list of map entries corresponding to user's recent conversations. */
|
||||
@NonNull
|
||||
public static List<PeopleSpaceTile> getRecentTiles(
|
||||
Context context, INotificationManager notificationManager, IPeopleManager peopleManager,
|
||||
LauncherApps launcherApps, NotificationEntryManager notificationEntryManager)
|
||||
throws Exception {
|
||||
if (DEBUG) Log.d(TAG, "Add recent conversations");
|
||||
List<ConversationChannelWrapper> conversations =
|
||||
notificationManager.getConversations(
|
||||
false).getList();
|
||||
Stream<ShortcutInfo> nonPriorityConversations = conversations.stream()
|
||||
.filter(c -> c.getNotificationChannel() == null
|
||||
|| !c.getNotificationChannel().isImportantConversation())
|
||||
@@ -159,10 +173,10 @@ public class PeopleSpaceUtils {
|
||||
recentConversations);
|
||||
List<PeopleSpaceTile> recentTiles =
|
||||
getSortedTiles(peopleManager, launcherApps, mergedStream);
|
||||
tiles.addAll(recentTiles);
|
||||
|
||||
tiles = augmentTilesFromVisibleNotifications(context, tiles, notificationEntryManager);
|
||||
return tiles;
|
||||
recentTiles = augmentTilesFromVisibleNotifications(
|
||||
context, recentTiles, notificationEntryManager);
|
||||
return recentTiles;
|
||||
}
|
||||
|
||||
/** Returns stored widgets for the conversation specified. */
|
||||
|
||||
@@ -239,37 +239,38 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTilesReturnsSortedListWithMultipleRecentConversations() throws Exception {
|
||||
public void testGetRecentTilesReturnsSortedListWithOnlyRecentConversations() throws Exception {
|
||||
// Ensure the less-recent Important conversation is before more recent conversations.
|
||||
ConversationChannelWrapper newerNonImportantConversation = getConversationChannelWrapper(
|
||||
SHORTCUT_ID_1, false, 3);
|
||||
ConversationChannelWrapper newerImportantConversation = getConversationChannelWrapper(
|
||||
SHORTCUT_ID_1 + 1, true, 3);
|
||||
ConversationChannelWrapper olderImportantConversation = getConversationChannelWrapper(
|
||||
SHORTCUT_ID_1 + 1,
|
||||
SHORTCUT_ID_1 + 2,
|
||||
true, 1);
|
||||
when(mNotificationManager.getConversations(anyBoolean())).thenReturn(
|
||||
new ParceledListSlice(Arrays.asList(
|
||||
newerNonImportantConversation, olderImportantConversation)));
|
||||
newerNonImportantConversation, newerImportantConversation,
|
||||
olderImportantConversation)));
|
||||
|
||||
// Ensure the non-Important conversation is sorted between these recent conversations.
|
||||
ConversationChannel recentConversationBeforeNonImportantConversation =
|
||||
getConversationChannel(
|
||||
SHORTCUT_ID_1 + 2, 4);
|
||||
SHORTCUT_ID_1 + 3, 4);
|
||||
ConversationChannel recentConversationAfterNonImportantConversation =
|
||||
getConversationChannel(SHORTCUT_ID_1 + 3,
|
||||
getConversationChannel(SHORTCUT_ID_1 + 4,
|
||||
2);
|
||||
when(mPeopleManager.getRecentConversations()).thenReturn(
|
||||
new ParceledListSlice(Arrays.asList(recentConversationAfterNonImportantConversation,
|
||||
recentConversationBeforeNonImportantConversation)));
|
||||
|
||||
List<String> orderedShortcutIds = PeopleSpaceUtils.getTiles(
|
||||
List<String> orderedShortcutIds = PeopleSpaceUtils.getRecentTiles(
|
||||
mContext, mNotificationManager, mPeopleManager,
|
||||
mLauncherApps, mNotificationEntryManager)
|
||||
.stream().map(tile -> tile.getId()).collect(Collectors.toList());
|
||||
|
||||
// Check for sorted recent conversations.
|
||||
assertThat(orderedShortcutIds).containsExactly(
|
||||
// Even though the oldest conversation, should be first since "important"
|
||||
olderImportantConversation.getShortcutInfo().getId(),
|
||||
// Non-priority conversations should be sorted within recent conversations.
|
||||
recentConversationBeforeNonImportantConversation.getShortcutInfo().getId(),
|
||||
newerNonImportantConversation.getShortcutInfo().getId(),
|
||||
recentConversationAfterNonImportantConversation.getShortcutInfo().getId())
|
||||
@@ -277,7 +278,7 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetTilesReturnsSortedListWithMultipleImportantAndRecentConversations()
|
||||
public void testGetPriorityTilesReturnsSortedListWithOnlyImportantConversations()
|
||||
throws Exception {
|
||||
// Ensure the less-recent Important conversation is before more recent conversations.
|
||||
ConversationChannelWrapper newerNonImportantConversation = getConversationChannelWrapper(
|
||||
@@ -303,19 +304,15 @@ public class PeopleSpaceUtilsTest extends SysuiTestCase {
|
||||
new ParceledListSlice(Arrays.asList(recentConversationAfterNonImportantConversation,
|
||||
recentConversationBeforeNonImportantConversation)));
|
||||
|
||||
List<String> orderedShortcutIds = PeopleSpaceUtils.getTiles(
|
||||
List<String> orderedShortcutIds = PeopleSpaceUtils.getPriorityTiles(
|
||||
mContext, mNotificationManager, mPeopleManager,
|
||||
mLauncherApps, mNotificationEntryManager)
|
||||
.stream().map(tile -> tile.getId()).collect(Collectors.toList());
|
||||
|
||||
// Check for sorted priority conversations.
|
||||
assertThat(orderedShortcutIds).containsExactly(
|
||||
// Important conversations should be sorted at the beginning.
|
||||
newerImportantConversation.getShortcutInfo().getId(),
|
||||
olderImportantConversation.getShortcutInfo().getId(),
|
||||
// Non-priority conversations should be sorted within recent conversations.
|
||||
recentConversationBeforeNonImportantConversation.getShortcutInfo().getId(),
|
||||
newerNonImportantConversation.getShortcutInfo().getId(),
|
||||
recentConversationAfterNonImportantConversation.getShortcutInfo().getId())
|
||||
olderImportantConversation.getShortcutInfo().getId())
|
||||
.inOrder();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user