| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 package org.adblockplus.sbrowser.contentblocker; | 18 package org.adblockplus.sbrowser.contentblocker; |
| 19 | 19 |
| 20 import java.io.BufferedReader; | |
| 21 import java.io.IOException; | |
| 22 import java.io.InputStreamReader; | |
| 23 | |
| 24 import org.adblockplus.sbrowser.contentblocker.engine.Engine; | 20 import org.adblockplus.sbrowser.contentblocker.engine.Engine; |
| 25 import org.adblockplus.sbrowser.contentblocker.engine.EngineService; | 21 import org.adblockplus.sbrowser.contentblocker.engine.EngineService; |
| 26 import org.adblockplus.adblockplussbrowser.R; | 22 import org.adblockplus.adblockplussbrowser.R; |
| 27 | 23 |
| 28 import android.app.AlertDialog; | 24 import android.app.AlertDialog; |
| 29 import android.app.Dialog; | 25 import android.app.Dialog; |
| 30 import android.app.ProgressDialog; | 26 import android.app.ProgressDialog; |
| 31 import android.content.DialogInterface; | 27 import android.content.DialogInterface; |
| 32 import android.content.DialogInterface.OnClickListener; | 28 import android.content.DialogInterface.OnClickListener; |
| 33 import android.content.Intent; | 29 import android.content.Intent; |
| 34 import android.content.SharedPreferences; | 30 import android.content.SharedPreferences; |
| 35 import android.net.Uri; | 31 import android.net.Uri; |
| 36 import android.os.Bundle; | 32 import android.os.Bundle; |
| 37 import android.preference.PreferenceActivity; | 33 import android.preference.PreferenceActivity; |
| 38 import android.preference.PreferenceManager; | 34 import android.preference.PreferenceManager; |
| 39 import android.text.Html; | 35 import android.text.Html; |
| 40 import android.util.Log; | 36 import android.util.Log; |
| 41 | 37 |
| 42 public class MainPreferences extends PreferenceActivity implements | 38 public class MainPreferences extends PreferenceActivity implements |
| 43 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC
hangeListener | 39 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC
hangeListener |
| 44 { | 40 { |
| 45 private static final String TAG = MainPreferences.class.getSimpleName(); | 41 private static final String TAG = MainPreferences.class.getSimpleName(); |
| 46 private static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser"; | |
| 47 private Engine engine = null; | 42 private Engine engine = null; |
| 48 private Dialog dialog; | 43 private Dialog dialog; |
| 49 private int dialogTitleResId; | 44 private int dialogTitleResId; |
| 50 | 45 |
| 51 private SharedPreferences getSharedPreferences() | 46 private SharedPreferences getSharedPreferences() |
| 52 { | 47 { |
| 53 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont
ext()); | 48 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont
ext()); |
| 54 } | 49 } |
| 55 | 50 |
| 56 @Override | 51 @Override |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 .setTitle(this.dialogTitleResId) | 118 .setTitle(this.dialogTitleResId) |
| 124 .setMessage(Html.fromHtml(getString(R.string.sbrowser_dialog_message))
) | 119 .setMessage(Html.fromHtml(getString(R.string.sbrowser_dialog_message))
) |
| 125 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener
() | 120 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener
() |
| 126 { | 121 { |
| 127 @Override | 122 @Override |
| 128 public void onClick(DialogInterface dialog, int which) | 123 public void onClick(DialogInterface dialog, int which) |
| 129 { | 124 { |
| 130 try | 125 try |
| 131 { | 126 { |
| 132 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/
/details?id=" | 127 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/
/details?id=" |
| 133 + SBROWSER_APP_ID))); | 128 + Engine.SBROWSER_APP_ID))); |
| 134 } | 129 } |
| 135 catch (final Throwable t) | 130 catch (final Throwable t) |
| 136 { | 131 { |
| 137 startActivity(new Intent(Intent.ACTION_VIEW, Uri | 132 startActivity(new Intent(Intent.ACTION_VIEW, Uri |
| 138 .parse("https://play.google.com/store/apps/details?id=" + SB
ROWSER_APP_ID))); | 133 .parse("https://play.google.com/store/apps/details?id=" + En
gine.SBROWSER_APP_ID))); |
| 139 } | 134 } |
| 140 } | 135 } |
| 141 }).create(); | 136 }).create(); |
| 142 this.dialog.show(); | 137 this.dialog.show(); |
| 143 } | 138 } |
| 144 else | 139 else |
| 145 { | 140 { |
| 146 this.checkAAStatusAndProceed(); | 141 this.checkAAStatusAndProceed(); |
| 147 } | 142 } |
| 148 } | 143 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 final boolean applicationActivated = this.getSharedPreferences() | 178 final boolean applicationActivated = this.getSharedPreferences() |
| 184 .getBoolean(this.getString(R.string.key_application_activated), false); | 179 .getBoolean(this.getString(R.string.key_application_activated), false); |
| 185 | 180 |
| 186 if (!applicationActivated) | 181 if (!applicationActivated) |
| 187 { | 182 { |
| 188 Log.d(TAG, "Showing setup dialog"); | 183 Log.d(TAG, "Showing setup dialog"); |
| 189 this.dialogTitleResId = R.string.setup_dialog_title; | 184 this.dialogTitleResId = R.string.setup_dialog_title; |
| 190 this.dialog = new AlertDialog.Builder(this) | 185 this.dialog = new AlertDialog.Builder(this) |
| 191 .setCancelable(false) | 186 .setCancelable(false) |
| 192 .setTitle(this.dialogTitleResId) | 187 .setTitle(this.dialogTitleResId) |
| 193 .setMessage(Html.fromHtml(getString(R.string.setup_dialog_message))) | 188 .setMessage(Html.fromHtml(getString(Engine.hasSamsungInternetVersion5O
rNewer(MainPreferences.this) ? |
| 189 R.string.setup_dialog_message_sbrowser_5 : R.string.setup_dial
og_message_sbrowser_4))) |
| 194 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener() | 190 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener() |
| 195 { | 191 { |
| 196 @Override | 192 @Override |
| 197 public void onClick(DialogInterface dialog, int which) | 193 public void onClick(DialogInterface dialog, int which) |
| 198 { | 194 { |
| 199 Engine.openSBrowserSettings(MainPreferences.this); | 195 Engine.openSBrowserSettings(MainPreferences.this); |
| 200 } | 196 } |
| 201 }) | 197 }) |
| 202 .create(); | 198 .create(); |
| 203 this.dialog.show(); | 199 this.dialog.show(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 232 this.engine.changeSubscriptionState(id, enabled); | 228 this.engine.changeSubscriptionState(id, enabled); |
| 233 } | 229 } |
| 234 else if (this.getString(R.string.key_application_activated).equals(key)) | 230 else if (this.getString(R.string.key_application_activated).equals(key)) |
| 235 { | 231 { |
| 236 if (this.dialogTitleResId == R.string.setup_dialog_title) | 232 if (this.dialogTitleResId == R.string.setup_dialog_title) |
| 237 { | 233 { |
| 238 this.dismissDialog(); | 234 this.dismissDialog(); |
| 239 } | 235 } |
| 240 } | 236 } |
| 241 } | 237 } |
| 242 } | 238 } |
| OLD | NEW |