Index: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
=================================================================== |
--- a/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
+++ b/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java |
@@ -19,64 +19,47 @@ package org.adblockplus.sbrowser.content |
import java.io.File; |
import java.io.FileNotFoundException; |
import java.io.IOException; |
import org.adblockplus.adblockplussbrowser.R; |
import org.adblockplus.sbrowser.contentblocker.engine.Engine; |
import org.adblockplus.sbrowser.contentblocker.engine.EngineService; |
+import org.adblockplus.sbrowser.contentblocker.util.SharedPrefsUtils; |
import android.content.ContentProvider; |
import android.content.ContentValues; |
import android.content.Intent; |
-import android.content.SharedPreferences; |
import android.database.Cursor; |
import android.net.Uri; |
import android.os.Bundle; |
import android.os.ParcelFileDescriptor; |
-import android.preference.PreferenceManager; |
import android.util.Log; |
public class ContentBlockerContentProvider extends ContentProvider |
{ |
private static final String TAG = ContentBlockerContentProvider.class.getSimpleName(); |
@Override |
public Bundle call(String method, String arg, Bundle extras) |
{ |
// As of SBC interface v1.4 we return `null` here to signal that we do not |
// use encryption |
return null; |
} |
- private static boolean getBooleanPref(final SharedPreferences prefs, final String key, |
- final boolean defValue) |
- { |
- try |
- { |
- return prefs.getBoolean(key, defValue); |
- } |
- catch (final Throwable t) |
- { |
- return defValue; |
- } |
- } |
- |
private void setApplicationActivated() |
{ |
- final SharedPreferences prefs = PreferenceManager |
- .getDefaultSharedPreferences(this.getContext().getApplicationContext()); |
- final String key = this.getContext().getString(R.string.key_application_activated); |
- final boolean applicationActived = getBooleanPref(prefs, key, false); |
- if (!applicationActived) |
+ final boolean applicationActivated = SharedPrefsUtils.getBoolean( |
+ this.getContext(), R.string.key_application_activated, false); |
+ |
+ if (!applicationActivated) |
{ |
- prefs.edit() |
- .putBoolean(key, true) |
- .commit(); |
+ SharedPrefsUtils.putBoolean(this.getContext(), R.string.key_application_activated, true); |
} |
} |
@Override |
public ParcelFileDescriptor openFile(final Uri uri, final String mode) |
throws FileNotFoundException |
{ |
try |