2 |
2 |
package info.guardianproject.checkey;
|
3 |
3 |
|
4 |
4 |
import android.content.Intent;
|
|
5 |
import android.net.Uri;
|
|
6 |
import android.net.http.SslError;
|
5 |
7 |
import android.os.Bundle;
|
6 |
8 |
import android.support.v7.app.ActionBar;
|
7 |
9 |
import android.support.v7.app.ActionBarActivity;
|
8 |
10 |
import android.util.Log;
|
|
11 |
import android.view.Menu;
|
|
12 |
import android.view.MenuItem;
|
|
13 |
import android.webkit.SslErrorHandler;
|
9 |
14 |
import android.webkit.WebView;
|
|
15 |
import android.webkit.WebViewClient;
|
10 |
16 |
|
11 |
17 |
public class WebViewActivity extends ActionBarActivity {
|
12 |
18 |
|
|
19 |
private Uri uri;
|
|
20 |
|
13 |
21 |
@Override
|
14 |
22 |
protected void onCreate(Bundle savedInstanceState) {
|
15 |
23 |
super.onCreate(savedInstanceState);
|
... | ... | |
23 |
31 |
actionBar.setTitle(resid);
|
24 |
32 |
|
25 |
33 |
WebView webView = (WebView) findViewById(R.id.webview);
|
26 |
|
webView.loadUrl(intent.getData().toString());
|
27 |
|
Log.i("WebViewActivity", intent.getData().toString());
|
|
34 |
webView.setWebViewClient(new MyWebViewClient());
|
|
35 |
uri = intent.getData();
|
|
36 |
webView.loadUrl(uri.toString());
|
|
37 |
Log.i("WebViewActivity", uri.toString());
|
28 |
38 |
}
|
29 |
39 |
|
|
40 |
private class MyWebViewClient extends WebViewClient {
|
|
41 |
@Override
|
|
42 |
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
|
43 |
Uri clickedUri = Uri.parse(url);
|
|
44 |
String host = clickedUri.getHost();
|
|
45 |
if (host.equals("www.virustotal.com") || host.equals("androidobservatory.org")) {
|
|
46 |
// do not override; let my WebView load the page
|
|
47 |
return false;
|
|
48 |
}
|
|
49 |
// otherwise launch another Activity to handle the link
|
|
50 |
startActivity(new Intent(Intent.ACTION_VIEW, clickedUri));
|
|
51 |
return true;
|
|
52 |
}
|
|
53 |
|
|
54 |
}
|
30 |
55 |
}
|