diff options
author | Kevin <kevhan@google.com> | 2019-03-18 12:59:40 -0700 |
---|---|---|
committer | Kevin <kevhan@google.com> | 2019-03-21 15:04:21 -0700 |
commit | fefe8b6d0edc9c397d54e16484650ca89385ea67 (patch) | |
tree | 240d9b07c8285ef39013c31d6ce0a5c3b5d79f5c /go | |
parent | 16675c566a15059f56d2a788590a559137636d6f (diff) | |
download | android_packages_apps_Trebuchet-fefe8b6d0edc9c397d54e16484650ca89385ea67.tar.gz android_packages_apps_Trebuchet-fefe8b6d0edc9c397d54e16484650ca89385ea67.tar.bz2 android_packages_apps_Trebuchet-fefe8b6d0edc9c397d54e16484650ca89385ea67.zip |
Add clear all button to Recents Go
Add a button to clear all tasks to the recents Go layout and hook it up
to the model.
Bug: 114136250
Test: Open recents, hit clear all
Change-Id: Id67310ce88053528d372e4dc21e2b011ed957646
Diffstat (limited to 'go')
-rw-r--r-- | go/quickstep/res/drawable/clear_all_button.xml | 22 | ||||
-rw-r--r-- | go/quickstep/res/layout/icon_recents_root_view.xml | 28 | ||||
-rw-r--r-- | go/quickstep/res/values/colors.xml | 20 | ||||
-rw-r--r-- | go/quickstep/res/values/dimens.xml | 3 | ||||
-rw-r--r-- | go/quickstep/src/com/android/quickstep/TaskInputController.java | 12 | ||||
-rw-r--r-- | go/quickstep/src/com/android/quickstep/TaskListLoader.java | 7 | ||||
-rw-r--r-- | go/quickstep/src/com/android/quickstep/views/IconRecentsView.java | 11 |
7 files changed, 93 insertions, 10 deletions
diff --git a/go/quickstep/res/drawable/clear_all_button.xml b/go/quickstep/res/drawable/clear_all_button.xml new file mode 100644 index 000000000..acac32de5 --- /dev/null +++ b/go/quickstep/res/drawable/clear_all_button.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2019 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="@color/clear_all_button_bg"/> + <corners android:radius="4dp"/> +</shape> diff --git a/go/quickstep/res/layout/icon_recents_root_view.xml b/go/quickstep/res/layout/icon_recents_root_view.xml index ff3dcef98..fddb1d347 100644 --- a/go/quickstep/res/layout/icon_recents_root_view.xml +++ b/go/quickstep/res/layout/icon_recents_root_view.xml @@ -19,13 +19,31 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - <androidx.recyclerview.widget.RecyclerView - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/recent_task_recycler_view" + <LinearLayout + android:id="@+id/recent_task_content_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:scrollbars="none" - android:visibility="gone"/> + android:orientation="vertical" + android:visibility="gone"> + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/recent_task_recycler_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_weight="1" + android:scrollbars="none"/> + <Button + android:id="@+id/clear_all_button" + android:layout_width="@dimen/clear_all_button_width" + android:layout_height="@dimen/clear_all_button_height" + android:layout_gravity="center_horizontal" + android:layout_marginVertical="@dimen/task_item_half_vert_margin" + android:background="@drawable/clear_all_button" + android:gravity="center" + android:text="@string/recents_clear_all" + android:textAllCaps="false" + android:textColor="@color/clear_all_button_text" + android:textSize="14sp"/> + </LinearLayout> <TextView android:id="@+id/recent_task_empty_view" android:layout_width="match_parent" diff --git a/go/quickstep/res/values/colors.xml b/go/quickstep/res/values/colors.xml new file mode 100644 index 000000000..ff9dc9c61 --- /dev/null +++ b/go/quickstep/res/values/colors.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2019 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. +--> +<resources> + <color name="clear_all_button_bg">#FFDADCE0</color> + <color name="clear_all_button_text">#FF5F6368</color> +</resources> diff --git a/go/quickstep/res/values/dimens.xml b/go/quickstep/res/values/dimens.xml index 726970415..e2fa387c8 100644 --- a/go/quickstep/res/values/dimens.xml +++ b/go/quickstep/res/values/dimens.xml @@ -20,4 +20,7 @@ <dimen name="task_thumbnail_height">60dp</dimen> <dimen name="task_thumbnail_width">36dp</dimen> <dimen name="task_icon_size">36dp</dimen> + + <dimen name="clear_all_button_width">106dp</dimen> + <dimen name="clear_all_button_height">36dp</dimen> </resources>
\ No newline at end of file diff --git a/go/quickstep/src/com/android/quickstep/TaskInputController.java b/go/quickstep/src/com/android/quickstep/TaskInputController.java index 843300741..10de5c83c 100644 --- a/go/quickstep/src/com/android/quickstep/TaskInputController.java +++ b/go/quickstep/src/com/android/quickstep/TaskInputController.java @@ -61,6 +61,14 @@ public final class TaskInputController { mAdapter.notifyItemRemoved(position); } - // TODO: Implement "Clear all" and notify adapter that data has updated - + /** + * Logic that occurs when clear all is triggered. + */ + public void onClearAllClicked(View view) { + // TODO: Play an animation so transition is more natural. + int count = mAdapter.getItemCount(); + ActivityManagerWrapper.getInstance().removeAllRecentTasks(); + mLoader.clearAllTasks(); + mAdapter.notifyItemRangeRemoved(0 /* positionStart */, count); + } } diff --git a/go/quickstep/src/com/android/quickstep/TaskListLoader.java b/go/quickstep/src/com/android/quickstep/TaskListLoader.java index e6d1a22df..c86c24e8f 100644 --- a/go/quickstep/src/com/android/quickstep/TaskListLoader.java +++ b/go/quickstep/src/com/android/quickstep/TaskListLoader.java @@ -93,6 +93,13 @@ public final class TaskListLoader { } /** + * Clears the current task list. + */ + void clearAllTasks() { + mTaskList.clear(); + } + + /** * Loads task content for a list of tasks, including the label, icon, and thumbnail. For content * that isn't cached, load the content asynchronously in the background. * diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index 504f64006..94f3e6625 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -79,6 +79,7 @@ public final class IconRecentsView extends FrameLayout { private RecentsToActivityHelper mActivityHelper; private RecyclerView mTaskRecyclerView; private View mEmptyView; + private View mContentView; public IconRecentsView(Context context, AttributeSet attrs) { super(context, attrs); @@ -102,6 +103,7 @@ public final class IconRecentsView extends FrameLayout { helper.attachToRecyclerView(mTaskRecyclerView); mEmptyView = findViewById(R.id.recent_task_empty_view); + mContentView = findViewById(R.id.recent_task_content_view); mTaskAdapter.registerAdapterDataObserver(new AdapterDataObserver() { @Override public void onChanged() { @@ -113,6 +115,9 @@ public final class IconRecentsView extends FrameLayout { updateContentViewVisibility(); } }); + + View clearAllView = findViewById(R.id.clear_all_button); + clearAllView.setOnClickListener(mTaskInputController::onClearAllClicked); } } @@ -162,11 +167,11 @@ public final class IconRecentsView extends FrameLayout { private void updateContentViewVisibility() { int taskListSize = mTaskLoader.getCurrentTaskList().size(); if (mEmptyView.getVisibility() != VISIBLE && taskListSize == 0) { - crossfadeViews(mEmptyView, mTaskRecyclerView); + crossfadeViews(mEmptyView, mContentView); mActivityHelper.leaveRecents(); } - if (mTaskRecyclerView.getVisibility() != VISIBLE && taskListSize > 0) { - crossfadeViews(mTaskRecyclerView, mEmptyView); + if (mContentView.getVisibility() != VISIBLE && taskListSize > 0) { + crossfadeViews(mContentView, mEmptyView); } } |