Loading protos/launcher_log.proto +1 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ enum ControlType { CANCEL_TARGET = 14; TASK_PREVIEW = 15; SPLIT_SCREEN_TARGET = 16; REMOTE_ACTION_SHORTCUT = 17; } enum TipType { Loading res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ <item type="id" name="action_deep_shortcuts" /> <item type="id" name="action_shortcuts_and_notifications"/> <item type="id" name="action_dismiss_notification" /> <item type="id" name="action_remote_action_shortcut" /> <!-- QSB IDs. DO not change --> <item type="id" name="search_container_workspace" /> Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -347,4 +347,7 @@ <string name="work_mode_off_label">Notifications and apps are off</string> <string name="bottom_work_tab_user_education_close_button">Close</string> <string name="bottom_work_tab_user_education_closed">Closed</string> <!-- Failed action error message: e.g. Failed: Pause --> <string name="remote_action_failed">Failed: <xliff:g id="what" example="Pause">%1$s</xliff:g></string> </resources> src/com/android/launcher3/popup/RemoteActionShortcut.java 0 → 100644 +72 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.launcher3.popup; import android.app.PendingIntent; import android.app.RemoteAction; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.userevent.nano.LauncherLogProto; public class RemoteActionShortcut extends SystemShortcut<Launcher> { private static final String TAG = "RemoteActionShortcut"; private final RemoteAction mAction; public RemoteActionShortcut(RemoteAction action) { super(action.getIcon(), action.getTitle(), action.getContentDescription(), R.id.action_remote_action_shortcut); mAction = action; } @Override public View.OnClickListener getOnClickListener( final Launcher launcher, final ItemInfo itemInfo) { return view -> { AbstractFloatingView.closeAllOpenViews(launcher); try { mAction.getActionIntent().send(0, (pendingIntent, intent, resultCode, resultData, resultExtras) -> { if (resultData != null && !resultData.isEmpty()) { Log.e(TAG, "Remote action returned result: " + mAction.getTitle() + " : " + resultData); Toast.makeText(launcher, resultData, Toast.LENGTH_SHORT).show(); } }, new Handler(Looper.getMainLooper())); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "Remote action canceled: " + mAction.getTitle(), e); Toast.makeText(launcher, launcher.getString( R.string.remote_action_failed, mAction.getTitle()), Toast.LENGTH_SHORT) .show(); } launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP, LauncherLogProto.ControlType.REMOTE_ACTION_SHORTCUT, view); }; } } src/com/android/launcher3/popup/SystemShortcut.java +11 −5 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; import android.content.Context; import android.content.Intent; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; Loading Loading @@ -36,7 +38,7 @@ import java.util.List; public abstract class SystemShortcut<T extends BaseDraggingActivity> extends ItemInfo { private final int mIconResId; private final int mLabelResId; private final Drawable mIcon; private final Icon mIcon; private final CharSequence mLabel; private final CharSequence mContentDescription; private final int mAccessibilityActionId; Loading @@ -50,7 +52,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite mContentDescription = null; } public SystemShortcut(Drawable icon, CharSequence label, CharSequence contentDescription, public SystemShortcut(Icon icon, CharSequence label, CharSequence contentDescription, int accessibilityActionId) { mIcon = icon; mLabel = label; Loading @@ -71,7 +73,9 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite public void setIconAndLabelFor(View iconView, TextView labelView) { if (mIcon != null) { iconView.setBackground(mIcon); mIcon.loadDrawableAsync(iconView.getContext(), iconView::setBackground, new Handler(Looper.getMainLooper())); } else { iconView.setBackgroundResource(mIconResId); } Loading @@ -85,7 +89,9 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite public void setIconAndContentDescriptionFor(ImageView view) { if (mIcon != null) { view.setImageDrawable(mIcon); mIcon.loadDrawableAsync(view.getContext(), view::setImageDrawable, new Handler(Looper.getMainLooper())); } else { view.setImageResource(mIconResId); } Loading Loading
protos/launcher_log.proto +1 −0 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ enum ControlType { CANCEL_TARGET = 14; TASK_PREVIEW = 15; SPLIT_SCREEN_TARGET = 16; REMOTE_ACTION_SHORTCUT = 17; } enum TipType { Loading
res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ <item type="id" name="action_deep_shortcuts" /> <item type="id" name="action_shortcuts_and_notifications"/> <item type="id" name="action_dismiss_notification" /> <item type="id" name="action_remote_action_shortcut" /> <!-- QSB IDs. DO not change --> <item type="id" name="search_container_workspace" /> Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -347,4 +347,7 @@ <string name="work_mode_off_label">Notifications and apps are off</string> <string name="bottom_work_tab_user_education_close_button">Close</string> <string name="bottom_work_tab_user_education_closed">Closed</string> <!-- Failed action error message: e.g. Failed: Pause --> <string name="remote_action_failed">Failed: <xliff:g id="what" example="Pause">%1$s</xliff:g></string> </resources>
src/com/android/launcher3/popup/RemoteActionShortcut.java 0 → 100644 +72 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 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.launcher3.popup; import android.app.PendingIntent; import android.app.RemoteAction; import android.os.Handler; import android.os.Looper; import android.util.Log; import android.view.View; import android.widget.Toast; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.userevent.nano.LauncherLogProto; public class RemoteActionShortcut extends SystemShortcut<Launcher> { private static final String TAG = "RemoteActionShortcut"; private final RemoteAction mAction; public RemoteActionShortcut(RemoteAction action) { super(action.getIcon(), action.getTitle(), action.getContentDescription(), R.id.action_remote_action_shortcut); mAction = action; } @Override public View.OnClickListener getOnClickListener( final Launcher launcher, final ItemInfo itemInfo) { return view -> { AbstractFloatingView.closeAllOpenViews(launcher); try { mAction.getActionIntent().send(0, (pendingIntent, intent, resultCode, resultData, resultExtras) -> { if (resultData != null && !resultData.isEmpty()) { Log.e(TAG, "Remote action returned result: " + mAction.getTitle() + " : " + resultData); Toast.makeText(launcher, resultData, Toast.LENGTH_SHORT).show(); } }, new Handler(Looper.getMainLooper())); } catch (PendingIntent.CanceledException e) { Log.e(TAG, "Remote action canceled: " + mAction.getTitle(), e); Toast.makeText(launcher, launcher.getString( R.string.remote_action_failed, mAction.getTitle()), Toast.LENGTH_SHORT) .show(); } launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP, LauncherLogProto.ControlType.REMOTE_ACTION_SHORTCUT, view); }; } }
src/com/android/launcher3/popup/SystemShortcut.java +11 −5 Original line number Diff line number Diff line Loading @@ -6,8 +6,10 @@ import static com.android.launcher3.userevent.nano.LauncherLogProto.ControlType; import android.content.Context; import android.content.Intent; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; Loading Loading @@ -36,7 +38,7 @@ import java.util.List; public abstract class SystemShortcut<T extends BaseDraggingActivity> extends ItemInfo { private final int mIconResId; private final int mLabelResId; private final Drawable mIcon; private final Icon mIcon; private final CharSequence mLabel; private final CharSequence mContentDescription; private final int mAccessibilityActionId; Loading @@ -50,7 +52,7 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite mContentDescription = null; } public SystemShortcut(Drawable icon, CharSequence label, CharSequence contentDescription, public SystemShortcut(Icon icon, CharSequence label, CharSequence contentDescription, int accessibilityActionId) { mIcon = icon; mLabel = label; Loading @@ -71,7 +73,9 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite public void setIconAndLabelFor(View iconView, TextView labelView) { if (mIcon != null) { iconView.setBackground(mIcon); mIcon.loadDrawableAsync(iconView.getContext(), iconView::setBackground, new Handler(Looper.getMainLooper())); } else { iconView.setBackgroundResource(mIconResId); } Loading @@ -85,7 +89,9 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite public void setIconAndContentDescriptionFor(ImageView view) { if (mIcon != null) { view.setImageDrawable(mIcon); mIcon.loadDrawableAsync(view.getContext(), view::setImageDrawable, new Handler(Looper.getMainLooper())); } else { view.setImageResource(mIconResId); } Loading