1 /* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.autofill.app.commoncases; 18 19 import android.content.Context; 20 import android.content.Intent; 21 import android.os.Bundle; 22 import android.support.v7.app.AppCompatActivity; 23 import android.util.Log; 24 import android.webkit.WebSettings; 25 import android.webkit.WebView; 26 import android.webkit.WebViewClient; 27 28 import com.example.android.autofill.app.R; 29 30 import static com.example.android.autofill.app.Util.DEBUG; 31 import static com.example.android.autofill.app.Util.TAG; 32 33 public class WebViewSignInActivity extends AppCompatActivity { 34 35 @Override 36 protected void onCreate(Bundle savedInstanceState) { 37 super.onCreate(savedInstanceState); 38 39 setContentView(R.layout.login_webview_activity); 40 41 WebView webView = findViewById(R.id.webview); 42 WebSettings webSettings = webView.getSettings(); 43 webView.setWebViewClient(new WebViewClient()); 44 webSettings.setJavaScriptEnabled(true); 45 46 String url = getIntent().getStringExtra("url"); 47 if (url == null) { 48 url = "file:///android_res/raw/sample_form.html"; 49 } 50 if (DEBUG) Log.d(TAG, "Clearing WebView data"); 51 webView.clearHistory(); 52 webView.clearFormData(); 53 webView.clearCache(true); 54 Log.i(TAG, "Loading URL " + url); 55 webView.loadUrl(url); 56 } 57 }