diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-06-12 21:42:50 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-06-12 21:42:57 +0000 |
| commit | 3fbcec5b86c5021783fed830dc015b926c1981e6 (patch) | |
| tree | a8e184cc2b1978bfba60634e0c5fcfdddabfaf6d /core/java | |
| parent | 7c2a12b658160ae98705c54d60117d7914ef58fc (diff) | |
| parent | d85915f78694dc15ee9ca1bbdbccffc183399810 (diff) | |
Merge changes from topic 'sysui-tooltip' into oc-dev
* changes:
Pass window token when creating a tooltip popup
Revert "Use a PopupWindow to show tooltips"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/view/TooltipPopup.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/core/java/com/android/internal/view/TooltipPopup.java b/core/java/com/android/internal/view/TooltipPopup.java index d834e6383acd..52357ac486c2 100644 --- a/core/java/com/android/internal/view/TooltipPopup.java +++ b/core/java/com/android/internal/view/TooltipPopup.java @@ -25,7 +25,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.view.WindowManagerGlobal; -import android.widget.PopupWindow; import android.widget.TextView; public class TooltipPopup { @@ -33,7 +32,6 @@ public class TooltipPopup { private final Context mContext; - private final PopupWindow mPopupWindow; private final View mContentView; private final TextView mMessageView; @@ -45,8 +43,6 @@ public class TooltipPopup { public TooltipPopup(Context context) { mContext = context; - mPopupWindow = new PopupWindow(context); - mPopupWindow.setBackgroundDrawable(null); mContentView = LayoutInflater.from(mContext).inflate( com.android.internal.R.layout.tooltip, null); mMessageView = (TextView) mContentView.findViewById( @@ -74,16 +70,17 @@ public class TooltipPopup { computePosition(anchorView, anchorX, anchorY, fromTouch, mLayoutParams); - mPopupWindow.setContentView(mContentView); - mPopupWindow.showAtLocation( - anchorView, mLayoutParams.gravity, mLayoutParams.x, mLayoutParams.y); + WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); + wm.addView(mContentView, mLayoutParams); } public void hide() { if (!isShowing()) { return; } - mPopupWindow.dismiss(); + + WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); + wm.removeView(mContentView); } public View getContentView() { @@ -91,7 +88,7 @@ public class TooltipPopup { } public boolean isShowing() { - return mPopupWindow.isShowing(); + return mContentView.getParent() != null; } public void updateContent(CharSequence tooltipText) { @@ -100,6 +97,8 @@ public class TooltipPopup { private void computePosition(View anchorView, int anchorX, int anchorY, boolean fromTouch, WindowManager.LayoutParams outParams) { + outParams.token = anchorView.getWindowToken(); + final int tooltipPreciseAnchorThreshold = mContext.getResources().getDimensionPixelOffset( com.android.internal.R.dimen.tooltip_precise_anchor_threshold); |
