Java Code Examples for android.webkit.WebView#setVisibility()

The following examples show how to use android.webkit.WebView#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebDialog.java    From platform-friends-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 2
Source File: WebViewDialog.java    From cloudflare-scrape-Android with MIT License 6 votes vote down vote up
private void initWebView(){
    mWebView = new WebView(mContext);
    ConstraintLayout.LayoutParams layoutParams =
            new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
    layoutParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
    mWebView.setLayoutParams(layoutParams);
    mWebView.setId(R.id.webview);
    mWebView.setVisibility(View.INVISIBLE);
    mLayout.addView(mWebView,-1);
    mAdvanceWebClient = new AdvanceWebClient(getContext(), mWebView,mUser_agent);
    mAdvanceWebClient.setListener(mLoginSuccessListener);
    mAdvanceWebClient.initWebView("https://" + mUrl.getHost());
}
 
Example 3
Source File: WebDialog.java    From FacebookImageShareIntent with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 4
Source File: WebDialog.java    From KlyphMessenger with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 5
Source File: WeiboDialog.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void initWebView()
{
    mWebViewContainer = new RelativeLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSavePassword(false);
    mWebView.setWebViewClient(new WeiboWebViewClient(null));
    mWebView.requestFocus();
    mWebView.setScrollBarStyle(0);
    mWebView.setVisibility(4);
    NetworkHelper.clearCookies(mContext, mAuthUrl);
    mWebView.loadUrl(mAuthUrl);
    android.widget.RelativeLayout.LayoutParams layoutparams = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    android.widget.RelativeLayout.LayoutParams layoutparams1 = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
    int i = (int)(10F * displaymetrics.density);
    layoutparams1.setMargins(i, i, i, i);
    Drawable drawable = ResourceManager.getNinePatchDrawable(mContext, 1);
    mWebViewContainer.setBackgroundDrawable(drawable);
    mWebViewContainer.addView(mWebView, layoutparams1);
    mWebViewContainer.setGravity(17);
    int j = 1 + ResourceManager.getDrawable(mContext, 2).getIntrinsicWidth() / 2;
    layoutparams.setMargins(j, (int)(25F * displaymetrics.density), j, j);
    mRootContainer.addView(mWebViewContainer, layoutparams);
}
 
Example 6
Source File: WebDialog.java    From Abelana-Android with Apache License 2.0 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 7
Source File: LxwBlogActivity.java    From stynico with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState)
    {
	super.onCreate(savedInstanceState);

	setContentView(R.layout.lxw_blog);

	initInstances();
	toolbar = (android.support.v7.widget.Toolbar)
	    findViewById(R.id.toolbar);
//		初始化Toolbar控件
	setSupportActionBar(toolbar);
//		用Toolbar取代ActionBar
	//toolbar.setTitleTextColor(getResources().getColor(R.color.text_font_white));//标题颜色
	//	toolbar.setSubtitleTextColor(getResources().getColor(R.color.text_font_white));//副标题颜色

	webview = (WebView) findViewById(R.id.webView);
//设置WebView属性,能够执行Javascript脚本

	webview.setVisibility(View.GONE);

	webview.getSettings().setJavaScriptEnabled(true);
//加载需要显示的网页
//设置Web视图
	webview.setWebViewClient(new HelloWebViewClient());
    }
 
Example 8
Source File: WebDialog.java    From android-skeleton-project with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setSaveFormData(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    webViewContainer.setBackgroundColor(BACKGROUND_GRAY);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 9
Source File: WebDialog.java    From facebooklogin with MIT License 6 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    LinearLayout webViewContainer = new LinearLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url);
    webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                                                         ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSavePassword(false);

    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    contentFrameLayout.addView(webViewContainer);
}
 
Example 10
Source File: LoginActivity.java    From android_packages_apps_GmsCore with Apache License 2.0 5 votes vote down vote up
private static WebView createWebView(Context context) {
    WebView webView = new WebView(context);
    if (SDK_INT < LOLLIPOP) {
        webView.setVisibility(VISIBLE);
    } else {
        webView.setVisibility(INVISIBLE);
    }
    webView.setLayoutParams(new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setBackgroundColor(Color.TRANSPARENT);
    prepareWebViewSettings(webView.getSettings());
    return webView;
}
 
Example 11
Source File: ResultsActivity.java    From ZbarCode with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);

    ImageView mImgBack = (ImageView) findViewById(R.id.img_back);
    mTxtTitle = (TextView) findViewById(R.id.scan_title);
    mWebView = (WebView) findViewById(R.id.web_view);
    mTxtContent = (TextView) findViewById(R.id.tv_result);

    if (getIntent() != null) {
        mResult = getIntent().getStringExtra(CaptureActivity.EXTRA_STRING);
    }

    mImgBack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    if (mResult.startsWith("http") || mResult.startsWith("https")) {
        mWebView.setVisibility(View.VISIBLE);
        mTxtContent.setVisibility(View.GONE);
        loadUrl();
    } else {
        mWebView.setVisibility(View.GONE);
        mTxtContent.setVisibility(View.VISIBLE);
        mTxtTitle.setText("扫描结果");
        mTxtContent.setText(mResult);
    }
}
 
Example 12
Source File: PageLoad.java    From quickhybrid-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
    if (view != null) {
        view.setVisibility(View.VISIBLE);
    }
    cancelTimeKeeper();
}
 
Example 13
Source File: ShowResultActivity.java    From YZxing with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity_show_result);
    webView = (WebView) findViewById(R.id.web_content);
    tv = (TextView) findViewById(R.id.tv);
    pb = (ProgressBar) findViewById(R.id.progress);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webView.setWebChromeClient(webChromeClient);
    webView.setWebViewClient(webViewClient);

    Intent intent = getIntent();
    if (intent != null) {
        resultText = intent.getStringExtra(Constant.EXTRA_RESULT_TEXT_FROM_PIC);
        if (Patterns.WEB_URL.matcher(resultText).matches()) {
            //是一个web url
            tv.setVisibility(View.GONE);
            webView.setVisibility(View.VISIBLE);
            webView.loadUrl(resultText);
        } else {
            //不是web url
            tv.setVisibility(View.VISIBLE);
            webView.setVisibility(View.GONE);
            pb.setVisibility(View.GONE);
            tv.setText(resultText);
        }
    }
}
 
Example 14
Source File: LetvOpenIDOAuthLoginActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
public void onPageFinished(WebView view, String url) {
    try {
        if (new URL(url).getPath().contains("callbackdata")) {
            view.setVisibility(4);
            view.loadUrl("javascript:window.handler.show(document.body.innerText);");
            view.stopLoading();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 15
Source File: LetvUtils.java    From letv with Apache License 2.0 5 votes vote down vote up
public static void setUa(Context context) {
    if (TextUtils.isEmpty(ua)) {
        ua = PreferencesManager.getInstance().getUA();
        if (!TextUtils.isEmpty(ua)) {
            ua = "LetvGphoneClient/" + getClientVersionName() + " " + ua;
        } else if (context instanceof Activity) {
            WebView webView = new WebView(context);
            webView.setVisibility(8);
            ua = webView.getSettings().getUserAgentString();
            PreferencesManager.getInstance().setUA(ua);
            ua = "LetvGphoneClient/" + getClientVersionName() + " " + ua;
        }
    }
}
 
Example 16
Source File: HWWebView.java    From RePlugin-GameSdk with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
	// TODO Auto-generated method stub
	progressBar.setVisibility(View.GONE);
	view.setVisibility(View.VISIBLE);
	super.onPageFinished(view, url);
}
 
Example 17
Source File: WebActivity.java    From Floo with Apache License 2.0 5 votes vote down vote up
@Override
public void onPageCommitVisible(WebView view, String url) {
  super.onPageCommitVisible(view, url);
  loading.clearAnimation();
  loading.setVisibility(View.GONE);
  view.setVisibility(View.VISIBLE);
  Animation animation = new AlphaAnimation(0.1f, 1.0f);
  animation.setDuration(800);
  view.setAnimation(animation);
  setTitle(view.getTitle());
}
 
Example 18
Source File: LoginActivity.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
private void showAboutDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
    builder.setTitle(R.string.about_label);

    String str = null;
    try {
        InputStream inputStream = getResources().getAssets().open(getString(R.string.about_readme));
        str = IOUtils.toString(inputStream);
    } catch (IOException i) {
        /* Do nothing */
    }

    WebView webView = new WebView(LoginActivity.this);
    webView.loadDataWithBaseURL(
            StyleMarkdown.BASE_URL,
            str,
            null,
            getString(R.string.webview_encoding),
            null
    );
    webView.setVisibility(View.VISIBLE);
    builder.setView(webView);

    builder.setPositiveButton(R.string.about_button_star, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Uri uri = Uri.parse(getString(R.string.about_url));
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    builder.setNegativeButton(R.string.about_button_close, null);
    builder.setInverseBackgroundForced(true);
    builder.setCancelable(false);
    builder.create();
    builder.show();
}
 
Example 19
Source File: VpaidState.java    From TubiPlayer with MIT License 4 votes vote down vote up
private void pausePlayerAndSHowVpaid(PlayerUIController controller, PlayerAdLogicController componentController,
        FsmPlayer fsmPlayer, AdMediaModel adMedia) {

    ExoPlayer moviePlayer = controller.getContentPlayer();

    if (moviePlayer != null && moviePlayer.getPlayWhenReady()) {
        moviePlayer.setPlayWhenReady(false);
    }

    ExoPlayer adPlayer = controller.getAdPlayer();
    if (adPlayer != null && adPlayer.getPlayWhenReady()) {
        adPlayer.setPlayWhenReady(false);
    }

    VpaidClient client = componentController.getVpaidClient();

    if (client != null) {

        MediaModel ad = adMedia.nextAD();

        if (ad == null) {
            ExoPlayerLogger.w(Constants.FSMPLAYER_TESTING, "Vpaid ad is null");
            return;
        }

        client.init(ad);

        controller.getExoPlayerView().setVisibility(View.INVISIBLE);

        WebView vpaidWebView = controller.getVpaidWebView();

        vpaidWebView.setVisibility(View.VISIBLE);
        vpaidWebView.bringToFront();
        vpaidWebView.invalidate();

        vpaidWebView.addJavascriptInterface(client, "TubiNativeJSInterface");
        vpaidWebView.loadUrl(fsmPlayer.getVPAID_END_POINT());

        //hide the subtitle view when vpaid is playing
        ((TubiExoPlayerView) controller.getExoPlayerView()).getSubtitleView().setVisibility(View.INVISIBLE);
    } else {
        ExoPlayerLogger.w(Constants.FSMPLAYER_TESTING, "VpaidClient is null");
    }

}
 
Example 20
Source File: MainActivity.java    From Bitocle with Apache License 2.0 4 votes vote down vote up
private void showAboutDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle(R.string.about_label);

    String lang;
    if (getResources().getConfiguration().locale.getLanguage().equals("zh")) {
        lang = getString(R.string.about_readme_zh);
    } else {
        lang = getString(R.string.about_readme_en);
    }

    String str = null;
    try {
        InputStream inputStream = getResources().getAssets().open(lang);
        str = IOUtils.toString(inputStream);
    } catch (IOException i) {
        /* Do nothing */
    }

    final WebView webView = new WebView(MainActivity.this);
    webView.loadDataWithBaseURL(
            StyleMarkdown.BASE_URL,
            str,
            null,
            getString(R.string.webview_encoding),
            null
    );
    webView.setVisibility(View.VISIBLE);
    builder.setView(webView);

    builder.setPositiveButton(R.string.about_button_star, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            new Thread(starThread).start();
            SuperToast.create(
                    MainActivity.this,
                    getString(R.string.about_thx),
                    SuperToast.Duration.VERY_SHORT,
                    Style.getStyle(Style.GREEN)
            ).show();
        }
    });
    builder.setNegativeButton(R.string.about_button_close, null);
    builder.setInverseBackgroundForced(true);
    builder.setCancelable(false);
    builder.create();
    builder.show();
}