| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 super.onStart(); | 71 super.onStart(); |
| 72 EngineService.startService(this, this); | 72 EngineService.startService(this, this); |
| 73 } | 73 } |
| 74 | 74 |
| 75 @Override | 75 @Override |
| 76 protected void onStop() | 76 protected void onStop() |
| 77 { | 77 { |
| 78 super.onStop(); | 78 super.onStop(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 private void checkForCompatibleSBrowser() | 81 private void checkForCompatibleSBrowserAndProceed() |
| 82 { | 82 { |
| 83 if (!Engine.hasCompatibleSBrowserInstalled(this.getApplicationContext())) | 83 if (!Engine.hasCompatibleSBrowserInstalled(this.getApplicationContext())) |
| 84 { | 84 { |
| 85 final AlertDialog d = new AlertDialog.Builder(this) | 85 final AlertDialog d = new AlertDialog.Builder(this) |
| 86 .setCancelable(false) | 86 .setCancelable(false) |
| 87 .setTitle(R.string.sbrowser_dialog_title) | 87 .setTitle(R.string.sbrowser_dialog_title) |
| 88 .setMessage(Html.fromHtml(this.readTextFile(R.raw.sbrowser_dialog))) | 88 .setMessage(Html.fromHtml(this.readTextFile(R.raw.sbrowser_dialog))) |
| 89 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener () | 89 .setNeutralButton(R.string.sbrowser_dialog_button, new OnClickListener () |
| 90 { | 90 { |
| 91 @Override | 91 @Override |
| 92 public void onClick(DialogInterface dialog, int which) | 92 public void onClick(DialogInterface dialog, int which) |
| 93 { | 93 { |
| 94 try | 94 try |
| 95 { | 95 { |
| 96 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/ /details?id=" | 96 startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market:/ /details?id=" |
| 97 + SBROWSER_APP_ID))); | 97 + SBROWSER_APP_ID))); |
| 98 } | 98 } |
| 99 catch (final Throwable t) | 99 catch (final Throwable t) |
| 100 { | 100 { |
| 101 startActivity(new Intent(Intent.ACTION_VIEW, Uri | 101 startActivity(new Intent(Intent.ACTION_VIEW, Uri |
| 102 .parse("https://play.google.com/store/apps/details?id=" + SB ROWSER_APP_ID))); | 102 .parse("https://play.google.com/store/apps/details?id=" + SB ROWSER_APP_ID))); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 }).create(); | 105 }).create(); |
| 106 d.show(); | 106 d.show(); |
| 107 } | 107 } |
| 108 else | 108 else |
| 109 { | 109 { |
| 110 this.checkAAStatus(); | 110 this.checkAAStatusAndProceed(); |
|
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.
| |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 private void checkAAStatus() | 114 private void checkAAStatusAndProceed() |
| 115 { | 115 { |
| 116 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(this); | 116 final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreference s(this); |
| 117 final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown); | 117 final String keyAaInfoShown = this.getString(R.string.key_aa_info_shown); |
| 118 final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false); | 118 final boolean aaInfoShown = prefs.getBoolean(keyAaInfoShown, false); |
| 119 if (!aaInfoShown) | 119 if (!aaInfoShown) |
| 120 { | 120 { |
| 121 final AlertDialog d = new AlertDialog.Builder(this) | 121 final AlertDialog d = new AlertDialog.Builder(this) |
| 122 .setCancelable(false) | 122 .setCancelable(false) |
| 123 .setTitle(R.string.aa_dialog_title) | 123 .setTitle(R.string.aa_dialog_title) |
| 124 .setMessage(Html.fromHtml(this.readTextFile(R.raw.aa_dialog))) | 124 .setMessage(Html.fromHtml(this.readTextFile(R.raw.aa_dialog))) |
| 125 .setNeutralButton(R.string.aa_dialog_button, new OnClickListener() | 125 .setNeutralButton(R.string.aa_dialog_button, new OnClickListener() |
| 126 { | 126 { |
| 127 @Override | 127 @Override |
| 128 public void onClick(DialogInterface dialog, int which) | 128 public void onClick(DialogInterface dialog, int which) |
| 129 { | 129 { |
| 130 prefs.edit() | 130 prefs.edit() |
| 131 .putBoolean(keyAaInfoShown, true) | 131 .putBoolean(keyAaInfoShown, true) |
| 132 .commit(); | 132 .commit(); |
| 133 MainPreferences.this.checkSetupStatus(); | 133 MainPreferences.this.checkSetupStatus(); |
| 134 } | 134 } |
| 135 }).create(); | 135 }).create(); |
| 136 d.show(); | 136 d.show(); |
| 137 } | 137 } |
| 138 else | 138 else |
| 139 { | 139 { |
| 140 this.checkSetupStatus(); | 140 this.checkSetupStatus(); |
|
Felix Dahlke
2016/04/01 08:54:53
Same as above.
René Jeschke
2016/04/10 22:03:25
See above.
| |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 private void checkSetupStatus() | 144 private void checkSetupStatus() |
| 145 { | 145 { |
| 146 final boolean applicationActivated = PreferenceManager.getDefaultSharedPrefe rences(this) | 146 final boolean applicationActivated = PreferenceManager.getDefaultSharedPrefe rences(this) |
| 147 .getBoolean(this.getString(R.string.key_application_activated), false); | 147 .getBoolean(this.getString(R.string.key_application_activated), false); |
| 148 | 148 |
| 149 if (!applicationActivated) | 149 if (!applicationActivated) |
| 150 { | 150 { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 169 @Override | 169 @Override |
| 170 public void onEngineCreated(Engine engine, boolean success) | 170 public void onEngineCreated(Engine engine, boolean success) |
| 171 { | 171 { |
| 172 Log.d(TAG, "onEngineCreated: " + success); | 172 Log.d(TAG, "onEngineCreated: " + success); |
| 173 this.engine = success ? engine : null; | 173 this.engine = success ? engine : null; |
| 174 if (this.progressDialog != null) | 174 if (this.progressDialog != null) |
| 175 { | 175 { |
| 176 this.progressDialog.dismiss(); | 176 this.progressDialog.dismiss(); |
| 177 this.progressDialog = null; | 177 this.progressDialog = null; |
| 178 | 178 |
| 179 this.checkForCompatibleSBrowser(); | 179 this.checkForCompatibleSBrowserAndProceed(); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 @Override | 183 @Override |
| 184 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) | 184 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Str ing key) |
| 185 { | 185 { |
| 186 if (this.getString(R.string.key_automatic_updates).equals(key) && this.engin e != null) | 186 if (this.getString(R.string.key_automatic_updates).equals(key) && this.engin e != null) |
| 187 { | 187 { |
| 188 this.engine.connectivityChanged(); | 188 this.engine.connectivityChanged(); |
| 189 } | 189 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 r.close(); | 225 r.close(); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 catch (IOException e) | 228 catch (IOException e) |
| 229 { | 229 { |
| 230 Log.e(TAG, "Resource reading failed for: " + id, e); | 230 Log.e(TAG, "Resource reading failed for: " + id, e); |
| 231 return "..."; | 231 return "..."; |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| LEFT | RIGHT |