Revision 03f389d1

View differences:

res/menu/webview.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
3

  
4
    <item
5
        android:id="@+id/share"
6
        android:icon="@android:drawable/ic_menu_share"
7
        android:showAsAction="always"
8
        android:title="@string/share"/>
9
    <item
10
        android:id="@+id/open_in_browser"
11
        android:icon="@android:drawable/ic_menu_view"
12
        android:showAsAction="ifRoom|withText"
13
        android:title="@string/open_in_browser"/>
14

  
15
</menu>
res/values/strings.xml
9 9
    <string name="by_package_name">By Package Name</string>
10 10
    <string name="by_apk_hash">By APK Hash</string>
11 11
    <string name="by_signing_certificate">By Signing Certificate</string>
12
    <string name="open_in_browser">Open in Browser</string>
13
    <string name="share">Share</string>
14
    <string name="share_url_using">Share URL using:</string>
15
    <string name="save">Save…</string>
12 16

  
13 17
</resources>
src/info/guardianproject/checkey/AppListFragment.java
176 176
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
177 177
            AppEntry appEntry = (AppEntry) adapter.getItem(selectedItem);
178 178
            Intent intent = new Intent(getActivity(), WebViewActivity.class);
179
            intent.putExtra(Intent.EXTRA_TEXT, appEntry.getLabel());
179 180
            switch (item.getItemId()) {
180 181
                case R.id.virustotal:
181 182
                    virustotal(appEntry, intent);
src/info/guardianproject/checkey/WebViewActivity.java
7 7
import android.os.Bundle;
8 8
import android.support.v7.app.ActionBar;
9 9
import android.support.v7.app.ActionBarActivity;
10
import android.util.Log;
11 10
import android.view.Menu;
12 11
import android.view.MenuItem;
13 12
import android.webkit.SslErrorHandler;
......
16 15

  
17 16
public class WebViewActivity extends ActionBarActivity {
18 17

  
18
    private Intent intent;
19 19
    private Uri uri;
20 20

  
21 21
    @Override
......
25 25
        ActionBar actionBar = getSupportActionBar();
26 26
        actionBar.setDisplayHomeAsUpEnabled(true);
27 27

  
28
        Intent intent = getIntent();
28
        intent = getIntent();
29 29
        int resid = intent.getIntExtra(Intent.EXTRA_TITLE, 0);
30 30
        if (resid != 0)
31 31
            actionBar.setTitle(resid);
......
34 34
        webView.setWebViewClient(new MyWebViewClient());
35 35
        uri = intent.getData();
36 36
        webView.loadUrl(uri.toString());
37
        Log.i("WebViewActivity", uri.toString());
37
    }
38

  
39
    @Override
40
    public boolean onCreateOptionsMenu(Menu menu) {
41
        getMenuInflater().inflate(R.menu.webview, menu);
42
        return true;
43
    }
44

  
45
    @Override
46
    public boolean onOptionsItemSelected(MenuItem item) {
47
        switch (item.getItemId()) {
48
            case android.R.id.home:
49
                setResult(RESULT_CANCELED);
50
                finish();
51
                return true;
52
            case R.id.share:
53
                String appName = intent.getStringExtra(Intent.EXTRA_TEXT);
54
                Intent i = new Intent(Intent.ACTION_SEND);
55
                i.setType("plain/text");
56
                i.putExtra(Intent.EXTRA_TITLE, appName);
57
                i.putExtra(Intent.EXTRA_SUBJECT, appName);
58
                i.putExtra(Intent.EXTRA_TEXT, uri.toString());
59
                startActivity(Intent.createChooser(i, getString(R.string.share_url_using)));
60
                return true;
61
            case R.id.open_in_browser:
62
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
63
                return true;
64
        }
65
        return super.onOptionsItemSelected(item);
38 66
    }
39 67

  
40 68
    private class MyWebViewClient extends WebViewClient {
......
53 81

  
54 82
        @Override
55 83
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
56
            Log.i("MyWebViewClient", "onReceivedSslError: " + uri);
57 84
            String host = uri.getHost();
58
            Log.i("MyWebViewClient", "getPrimaryError: " + error.getPrimaryError());
59 85
            int errno = error.getPrimaryError();
60 86
            if (host.equals("androidobservatory.org")
61 87
                    && (errno == SslError.SSL_EXPIRED || errno == SslError.SSL_UNTRUSTED)) {

Also available in: Unified diff