diff --git a/api/current.txt b/api/current.txt index f21d18faf9b26..9355408f929ae 100644 --- a/api/current.txt +++ b/api/current.txt @@ -5717,6 +5717,8 @@ package android.app { method public java.lang.CharSequence getContentDescription(); method public android.graphics.drawable.Icon getIcon(); method public java.lang.CharSequence getTitle(); + method public boolean isEnabled(); + method public void setEnabled(boolean); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } diff --git a/api/system-current.txt b/api/system-current.txt index 26d43e3891286..821d6e6571ebe 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5920,6 +5920,8 @@ package android.app { method public java.lang.CharSequence getContentDescription(); method public android.graphics.drawable.Icon getIcon(); method public java.lang.CharSequence getTitle(); + method public boolean isEnabled(); + method public void setEnabled(boolean); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } diff --git a/api/test-current.txt b/api/test-current.txt index 49bab6f67f812..e5ce7909b241c 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -5728,6 +5728,8 @@ package android.app { method public java.lang.CharSequence getContentDescription(); method public android.graphics.drawable.Icon getIcon(); method public java.lang.CharSequence getTitle(); + method public boolean isEnabled(); + method public void setEnabled(boolean); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } diff --git a/core/java/android/app/RemoteAction.java b/core/java/android/app/RemoteAction.java index 5958bc14d4746..e7fe407b29b33 100644 --- a/core/java/android/app/RemoteAction.java +++ b/core/java/android/app/RemoteAction.java @@ -41,12 +41,14 @@ public final class RemoteAction implements Parcelable { private final CharSequence mTitle; private final CharSequence mContentDescription; private final PendingIntent mActionIntent; + private boolean mEnabled; RemoteAction(Parcel in) { mIcon = Icon.CREATOR.createFromParcel(in); mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); mActionIntent = PendingIntent.CREATOR.createFromParcel(in); + mEnabled = in.readBoolean(); } public RemoteAction(@NonNull Icon icon, @NonNull CharSequence title, @@ -59,6 +61,21 @@ public final class RemoteAction implements Parcelable { mTitle = title; mContentDescription = contentDescription; mActionIntent = intent; + mEnabled = true; + } + + /** + * Sets whether this action is enabled. + */ + public void setEnabled(boolean enabled) { + mEnabled = enabled; + } + + /** + * Return whether this action is enabled. + */ + public boolean isEnabled() { + return mEnabled; } /** @@ -91,7 +108,9 @@ public final class RemoteAction implements Parcelable { @Override public RemoteAction clone() { - return new RemoteAction(mIcon, mTitle, mContentDescription, mActionIntent); + RemoteAction action = new RemoteAction(mIcon, mTitle, mContentDescription, mActionIntent); + action.setEnabled(mEnabled); + return action; } @Override @@ -105,11 +124,13 @@ public final class RemoteAction implements Parcelable { TextUtils.writeToParcel(mTitle, out, flags); TextUtils.writeToParcel(mContentDescription, out, flags); mActionIntent.writeToParcel(out, flags); + out.writeBoolean(mEnabled); } public void dump(String prefix, PrintWriter pw) { pw.print(prefix); pw.print("title=" + mTitle); + pw.print(" enabled=" + mEnabled); pw.print(" contentDescription=" + mContentDescription); pw.print(" icon=" + mIcon); pw.print(" action=" + mActionIntent.getIntent()); diff --git a/packages/SystemUI/res/layout/pip_menu_action.xml b/packages/SystemUI/res/layout/pip_menu_action.xml index 77efc9be5bc82..9150a000de004 100644 --- a/packages/SystemUI/res/layout/pip_menu_action.xml +++ b/packages/SystemUI/res/layout/pip_menu_action.xml @@ -18,4 +18,5 @@ android:layout_width="@dimen/pip_action_size" android:layout_height="@dimen/pip_action_size" android:padding="@dimen/pip_action_padding" - android:background="?android:selectableItemBackgroundBorderless" /> \ No newline at end of file + android:background="?android:selectableItemBackgroundBorderless" + android:forceHasOverlappingRendering="false" /> \ No newline at end of file diff --git a/packages/SystemUI/res/layout/pip_menu_activity.xml b/packages/SystemUI/res/layout/pip_menu_activity.xml index c6837fa30925f..44ced1736f658 100644 --- a/packages/SystemUI/res/layout/pip_menu_activity.xml +++ b/packages/SystemUI/res/layout/pip_menu_activity.xml @@ -23,7 +23,8 @@ + android:layout_height="match_parent" + android:forceHasOverlappingRendering="false"> mActions = new ArrayList<>(); private View mViewRoot; @@ -371,13 +371,18 @@ public class PipMenuActivity extends Activity { actionView.setImageDrawable(d); }, mHandler); actionView.setContentDescription(action.getContentDescription()); - actionView.setOnClickListener(v -> { - try { - action.getActionIntent().send(); - } catch (CanceledException e) { - Log.w(TAG, "Failed to send action", e); - } - }); + if (action.isEnabled()) { + actionView.setOnClickListener(v -> { + try { + action.getActionIntent().send(); + } catch (CanceledException e) { + Log.w(TAG, "Failed to send action", e); + } + }); + } else { + actionView.setAlpha(DISABLED_ACTION_ALPHA); + actionView.setEnabled(false); + } if (isLandscapePip && i > 0) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) actionView.getLayoutParams();