Merge "Use a PopupWindow to show tooltips" into oc-dev

am: 8493543ce3

Change-Id: I4b026c2f273ee34860f8100b017c56fe627a2d1f
This commit is contained in:
Manu Cornet
2017-06-02 20:15:45 +00:00
committed by android-build-merger

View File

@@ -25,6 +25,7 @@ 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 {
@@ -32,6 +33,7 @@ public class TooltipPopup {
private final Context mContext;
private final PopupWindow mPopupWindow;
private final View mContentView;
private final TextView mMessageView;
@@ -43,6 +45,8 @@ 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(
@@ -70,17 +74,16 @@ public class TooltipPopup {
computePosition(anchorView, anchorX, anchorY, fromTouch, mLayoutParams);
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
wm.addView(mContentView, mLayoutParams);
mPopupWindow.setContentView(mContentView);
mPopupWindow.showAtLocation(
anchorView, mLayoutParams.gravity, mLayoutParams.x, mLayoutParams.y);
}
public void hide() {
if (!isShowing()) {
return;
}
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(mContentView);
mPopupWindow.dismiss();
}
public View getContentView() {
@@ -88,7 +91,7 @@ public class TooltipPopup {
}
public boolean isShowing() {
return mContentView.getParent() != null;
return mPopupWindow.isShowing();
}
public void updateContent(CharSequence tooltipText) {