| Index: src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
| diff --git a/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java b/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
| index a2ef1491936baba1da434497142bc654cb80bddd..a7ca55b0fd0d0a9da503dbfb77a9eb9f2d394a19 100644 |
| --- a/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
| +++ b/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java |
| @@ -29,7 +29,9 @@ import android.app.AlertDialog; |
| import android.app.ProgressDialog; |
| import android.content.DialogInterface; |
| import android.content.DialogInterface.OnClickListener; |
| +import android.content.Intent; |
| import android.content.SharedPreferences; |
| +import android.net.Uri; |
| import android.os.Bundle; |
| import android.preference.PreferenceActivity; |
| import android.preference.PreferenceManager; |
| @@ -40,6 +42,7 @@ public class MainPreferences extends PreferenceActivity implements |
| EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceChangeListener |
| { |
| private static final String TAG = MainPreferences.class.getSimpleName(); |
| + private static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser"; |
| private ProgressDialog progressDialog = null; |
| private Engine engine = null; |
| private AlertDialog setupDialog = null; |
| @@ -75,6 +78,69 @@ public class MainPreferences extends PreferenceActivity implements |
| super.onStop(); |
| } |
| + private void checkForCompatibleSBrowser() |
| + { |
| + if (!Engine.hasCompatibleSBrowserInstalled(this.getApplicationContext())) |
| + { |
| + final AlertDialog d = new AlertDialog.Builder(this) |
| + .setCancelable(false) |
| + .setTitle(R.string.sbrowser_dialog_title) |
| + .setMessage(Html.fromHtml(this.readTextFile(R.raw.sbrowser_dialog))) |
| + .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener() |
| + { |
| + @Override |
| + public void onClick(DialogInterface dialog, int which) |
| + { |
| + try |
| + { |
| + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" |
| + + SBROWSER_APP_ID))); |
| + } |
| + catch (final Throwable t) |
| + { |
| + startActivity(new Intent(Intent.ACTION_VIEW, Uri |
| + .parse("https://play.google.com/store/apps/details?id=" + SBROWSER_APP_ID))); |
| + } |
| + } |
| + }).create(); |
| + d.show(); |
| + } |
| + else |
| + { |
| + this.checkAAStatus(); |
|
Felix Dahlke
2016/04/01 08:54:53
Unless I'm missing something, this has nothing to
René Jeschke
2016/04/10 22:03:25
Well, yeah, those methods aren't really named corr
Felix Dahlke
2016/04/11 13:53:48
Well, all the logic would be in the caller and non
René Jeschke
2016/04/12 09:10:04
Na, the thing is ... the method need to _exit_ to
Felix Dahlke
2016/04/12 11:44:46
OK I see, didn't realise that `checkAAStatus` is c
René Jeschke
2016/04/12 13:32:39
Done.
|
| + } |
| + } |
| + |
| + private void checkAAStatus() |
| + { |
| + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
| + final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown); |
| + final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false); |
| + if (!aaInfoShown) |
| + { |
| + final AlertDialog d = new AlertDialog.Builder(this) |
| + .setCancelable(false) |
| + .setTitle(R.string.aa_dialog_title) |
| + .setMessage(Html.fromHtml(this.readTextFile(R.raw.aa_dialog))) |
| + .setNeutralButton(R.string.aa_dialog_button, new OnClickListener() |
| + { |
| + @Override |
| + public void onClick(DialogInterface dialog, int which) |
| + { |
| + prefs.edit() |
| + .putBoolean(keyAaInfoShown, true) |
| + .commit(); |
| + MainPreferences.this.checkSetupStatus(); |
| + } |
| + }).create(); |
| + d.show(); |
| + } |
| + else |
| + { |
| + this.checkSetupStatus(); |
|
Felix Dahlke
2016/04/01 08:54:53
Same as above.
René Jeschke
2016/04/10 22:03:25
See above.
|
| + } |
| + } |
| + |
| private void checkSetupStatus() |
| { |
| final boolean applicationActivated = PreferenceManager.getDefaultSharedPreferences(this) |
| @@ -110,32 +176,7 @@ public class MainPreferences extends PreferenceActivity implements |
| this.progressDialog.dismiss(); |
| this.progressDialog = null; |
| - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); |
| - final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown); |
| - final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false); |
| - if (!aaInfoShown) |
| - { |
| - AlertDialog d = new AlertDialog.Builder(this) |
| - .setCancelable(false) |
| - .setTitle(R.string.aa_dialog_title) |
| - .setMessage(Html.fromHtml(this.readTextFile(R.raw.aa_dialog))) |
| - .setNeutralButton(R.string.aa_dialog_button, new OnClickListener() |
| - { |
| - @Override |
| - public void onClick(DialogInterface dialog, int which) |
| - { |
| - prefs.edit() |
| - .putBoolean(keyAaInfoShown, true) |
| - .commit(); |
| - MainPreferences.this.checkSetupStatus(); |
| - } |
| - }).create(); |
| - d.show(); |
| - } |
| - else |
| - { |
| - this.checkSetupStatus(); |
| - } |
| + this.checkForCompatibleSBrowser(); |
| } |
| } |