Index: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
=================================================================== |
--- a/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
+++ b/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
@@ -33,17 +33,18 @@ import android.preference.PreferenceActi |
import android.preference.PreferenceManager; |
import android.text.Html; |
import android.util.Log; |
import android.view.Gravity; |
import android.widget.Button; |
import android.widget.LinearLayout; |
public class MainPreferences extends PreferenceActivity implements |
- EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceChangeListener |
+ EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceChangeListener, |
+ Engine.SubscriptionUpdateCallback |
{ |
private static final String TAG = MainPreferences.class.getSimpleName(); |
private Engine engine = null; |
private AlertDialog dialog; |
private int dialogTitleResId; |
private SharedPreferences getSharedPreferences() |
{ |
@@ -208,16 +209,22 @@ public class MainPreferences extends Pre |
} |
} |
@Override |
public void onEngineCreated(Engine engine, boolean success) |
{ |
Log.d(TAG, "onEngineCreated: " + success); |
this.engine = success ? engine : null; |
+ |
+ if (this.engine != null) |
+ { |
+ this.engine.setSubscriptionUpdateCallback(this); |
+ } |
+ |
if (this.dialogTitleResId == R.string.initialization_title) |
{ |
this.dismissDialog(); |
this.checkForCompatibleSBrowserAndProceed(); |
} |
} |
@@ -238,9 +245,25 @@ public class MainPreferences extends Pre |
else if (this.getString(R.string.key_application_activated).equals(key)) |
{ |
if (this.dialogTitleResId == R.string.setup_dialog_title) |
{ |
this.dismissDialog(); |
} |
} |
} |
+ |
+ @Override |
+ public void subscriptionUpdateRequested(final boolean enabled) |
+ { |
+ this.dialog = ProgressDialog.show(this, null, enabled ? |
+ getString(R.string.add_subscription_dialog_message) : getString(R.string.remove_subscription_dialog_message)); |
+ } |
+ |
+ @Override |
+ public void subscriptionUpdatedApplied() |
+ { |
+ if (dialog != null) |
+ { |
+ 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
|
+ } |
+ } |
} |