use of android.view.WindowManager in project GT by Tencent.
the class DeviceUtils method getDevHeight.
/**
* 获取设备屏幕高度
*
* @param context
* 应用程序的上下文环境
* @return 设备屏幕高度
*/
public static int getDevHeight() {
WindowManager wm = (WindowManager) GTApp.getContext().getSystemService(Context.WINDOW_SERVICE);
int height = 800;
if (null != wm.getDefaultDisplay()) {
height = wm.getDefaultDisplay().getHeight();
}
return height;
}
use of android.view.WindowManager in project GT by Tencent.
the class DeviceUtils method getDevWidth.
/**
* 获取设备屏幕宽度
*
* @param context
* 应用程序的上下文环境
* @return 设备屏幕宽度
*/
public static int getDevWidth() {
WindowManager wm = (WindowManager) GTApp.getContext().getSystemService(Context.WINDOW_SERVICE);
int width = 480;
if (null != wm.getDefaultDisplay()) {
width = wm.getDefaultDisplay().getWidth();
}
return width;
}
use of android.view.WindowManager in project GT by Tencent.
the class GTFloatView method createView.
private void createView() {
wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
wmParams = new WindowManager.LayoutParams();
wmParams.type = 2002;
wmParams.flags |= 8;
wmParams.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | 8;
// 调整悬浮窗口至左上角
wmParams.gravity = Gravity.LEFT | Gravity.TOP;
wmParams.x = 0;
wmParams.y = 0;
wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
wmParams.format = 1;
try {
wm.addView(view_floatview, wmParams);
} catch (Exception e) {
/*
* 有的Android6会报permission denied for this window type问题
* https://github.com/intercom/intercom-android/issues/116
* 在这种系统上直接屏蔽悬浮窗
*/
stopSelf();
return;
}
final int sbar_height = DeviceUtils.getStatusBarHeight(getApplicationContext());
view_floatview.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
x = event.getRawX();
y = event.getRawY() - sbar_height;
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
move_event = false;
up_event = false;
state = MotionEvent.ACTION_DOWN;
StartX = x;
StartY = y;
mTouchStartX = event.getX();
mTouchStartY = event.getY();
touchX = mTouchStartX;
touchY = mTouchStartY;
ProX = event.getRawX();
ProY = event.getRawY();
clickHandler.sendEmptyMessage(0);
break;
case MotionEvent.ACTION_MOVE:
state = MotionEvent.ACTION_MOVE;
moveX = event.getRawX();
moveY = event.getRawY();
final ViewConfiguration configuration = ViewConfiguration.get(getApplicationContext());
int mTouchSlop = configuration.getScaledTouchSlop();
// 第一次move
if (move_oldX == -1000 && move_oldY == -1000) {
move_oldX = moveX;
move_oldY = moveY;
if (Math.abs(moveX - ProX) < mTouchSlop * 2 && Math.abs(moveY - ProY) < mTouchSlop * 2) {
move_event = false;
} else {
move_event = true;
updateViewPosition();
}
} else {
if (move_event == false) {
if (Math.abs(moveX - move_oldX) < mTouchSlop * 2 && Math.abs(moveY - move_oldY) < mTouchSlop * 2) {
move_event = false;
} else {
move_event = true;
updateViewPosition();
}
} else {
updateViewPosition();
}
}
break;
case MotionEvent.ACTION_UP:
state = MotionEvent.ACTION_UP;
updateViewPositionEnd();
move_oldX = -1000;
move_oldY = -1000;
mTouchStartX = mTouchStartY = 0;
up_event = true;
clickHandler.sendEmptyMessage(1);
break;
}
return true;
}
});
}
use of android.view.WindowManager in project cornerstone by Onskreen.
the class PhoneWindowManager method enablePointerLocation.
private void enablePointerLocation() {
if (mPointerLocationView == null) {
mPointerLocationView = new PointerLocationView(mContext);
mPointerLocationView.setPrintCoords(false);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
lp.format = PixelFormat.TRANSLUCENT;
lp.setTitle("PointerLocation");
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL;
wm.addView(mPointerLocationView, lp);
mPointerLocationInputChannel = mWindowManagerFuncs.monitorInput("PointerLocationView");
mPointerLocationInputEventReceiver = new PointerLocationInputEventReceiver(mPointerLocationInputChannel, Looper.myLooper(), mPointerLocationView);
}
}
use of android.view.WindowManager in project LuaViewSDK by alibaba.
the class AndroidUtil method getAppUsableScreenSize.
public static Point getAppUsableScreenSize(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}
Aggregations