Search in sources :

Example 61 with WindowManager

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;
}
Also used : WindowManager(android.view.WindowManager)

Example 62 with WindowManager

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;
}
Also used : WindowManager(android.view.WindowManager)

Example 63 with WindowManager

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;
        }
    });
}
Also used : ViewConfiguration(android.view.ViewConfiguration) OnTouchListener(android.view.View.OnTouchListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) WindowManager(android.view.WindowManager) MotionEvent(android.view.MotionEvent)

Example 64 with WindowManager

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);
    }
}
Also used : PointerLocationView(com.android.internal.widget.PointerLocationView) IWindowManager(android.view.IWindowManager) WindowManager(android.view.WindowManager)

Example 65 with WindowManager

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;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Aggregations

WindowManager (android.view.WindowManager)409 Display (android.view.Display)185 Point (android.graphics.Point)129 DisplayMetrics (android.util.DisplayMetrics)103 View (android.view.View)43 IWindowManager (android.view.IWindowManager)37 Context (android.content.Context)36 Resources (android.content.res.Resources)25 ImageView (android.widget.ImageView)24 Configuration (android.content.res.Configuration)20 SuppressLint (android.annotation.SuppressLint)19 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 Rect (android.graphics.Rect)16 RemoteException (android.os.RemoteException)15 LayoutParams (android.view.WindowManager.LayoutParams)15 TextView (android.widget.TextView)15 Dialog (android.app.Dialog)14 Method (java.lang.reflect.Method)12 PackageManager (android.content.pm.PackageManager)11