summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-03-17 17:51:40 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-03-17 17:51:45 +0000
commit6e4075bde6be784bf13336cae40c4654a0de01e4 (patch)
treebedba13e94c5e7e4bca6e4d421e2cba9f023e7ba
parentb2312cdbb6507b27154c32ece2adc789e071a1db (diff)
parent6b88baf1e8cf85f0e44054464824c3af76b2b6ce (diff)
Merge "Adding enabled state for remote actions."
-rw-r--r--api/current.txt2
-rw-r--r--api/system-current.txt2
-rw-r--r--api/test-current.txt2
-rw-r--r--core/java/android/app/RemoteAction.java23
-rw-r--r--packages/SystemUI/res/layout/pip_menu_action.xml3
-rw-r--r--packages/SystemUI/res/layout/pip_menu_activity.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java25
7 files changed, 47 insertions, 13 deletions
diff --git a/api/current.txt b/api/current.txt
index f21d18faf9b2..9355408f929a 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<android.app.RemoteAction> CREATOR;
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 26d43e389128..821d6e6571eb 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<android.app.RemoteAction> CREATOR;
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 49bab6f67f81..e5ce7909b241 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<android.app.RemoteAction> CREATOR;
}
diff --git a/core/java/android/app/RemoteAction.java b/core/java/android/app/RemoteAction.java
index 5958bc14d474..e7fe407b29b3 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 77efc9be5bc8..9150a000de00 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 c6837fa30925..44ced1736f65 100644
--- a/packages/SystemUI/res/layout/pip_menu_activity.xml
+++ b/packages/SystemUI/res/layout/pip_menu_activity.xml
@@ -23,7 +23,8 @@
<FrameLayout
android:id="@+id/menu_container"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:forceHasOverlappingRendering="false">
<ImageView
android:id="@+id/dismiss"
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index 0547cbb4dd92..9cb518cfe2e7 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -19,8 +19,8 @@ package com.android.systemui.pip.phone;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_ACTIONS;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_CONTROLLER_MESSENGER;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_MOVEMENT_BOUNDS;
-import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_STACK_BOUNDS;
import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_SHOW_MENU;
+import static com.android.systemui.pip.phone.PipMenuActivityController.EXTRA_STACK_BOUNDS;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -33,13 +33,11 @@ import android.app.PendingIntent.CanceledException;
import android.app.RemoteAction;
import android.content.Intent;
import android.content.pm.ParceledListSlice;
-import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -84,6 +82,8 @@ public class PipMenuActivity extends Activity {
private static final float MENU_BACKGROUND_ALPHA = 0.3f;
private static final float DISMISS_BACKGROUND_ALPHA = 0.8f;
+ private static final float DISABLED_ACTION_ALPHA = 0.54f;
+
private boolean mMenuVisible;
private final List<RemoteAction> 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();