diff options
7 files changed, 78 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/IRecentsNonSystemUserCallbacks.aidl b/packages/SystemUI/src/com/android/systemui/recents/IRecentsNonSystemUserCallbacks.aidl index 940366444e63..9214eef61df5 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/IRecentsNonSystemUserCallbacks.aidl +++ b/packages/SystemUI/src/com/android/systemui/recents/IRecentsNonSystemUserCallbacks.aidl @@ -35,4 +35,5 @@ oneway interface IRecentsNonSystemUserCallbacks { in Rect initialBounds); void onDraggingInRecents(float distanceFromTop); void onDraggingInRecentsEnded(float velocity); + void showCurrentUserToast(int msgResId, int msgLength); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index de51c939b13e..72074635999c 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -55,6 +55,7 @@ import com.android.systemui.recents.events.activity.DockedTopTaskEvent; import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent; import com.android.systemui.recents.events.component.ScreenPinningRequestEvent; +import com.android.systemui.recents.events.component.ShowUserToastEvent; import com.android.systemui.recents.events.ui.RecentsDrawnEvent; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.model.RecentsTaskLoader; @@ -477,8 +478,8 @@ public class Recents extends SystemUI mDraggingInRecentsCurrentUser = currentUser; return true; } else { - Toast.makeText(mContext, R.string.recents_incompatible_app_message, - Toast.LENGTH_SHORT).show(); + EventBus.getDefault().send(new ShowUserToastEvent( + R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT)); return false; } } else { @@ -696,6 +697,27 @@ public class Recents extends SystemUI mImpl.onConfigurationChanged(); } + public final void onBusEvent(ShowUserToastEvent event) { + int currentUser = sSystemServicesProxy.getCurrentUser(); + if (sSystemServicesProxy.isSystemUser(currentUser)) { + mImpl.onShowCurrentUserToast(event.msgResId, event.msgLength); + } else { + if (mSystemToUserCallbacks != null) { + IRecentsNonSystemUserCallbacks callbacks = + mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser); + if (callbacks != null) { + try { + callbacks.showCurrentUserToast(event.msgResId, event.msgLength); + } catch (RemoteException e) { + Log.e(TAG, "Callback failed", e); + } + } else { + Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser); + } + } + } + } + /** * Attempts to register with the system user. */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index d813170f9239..a7f271648e13 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -40,6 +40,7 @@ import android.view.LayoutInflater; import android.view.ViewConfiguration; import android.view.WindowManager; +import android.widget.Toast; import com.android.internal.logging.MetricsLogger; import com.android.internal.policy.DockedDividerUtils; import com.android.systemui.R; @@ -396,6 +397,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener EventBus.getDefault().sendOntoMainThread(new DraggingInRecentsEndedEvent(velocity)); } + public void onShowCurrentUserToast(int msgResId, int msgLength) { + Toast.makeText(mContext, msgResId, msgLength).show(); + } + /** * Transitions to the next recent task in the stack. */ diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImplProxy.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImplProxy.java index 60bf760bfb44..ff9e89e9e00b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImplProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImplProxy.java @@ -38,6 +38,7 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub { private static final int MSG_DOCK_TOP_TASK = 7; private static final int MSG_ON_DRAGGING_IN_RECENTS = 8; private static final int MSG_ON_DRAGGING_IN_RECENTS_ENDED = 9; + private static final int MSG_SHOW_USER_TOAST = 10; private RecentsImpl mImpl; @@ -109,6 +110,11 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub { mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_DRAGGING_IN_RECENTS_ENDED, velocity)); } + @Override + public void showCurrentUserToast(int msgResId, int msgLength) { + mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_USER_TOAST, msgResId, msgLength)); + } + private final Handler mHandler = new Handler() { @Override @@ -147,6 +153,9 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub { case MSG_ON_DRAGGING_IN_RECENTS_ENDED: mImpl.onDraggingInRecentsEnded((Float) msg.obj); break; + case MSG_SHOW_USER_TOAST: + mImpl.onShowCurrentUserToast(msg.arg1, msg.arg2); + break; default: super.handleMessage(msg); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/events/component/ShowUserToastEvent.java b/packages/SystemUI/src/com/android/systemui/recents/events/component/ShowUserToastEvent.java new file mode 100644 index 000000000000..e2b39c39b586 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recents/events/component/ShowUserToastEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 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. + */ + +package com.android.systemui.recents.events.component; + +import com.android.systemui.recents.events.EventBus; + +/** + * This is sent when we want to show a toast for the current user. + */ +public class ShowUserToastEvent extends EventBus.Event { + + public final int msgResId; + public final int msgLength; + + public ShowUserToastEvent(int msgResId, int msgLength) { + this.msgResId = msgResId; + this.msgLength = msgLength; + } +} diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index 702b076d5aec..fce7f9d51ea4 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -1258,7 +1258,7 @@ public class TaskStackLayoutAlgorithm { String innerPrefix = prefix + " "; writer.print(prefix); writer.print(TAG); - writer.write(" numStackTasks="); writer.write(mNumStackTasks); + writer.write(" numStackTasks="); writer.print(mNumStackTasks); writer.println(); writer.print(innerPrefix); diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java index 5f083d57f9ae..5920f46b12f6 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/ForcedResizableInfoActivityController.java @@ -20,12 +20,14 @@ import android.app.ActivityOptions; import android.content.Context; import android.content.Intent; import android.os.Handler; +import android.os.UserHandle; import android.util.ArraySet; import android.widget.Toast; import com.android.systemui.R; import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent; +import com.android.systemui.recents.events.component.ShowUserToastEvent; import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener; import com.android.systemui.stackdivider.events.StartedDragingEvent; @@ -100,9 +102,8 @@ public class ForcedResizableInfoActivityController { } private void activityDismissingDockedStack() { - Toast toast = Toast.makeText(mContext, R.string.dock_non_resizeble_failed_to_dock_text, - Toast.LENGTH_SHORT); - toast.show(); + EventBus.getDefault().send(new ShowUserToastEvent( + R.string.dock_non_resizeble_failed_to_dock_text, Toast.LENGTH_SHORT)); } private void showPending() { @@ -112,7 +113,7 @@ public class ForcedResizableInfoActivityController { ActivityOptions options = ActivityOptions.makeBasic(); options.setLaunchTaskId(mPendingTaskIds.valueAt(i)); options.setTaskOverlay(true); - mContext.startActivity(intent, options.toBundle()); + mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT); } mPendingTaskIds.clear(); } |