Revision 71589712

View differences:

AndroidManifest.xml
5 5
    android:versionName="1.0" >
6 6

  
7 7
    <uses-sdk
8
        android:minSdkVersion="7"
8
        android:minSdkVersion="8"
9 9
        android:targetSdkVersion="19" />
10 10

  
11 11
    <uses-permission android:name="android.permission.INTERNET" />
......
32 32
            <meta-data
33 33
                android:name="android.support.PARENT_ACTIVITY"
34 34
                android:value=".MainActivity" />
35

  
36
            <intent-filter>
37
                <action android:name="android.intent.action.VIEW" />
38

  
39
                <category android:name="android.intent.category.DEFAULT" />
40
                <category android:name="android.intent.category.BROWSABLE" />
41

  
42
                <data android:host="androidobservatory.org" />
43
                <data android:scheme="http" />
44
                <data android:scheme="https" />
45
            </intent-filter>
46 35
        </activity>
47 36
    </application>
48 37

  
src/info/guardianproject/checkey/WebViewActivity.java
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
}

Also available in: Unified diff