WindowManager не пропускает щелчок к представлению ниже в OREO - PullRequest
0 голосов
/ 08 января 2019

просто хочет нарисовать линию в виде наложения, но она перестает передавать изображение, показанное ниже, на устройствах OREO.

Приведенный ниже код работает нормально на старых устройствах ..

public View initiateBackView() {

        int LAYOUT_FLAG = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? WindowManager.
                LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

        lineParams = new WindowManager.LayoutParams(
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                ///WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
                LAYOUT_FLAG,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                ///WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
                ///WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                        //|
                   /*WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                        | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                        | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                        | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        //| WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                        | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,*/
                PixelFormat.TRANSLUCENT);


        lineParams.gravity = Gravity.LEFT | Gravity.TOP;
        lineParams.x = 0;
        lineParams.y = 1000;
        getNewLineView();

        try {
            // FIXME: 08/04/2018 added twice that's why
            wm.addView(lineView, lineParams);
        } catch (WindowManager.BadTokenException e) {
            e.printStackTrace();
        }
        return lineView;
    }

    private void getNewLineView() {
        lineView = new DrawView(mContext);
        lineView.setId(LINE_VIEW_ID);

        SharedPreferences prefs = mContext.getSharedPreferences("myPref",
                Context.MODE_PRIVATE);
        lineView.setStartX(prefs.getInt("startX", offsetFromScreen));
        lineView.setStartY(prefs.getInt("startY", offsetFromScreen));
        lineView.setEndX(prefs.getInt("endX", widthInPixels - offsetFromScreen));//200
        lineView.setEndY(prefs.getInt("endY", heightInPixels - offsetFromScreen));//200
        lineView.setMidX(prefs.getInt("midX", widthInPixels/2));//100
        lineView.setMidY(prefs.getInt("midY", heightInPixels/2));//100
        lineView.setAngleX(prefs.getInt("angleX", 50));//50
        lineView.setAngleY(prefs.getInt("angleY", 50));//50
    }
...