summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2016-12-08 19:25:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-12-08 19:25:53 +0000
commitac30b3bb5fc60d01549f35b4e503ac87f7e181d2 (patch)
treedff4bad81a822f482d1da855529ac66fcabebc91 /core/java/android
parente67e2a28ed3c824910d7f5247d4802fd513608dd (diff)
parentb265617b810082ec743389fa0468d1df91d66f68 (diff)
Merge "Replace Toast-based cheat sheets with tooltips"
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/MediaRouteActionProvider.java1
-rw-r--r--core/java/android/app/MediaRouteButton.java58
2 files changed, 4 insertions, 55 deletions
diff --git a/core/java/android/app/MediaRouteActionProvider.java b/core/java/android/app/MediaRouteActionProvider.java
index dffa969a7148..85ca0123c5d3 100644
--- a/core/java/android/app/MediaRouteActionProvider.java
+++ b/core/java/android/app/MediaRouteActionProvider.java
@@ -119,7 +119,6 @@ public class MediaRouteActionProvider extends ActionProvider {
}
mButton = new MediaRouteButton(mContext);
- mButton.setCheatSheetEnabled(true);
mButton.setRouteTypes(mRouteTypes);
mButton.setExtendedSettingsClickListener(mExtendedSettingsListener);
mButton.setLayoutParams(new ViewGroup.LayoutParams(
diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java
index 70a5e15c6c27..09e95dfa3044 100644
--- a/core/java/android/app/MediaRouteButton.java
+++ b/core/java/android/app/MediaRouteButton.java
@@ -24,18 +24,13 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.TypedArray;
import android.graphics.Canvas;
-import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.media.MediaRouter;
import android.media.MediaRouter.RouteGroup;
import android.media.MediaRouter.RouteInfo;
-import android.text.TextUtils;
import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.HapticFeedbackConstants;
import android.view.SoundEffectConstants;
import android.view.View;
-import android.widget.Toast;
public class MediaRouteButton extends View {
private final MediaRouter mRouter;
@@ -47,7 +42,6 @@ public class MediaRouteButton extends View {
private Drawable mRemoteIndicator;
private boolean mRemoteActive;
- private boolean mCheatSheetEnabled;
private boolean mIsConnecting;
private int mMinWidth;
@@ -98,7 +92,6 @@ public class MediaRouteButton extends View {
a.recycle();
setClickable(true);
- setLongClickable(true);
setRouteTypes(routeTypes);
}
@@ -178,12 +171,10 @@ public class MediaRouteButton extends View {
throw new IllegalStateException("The MediaRouteButton's Context is not an Activity.");
}
- /**
- * Sets whether to enable showing a toast with the content descriptor of the
- * button when the button is long pressed.
- */
- void setCheatSheetEnabled(boolean enable) {
- mCheatSheetEnabled = enable;
+ @Override
+ public void setContentDescription(CharSequence contentDescription) {
+ super.setContentDescription(contentDescription);
+ setTooltip(contentDescription);
}
@Override
@@ -197,47 +188,6 @@ public class MediaRouteButton extends View {
}
@Override
- public boolean performLongClick() {
- if (super.performLongClick()) {
- return true;
- }
-
- if (!mCheatSheetEnabled) {
- return false;
- }
-
- final CharSequence contentDesc = getContentDescription();
- if (TextUtils.isEmpty(contentDesc)) {
- // Don't show the cheat sheet if we have no description
- return false;
- }
-
- final int[] screenPos = new int[2];
- final Rect displayFrame = new Rect();
- getLocationOnScreen(screenPos);
- getWindowVisibleDisplayFrame(displayFrame);
-
- final Context context = getContext();
- final int width = getWidth();
- final int height = getHeight();
- final int midy = screenPos[1] + height / 2;
- final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
-
- Toast cheatSheet = Toast.makeText(context, contentDesc, Toast.LENGTH_SHORT);
- if (midy < displayFrame.height()) {
- // Show along the top; follow action buttons
- cheatSheet.setGravity(Gravity.TOP | Gravity.END,
- screenWidth - screenPos[0] - width / 2, height);
- } else {
- // Show along the bottom center
- cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
- }
- cheatSheet.show();
- performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
- return true;
- }
-
- @Override
protected int[] onCreateDrawableState(int extraSpace) {
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);