Loading quickstep/src/com/android/quickstep/TaskSystemShortcut.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut protected T mSystemShortcut; protected TaskSystemShortcut(T systemShortcut) { super(systemShortcut.iconResId, systemShortcut.labelResId); super(systemShortcut); mSystemShortcut = systemShortcut; } Loading quickstep/src/com/android/quickstep/views/TaskMenuView.java +2 −2 Original line number Diff line number Diff line Loading @@ -208,8 +208,8 @@ public class TaskMenuView extends AbstractFloatingView { private void addMenuOption(TaskSystemShortcut menuOption, OnClickListener onClickListener) { ViewGroup menuOptionView = (ViewGroup) mActivity.getLayoutInflater().inflate( R.layout.task_view_menu_option, this, false); menuOptionView.findViewById(R.id.icon).setBackgroundResource(menuOption.iconResId); ((TextView) menuOptionView.findViewById(R.id.text)).setText(menuOption.labelResId); menuOption.setIconAndLabelFor( menuOptionView.findViewById(R.id.icon), menuOptionView.findViewById(R.id.text)); menuOptionView.setOnClickListener(onClickListener); mOptionLayout.addView(menuOptionView); } Loading quickstep/src/com/android/quickstep/views/TaskView.java +2 −3 Original line number Diff line number Diff line Loading @@ -387,8 +387,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) { OnClickListener onClickListener = menuOption.getOnClickListener(activity, this); if (onClickListener != null) { info.addAction(new AccessibilityNodeInfo.AccessibilityAction(menuOption.labelResId, context.getText(menuOption.labelResId))); info.addAction(menuOption.createAccessibilityAction(context)); } } Loading @@ -409,7 +408,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback } for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) { if (action == menuOption.labelResId) { if (menuOption.hasHandlerForAction(action)) { OnClickListener onClickListener = menuOption.getOnClickListener( fromContext(getContext()), this); if (onClickListener != null) { Loading src/com/android/launcher3/popup/PopupContainerWithArrow.java +2 −5 Original line number Diff line number Diff line Loading @@ -391,13 +391,10 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, if (view instanceof DeepShortcutView) { // Expanded system shortcut, with both icon and text shown on white background. final DeepShortcutView shortcutView = (DeepShortcutView) view; shortcutView.getIconView().setBackgroundResource(info.iconResId); shortcutView.getBubbleText().setText(info.labelResId); info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText()); } else if (view instanceof ImageView) { // Only the system shortcut icon shows on a gray background header. final ImageView shortcutIcon = (ImageView) view; shortcutIcon.setImageResource(info.iconResId); shortcutIcon.setContentDescription(getContext().getText(info.labelResId)); info.setIconAndContentDescriptionFor((ImageView) view); } view.setTag(info); view.setOnClickListener(info.getOnClickListener(mLauncher, Loading src/com/android/launcher3/popup/SystemShortcut.java +75 −6 Original line number Diff line number Diff line Loading @@ -3,10 +3,15 @@ package com.android.launcher3.popup; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action; 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.os.Bundle; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; import android.widget.TextView; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; Loading @@ -23,18 +28,82 @@ import com.android.launcher3.widget.WidgetsBottomSheet; import java.util.List; /** * Represents a system shortcut for a given app. The shortcut should have a static label and * icon, and an onClickListener that depends on the item that the shortcut services. * Represents a system shortcut for a given app. The shortcut should have a label and icon, and an * onClickListener that depends on the item that the shortcut services. * * Example system shortcuts, defined as inner classes, include Widgets and AppInfo. */ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends ItemInfo { public final int iconResId; public final int labelResId; private final int mIconResId; private final int mLabelResId; private final Drawable mIcon; private final CharSequence mLabel; private final CharSequence mContentDescription; private final int mAccessibilityActionId; public SystemShortcut(int iconResId, int labelResId) { this.iconResId = iconResId; this.labelResId = labelResId; mIconResId = iconResId; mLabelResId = labelResId; mAccessibilityActionId = labelResId; mIcon = null; mLabel = null; mContentDescription = null; } public SystemShortcut(Drawable icon, CharSequence label, CharSequence contentDescription, int accessibilityActionId) { mIcon = icon; mLabel = label; mContentDescription = contentDescription; mAccessibilityActionId = accessibilityActionId; mIconResId = 0; mLabelResId = 0; } public SystemShortcut(SystemShortcut other) { mIconResId = other.mIconResId; mLabelResId = other.mLabelResId; mIcon = other.mIcon; mLabel = other.mLabel; mContentDescription = other.mContentDescription; mAccessibilityActionId = other.mAccessibilityActionId; } public void setIconAndLabelFor(View iconView, TextView labelView) { if (mIcon != null) { iconView.setBackground(mIcon); } else { iconView.setBackgroundResource(mIconResId); } if (mLabel != null) { labelView.setText(mLabel); } else { labelView.setText(mLabelResId); } } public void setIconAndContentDescriptionFor(ImageView view) { if (mIcon != null) { view.setImageDrawable(mIcon); } else { view.setImageResource(mIconResId); } view.setContentDescription(getContentDescription(view.getContext())); } private CharSequence getContentDescription(Context context) { return mContentDescription != null ? mContentDescription : context.getText(mLabelResId); } public AccessibilityNodeInfo.AccessibilityAction createAccessibilityAction(Context context) { return new AccessibilityNodeInfo.AccessibilityAction(mAccessibilityActionId, getContentDescription(context)); } public boolean hasHandlerForAction(int action) { return mAccessibilityActionId == action; } public abstract View.OnClickListener getOnClickListener(T activity, ItemInfo itemInfo); Loading Loading
quickstep/src/com/android/quickstep/TaskSystemShortcut.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut protected T mSystemShortcut; protected TaskSystemShortcut(T systemShortcut) { super(systemShortcut.iconResId, systemShortcut.labelResId); super(systemShortcut); mSystemShortcut = systemShortcut; } Loading
quickstep/src/com/android/quickstep/views/TaskMenuView.java +2 −2 Original line number Diff line number Diff line Loading @@ -208,8 +208,8 @@ public class TaskMenuView extends AbstractFloatingView { private void addMenuOption(TaskSystemShortcut menuOption, OnClickListener onClickListener) { ViewGroup menuOptionView = (ViewGroup) mActivity.getLayoutInflater().inflate( R.layout.task_view_menu_option, this, false); menuOptionView.findViewById(R.id.icon).setBackgroundResource(menuOption.iconResId); ((TextView) menuOptionView.findViewById(R.id.text)).setText(menuOption.labelResId); menuOption.setIconAndLabelFor( menuOptionView.findViewById(R.id.icon), menuOptionView.findViewById(R.id.text)); menuOptionView.setOnClickListener(onClickListener); mOptionLayout.addView(menuOptionView); } Loading
quickstep/src/com/android/quickstep/views/TaskView.java +2 −3 Original line number Diff line number Diff line Loading @@ -387,8 +387,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) { OnClickListener onClickListener = menuOption.getOnClickListener(activity, this); if (onClickListener != null) { info.addAction(new AccessibilityNodeInfo.AccessibilityAction(menuOption.labelResId, context.getText(menuOption.labelResId))); info.addAction(menuOption.createAccessibilityAction(context)); } } Loading @@ -409,7 +408,7 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback } for (TaskSystemShortcut menuOption : TaskMenuView.MENU_OPTIONS) { if (action == menuOption.labelResId) { if (menuOption.hasHandlerForAction(action)) { OnClickListener onClickListener = menuOption.getOnClickListener( fromContext(getContext()), this); if (onClickListener != null) { Loading
src/com/android/launcher3/popup/PopupContainerWithArrow.java +2 −5 Original line number Diff line number Diff line Loading @@ -391,13 +391,10 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource, if (view instanceof DeepShortcutView) { // Expanded system shortcut, with both icon and text shown on white background. final DeepShortcutView shortcutView = (DeepShortcutView) view; shortcutView.getIconView().setBackgroundResource(info.iconResId); shortcutView.getBubbleText().setText(info.labelResId); info.setIconAndLabelFor(shortcutView.getIconView(), shortcutView.getBubbleText()); } else if (view instanceof ImageView) { // Only the system shortcut icon shows on a gray background header. final ImageView shortcutIcon = (ImageView) view; shortcutIcon.setImageResource(info.iconResId); shortcutIcon.setContentDescription(getContext().getText(info.labelResId)); info.setIconAndContentDescriptionFor((ImageView) view); } view.setTag(info); view.setOnClickListener(info.getOnClickListener(mLauncher, Loading
src/com/android/launcher3/popup/SystemShortcut.java +75 −6 Original line number Diff line number Diff line Loading @@ -3,10 +3,15 @@ package com.android.launcher3.popup; import static com.android.launcher3.userevent.nano.LauncherLogProto.Action; 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.os.Bundle; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.ImageView; import android.widget.TextView; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; Loading @@ -23,18 +28,82 @@ import com.android.launcher3.widget.WidgetsBottomSheet; import java.util.List; /** * Represents a system shortcut for a given app. The shortcut should have a static label and * icon, and an onClickListener that depends on the item that the shortcut services. * Represents a system shortcut for a given app. The shortcut should have a label and icon, and an * onClickListener that depends on the item that the shortcut services. * * Example system shortcuts, defined as inner classes, include Widgets and AppInfo. */ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends ItemInfo { public final int iconResId; public final int labelResId; private final int mIconResId; private final int mLabelResId; private final Drawable mIcon; private final CharSequence mLabel; private final CharSequence mContentDescription; private final int mAccessibilityActionId; public SystemShortcut(int iconResId, int labelResId) { this.iconResId = iconResId; this.labelResId = labelResId; mIconResId = iconResId; mLabelResId = labelResId; mAccessibilityActionId = labelResId; mIcon = null; mLabel = null; mContentDescription = null; } public SystemShortcut(Drawable icon, CharSequence label, CharSequence contentDescription, int accessibilityActionId) { mIcon = icon; mLabel = label; mContentDescription = contentDescription; mAccessibilityActionId = accessibilityActionId; mIconResId = 0; mLabelResId = 0; } public SystemShortcut(SystemShortcut other) { mIconResId = other.mIconResId; mLabelResId = other.mLabelResId; mIcon = other.mIcon; mLabel = other.mLabel; mContentDescription = other.mContentDescription; mAccessibilityActionId = other.mAccessibilityActionId; } public void setIconAndLabelFor(View iconView, TextView labelView) { if (mIcon != null) { iconView.setBackground(mIcon); } else { iconView.setBackgroundResource(mIconResId); } if (mLabel != null) { labelView.setText(mLabel); } else { labelView.setText(mLabelResId); } } public void setIconAndContentDescriptionFor(ImageView view) { if (mIcon != null) { view.setImageDrawable(mIcon); } else { view.setImageResource(mIconResId); } view.setContentDescription(getContentDescription(view.getContext())); } private CharSequence getContentDescription(Context context) { return mContentDescription != null ? mContentDescription : context.getText(mLabelResId); } public AccessibilityNodeInfo.AccessibilityAction createAccessibilityAction(Context context) { return new AccessibilityNodeInfo.AccessibilityAction(mAccessibilityActionId, getContentDescription(context)); } public boolean hasHandlerForAction(int action) { return mAccessibilityActionId == action; } public abstract View.OnClickListener getOnClickListener(T activity, ItemInfo itemInfo); Loading