I'm make floating webview target android 9.0

FullScreen mode text select well But, floating mode(TYPE_PHONE and TYPE_APLICATION_OVERAY) Highlight text and select not work(0.1s show then invisible . log cat say abandon )

Here some log when clicking webview in floating

''' Action down

01:37:16.417 com.jw.webviewtest D/SmartSelectEventTracker: New selection session: webview (f63a19d4a2d9)

01:37:16.418 com.jw.webviewtest D/SmartSelectEventTracker: 0: SELECTION_STARTED/, range=0,1 - smart_range=0,0 (webview/)

01:37:16.624 com.jw.webviewtest D/SmartSelectEventTracker: 1: SMART_SELECTION_SINGLE/other, range=0,1 - smart_range=0,1 (webview/)

01:37:16.630 com.jw.webviewtest D/SmartSelectEventTracker: 2: ABANDON/, range=0,1 - smart_range=0,1 (webview/)

Action up '''

What is smart select abandon?

Android WebView input type="text" cursor not showing ->it's not work my app

Android WebView - Text Selection Listener in 2018 ->my app have not actionbar

'''

import static android.content.Context.WINDOW_SERVICE;

public class FloatViewManager extends Activity {
    private static boolean mIsFloatViewShowing;

private Activity mActivity;
private WindowManager mWindowManager;
private View mFloatView;
private WindowManager.LayoutParams mFloatViewLayoutParams;
private boolean mFloatViewTouchConsumedByMove = false;
private int mFloatViewLastX;
private int mFloatViewLastY;
private int mFloatViewFirstX;
private int mFloatViewFirstY;
    public FloatViewManager(Activity activity) {
    mActivity = activity;
    LayoutInflater inflater = (LayoutInflater)activity.getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
    mFloatView = inflater.inflate(R.layout.activity_main, null)

    WebView mWebView = (WebView)mFloatView.findViewById(R.id.webViewMain);

    mWebView.setWebViewClient(new browserClient());
    mWebView.setWebChromeClient(new WebChromeClient());

    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.loadUrl("https://www.winehq.org");

    mFloatView.setOnClickListener(mFloatViewOnClickListener);
   mFloatView.setOnTouchListener(mFloatViewOnTouchListener);

    mFloatViewLayoutParams = new WindowManager.LayoutParams();
    mFloatViewLayoutParams.format = PixelFormat.TRANSLUCENT;
    mFloatViewLayoutParams.flags = WindowManager.LayoutParams.FORMAT_CHANGED;
    mFloatViewLayoutParams.type = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
          ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
           : WindowManager.LayoutParams.TYPE_PHONE;

    mFloatViewLayoutParams.gravity = Gravity.CENTER;
    mFloatViewLayoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mFloatViewLayoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;

}

'''

public void dismissFloatView() {
    if (mIsFloatViewShowing) {
        mIsFloatViewShowing = false;
        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (mWindowManager != null) {
                    mWindowManager.removeViewImmediate(mFloatView);
                }
            }
        });
    }
}

public void showFloatView() {
    if (!mIsFloatViewShowing) {
        mIsFloatViewShowing = true;
        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (!mActivity.isFinishing()) {
                    mWindowManager = (WindowManager) mActivity.getSystemService(WINDOW_SERVICE);
                    if (mWindowManager != null) {
                        mWindowManager.addView(mFloatView, mFloatViewLayoutParams);
                    }
                }
            }
        });
    }
}

@SuppressWarnings("FieldCanBeLocal")
private View.OnClickListener mFloatViewOnClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(mActivity, "Float view is clicked!", Toast.LENGTH_SHORT).show();
            }
        });
    }
};

@SuppressWarnings("FieldCanBeLocal")
private View.OnTouchListener mFloatViewOnTouchListener = new View.OnTouchListener() {

    @SuppressLint("ClickableViewAccessibility")
    @TargetApi(Build.VERSION_CODES.FROYO)
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        WindowManager.LayoutParams prm = mFloatViewLayoutParams;
        int totalDeltaX = mFloatViewLastX - mFloatViewFirstX;
        int totalDeltaY = mFloatViewLastY - mFloatViewFirstY;

0 Answers