@SuppressLint("SetJavaScriptEnabled")
  protected void loginWebview(final OsmOAuth.AuthType type) {
    final WebView webview = new InputWebView(mFragment.getActivity());
    webview.getSettings().setJavaScriptEnabled(true);
    final AlertDialog dialog =
        new AlertDialog.Builder(mFragment.getActivity()).setView(webview).create();

    ThreadPool.getWorker()
        .execute(
            new Runnable() {
              @Override
              public void run() {
                final String[] auth =
                    (type == OsmOAuth.AuthType.FACEBOOK)
                        ? OsmOAuth.nativeGetFacebookAuthUrl()
                        : OsmOAuth.nativeGetGoogleAuthUrl();

                UiThread.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (mFragment.isAdded()) loadWebviewAuth(dialog, webview, auth, type);
                      }
                    });
              }
            });

    dialog.show();
  }
 protected void finishWebviewAuth(
     final String key, final String secret, final String verifier, final OsmOAuth.AuthType type) {
   ThreadPool.getWorker()
       .execute(
           new Runnable() {
             @Override
             public void run() {
               final String[] auth = OsmOAuth.nativeAuthWithWebviewToken(key, secret, verifier);
               final String username =
                   auth == null ? null : OsmOAuth.nativeGetOsmUsername(auth[0], auth[1]);
               UiThread.run(
                   new Runnable() {
                     @Override
                     public void run() {
                       processAuth(auth, type, username);
                     }
                   });
             }
           });
 }