Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../img/srcFileCovDistChart5.png 71% of files have more coverage
29   117   12   3,22
6   79   0,41   4,5
9     1,33  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  HelpActivity       Line # 38 22 9 52,9% 0.5294118
  HelpActivity.HelpClient       Line # 97 7 3 40% 0.4
 
No Tests
 
1    /*
2    This file is part of Subsonic.
3   
4    Subsonic is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8   
9    Subsonic is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12    GNU General Public License for more details.
13   
14    You should have received a copy of the GNU General Public License
15    along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
16   
17    Copyright 2009 (C) Sindre Mehus
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    * An HTML-based help screen with Back and Done buttons at the bottom.
35    *
36    * @author Sindre Mehus
37    */
 
38    public final class HelpActivity extends Activity {
39   
40    private WebView webView;
41    private Button backButton;
42   
 
43  1 toggle @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() {
 
61  0 toggle @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() {
 
69  1 toggle @Override
70    public void onClick(View view) {
71  1 finish();
72    }
73    });
74    }
75   
 
76  1 toggle @Override
77    public void onResume() {
78  1 super.onResume();
79    }
80   
 
81  0 toggle @Override
82    protected void onSaveInstanceState(Bundle state) {
83  0 webView.saveState(state);
84    }
85   
 
86  0 toggle @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   
 
97    private final class HelpClient extends WebViewClient {
 
98  0 toggle @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   
 
105  1 toggle @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   
 
112  0 toggle @Override
113    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
114  0 Util.toast(HelpActivity.this, description);
115    }
116    }
117    }