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

Delta Between Two Patch Sets: src/org/adblockplus/android/Preferences.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Fixed leftover first-batch review issues. Created April 16, 2014, 5:51 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private static final String TAG = Utils.getTag(Preferences.class); 65 private static final String TAG = Utils.getTag(Preferences.class);
66 private static final int ABOUT_DIALOG = 1; 66 private static final int ABOUT_DIALOG = 1;
67 private static final int HIDEICONWARNING_DIALOG = 2; 67 private static final int HIDEICONWARNING_DIALOG = 2;
68 68
69 private static ProxyService proxyService = null; 69 private static ProxyService proxyService = null;
70 private static boolean firstRunActionsPending = true; 70 private static boolean firstRunActionsPending = true;
71 71
72 private RefreshableListPreference subscriptionList; 72 private RefreshableListPreference subscriptionList;
73 private String subscriptionSummary; 73 private String subscriptionSummary;
74 74
75 @SuppressWarnings("deprecation")
76 @Override 75 @Override
77 public void onCreate(final Bundle savedInstanceState) 76 public void onCreate(final Bundle savedInstanceState)
78 { 77 {
79 super.onCreate(savedInstanceState); 78 super.onCreate(savedInstanceState);
80 79
81 PreferenceManager.setDefaultValues(this, R.xml.preferences, true); 80 PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
82 PreferenceManager.setDefaultValues(this, R.xml.preferences_advanced, true); 81 PreferenceManager.setDefaultValues(this, R.xml.preferences_advanced, true);
83 setContentView(R.layout.preferences); 82 setContentView(R.layout.preferences);
84 addPreferencesFromResource(R.xml.preferences); 83 addPreferencesFromResource(R.xml.preferences);
85 84
(...skipping 11 matching lines...) Expand all
97 editor.putInt(getString(R.string.pref_version), thisVersion); 96 editor.putInt(getString(R.string.pref_version), thisVersion);
98 editor.commit(); 97 editor.commit();
99 } 98 }
100 } 99 }
101 catch (final NameNotFoundException e) 100 catch (final NameNotFoundException e)
102 { 101 {
103 copyAssets(); 102 copyAssets();
104 } 103 }
105 } 104 }
106 105
107 @SuppressWarnings("deprecation")
108 @Override 106 @Override
109 protected void onStart() 107 protected void onStart()
110 { 108 {
111 super.onStart(); 109 super.onStart();
112 final AdblockPlus application = AdblockPlus.getApplication(); 110 final AdblockPlus application = AdblockPlus.getApplication();
113 application.startEngine(); 111 application.startEngine();
114 112
115 // Initialize subscription list 113 // Initialize subscription list
116 subscriptionList = (RefreshableListPreference) findPreference(getString(R.st ring.pref_subscription)); 114 subscriptionList = (RefreshableListPreference) findPreference(getString(R.st ring.pref_subscription));
117 final Subscription[] subscriptions = application.getRecommendedSubscriptions (); 115 final Subscription[] subscriptions = application.getRecommendedSubscriptions ();
118 final String[] entries = new String[subscriptions.length]; 116 final String[] entries = new String[subscriptions.length];
119 final String[] entryValues = new String[subscriptions.length]; 117 final String[] entryValues = new String[subscriptions.length];
120 int i = 0; 118 int i = 0;
121 for (final Subscription subscription : subscriptions) 119 for (final Subscription subscription : subscriptions)
122 { 120 {
123 entries[i] = subscription.title; 121 entries[i] = subscription.title;
124 entryValues[i] = subscription.url; 122 entryValues[i] = subscription.url;
125 i++; 123 i++;
126 } 124 }
127 subscriptionList.setEntries(entries); 125 subscriptionList.setEntries(entries);
128 subscriptionList.setEntryValues(entryValues); 126 subscriptionList.setEntryValues(entryValues);
129 127
130 // Set Acceptable Ads FAQ link 128 // Set Acceptable Ads FAQ link
131 final HelpfulCheckBoxPreference acceptableAdsCheckBox = 129 final HelpfulCheckBoxPreference acceptableAdsCheckBox =
132 (HelpfulCheckBoxPreference) findPreference(getString(R.string.pref_accep tableads)); 130 (HelpfulCheckBoxPreference) findPreference(getString(R.string.pref_accep tableads));
133 acceptableAdsCheckBox.setHelpUrl(AdblockPlus.getApplication().getAcceptableA dsUrl()); 131 acceptableAdsCheckBox.setHelpUrl(AdblockPlus.getApplication().getAcceptableA dsUrl());
134 } 132 }
135 133
136 @SuppressWarnings("deprecation")
137 @Override 134 @Override
138 public void onResume() 135 public void onResume()
139 { 136 {
140 super.onResume(); 137 super.onResume();
141 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(this); 138 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(this);
142 139
143 final AdblockPlus application = AdblockPlus.getApplication(); 140 final AdblockPlus application = AdblockPlus.getApplication();
144 141
145 Subscription current = null; 142 Subscription current = null;
146 final Subscription[] subscriptions = application.getListedSubscriptions(); 143 final Subscription[] subscriptions = application.getListedSubscriptions();
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 252 }
256 253
257 @Override 254 @Override
258 public boolean onCreateOptionsMenu(final Menu menu) 255 public boolean onCreateOptionsMenu(final Menu menu)
259 { 256 {
260 final MenuInflater inflater = getSupportMenuInflater(); 257 final MenuInflater inflater = getSupportMenuInflater();
261 inflater.inflate(R.menu.menu_preferences, menu); 258 inflater.inflate(R.menu.menu_preferences, menu);
262 return true; 259 return true;
263 } 260 }
264 261
265 @SuppressWarnings("deprecation")
266 @Override 262 @Override
267 public boolean onOptionsItemSelected(final MenuItem item) 263 public boolean onOptionsItemSelected(final MenuItem item)
268 { 264 {
269 switch (item.getItemId()) 265 switch (item.getItemId())
270 { 266 {
271 case R.id.menu_help: 267 case R.id.menu_help:
272 final Uri uri = Uri.parse(getString(R.string.configuring_url)); 268 final Uri uri = Uri.parse(getString(R.string.configuring_url));
273 final Intent intent = new Intent(Intent.ACTION_VIEW, uri); 269 final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
274 startActivity(intent); 270 startActivity(intent);
275 return true; 271 return true;
276 case R.id.menu_about: 272 case R.id.menu_about:
277 showDialog(ABOUT_DIALOG); 273 showDialog(ABOUT_DIALOG);
278 return true; 274 return true;
279 case R.id.menu_advanced: 275 case R.id.menu_advanced:
280 startActivity(new Intent(this, AdvancedPreferences.class)); 276 startActivity(new Intent(this, AdvancedPreferences.class));
281 return true; 277 return true;
282 default: 278 default:
283 return super.onOptionsItemSelected(item); 279 return super.onOptionsItemSelected(item);
284 } 280 }
285 } 281 }
286 282
287 @SuppressWarnings("deprecation")
288 private void setAcceptableAdsEnabled(final boolean enabled) 283 private void setAcceptableAdsEnabled(final boolean enabled)
289 { 284 {
290 final CheckBoxPreference acceptableAdsPreference = 285 final CheckBoxPreference acceptableAdsPreference =
291 (CheckBoxPreference) findPreference(getString(R.string.pref_acceptablead s)); 286 (CheckBoxPreference) findPreference(getString(R.string.pref_acceptablead s));
292 acceptableAdsPreference.setChecked(enabled); 287 acceptableAdsPreference.setChecked(enabled);
293 final AdblockPlus application = AdblockPlus.getApplication(); 288 final AdblockPlus application = AdblockPlus.getApplication();
294 application.setAcceptableAdsEnabled(enabled); 289 application.setAcceptableAdsEnabled(enabled);
295 } 290 }
296 291
297 @SuppressWarnings("deprecation")
298 private void setFilteringEnabled(final boolean enabled) 292 private void setFilteringEnabled(final boolean enabled)
299 { 293 {
300 final SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPr eferences(this).edit(); 294 final SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPr eferences(this).edit();
301 editor.putBoolean(getString(R.string.pref_enabled), enabled); 295 editor.putBoolean(getString(R.string.pref_enabled), enabled);
302 editor.commit(); 296 editor.commit();
303 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled); 297 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled);
304 final AdblockPlus application = AdblockPlus.getApplication(); 298 final AdblockPlus application = AdblockPlus.getApplication();
305 application.setFilteringEnabled(enabled); 299 application.setFilteringEnabled(enabled);
306 } 300 }
307 301
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 } 391 }
398 }); 392 });
399 } 393 }
400 builder.setMessage(Html.fromHtml(message.toString())); 394 builder.setMessage(Html.fromHtml(message.toString()));
401 dialog = builder.create(); 395 dialog = builder.create();
402 break; 396 break;
403 } 397 }
404 return dialog; 398 return dialog;
405 } 399 }
406 400
407 @SuppressWarnings("deprecation")
408 @Override 401 @Override
409 public void onSharedPreferenceChanged(final SharedPreferences sharedPreference s, final String key) 402 public void onSharedPreferenceChanged(final SharedPreferences sharedPreference s, final String key)
410 { 403 {
411 final AdblockPlus application = AdblockPlus.getApplication(); 404 final AdblockPlus application = AdblockPlus.getApplication();
412 if (getString(R.string.pref_enabled).equals(key)) 405 if (getString(R.string.pref_enabled).equals(key))
413 { 406 {
414 final boolean enabled = sharedPreferences.getBoolean(key, false); 407 final boolean enabled = sharedPreferences.getBoolean(key, false);
415 final boolean autoconfigured = sharedPreferences.getBoolean(getString(R.st ring.pref_proxyautoconfigured), false); 408 final boolean autoconfigured = sharedPreferences.getBoolean(getString(R.st ring.pref_proxyautoconfigured), false);
416 final boolean serviceRunning = application.isServiceRunning(); 409 final boolean serviceRunning = application.isServiceRunning();
417 application.setFilteringEnabled(enabled); 410 application.setFilteringEnabled(enabled);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 }; 506 };
514 507
515 /** 508 /**
516 * Constructs and updates subscription status text. 509 * Constructs and updates subscription status text.
517 * 510 *
518 * @param text 511 * @param text
519 * status message 512 * status message
520 * @param time 513 * @param time
521 * time of last change 514 * time of last change
522 */ 515 */
523 @SuppressWarnings("deprecation")
524 private void setSubscriptionStatus(final String text, final long time) 516 private void setSubscriptionStatus(final String text, final long time)
525 { 517 {
526 final ListPreference subscriptionList = (ListPreference) findPreference(getS tring(R.string.pref_subscription)); 518 final ListPreference subscriptionList = (ListPreference) findPreference(getS tring(R.string.pref_subscription));
527 final CharSequence summary = subscriptionList.getEntry(); 519 final CharSequence summary = subscriptionList.getEntry();
528 final StringBuilder builder = new StringBuilder(); 520 final StringBuilder builder = new StringBuilder();
529 if (summary != null) 521 if (summary != null)
530 { 522 {
531 builder.append(summary); 523 builder.append(summary);
532 if (text != "") 524 if (text != "")
533 { 525 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 573 }
582 574
583 @Override 575 @Override
584 public void onServiceDisconnected(final ComponentName className) 576 public void onServiceDisconnected(final ComponentName className)
585 { 577 {
586 proxyService = null; 578 proxyService = null;
587 Log.d(TAG, "Proxy service disconnected"); 579 Log.d(TAG, "Proxy service disconnected");
588 } 580 }
589 }; 581 };
590 } 582 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld