Web browsing controls

I have a web view where you can go to the inline link. This link refers to the image, and I enable zooming when navigating to this image and turn it off when the user returns. This works great except for the zoom buttons. For some reason, they linger a bit when I return, and this allows the user to tinker with the zoom level of the web view, which is not intended to be enlarged. As soon as they disappear, they do not return, I just need to somehow turn them off right away, and not wait until they disappear. Any answers?

I will disable scaling as follows:

contentView.getSettings().setJavaScriptEnabled(false);
contentView.getSettings().setSupportZoom(false);
contentView.getSettings().setBuiltInZoomControls(false);

Edit:

It also crashes when I try to go back to the previous action when the controls are still showing. Here is a dump from him, if it helps to fix any problem.

FATAL EXCEPTION: main
java.lang.IllegalArgumentException: Receiver not registered: android.widget.ZoomButtonsController$1@47979810
    at android.app.ActivityThread$PackageInfo.forgetReceiverDispatcher(ActivityThread.java:859)
    at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:869)
    at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:331)
    at android.widget.ZoomButtonsController.setVisible(ZoomButtonsController.java:404)
    at android.widget.ZoomButtonsController$2.handleMessage(ZoomButtonsController.java:178)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:143)
    at android.app.ActivityThread.main(ActivityThread.java:5073)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    at dalvik.system.NativeStart.main(Native Method)

Edit2:

Here is some code, not sure how it helps

In onCreate function

contentView = (WebView) findViewById(R.id.message_content);
contentView.setWebViewClient(new WebViewClient()
{
    @Override
    public void onPageFinished(WebView view, String url )
    {
        if ( !url.startsWith("http") )
        {
            view.clearHistory();
        }
        else
        {
            contentView.getSettings().setJavaScriptEnabled(true);
            contentView.getSettings().setSupportZoom(true);
            contentView.getSettings().setBuiltInZoomControls(true);
            topButton.setText("Go back");
            topButton.setOnClickListener(backClick);
        }
    }

    @Override
    public boolean shouldOverrideUrlLoading( WebView view, String url )
    {
        view.loadUrl(url);              
        return true;
    }
});

And this is how I come back from the scaling page

@Override
public boolean onKeyDown( int keyCode, KeyEvent event )
{
    if ( keyCode == KeyEvent.KEYCODE_BACK )
    {
        if ( contentView.canGoBack() )
        {
            contentView.getSettings().setJavaScriptEnabled(false);
            contentView.getSettings().setSupportZoom(false);
            contentView.getSettings().setBuiltInZoomControls(false);
            topButton.setText("Add a comment");
            topButton.setOnClickListener(postClick);
            contentView.goBack();
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}
+3
source share
1 answer

You can always disable the built-in zoom controls and implement your own.

0
source

All Articles