Clover Coverage Report - Hangeulider Coverage Report
Coverage timestamp: mar dic 16 2014 11:36:46 EST
../../../../img/srcFileCovDistChart9.png 0% of files have more coverage
84   215   32   4,94
30   182   0,38   17
17     1,88  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  Hangeulider       Line # 27 84 32 87,8% 0.8778626
 
No Tests
 
1    package com.choibean.android.hangeulider;
2   
3    import java.util.Iterator;
4    import java.util.Set;
5   
6    import android.app.Activity;
7    import android.app.Notification;
8    import android.app.NotificationManager;
9    import android.app.PendingIntent;
10    import android.content.ComponentName;
11    import android.content.Context;
12    import android.content.Intent;
13    import android.content.SharedPreferences;
14    import android.os.Bundle;
15    import android.util.Log;
16    import android.view.Display;
17    import android.view.Menu;
18    import android.view.MenuInflater;
19    import android.view.MenuItem;
20    import android.view.View;
21    import android.view.Window;
22    import android.view.WindowManager;
23    import android.widget.EditText;
24    import android.widget.ImageView;
25    import android.widget.TextView;
26   
 
27    public class Hangeulider extends Activity {
28   
29    protected static HangeulParser parser;
30    protected static final int modeDubeolshik = 0;
31    protected static final int modeKonglish = 1;
32    protected static int inputMode = 1;
33    protected NotificationManager mNotificationManager;
34    protected Menu mMenu = null;
35    private int YOURAPP_NOTIFICATION_ID = 0;
36   
37    private static Hangeulider mInstance;
38   
 
39  7 toggle public static Hangeulider getInstance() {
40  7 return mInstance;
41    }
42   
43    /** Called when the activity is first created. */
 
44  1 toggle @Override
45    public void onCreate(Bundle savedInstanceState) {
46  1 super.onCreate(savedInstanceState);
47  1 mInstance = this;
48  1 Window window = getWindow();
49  1 window.setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
50    WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
51  1 setContentView(isWide() ? R.layout.wide : R.layout.tall);
52   
53    // load previous text
54  1 mSaved = (EditText) findViewById(R.id.outputEdit);
55  1 parser = new HangeulParser(this);
56  1 setDubeolshikMode(false);
57   
58  1 if (savedInstanceState == null) {
59  1 logD("State", "onCreate(null)");
60    } else {
61  0 logD("State", "onCreate(**something**)");
62    }
63    }
64   
 
65  4 toggle @Override
66    protected void onSaveInstanceState(Bundle outState) {
67  4 super.onSaveInstanceState(outState);
68  4 logD("State", "onSIS: got to Child");
69  4 Set<String> set = outState.keySet();
70  4 Iterator<String> iterator = set.iterator();
71  8 while (iterator.hasNext()) {
72  4 logD("State", outState.get(iterator.next()).getClass().getName());
73    }
74    }
75   
 
76  5 toggle @Override
77    protected void onStart() {
78  5 super.onStart();
79  5 toggleNotification(true);
80  5 logD("status", "start");
81    }
82   
 
83  5 toggle @Override
84    protected void onResume() {
85  5 super.onResume();
86   
87  5 SharedPreferences prefs = getPreferences(0);
88  5 String restoredText = prefs.getString("text", null);
89  5 if (restoredText != null) {
90  4 mSaved.setText(restoredText, TextView.BufferType.EDITABLE);
91    }
92    }
93   
 
94  5 toggle @Override
95    protected void onPause() {
96  5 super.onPause();
97   
98  5 SharedPreferences.Editor editor = getPreferences(0).edit();
99  5 editor.putString("text", mSaved.getText().toString());
100  5 editor.commit();
101    }
102   
103    private EditText mSaved;
104   
 
105  6 toggle protected void sendNotification(Context context) {
106  6 mNotificationManager = (NotificationManager) context
107    .getSystemService(Context.NOTIFICATION_SERVICE);
108  6 ComponentName comp = new ComponentName(context.getPackageName(),
109    getClass().getName());
110  6 Intent intent = new Intent().setComponent(comp);
111  6 PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
112    intent, Intent.FLAG_ACTIVITY_NEW_TASK);
113  6 Notification n = new Notification(R.drawable.flag,
114    getString(R.string.app_name), System.currentTimeMillis());
115  6 n.setLatestEventInfo(context, getString(R.string.notification_title),
116    getString(R.string.notification_motto), pendingIntent);
117  6 n.flags = Notification.FLAG_ONGOING_EVENT;
118  6 mNotificationManager.notify(YOURAPP_NOTIFICATION_ID, n);
119  6 if (mMenu != null) {
120  4 MenuItem notiMode = mMenu.findItem(R.id.notificationMenuItem);
121  4 notiMode.setChecked(true);
122    }
123    }
124   
 
125  1 toggle protected void cancelNotification() {
126  1 mNotificationManager.cancel(YOURAPP_NOTIFICATION_ID);
127  1 if (mMenu != null) {
128  1 MenuItem notiMode = mMenu.findItem(R.id.notificationMenuItem);
129  1 notiMode.setChecked(false);
130    }
131    }
132   
 
133  1 toggle @Override
134    public boolean onCreateOptionsMenu(Menu menu) {
135  1 MenuInflater inflater = getMenuInflater();
136  1 inflater.inflate(R.menu.main_menu, menu);
137  1 mMenu = menu;
138  1 return true;
139    }
140   
 
141  3 toggle @Override
142    public boolean onMenuOpened(int featureId, Menu menu) {
143  3 logD("mode", String.valueOf(getDubeolshikMode()));
144  3 mMenu = menu;
145  3 if (mMenu == null) {
146  0 return false;
147    }
148  3 MenuItem notification = mMenu.findItem(R.id.notificationMenuItem);
149  3 boolean nMode = notification.isChecked();
150  3 int iconId = nMode ? android.R.drawable.checkbox_on_background
151    : android.R.drawable.checkbox_off_background;
152  3 notification.setIcon(iconId);
153  3 notification.setChecked(nMode);
154   
155  3 return super.onMenuOpened(featureId, menu);
156    }
157   
 
158  3 toggle @Override
159    public boolean onOptionsItemSelected(MenuItem item) {
160  3 int id = item.getItemId();
161  3 logD("menu ", String.valueOf(id));
162  3 if (id == R.id.notificationMenuItem) {
163  2 if (item.isChecked()) {
164  1 toggleNotification(false);
165    } else {
166  1 toggleNotification(true);
167    }
168  1 } else if (id == R.id.exitMenuItem) {
169  1 this.finish();
170    }
171    // cancelNotification
172  3 return false;
173    }
174   
 
175  7 toggle public void toggleNotification(boolean toggle) {
176  7 if (toggle) {
177  6 sendNotification(this);
178    } else {
179  1 cancelNotification();
180    }
181   
182    }
183   
 
184  0 toggle public void toggleDubeolshikMode() {
185  0 setDubeolshikMode(!getDubeolshikMode());
186    }
187   
 
188  284 toggle public boolean getDubeolshikMode() {
189    // tall mode has no dbs
190  284 return (Hangeulider.inputMode == modeDubeolshik) && isWide();
191    }
192   
 
193  1 toggle public void setDubeolshikMode(boolean dubeolshik) {
194  1 logD("mode", String.valueOf(dubeolshik));
195  1 Hangeulider.inputMode = dubeolshik ? modeDubeolshik : modeKonglish;
196  1 ImageView dbs = (ImageView) findViewById(R.id.dbs);
197  1 if (dbs != null) {
198  0 if (dubeolshik) {
199  0 dbs.setVisibility(View.VISIBLE);
200    } else {
201  0 dbs.setVisibility(View.INVISIBLE);
202    }
203    }
204  1 parser.setModeText();
205    }
206   
 
207  2 toggle public boolean isWide() {
208  2 Display display = getWindowManager().getDefaultDisplay();
209  2 return display.getWidth() > display.getHeight();
210    }
211   
 
212  460 toggle public static void logD(String tag, String msg) {
213  460 Log.d(tag, msg);
214    }
215    }