| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 */ | 59 */ |
| 60 public class Preferences extends SummarizedPreferences | 60 public class Preferences extends SummarizedPreferences |
| 61 { | 61 { |
| 62 private static final String TAG = "Preferences"; | 62 private static final String TAG = "Preferences"; |
| 63 | 63 |
| 64 private static final int ABOUT_DIALOG = 1; | 64 private static final int ABOUT_DIALOG = 1; |
| 65 private static final int HIDEICONWARNING_DIALOG = 2; | 65 private static final int HIDEICONWARNING_DIALOG = 2; |
| 66 | 66 |
| 67 private static ProxyService proxyService = null; | 67 private static ProxyService proxyService = null; |
| 68 | 68 |
| 69 private static boolean firstRunActionsPending = true; | |
| 70 | |
| 69 private RefreshableListPreference subscriptionList; | 71 private RefreshableListPreference subscriptionList; |
| 70 | 72 |
| 71 private String subscriptionSummary; | 73 private String subscriptionSummary; |
| 72 | 74 |
| 73 @Override | 75 @Override |
| 74 public void onCreate(Bundle savedInstanceState) | 76 public void onCreate(Bundle savedInstanceState) |
| 75 { | 77 { |
| 76 super.onCreate(savedInstanceState); | 78 super.onCreate(savedInstanceState); |
| 77 | 79 |
| 78 PreferenceManager.setDefaultValues(this, R.xml.preferences, true); | 80 PreferenceManager.setDefaultValues(this, R.xml.preferences, true); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 | 134 |
| 133 final AdblockPlus application = AdblockPlus.getApplication(); | 135 final AdblockPlus application = AdblockPlus.getApplication(); |
| 134 | 136 |
| 135 Subscription current = null; | 137 Subscription current = null; |
| 136 Subscription[] subscriptions = application.getListedSubscriptions(); | 138 Subscription[] subscriptions = application.getListedSubscriptions(); |
| 137 if (subscriptions.length > 0) | 139 if (subscriptions.length > 0) |
| 138 { | 140 { |
| 139 current = subscriptions[0]; | 141 current = subscriptions[0]; |
| 140 } | 142 } |
| 141 | 143 |
| 142 boolean firstRun = false; | 144 boolean firstRun = firstRunActionsPending && application.isFirstRun(); |
| 143 if (application.isFirstRun()) | 145 if (firstRun && current != null) |
| 144 { | 146 { |
| 145 firstRun = true; | 147 new AlertDialog.Builder(this).setTitle(R.string.app_name) |
| 146 | 148 .setMessage(String.format(getString(R.string.msg_subscription_offer, c urrent.title))) |
| 147 if (current != null) | 149 .setIcon(android.R.drawable.ic_dialog_info) |
| 148 { | 150 .setPositiveButton(R.string.ok, null).create().show(); |
| 149 new AlertDialog.Builder(this).setTitle(R.string.app_name).setMessage(Str ing.format(getString(R.string.msg_subscription_offer, current.title))).setIcon(a ndroid.R.drawable.ic_dialog_info) | |
| 150 .setPositiveButton(R.string.ok, null).create().show(); | |
| 151 } | |
| 152 } | 151 } |
| 153 | 152 |
| 154 // Enable manual subscription refresh | 153 // Enable manual subscription refresh |
| 155 subscriptionList.setOnRefreshClickListener(new View.OnClickListener() | 154 subscriptionList.setOnRefreshClickListener(new View.OnClickListener() |
| 156 { | 155 { |
| 157 @Override | 156 @Override |
| 158 public void onClick(View v) | 157 public void onClick(View v) |
| 159 { | 158 { |
| 160 application.refreshSubscriptions(); | 159 application.refreshSubscriptions(); |
| 161 } | 160 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 184 | 183 |
| 185 // This is weird but UI does not update on back button (when returning from advanced preferences) | 184 // This is weird but UI does not update on back button (when returning from advanced preferences) |
| 186 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled); | 185 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled); |
| 187 | 186 |
| 188 if (enabled || firstRun) | 187 if (enabled || firstRun) |
| 189 setFilteringEnabled(true); | 188 setFilteringEnabled(true); |
| 190 if (enabled || firstRun || (proxyenabled && !autoconfigured)) | 189 if (enabled || firstRun || (proxyenabled && !autoconfigured)) |
| 191 setProxyEnabled(true); | 190 setProxyEnabled(true); |
| 192 | 191 |
| 193 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ; | 192 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ; |
| 193 firstRunActionsPending = false; | |
|
Wladimir Palant
2013/11/08 06:08:20
IMHO it's better to group related operations - I w
Felix Dahlke
2013/11/08 08:37:36
Hehe, I was actually pondering that :) I'd prefer
| |
| 194 } | 194 } |
| 195 | 195 |
| 196 @Override | 196 @Override |
| 197 public void onPause() | 197 public void onPause() |
| 198 { | 198 { |
| 199 super.onPause(); | 199 super.onPause(); |
| 200 try | 200 try |
| 201 { | 201 { |
| 202 unregisterReceiver(receiver); | 202 unregisterReceiver(receiver); |
| 203 } | 203 } |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 showConfigurationMsg(getString(R.string.msg_configuration)); | 524 showConfigurationMsg(getString(R.string.msg_configuration)); |
| 525 } | 525 } |
| 526 | 526 |
| 527 public void onServiceDisconnected(ComponentName className) | 527 public void onServiceDisconnected(ComponentName className) |
| 528 { | 528 { |
| 529 proxyService = null; | 529 proxyService = null; |
| 530 Log.d(TAG, "Proxy service disconnected"); | 530 Log.d(TAG, "Proxy service disconnected"); |
| 531 } | 531 } |
| 532 }; | 532 }; |
| 533 } | 533 } |
| OLD | NEW |