Merge "Adding debug ui to dock windows."
This commit is contained in:
@@ -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="#FF0000FF"
|
||||
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>
|
||||
@@ -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="#FF0000FF"
|
||||
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>
|
||||
@@ -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="#FF0000FF"
|
||||
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>
|
||||
@@ -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="#FF0000FF"
|
||||
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>
|
||||
@@ -26,6 +26,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/place_dock_left"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_left" />
|
||||
<Button
|
||||
android:id="@+id/place_dock_right"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_right" />
|
||||
<Button
|
||||
android:id="@+id/place_left"
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -26,6 +26,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/place_dock_top"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_top" />
|
||||
<Button
|
||||
android:id="@+id/place_dock_bottom"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_bottom" />
|
||||
<Button
|
||||
android:id="@+id/place_top"
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -26,6 +26,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/place_dock_left"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_left" />
|
||||
<Button
|
||||
android:id="@+id/place_dock_right"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_right" />
|
||||
<Button
|
||||
android:id="@+id/place_left"
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -26,6 +26,20 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/place_dock_top"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_top" />
|
||||
<Button
|
||||
android:id="@+id/place_dock_bottom"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/vector_drawable_place_dock_bottom" />
|
||||
<Button
|
||||
android:id="@+id/place_top"
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.recents;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
@@ -27,6 +28,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
import com.android.systemui.recents.model.RecentsTaskLoader;
|
||||
@@ -50,10 +52,18 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
private static final int PLACE_BOTTOM_LEFT = 7;
|
||||
private static final int PLACE_BOTTOM_RIGHT = 8;
|
||||
private static final int PLACE_FULL = 9;
|
||||
private static final int PLACE_DOCK_LEFT = 10;
|
||||
private static final int PLACE_DOCK_RIGHT = 11;
|
||||
private static final int PLACE_DOCK_TOP = 12;
|
||||
private static final int PLACE_DOCK_BOTTOM = 13;
|
||||
|
||||
// The button resource ID combined with the arrangement command.
|
||||
private static final int[][] BUTTON_DEFINITIONS =
|
||||
{{R.id.place_left, PLACE_LEFT},
|
||||
{{R.id.place_dock_left, PLACE_DOCK_LEFT},
|
||||
{R.id.place_dock_right, PLACE_DOCK_RIGHT},
|
||||
{R.id.place_dock_top, PLACE_DOCK_TOP},
|
||||
{R.id.place_dock_bottom, PLACE_DOCK_BOTTOM},
|
||||
{R.id.place_left, PLACE_LEFT},
|
||||
{R.id.place_right, PLACE_RIGHT},
|
||||
{R.id.place_top, PLACE_TOP},
|
||||
{R.id.place_bottom, PLACE_BOTTOM},
|
||||
@@ -72,6 +82,12 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
private Rect[] mBounds = {new Rect(), new Rect(), new Rect(), new Rect()};
|
||||
private Task[] mTasks = {null, null, null, null};
|
||||
|
||||
/**
|
||||
* Called by FragmentManager
|
||||
*/
|
||||
public RecentsResizeTaskDialog() {
|
||||
}
|
||||
|
||||
public RecentsResizeTaskDialog(FragmentManager mgr, RecentsActivity activity) {
|
||||
mFragmentManager = mgr;
|
||||
mRecentsActivity = activity;
|
||||
@@ -82,13 +98,11 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
void showResizeTaskDialog(Task mainTask, RecentsView rv) {
|
||||
mTasks[0] = mainTask;
|
||||
mRecentsView = rv;
|
||||
|
||||
show(mFragmentManager, TAG);
|
||||
showAllowingStateLoss(mFragmentManager, TAG);
|
||||
}
|
||||
|
||||
/** Creates a new resize-task dialog. */
|
||||
private void createResizeTaskDialog(final Context context, LayoutInflater inflater,
|
||||
AlertDialog.Builder builder) {
|
||||
private void createResizeTaskDialog(LayoutInflater inflater, AlertDialog.Builder builder) {
|
||||
builder.setTitle(R.string.recents_caption_resize);
|
||||
mResizeTaskDialogContent =
|
||||
inflater.inflate(R.layout.recents_task_resize_dialog, null, false);
|
||||
@@ -100,7 +114,17 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
b.setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
placeTasks(action);
|
||||
switch (action) {
|
||||
case PLACE_DOCK_LEFT:
|
||||
case PLACE_DOCK_RIGHT:
|
||||
case PLACE_DOCK_TOP:
|
||||
case PLACE_DOCK_BOTTOM:
|
||||
placeDockTasks(action);
|
||||
break;
|
||||
default:
|
||||
placeTasks(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,7 +133,7 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dismiss();
|
||||
dismissAllowingStateLoss();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -118,7 +142,7 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
|
||||
/** Helper function to place window(s) on the display according to an arrangement request. */
|
||||
private void placeTasks(int arrangement) {
|
||||
Rect rect = mSsp.getWindowRect();
|
||||
Rect rect = mSsp.getDisplayRect();
|
||||
for (int i = 0; i < mBounds.length; ++i) {
|
||||
mBounds[i].set(rect);
|
||||
if (i != 0) {
|
||||
@@ -193,7 +217,7 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
break;
|
||||
case PLACE_FULL:
|
||||
// Nothing to change.
|
||||
mBounds[0] = null;
|
||||
mBounds[0] = new Rect();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -207,7 +231,7 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
// Get rid of the dialog.
|
||||
dismiss();
|
||||
dismissAllowingStateLoss();
|
||||
mRecentsActivity.dismissRecentsToHomeWithoutTransitionAnimation();
|
||||
|
||||
// In debug mode, we force all task to be resizeable regardless of the
|
||||
@@ -229,12 +253,44 @@ public class RecentsResizeTaskDialog extends DialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to place docked window(s) on the display according to an arrangement request.
|
||||
*/
|
||||
private void placeDockTasks(int arrangement) {
|
||||
int createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
|
||||
switch (arrangement) {
|
||||
case PLACE_DOCK_LEFT:
|
||||
createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
|
||||
break;
|
||||
case PLACE_DOCK_TOP:
|
||||
createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
|
||||
break;
|
||||
case PLACE_DOCK_RIGHT:
|
||||
createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
|
||||
break;
|
||||
case PLACE_DOCK_BOTTOM:
|
||||
createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
// Dismiss the dialog before trying to launch the task
|
||||
dismissAllowingStateLoss();
|
||||
|
||||
if (mTasks[0].key.stackId != ActivityManager.DOCKED_STACK_ID) {
|
||||
int taskId = mTasks[0].key.id;
|
||||
mSsp.setTaskResizeable(taskId);
|
||||
mSsp.dockTask(taskId, createMode);
|
||||
mRecentsView.launchTask(mTasks[0], null);
|
||||
} else {
|
||||
Toast.makeText(getContext(), "Already docked", Toast.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle args) {
|
||||
final Context context = this.getActivity();
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
createResizeTaskDialog(context, inflater, builder);
|
||||
createResizeTaskDialog(inflater, builder);
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageParser;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -282,6 +283,30 @@ public class SystemServicesProxy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the given task to the new bounds.
|
||||
*/
|
||||
public void resizeTask(int taskId, Rect bounds) {
|
||||
if (mIam == null) return;
|
||||
|
||||
try {
|
||||
mIam.resizeTask(taskId, bounds, ActivityManager.RESIZE_MODE_FORCED);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Docks a task to the side of the screen. */
|
||||
public void dockTask(int taskId, int createMode) {
|
||||
if (mIam == null) return;
|
||||
|
||||
try {
|
||||
mIam.moveTaskToDockedStack(taskId, createMode, true);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the focused stack id. */
|
||||
public int getFocusedStack() {
|
||||
if (mIam == null) return -1;
|
||||
@@ -636,6 +661,19 @@ public class SystemServicesProxy {
|
||||
return SystemProperties.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display rect.
|
||||
*/
|
||||
public Rect getDisplayRect() {
|
||||
Rect displayRect = new Rect();
|
||||
if (mWm == null) return displayRect;
|
||||
|
||||
Point p = new Point();
|
||||
mWm.getDefaultDisplay().getRealSize(p);
|
||||
displayRect.set(0, 0, p.x, p.y);
|
||||
return displayRect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the window rect.
|
||||
*/
|
||||
|
||||
@@ -184,7 +184,8 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
|
||||
for (int j = 0; j < taskViewCount; j++) {
|
||||
TaskView tv = taskViews.get(j);
|
||||
if (tv.getTask() == task) {
|
||||
onTaskViewClicked(mTaskStackView, tv, stack, task, false, true, taskBounds);
|
||||
onTaskViewClicked(mTaskStackView, tv, stack, task, false, taskBounds != null,
|
||||
taskBounds);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -593,7 +594,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
|
||||
opts = ActivityOptions.makeBasic();
|
||||
}
|
||||
if (boundsValid) {
|
||||
opts.setBounds(bounds);
|
||||
opts.setBounds(bounds.isEmpty() ? null : bounds);
|
||||
}
|
||||
final ActivityOptions launchOpts = opts;
|
||||
final boolean screenPinningRequested = (animStartedListener == null) && lockToTask;
|
||||
|
||||
Reference in New Issue
Block a user