Merge changes from topic 'sysui-tooltip' into oc-dev
am: 3fbcec5b86
Change-Id: I9ff9e36b3fa7c0e3c0bd4cd2048f9d0ce510399c
This commit is contained in:
@@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
import android.widget.PopupWindow;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class TooltipPopup {
|
public class TooltipPopup {
|
||||||
@@ -33,7 +32,6 @@ public class TooltipPopup {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
private final PopupWindow mPopupWindow;
|
|
||||||
private final View mContentView;
|
private final View mContentView;
|
||||||
private final TextView mMessageView;
|
private final TextView mMessageView;
|
||||||
|
|
||||||
@@ -45,8 +43,6 @@ public class TooltipPopup {
|
|||||||
public TooltipPopup(Context context) {
|
public TooltipPopup(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
|
||||||
mPopupWindow = new PopupWindow(context);
|
|
||||||
mPopupWindow.setBackgroundDrawable(null);
|
|
||||||
mContentView = LayoutInflater.from(mContext).inflate(
|
mContentView = LayoutInflater.from(mContext).inflate(
|
||||||
com.android.internal.R.layout.tooltip, null);
|
com.android.internal.R.layout.tooltip, null);
|
||||||
mMessageView = (TextView) mContentView.findViewById(
|
mMessageView = (TextView) mContentView.findViewById(
|
||||||
@@ -74,16 +70,17 @@ public class TooltipPopup {
|
|||||||
|
|
||||||
computePosition(anchorView, anchorX, anchorY, fromTouch, mLayoutParams);
|
computePosition(anchorView, anchorX, anchorY, fromTouch, mLayoutParams);
|
||||||
|
|
||||||
mPopupWindow.setContentView(mContentView);
|
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||||
mPopupWindow.showAtLocation(
|
wm.addView(mContentView, mLayoutParams);
|
||||||
anchorView, mLayoutParams.gravity, mLayoutParams.x, mLayoutParams.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
if (!isShowing()) {
|
if (!isShowing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mPopupWindow.dismiss();
|
|
||||||
|
WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
wm.removeView(mContentView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getContentView() {
|
public View getContentView() {
|
||||||
@@ -91,7 +88,7 @@ public class TooltipPopup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowing() {
|
public boolean isShowing() {
|
||||||
return mPopupWindow.isShowing();
|
return mContentView.getParent() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateContent(CharSequence tooltipText) {
|
public void updateContent(CharSequence tooltipText) {
|
||||||
@@ -100,6 +97,8 @@ public class TooltipPopup {
|
|||||||
|
|
||||||
private void computePosition(View anchorView, int anchorX, int anchorY, boolean fromTouch,
|
private void computePosition(View anchorView, int anchorX, int anchorY, boolean fromTouch,
|
||||||
WindowManager.LayoutParams outParams) {
|
WindowManager.LayoutParams outParams) {
|
||||||
|
outParams.token = anchorView.getWindowToken();
|
||||||
|
|
||||||
final int tooltipPreciseAnchorThreshold = mContext.getResources().getDimensionPixelOffset(
|
final int tooltipPreciseAnchorThreshold = mContext.getResources().getDimensionPixelOffset(
|
||||||
com.android.internal.R.dimen.tooltip_precise_anchor_threshold);
|
com.android.internal.R.dimen.tooltip_precise_anchor_threshold);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user