| Index: mobile/android/thirdparty/org/adblockplus/browser/AbpCheckBoxPreference.java | 
| diff --git a/mobile/android/thirdparty/org/adblockplus/browser/AbpCheckBoxPreference.java b/mobile/android/thirdparty/org/adblockplus/browser/AbpCheckBoxPreference.java | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..507034d295be5dfcadaa660cf3e34f1de1046aca | 
| --- /dev/null | 
| +++ b/mobile/android/thirdparty/org/adblockplus/browser/AbpCheckBoxPreference.java | 
| @@ -0,0 +1,111 @@ | 
| +/* | 
| + * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| + * Copyright (C) 2006-2015 Eyeo GmbH | 
| + * | 
| + * Adblock Plus is free software: you can redistribute it and/or modify | 
| + * it under the terms of the GNU General Public License version 3 as | 
| + * published by the Free Software Foundation. | 
| + * | 
| + * Adblock Plus is distributed in the hope that it will be useful, | 
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| + * GNU General Public License for more details. | 
| + * | 
| + * You should have received a copy of the GNU General Public License | 
| + * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| + */ | 
| + | 
| +package org.adblockplus.browser; | 
| + | 
| +import org.mozilla.gecko.preferences.CustomCheckBoxPreference; | 
| +import org.mozilla.gecko.util.NativeJSObject; | 
| +import org.mozilla.gecko.util.ThreadUtils; | 
| + | 
| +import android.content.Context; | 
| +import android.preference.PreferenceManager; | 
| +import android.util.AttributeSet; | 
| +import android.util.Log; | 
| +import android.view.View; | 
| + | 
| +public class AbpCheckBoxPreference extends CustomCheckBoxPreference implements | 
| + AdblockPlusApiCallback | 
| +{ | 
| + private static final String TAG = "AdblockBrowser.AbpCheckBoxPreference"; | 
| + private String apiKey = ""; | 
| + | 
| + public AbpCheckBoxPreference(Context context) | 
| + { | 
| + super(context); | 
| + } | 
| + | 
| + public AbpCheckBoxPreference(Context context, AttributeSet attrs) | 
| + { | 
| + super(context, attrs); | 
| + } | 
| + | 
| + public AbpCheckBoxPreference(Context context, AttributeSet attrs, int defStyle) | 
| + { | 
| + super(context, attrs, defStyle); | 
| + } | 
| + | 
| + @Override | 
| + protected void onAttachedToActivity() | 
| + { | 
| + super.onAttachedToActivity(); | 
| + } | 
| + | 
| + @Override | 
| + protected void onAttachedToHierarchy(PreferenceManager preferenceManager) | 
| + { | 
| + super.onAttachedToHierarchy(preferenceManager); | 
| + this.apiKey = this.getKey().substring(this.getKey().lastIndexOf('.') + 1); | 
| + this.setEnabled(false); | 
| + this.recheckValue(); | 
| + Log.d(TAG, "ApiKey: " + this.apiKey); | 
| + } | 
| + | 
| + @Override | 
| + protected void onBindView(View view) | 
| + { | 
| + super.onBindView(view); | 
| + } | 
| + | 
| + private void recheckValue() | 
| + { | 
| + AddonBridge.queryBoolean(this, "query_" + this.apiKey); | 
| + } | 
| + | 
| + @Override | 
| + protected void onClick() | 
| + { | 
| + super.onClick(); | 
| + AddonBridge.setBoolean(this, "change_" + this.apiKey, this.isChecked()); | 
| + this.recheckValue(); | 
| + } | 
| + | 
| + @Override | 
| + public void onApiRequestSucceeded(NativeJSObject jsObject) | 
| + { | 
| + Log.d(TAG, "Result: " + jsObject); | 
| + if (jsObject.has("value")) | 
| + { | 
| + final boolean enabled = AddonBridge.getBooleanFromJSObject(jsObject, "value", false); | 
| + | 
| + ThreadUtils.postToUiThread(new Runnable() | 
| + { | 
| + @Override | 
| + public void run() | 
| + { | 
| + AbpCheckBoxPreference.this.setChecked(enabled); | 
| + AbpCheckBoxPreference.this.setEnabled(true); | 
| + } | 
| + }); | 
| + } | 
| + } | 
| + | 
| + @Override | 
| + public void onApiRequestFailed(String errorMessage) | 
| + { | 
| + // Currently ignored | 
| + } | 
| +} |