Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/android/AdvancedPreferences.java

Issue 8959056: android: notification icon option (Closed)
Patch Set: Created Nov. 28, 2012, 8:19 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « res/xml/preferences_advanced.xml ('k') | src/org/adblockplus/android/ProxyService.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus, 2 * This file is part of the Adblock Plus,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 import android.widget.Toast; 45 import android.widget.Toast;
46 46
47 /** 47 /**
48 * Advanced settings UI. 48 * Advanced settings UI.
49 */ 49 */
50 public class AdvancedPreferences extends SummarizedPreferences 50 public class AdvancedPreferences extends SummarizedPreferences
51 { 51 {
52 private static final String TAG = "AdvancedPreferences"; 52 private static final String TAG = "AdvancedPreferences";
53 53
54 private static final int CONFIGURATION_DIALOG = 1; 54 private static final int CONFIGURATION_DIALOG = 1;
55 private static final int PRIORITY_WARNING_DIALOG = 2;
55 56
56 private static ProxyService proxyService = null; 57 private static ProxyService proxyService = null;
57 58
58 @Override 59 @Override
59 public void onCreate(Bundle savedInstanceState) 60 public void onCreate(Bundle savedInstanceState)
60 { 61 {
61 super.onCreate(savedInstanceState); 62 super.onCreate(savedInstanceState);
62 63
63 addPreferencesFromResource(R.xml.preferences_advanced); 64 addPreferencesFromResource(R.xml.preferences_advanced);
64 65
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 @Override 110 @Override
110 public void onPause() 111 public void onPause()
111 { 112 {
112 super.onPause(); 113 super.onPause();
113 disconnect(); 114 disconnect();
114 } 115 }
115 116
116 @Override 117 @Override
117 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) 118 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key)
118 { 119 {
120 if (getString(R.string.pref_priority).equals(key))
121 {
122 if (!sharedPreferences.getBoolean(key, false))
123 showDialog(PRIORITY_WARNING_DIALOG);
124 }
119 if (getString(R.string.pref_refresh).equals(key)) 125 if (getString(R.string.pref_refresh).equals(key))
120 { 126 {
121 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0")); 127 int refresh = Integer.valueOf(sharedPreferences.getString(key, "0"));
122 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0); 128 findPreference(getString(R.string.pref_wifirefresh)).setEnabled(refresh > 0);
123 } 129 }
124 if (getString(R.string.pref_crashreport).equals(key)) 130 if (getString(R.string.pref_crashreport).equals(key))
125 { 131 {
126 boolean report = sharedPreferences.getBoolean(key, getResources().getBoole an(R.bool.def_crashreport)); 132 boolean report = sharedPreferences.getBoolean(key, getResources().getBoole an(R.bool.def_crashreport));
127 try 133 try
128 { 134 {
129 CrashHandler handler = (CrashHandler) Thread.getDefaultUncaughtException Handler(); 135 CrashHandler handler = (CrashHandler) Thread.getDefaultUncaughtException Handler();
130 handler.generateReport(report); 136 handler.generateReport(report);
131 } 137 }
132 catch (ClassCastException e) 138 catch (ClassCastException e)
133 { 139 {
134 // ignore - default handler in use 140 // ignore - default handler in use
135 } 141 }
136 } 142 }
137 super.onSharedPreferenceChanged(sharedPreferences, key); 143 super.onSharedPreferenceChanged(sharedPreferences, key);
138 } 144 }
139 145
140 @Override 146 @Override
141 protected Dialog onCreateDialog(int id) 147 protected Dialog onCreateDialog(int id)
142 { 148 {
143 Dialog dialog = null; 149 Dialog dialog = null;
150 AlertDialog.Builder builder = new AlertDialog.Builder(this);
151
144 switch (id) 152 switch (id)
145 { 153 {
154 case PRIORITY_WARNING_DIALOG:
155 // @formatter:off
Felix Dahlke 2012/11/28 09:47:35 Why do this? You can set up Eclipse do indent that
Andrey Novikov 2012/11/28 09:53:33 Really? How do I achieve that?
156 builder.setTitle(R.string.warning)
157 .setIcon(android.R.drawable.ic_dialog_alert)
158 .setMessage(R.string.msg_priority_warning)
159 .setCancelable(false)
160 .setPositiveButton(R.string.gotit, new DialogInterface.OnClickLis tener()
161 {
162 public void onClick(DialogInterface dialog, int id)
163 {
164 dialog.cancel();
165 }
166 });
167 // @formatter:on
168 dialog = builder.create();
169 break;
146 case CONFIGURATION_DIALOG: 170 case CONFIGURATION_DIALOG:
147 List<String> items = new ArrayList<String>(); 171 List<String> items = new ArrayList<String>();
148 items.add(AdblockPlus.getDeviceName()); 172 items.add(AdblockPlus.getDeviceName());
149 items.add(String.format("API: %d Build: %d", Build.VERSION.SDK_INT, Adbl ockPlus.getApplication().getBuildNumber())); 173 items.add(String.format("API: %d Build: %d", Build.VERSION.SDK_INT, Adbl ockPlus.getApplication().getBuildNumber()));
150 if (proxyService != null) 174 if (proxyService != null)
151 { 175 {
152 items.add(String.format("Local port: %d", proxyService.port)); 176 items.add(String.format("Local port: %d", proxyService.port));
153 if (proxyService.isTransparent()) 177 if (proxyService.isTransparent())
154 { 178 {
155 items.add("Running in root mode"); 179 items.add("Running in root mode");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 public void onClick(View v) 223 public void onClick(View v)
200 { 224 {
201 ClipboardManager manager = (ClipboardManager) getSystemService(CLIPB OARD_SERVICE); 225 ClipboardManager manager = (ClipboardManager) getSystemService(CLIPB OARD_SERVICE);
202 TextView showTextParam = (TextView) v; 226 TextView showTextParam = (TextView) v;
203 manager.setText(showTextParam.getText()); 227 manager.setText(showTextParam.getText());
204 Toast.makeText(v.getContext(), R.string.msg_clipboard, Toast.LENGTH_ SHORT).show(); 228 Toast.makeText(v.getContext(), R.string.msg_clipboard, Toast.LENGTH_ SHORT).show();
205 } 229 }
206 }); 230 });
207 scrollPane.addView(messageText); 231 scrollPane.addView(messageText);
208 232
209 AlertDialog.Builder builder = new AlertDialog.Builder(this); 233 // @formatter:off
Felix Dahlke 2012/11/28 09:47:35 See above, I think we should configure the formatt
210 builder.setView(scrollPane).setTitle(R.string.configuration_name).setIco n(android.R.drawable.ic_dialog_info).setCancelable(false) 234 builder.setView(scrollPane)
211 .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener( ) 235 .setTitle(R.string.configuration_name)
212 { 236 .setIcon(android.R.drawable.ic_dialog_info)
213 public void onClick(DialogInterface dialog, int id) 237 .setCancelable(false)
214 { 238 .setPositiveButton(R.string.ok, new DialogInterface.OnClickListen er()
215 dialog.cancel(); 239 {
216 } 240 public void onClick(DialogInterface dialog, int id)
217 }); 241 {
242 dialog.cancel();
243 }
244 });
245 // @formatter:on
218 dialog = builder.create(); 246 dialog = builder.create();
219 break; 247 break;
220 } 248 }
221 return dialog; 249 return dialog;
222 } 250 }
223 251
224 private void connect() 252 private void connect()
225 { 253 {
226 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ; 254 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ;
227 } 255 }
(...skipping 12 matching lines...) Expand all
240 Log.d(TAG, "Proxy service connected"); 268 Log.d(TAG, "Proxy service connected");
241 } 269 }
242 270
243 public void onServiceDisconnected(ComponentName className) 271 public void onServiceDisconnected(ComponentName className)
244 { 272 {
245 proxyService = null; 273 proxyService = null;
246 Log.d(TAG, "Proxy service disconnected"); 274 Log.d(TAG, "Proxy service disconnected");
247 } 275 }
248 }; 276 };
249 } 277 }
OLDNEW
« no previous file with comments | « res/xml/preferences_advanced.xml ('k') | src/org/adblockplus/android/ProxyService.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld