| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 import android.content.pm.PackageManager.NameNotFoundException; | 39 import android.content.pm.PackageManager.NameNotFoundException; |
| 40 import android.content.res.AssetManager; | 40 import android.content.res.AssetManager; |
| 41 import android.net.Uri; | 41 import android.net.Uri; |
| 42 import android.os.Bundle; | 42 import android.os.Bundle; |
| 43 import android.os.IBinder; | 43 import android.os.IBinder; |
| 44 import android.preference.CheckBoxPreference; | 44 import android.preference.CheckBoxPreference; |
| 45 import android.preference.ListPreference; | 45 import android.preference.ListPreference; |
| 46 import android.preference.PreferenceManager; | 46 import android.preference.PreferenceManager; |
| 47 import android.text.format.DateFormat; | 47 import android.text.format.DateFormat; |
| 48 import android.util.Log; | 48 import android.util.Log; |
| 49 import android.view.Menu; | |
| 50 import android.view.MenuInflater; | |
| 51 import android.view.MenuItem; | |
| 52 import android.view.View; | 49 import android.view.View; |
| 53 import android.view.Window; | |
| 54 import android.widget.TextView; | 50 import android.widget.TextView; |
| 55 | 51 |
| 52 import com.actionbarsherlock.view.Menu; |
| 53 import com.actionbarsherlock.view.MenuInflater; |
| 54 import com.actionbarsherlock.view.MenuItem; |
| 55 import com.actionbarsherlock.view.Window; |
| 56 |
| 56 /** | 57 /** |
| 57 * Main settings UI. | 58 * Main settings UI. |
| 58 */ | 59 */ |
| 59 public class Preferences extends SummarizedPreferences | 60 public class Preferences extends SummarizedPreferences |
| 60 { | 61 { |
| 61 private static final String TAG = "Preferences"; | 62 private static final String TAG = "Preferences"; |
| 62 | 63 |
| 63 private static final int ABOUT_DIALOG = 1; | 64 private static final int ABOUT_DIALOG = 1; |
| 64 private static final int HIDEICONWARNING_DIALOG = 2; | 65 private static final int HIDEICONWARNING_DIALOG = 2; |
| 65 | 66 |
| 66 private static ProxyService proxyService = null; | 67 private static ProxyService proxyService = null; |
| 67 | 68 |
| 68 private RefreshableListPreference subscriptionList; | 69 private RefreshableListPreference subscriptionList; |
| 69 | 70 |
| 70 private boolean trafficDetected = false; | 71 private boolean trafficDetected = false; |
| 71 private String subscriptionSummary; | 72 private String subscriptionSummary; |
| 72 | 73 |
| 73 @Override | 74 @Override |
| 74 public void onCreate(Bundle savedInstanceState) | 75 public void onCreate(Bundle savedInstanceState) |
| 75 { | 76 { |
| 76 requestWindowFeature(Window.FEATURE_NO_TITLE); | |
| 77 | |
| 78 super.onCreate(savedInstanceState); | 77 super.onCreate(savedInstanceState); |
| 79 | 78 |
| 80 PreferenceManager.setDefaultValues(this, R.xml.preferences, false); | 79 PreferenceManager.setDefaultValues(this, R.xml.preferences, false); |
| 81 PreferenceManager.setDefaultValues(this, R.xml.preferences_advanced, false); | 80 PreferenceManager.setDefaultValues(this, R.xml.preferences_advanced, false); |
| 82 setContentView(R.layout.preferences); | 81 setContentView(R.layout.preferences); |
| 83 addPreferencesFromResource(R.xml.preferences); | 82 addPreferencesFromResource(R.xml.preferences); |
| 84 | 83 |
| 85 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this
); | 84 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this
); |
| 86 | 85 |
| 87 // Check if we need to update assets | 86 // Check if we need to update assets |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 boolean enabled = prefs.getBoolean(getString(R.string.pref_enabled), false); | 234 boolean enabled = prefs.getBoolean(getString(R.string.pref_enabled), false); |
| 236 AdblockPlus application = AdblockPlus.getApplication(); | 235 AdblockPlus application = AdblockPlus.getApplication(); |
| 237 application.stopInteractive(); | 236 application.stopInteractive(); |
| 238 if (!enabled) | 237 if (!enabled) |
| 239 application.stopEngine(true); | 238 application.stopEngine(true); |
| 240 } | 239 } |
| 241 | 240 |
| 242 @Override | 241 @Override |
| 243 public boolean onCreateOptionsMenu(Menu menu) | 242 public boolean onCreateOptionsMenu(Menu menu) |
| 244 { | 243 { |
| 245 MenuInflater inflater = getMenuInflater(); | 244 MenuInflater inflater = getSupportMenuInflater(); |
| 246 inflater.inflate(R.menu.menu_preferences, menu); | 245 inflater.inflate(R.menu.menu_preferences, menu); |
| 247 return true; | 246 return true; |
| 248 } | 247 } |
| 249 | 248 |
| 250 @Override | 249 @Override |
| 251 public boolean onOptionsItemSelected(MenuItem item) | 250 public boolean onOptionsItemSelected(MenuItem item) |
| 252 { | 251 { |
| 253 switch (item.getItemId()) | 252 switch (item.getItemId()) |
| 254 { | 253 { |
| 254 case R.id.menu_help: |
| 255 Uri uri = Uri.parse(getString(R.string.configuring_url)); |
| 256 Intent intent = new Intent(Intent.ACTION_VIEW, uri); |
| 257 startActivity(intent); |
| 258 return true; |
| 259 case R.id.menu_about: |
| 260 showDialog(ABOUT_DIALOG); |
| 261 return true; |
| 255 case R.id.menu_advanced: | 262 case R.id.menu_advanced: |
| 256 startActivity(new Intent(this, AdvancedPreferences.class)); | 263 startActivity(new Intent(this, AdvancedPreferences.class)); |
| 257 return true; | 264 return true; |
| 258 default: | 265 default: |
| 259 return super.onOptionsItemSelected(item); | 266 return super.onOptionsItemSelected(item); |
| 260 } | 267 } |
| 261 } | 268 } |
| 262 | 269 |
| 263 private void setEnabled(boolean enabled) | 270 private void setEnabled(boolean enabled) |
| 264 { | 271 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 out.flush(); | 324 out.flush(); |
| 318 out.close(); | 325 out.close(); |
| 319 } | 326 } |
| 320 catch (Exception e) | 327 catch (Exception e) |
| 321 { | 328 { |
| 322 Log.e(TAG, "Asset copy error", e); | 329 Log.e(TAG, "Asset copy error", e); |
| 323 } | 330 } |
| 324 } | 331 } |
| 325 } | 332 } |
| 326 | 333 |
| 327 /** | |
| 328 * Redirects user to configuration URL. | |
| 329 */ | |
| 330 public void onHelp(View view) | |
| 331 { | |
| 332 Uri uri = Uri.parse(getString(R.string.configuring_url)); | |
| 333 Intent intent = new Intent(Intent.ACTION_VIEW, uri); | |
| 334 startActivity(intent); | |
| 335 } | |
| 336 | |
| 337 /** | |
| 338 * Shows about dialog. | |
| 339 */ | |
| 340 public void onAbout(View view) | |
| 341 { | |
| 342 showDialog(ABOUT_DIALOG); | |
| 343 } | |
| 344 | |
| 345 @Override | 334 @Override |
| 346 protected Dialog onCreateDialog(int id) | 335 protected Dialog onCreateDialog(int id) |
| 347 { | 336 { |
| 348 Dialog dialog = null; | 337 Dialog dialog = null; |
| 349 switch (id) | 338 switch (id) |
| 350 { | 339 { |
| 351 case ABOUT_DIALOG: | 340 case ABOUT_DIALOG: |
| 352 dialog = new AboutDialog(this); | 341 dialog = new AboutDialog(this); |
| 353 break; | 342 break; |
| 354 case HIDEICONWARNING_DIALOG: | 343 case HIDEICONWARNING_DIALOG: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 showConfigurationMsg(getString(R.string.msg_configuration, proxyServic
e.port)); | 518 showConfigurationMsg(getString(R.string.msg_configuration, proxyServic
e.port)); |
| 530 } | 519 } |
| 531 | 520 |
| 532 public void onServiceDisconnected(ComponentName className) | 521 public void onServiceDisconnected(ComponentName className) |
| 533 { | 522 { |
| 534 proxyService = null; | 523 proxyService = null; |
| 535 Log.d(TAG, "Proxy service disconnected"); | 524 Log.d(TAG, "Proxy service disconnected"); |
| 536 } | 525 } |
| 537 }; | 526 }; |
| 538 } | 527 } |
| OLD | NEW |