diff options
author | Skuhne <skuhne@google.com> | 2015-03-20 13:40:53 -0700 |
---|---|---|
committer | Skuhne <skuhne@google.com> | 2015-03-24 09:20:51 -0700 |
commit | 8aa7d161a11965cd75eace74e1bcf15421bbea18 (patch) | |
tree | a376af8d6a79ba9208fd9758e331718d4379ad92 /packages/SystemUI | |
parent | 1cef4196886b0cc1238111d396c1e3665a5fd2ae (diff) | |
download | frameworks_base-8aa7d161a11965cd75eace74e1bcf15421bbea18.zip frameworks_base-8aa7d161a11965cd75eace74e1bcf15421bbea18.tar.gz frameworks_base-8aa7d161a11965cd75eace74e1bcf15421bbea18.tar.bz2 |
Adding menu to arrange one or two tasks and arrange them accordingly
Added dialog with buttons for task arrangement upon click on decorator
icon.
BUG: 19492945,19868830,19656507
Change-Id: Ie31e2788efb097db1c1f54f0ef1b2fda1ccc71ec
Diffstat (limited to 'packages/SystemUI')
13 files changed, 385 insertions, 131 deletions
diff --git a/packages/SystemUI/res/drawable/vector_drawable_place_bottom.xml b/packages/SystemUI/res/drawable/vector_drawable_place_bottom.xml new file mode 100644 index 0000000..14f1981 --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_place_bottom.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2015 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M0.0,0.0l0.0,24.0l24.0,0.0L24.0,0.0L0.0,0.0zM4.0,10.0l16.0,0.0l0.0,10.0L4.0,20.0L4.0,10.0z"/> +</vector> diff --git a/packages/SystemUI/res/drawable/vector_drawable_place_fullscreen.xml b/packages/SystemUI/res/drawable/vector_drawable_place_fullscreen.xml new file mode 100644 index 0000000..aee0b7f --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_place_fullscreen.xml @@ -0,0 +1,33 @@ +<!-- +Copyright (C) 2015 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M0.0,8.0l4.0,0.0 0.0,-4.0 4.0,0.0 0.0,-4.0 -8.0,0.0z"/> + <path + android:fillColor="#FF000000" + android:pathData="M4.0,16.0l-4.0,0.0 0.0,8.0 8.0,0.0 0.0,-4.0 -4.0,0.0z"/> + <path + android:fillColor="#FF000000" + android:pathData="M16.0,0.0l0.0,4.0 4.0,0.0 0.0,4.0 4.0,0.0 0.0,-8.0z"/> + <path + android:fillColor="#FF000000" + android:pathData="M20.0,20.0l-4.0,0.0 0.0,4.0 8.0,0.0 0.0,-8.0 -4.0,0.0z"/> +</vector> diff --git a/packages/SystemUI/res/drawable/vector_drawable_place_left.xml b/packages/SystemUI/res/drawable/vector_drawable_place_left.xml new file mode 100644 index 0000000..078f83c --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_place_left.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2015 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M24.0,0.0L0.0,0.0l0.0,24.0l24.0,0.0L24.0,0.0zM14.0,4.0l0.0,16.0L4.0,20.0L4.0,4.0L14.0,4.0z"/> +</vector> diff --git a/packages/SystemUI/res/drawable/vector_drawable_place_right.xml b/packages/SystemUI/res/drawable/vector_drawable_place_right.xml new file mode 100644 index 0000000..86730db --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_place_right.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2015 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M0.0,24.0l24.0,0.0L24.0,0.0L0.0,0.0L0.0,24.0zM10.0,20.0L10.0,4.0l10.0,0.0l0.0,16.0L10.0,20.0z"/> +</vector> diff --git a/packages/SystemUI/res/drawable/vector_drawable_place_top.xml b/packages/SystemUI/res/drawable/vector_drawable_place_top.xml new file mode 100644 index 0000000..92e01af --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_place_top.xml @@ -0,0 +1,24 @@ +<!-- +Copyright (C) 2015 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24.0dp" + android:height="24.0dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FF000000" + android:pathData="M24.0,24.0L24.0,0.0L0.0,0.0l0.0,24.0L24.0,24.0zM20.0,14.0L4.0,14.0L4.0,4.0l16.0,0.0L20.0,14.0z"/> +</vector> diff --git a/packages/SystemUI/res/layout/recents_multistack_stack_size_dialog.xml b/packages/SystemUI/res/layout/recents_multistack_stack_size_dialog.xml deleted file mode 100644 index 36e54a0..0000000 --- a/packages/SystemUI/res/layout/recents_multistack_stack_size_dialog.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2015 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. ---> - -<LinearLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="16dp" - android:orientation="vertical" - android:descendantFocusability="beforeDescendants" - android:focusableInTouchMode="true"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - <EditText - android:id="@+id/inset_left" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:hint="Left" - android:singleLine="true" - android:imeOptions="actionNext" - android:inputType="number" - android:selectAllOnFocus="true" /> - <EditText - android:id="@+id/inset_top" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:hint="Top" - android:singleLine="true" - android:imeOptions="actionNext" - android:inputType="number" - android:selectAllOnFocus="true" /> - <EditText - android:id="@+id/inset_right" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:hint="Right" - android:singleLine="true" - android:imeOptions="actionNext" - android:inputType="number" - android:selectAllOnFocus="true" /> - <EditText - android:id="@+id/inset_bottom" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:hint="Bottom" - android:singleLine="true" - android:imeOptions="actionDone" - android:inputType="number" - android:selectAllOnFocus="true" /> - </LinearLayout> -</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/recents_task_resize_dialog.xml b/packages/SystemUI/res/layout/recents_task_resize_dialog.xml new file mode 100644 index 0000000..a8c6ee9 --- /dev/null +++ b/packages/SystemUI/res/layout/recents_task_resize_dialog.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 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. +--> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="16dp" + android:orientation="vertical" + android:descendantFocusability="beforeDescendants" + android:focusableInTouchMode="true"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + <Button + android:id="@+id/place_left" + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_weight="1" + android:layout_margin="10dp" + android:background="@drawable/vector_drawable_place_left" /> + <Button + android:id="@+id/place_right" + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_weight="1" + android:layout_margin="10dp" + android:background="@drawable/vector_drawable_place_right" /> + <Button + android:id="@+id/place_top" + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_weight="1" + android:layout_margin="10dp" + android:background="@drawable/vector_drawable_place_top" /> + <Button + android:id="@+id/place_bottom" + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_weight="1" + android:layout_margin="10dp" + android:background="@drawable/vector_drawable_place_bottom" /> + <Button + android:id="@+id/place_full" + android:layout_width="36dp" + android:layout_height="36dp" + android:layout_weight="1" + android:layout_margin="10dp" + android:background="@drawable/vector_drawable_place_fullscreen" /> + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 66d494b..b696787 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -216,6 +216,10 @@ <string name="phone_label">open phone</string> <!-- Click action label for accessibility for the phone button. [CHAR LIMIT=NONE] --> <string name="camera_label">open camera</string> + <!-- Caption for "Recents resize" developer debug feature. [CHAR LIMIT=NONE] --> + <string name="recents_caption_resize">Select new task layout</string> + <!-- Button name for "Cancel". [CHAR LIMIT=NONE] --> + <string name="cancel">Cancel</string> <!-- Content description of the compatibility zoom button for accessibility (not shown on the screen). [CHAR LIMIT=NONE] --> <string name="accessibility_compatibility_zoom_button">Compatibility zoom button.</string> diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index c259c9d..f014f09 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -592,14 +592,14 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView private RecentsResizeTaskDialog getResizeTaskDebugDialog() { if (mResizeTaskDebugDialog == null) { - mResizeTaskDebugDialog = new RecentsResizeTaskDialog(getFragmentManager()); + mResizeTaskDebugDialog = new RecentsResizeTaskDialog(getFragmentManager(), this); } return mResizeTaskDebugDialog; } @Override public void onTaskResize(Task t) { - getResizeTaskDebugDialog().showResizeTaskDialog(t); + getResizeTaskDebugDialog().showResizeTaskDialog(t, mRecentsView); } /**** RecentsView.RecentsViewCallbacks Implementation ****/ diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsResizeTaskDialog.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsResizeTaskDialog.java index d67eceb..7c11894 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsResizeTaskDialog.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsResizeTaskDialog.java @@ -16,31 +16,23 @@ package com.android.systemui.recents; -import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.FragmentManager; -import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.ResolveInfo; import android.graphics.Rect; import android.os.Bundle; -import android.util.MutableInt; -import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; -import android.widget.EditText; -import android.widget.Toast; +import android.widget.Button; import com.android.systemui.R; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.Task; - -import java.util.List; +import com.android.systemui.recents.RecentsActivity; +import com.android.systemui.recents.views.RecentsView; /** * A helper for the dialogs that show when task debugging is on. @@ -49,80 +41,137 @@ public class RecentsResizeTaskDialog extends DialogFragment { static final String TAG = "RecentsResizeTaskDialog"; - // The task we want to resize. - Task mTaskToResize; - FragmentManager mFragmentManager; - View mResizeTaskDialogContent; + // The various window arrangements we can handle. + private static final int PLACE_LEFT = 1; + private static final int PLACE_RIGHT = 2; + private static final int PLACE_TOP = 3; + private static final int PLACE_BOTTOM = 4; + private static final int PLACE_FULL = 5; - public RecentsResizeTaskDialog() {} + // The task we want to resize. + private Task mTaskToResize; + private Task mNextTaskToResize; + private FragmentManager mFragmentManager; + private View mResizeTaskDialogContent; + private RecentsActivity mRecentsActivity; + private RecentsView mRecentsView; + private SystemServicesProxy mSsp; - public RecentsResizeTaskDialog(FragmentManager mgr) { + public RecentsResizeTaskDialog(FragmentManager mgr, RecentsActivity activity) { mFragmentManager = mgr; + mRecentsActivity = activity; + mSsp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); } /** Shows the resize-task dialog. */ - void showResizeTaskDialog(Task t) { - mTaskToResize = t; + void showResizeTaskDialog(Task mainTask, RecentsView rv) { + mTaskToResize = mainTask; + mRecentsView = rv; + mNextTaskToResize = mRecentsView.getNextTaskOrTopTask(mainTask); + show(mFragmentManager, TAG); } /** Creates a new resize-task dialog. */ private void createResizeTaskDialog(final Context context, LayoutInflater inflater, - AlertDialog.Builder builder, final SystemServicesProxy ssp) { - builder.setTitle("Resize Task - Enter new dimensions"); + AlertDialog.Builder builder) { + builder.setTitle(R.string.recents_caption_resize); mResizeTaskDialogContent = - inflater.inflate(R.layout.recents_multistack_stack_size_dialog, null, false); - Rect bounds = ssp.getTaskBounds(mTaskToResize.key.stackId); - setDimensionInEditText(mResizeTaskDialogContent, R.id.inset_left, bounds.left); - setDimensionInEditText(mResizeTaskDialogContent, R.id.inset_top, bounds.top); - setDimensionInEditText(mResizeTaskDialogContent, R.id.inset_right, bounds.right); - setDimensionInEditText(mResizeTaskDialogContent, R.id.inset_bottom, bounds.bottom); - builder.setView(mResizeTaskDialogContent); - builder.setPositiveButton("Resize Task", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - int left = getDimensionFromEditText(mResizeTaskDialogContent, R.id.inset_left); - int top = getDimensionFromEditText(mResizeTaskDialogContent, R.id.inset_top); - int right = getDimensionFromEditText(mResizeTaskDialogContent, R.id.inset_right); - int bottom = getDimensionFromEditText(mResizeTaskDialogContent, R.id.inset_bottom); - if (bottom <= top || right <= left) { - Toast.makeText(context, "Invalid dimensions", Toast.LENGTH_SHORT).show(); - dismiss(); - return; - } - ssp.resizeTask(mTaskToResize.key.id, new Rect(left, top, right, bottom)); - dismiss(); + inflater.inflate(R.layout.recents_task_resize_dialog, null, false); + + ((Button)mResizeTaskDialogContent.findViewById(R.id.place_left)).setOnClickListener( + new View.OnClickListener() { + public void onClick(View v) { + placeTasks(PLACE_LEFT); + } + }); + ((Button)mResizeTaskDialogContent.findViewById(R.id.place_right)).setOnClickListener( + new View.OnClickListener() { + public void onClick(View v) { + placeTasks(PLACE_RIGHT); + } + }); + ((Button)mResizeTaskDialogContent.findViewById(R.id.place_top)).setOnClickListener( + new View.OnClickListener() { + public void onClick(View v) { + placeTasks(PLACE_TOP); } }); - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + ((Button)mResizeTaskDialogContent.findViewById(R.id.place_bottom)).setOnClickListener( + new View.OnClickListener() { + public void onClick(View v) { + placeTasks(PLACE_BOTTOM); + } + }); + ((Button)mResizeTaskDialogContent.findViewById(R.id.place_full)).setOnClickListener( + new View.OnClickListener() { + public void onClick(View v) { + placeTasks(PLACE_FULL); + } + }); + + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); + + builder.setView(mResizeTaskDialogContent); } - /** Helper to get an integer value from an edit text. */ - private int getDimensionFromEditText(View container, int id) { - String text = ((EditText) container.findViewById(id)).getText().toString(); - if (text.trim().length() != 0) { - return Integer.parseInt(text.trim()); + /** Helper function to place window(s) on the display according to an arrangement request. */ + private void placeTasks(int arrangement) { + Rect focusedBounds = mSsp.getWindowRect(); + Rect otherBounds = new Rect(focusedBounds); + + switch (arrangement) { + case PLACE_LEFT: + focusedBounds.right = focusedBounds.centerX(); + otherBounds.left = focusedBounds.right; + break; + case PLACE_RIGHT: + otherBounds.right = otherBounds.centerX(); + focusedBounds.left = otherBounds.right; + break; + case PLACE_TOP: + focusedBounds.bottom = focusedBounds.centerY(); + otherBounds.top = focusedBounds.bottom; + break; + case PLACE_BOTTOM: + otherBounds.bottom = otherBounds.centerY(); + focusedBounds.top = otherBounds.bottom; + break; + case PLACE_FULL: + // Null the rectangle to avoid the other task to show up. + otherBounds = new Rect(); + break; } - return 0; - } - /** Helper to set an integer value to an edit text. */ - private void setDimensionInEditText(View container, int id, int value) { - ((EditText) container.findViewById(id)).setText("" + value); + // Resize all other tasks to go to the other side. + if (mNextTaskToResize != null && !otherBounds.isEmpty()) { + mSsp.resizeTask(mNextTaskToResize.key.id, otherBounds); + } + mSsp.resizeTask(mTaskToResize.key.id, focusedBounds); + + // Get rid of the dialog. + dismiss(); + mRecentsActivity.dismissRecentsToHomeRaw(false); + + // Show tasks - beginning with the other first so that the focus ends on the selected one. + // TODO: Remove this once issue b/19893373 is resolved. + if (mNextTaskToResize != null && !otherBounds.isEmpty()) { + mRecentsView.launchTask(mNextTaskToResize); + } + mRecentsView.launchTask(mTaskToResize); } @Override public Dialog onCreateDialog(Bundle args) { final Context context = this.getActivity(); - final SystemServicesProxy ssp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - createResizeTaskDialog(context, inflater, builder, ssp); + createResizeTaskDialog(context, inflater, builder); return builder.create(); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index a473a29..d60df9c 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -259,7 +259,7 @@ public class SystemServicesProxy { public Rect getTaskBounds(int stackId) { ActivityManager.StackInfo info = getAllStackInfos().get(stackId); if (info != null) - return getAllStackInfos().get(stackId).bounds; + return info.bounds; return new Rect(); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 448a7a9..abed7a5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -149,6 +149,31 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV return mTaskStackViews; } + /** Gets the next task in the stack - or if the last - the top task */ + public Task getNextTaskOrTopTask(Task taskToSearch) { + Task returnTask = null; + boolean found = false; + List<TaskStackView> stackViews = getTaskStackViews(); + int stackCount = stackViews.size(); + for (int i = stackCount - 1; i >= 0; --i) { + TaskStack stack = stackViews.get(i).getStack(); + ArrayList<Task> taskList = stack.getTasks(); + // Iterate the stack views and try and find the focused task + for (int j = taskList.size() - 1; j >= 0; --j) { + Task task = taskList.get(j); + // Return the next task in the line. + if (found) + return task; + // Remember the first possible task as the top task. + if (returnTask == null) + returnTask = task; + if (task == taskToSearch) + found = true; + } + } + return returnTask; + } + /** Launches the focused task from the first stack if possible */ public boolean launchFocusedTask() { // Get the first stack view @@ -172,6 +197,28 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV return false; } + /** Launches a given task. */ + public boolean launchTask(Task task) { + // Get the first stack view + List<TaskStackView> stackViews = getTaskStackViews(); + int stackCount = stackViews.size(); + for (int i = 0; i < stackCount; i++) { + TaskStackView stackView = stackViews.get(i); + TaskStack stack = stackView.getStack(); + // Iterate the stack views and try and find the given task. + List<TaskView> taskViews = stackView.getTaskViews(); + int taskViewCount = taskViews.size(); + for (int j = 0; j < taskViewCount; j++) { + TaskView tv = taskViews.get(j); + if (tv.getTask() == task) { + onTaskViewClicked(stackView, tv, stack, task, false); + return true; + } + } + } + return false; + } + /** Launches the task that Recents was launched from, if possible */ public boolean launchPreviousTask() { // Get the first stack view diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java index 56801e5..42399a3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java @@ -26,14 +26,15 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.RippleDrawable; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffXfermode; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.RippleDrawable; +import android.graphics.Rect; import android.util.AttributeSet; import android.view.View; import android.view.ViewOutlineProvider; @@ -43,7 +44,9 @@ import android.widget.TextView; import com.android.systemui.R; import com.android.systemui.recents.Constants; import com.android.systemui.recents.RecentsConfiguration; +import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.Utilities; +import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.Task; @@ -51,6 +54,7 @@ import com.android.systemui.recents.model.Task; public class TaskViewHeader extends FrameLayout { RecentsConfiguration mConfig; + private SystemServicesProxy mSsp; // Header views ImageView mMoveTaskButton; @@ -91,6 +95,7 @@ public class TaskViewHeader extends FrameLayout { public TaskViewHeader(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mConfig = RecentsConfiguration.getInstance(); + mSsp = RecentsTaskLoader.getInstance().getSystemServicesProxy(); setWillNotDraw(false); setClipToOutline(true); setOutlineProvider(new ViewOutlineProvider() { @@ -209,6 +214,31 @@ public class TaskViewHeader extends FrameLayout { mMoveTaskButton.setVisibility((mConfig.multiStackEnabled) ? View.VISIBLE : View.INVISIBLE); } + /** Updates the resize task bar button. */ + void updateResizeTaskBarIcon(Task t) { + Rect display = mSsp.getWindowRect(); + Rect taskRect = mSsp.getTaskBounds(t.key.stackId); + int resId = R.drawable.star; + if (display.equals(taskRect)) { + resId = R.drawable.vector_drawable_place_fullscreen; + } else { + boolean top = display.top == taskRect.top; + boolean bottom = display.bottom == taskRect.bottom; + boolean left = display.left == taskRect.left; + boolean right = display.right == taskRect.right; + if (top && bottom && left) { + resId = R.drawable.vector_drawable_place_left; + } else if (top && bottom && right) { + resId = R.drawable.vector_drawable_place_right; + } else if (top && left && right) { + resId = R.drawable.vector_drawable_place_top; + } else if (bottom && left && right) { + resId = R.drawable.vector_drawable_place_bottom; + } + } + mMoveTaskButton.setImageResource(resId); + } + /** Unbinds the bar view from the task */ void unbindFromTask() { mApplicationIcon.setImageDrawable(null); |