| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 20 matching lines...) Expand all Loading... | |
| 31 import android.os.Bundle; | 31 import android.os.Bundle; | 
| 32 import android.preference.PreferenceActivity; | 32 import android.preference.PreferenceActivity; | 
| 33 import android.preference.PreferenceManager; | 33 import android.preference.PreferenceManager; | 
| 34 import android.text.Html; | 34 import android.text.Html; | 
| 35 import android.util.Log; | 35 import android.util.Log; | 
| 36 import android.view.Gravity; | 36 import android.view.Gravity; | 
| 37 import android.widget.Button; | 37 import android.widget.Button; | 
| 38 import android.widget.LinearLayout; | 38 import android.widget.LinearLayout; | 
| 39 | 39 | 
| 40 public class MainPreferences extends PreferenceActivity implements | 40 public class MainPreferences extends PreferenceActivity implements | 
| 41 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC hangeListener | 41 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC hangeListener, | 
| 42 Engine.SubscriptionUpdateCallback | |
| 42 { | 43 { | 
| 43 private static final String TAG = MainPreferences.class.getSimpleName(); | 44 private static final String TAG = MainPreferences.class.getSimpleName(); | 
| 44 private Engine engine = null; | 45 private Engine engine = null; | 
| 45 private AlertDialog dialog; | 46 private AlertDialog dialog; | 
| 46 private int dialogTitleResId; | 47 private int dialogTitleResId; | 
| 47 | 48 | 
| 48 private SharedPreferences getSharedPreferences() | 49 private SharedPreferences getSharedPreferences() | 
| 49 { | 50 { | 
| 50 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont ext()); | 51 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont ext()); | 
| 51 } | 52 } | 
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 btNeutralLayoutParams.gravity = Gravity.CENTER; | 207 btNeutralLayoutParams.gravity = Gravity.CENTER; | 
| 207 btNeutral.setLayoutParams(btNeutralLayoutParams); | 208 btNeutral.setLayoutParams(btNeutralLayoutParams); | 
| 208 } | 209 } | 
| 209 } | 210 } | 
| 210 | 211 | 
| 211 @Override | 212 @Override | 
| 212 public void onEngineCreated(Engine engine, boolean success) | 213 public void onEngineCreated(Engine engine, boolean success) | 
| 213 { | 214 { | 
| 214 Log.d(TAG, "onEngineCreated: " + success); | 215 Log.d(TAG, "onEngineCreated: " + success); | 
| 215 this.engine = success ? engine : null; | 216 this.engine = success ? engine : null; | 
| 217 | |
| 218 if (this.engine != null) | |
| 219 { | |
| 220 this.engine.setSubscriptionUpdateCallback(this); | |
| 221 } | |
| 222 | |
| 216 if (this.dialogTitleResId == R.string.initialization_title) | 223 if (this.dialogTitleResId == R.string.initialization_title) | 
| 217 { | 224 { | 
| 218 this.dismissDialog(); | 225 this.dismissDialog(); | 
| 219 | 226 | 
| 220 this.checkForCompatibleSBrowserAndProceed(); | 227 this.checkForCompatibleSBrowserAndProceed(); | 
| 221 } | 228 } | 
| 222 } | 229 } | 
| 223 | 230 | 
| 224 @Override | 231 @Override | 
| 225 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) | 232 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 236 this.engine.changeSubscriptionState(id, enabled); | 243 this.engine.changeSubscriptionState(id, enabled); | 
| 237 } | 244 } | 
| 238 else if (this.getString(R.string.key_application_activated).equals(key)) | 245 else if (this.getString(R.string.key_application_activated).equals(key)) | 
| 239 { | 246 { | 
| 240 if (this.dialogTitleResId == R.string.setup_dialog_title) | 247 if (this.dialogTitleResId == R.string.setup_dialog_title) | 
| 241 { | 248 { | 
| 242 this.dismissDialog(); | 249 this.dismissDialog(); | 
| 243 } | 250 } | 
| 244 } | 251 } | 
| 245 } | 252 } | 
| 253 | |
| 254 @Override | |
| 255 public void subscriptionUpdateRequested(final boolean enabled) | |
| 256 { | |
| 257 this.dialog = ProgressDialog.show(this, null, enabled ? | |
| 258 getString(R.string.add_subscription_dialog_message) : getString(R.string .remove_subscription_dialog_message)); | |
| 259 } | |
| 260 | |
| 261 @Override | |
| 262 public void subscriptionUpdatedApplied() | |
| 263 { | |
| 264 if (dialog != null) | |
| 265 { | |
| 266 dialog.dismiss(); | |
| 
 
anton
2017/06/26 13:49:34
don't we need to `dialog = null` after it's dismis
 
jens
2017/06/26 14:05:20
Yeah, you're right. I think it's cleaner. I will u
 
 | |
| 267 } | |
| 268 } | |
| 246 } | 269 } | 
| OLD | NEW |