1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package net.sourceforge.subsonic.androidapp.activity; |
21 |
|
|
22 |
|
import android.app.Activity; |
23 |
|
import android.os.Bundle; |
24 |
|
import android.view.KeyEvent; |
25 |
|
import android.view.View; |
26 |
|
import android.view.Window; |
27 |
|
import android.webkit.WebView; |
28 |
|
import android.webkit.WebViewClient; |
29 |
|
import android.widget.Button; |
30 |
|
import net.sourceforge.subsonic.androidapp.R; |
31 |
|
import net.sourceforge.subsonic.androidapp.util.Util; |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
@author |
37 |
|
|
|
|
| 52,9% |
Uncovered Elements: 16 (34) |
Complexity: 9 |
Complexity Density: 0,41 |
|
38 |
|
public final class HelpActivity extends Activity { |
39 |
|
|
40 |
|
private WebView webView; |
41 |
|
private Button backButton; |
42 |
|
|
|
|
| 86,7% |
Uncovered Elements: 2 (15) |
Complexity: 2 |
Complexity Density: 0,15 |
|
43 |
1
|
@Override... |
44 |
|
protected void onCreate(Bundle bundle) { |
45 |
1
|
super.onCreate(bundle); |
46 |
1
|
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); |
47 |
|
|
48 |
1
|
setContentView(R.layout.help); |
49 |
|
|
50 |
1
|
webView = (WebView) findViewById(R.id.help_contents); |
51 |
1
|
webView.getSettings().setJavaScriptEnabled(true); |
52 |
1
|
webView.setWebViewClient(new HelpClient()); |
53 |
1
|
if (bundle != null) { |
54 |
0
|
webView.restoreState(bundle); |
55 |
|
} else { |
56 |
1
|
webView.loadUrl(getResources().getString(R.string.help_url)); |
57 |
|
} |
58 |
|
|
59 |
1
|
backButton = (Button) findViewById(R.id.help_back); |
60 |
1
|
backButton.setOnClickListener(new Button.OnClickListener() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0
|
@Override... |
62 |
|
public void onClick(View view) { |
63 |
0
|
webView.goBack(); |
64 |
|
} |
65 |
|
}); |
66 |
|
|
67 |
1
|
Button doneButton = (Button) findViewById(R.id.help_close); |
68 |
1
|
doneButton.setOnClickListener(new Button.OnClickListener() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
1
|
@Override... |
70 |
|
public void onClick(View view) { |
71 |
1
|
finish(); |
72 |
|
} |
73 |
|
}); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
1
|
@Override... |
77 |
|
public void onResume() { |
78 |
1
|
super.onResume(); |
79 |
|
} |
80 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
81 |
0
|
@Override... |
82 |
|
protected void onSaveInstanceState(Bundle state) { |
83 |
0
|
webView.saveState(state); |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0,6 |
|
86 |
0
|
@Override... |
87 |
|
public boolean onKeyDown(int keyCode, KeyEvent event) { |
88 |
0
|
if (keyCode == KeyEvent.KEYCODE_BACK) { |
89 |
0
|
if (webView.canGoBack()) { |
90 |
0
|
webView.goBack(); |
91 |
0
|
return true; |
92 |
|
} |
93 |
|
} |
94 |
0
|
return super.onKeyDown(keyCode, event); |
95 |
|
} |
96 |
|
|
|
|
| 40% |
Uncovered Elements: 6 (10) |
Complexity: 3 |
Complexity Density: 0,43 |
|
97 |
|
private final class HelpClient extends WebViewClient { |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
98 |
0
|
@Override... |
99 |
|
public void onLoadResource(WebView webView, String url) { |
100 |
0
|
setProgressBarIndeterminateVisibility(true); |
101 |
0
|
setTitle(getResources().getString(R.string.help_loading)); |
102 |
0
|
super.onLoadResource(webView, url); |
103 |
|
} |
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
105 |
1
|
@Override... |
106 |
|
public void onPageFinished(WebView view, String url) { |
107 |
1
|
setProgressBarIndeterminateVisibility(false); |
108 |
1
|
setTitle(view.getTitle()); |
109 |
1
|
backButton.setEnabled(view.canGoBack()); |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0
|
@Override... |
113 |
|
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { |
114 |
0
|
Util.toast(HelpActivity.this, description); |
115 |
|
} |
116 |
|
} |
117 |
|
} |