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 org.adblockplus.sbrowser.contentblocker.engine.Engine; | 20 import org.adblockplus.sbrowser.contentblocker.engine.Engine; |
21 import org.adblockplus.sbrowser.contentblocker.engine.EngineService; | 21 import org.adblockplus.sbrowser.contentblocker.engine.EngineService; |
22 import org.adblockplus.adblockplussbrowser.R; | 22 import org.adblockplus.adblockplussbrowser.R; |
23 | 23 |
24 import android.app.AlertDialog; | 24 import android.app.AlertDialog; |
25 import android.app.Dialog; | |
26 import android.app.ProgressDialog; | 25 import android.app.ProgressDialog; |
27 import android.content.DialogInterface; | 26 import android.content.DialogInterface; |
28 import android.content.DialogInterface.OnClickListener; | 27 import android.content.DialogInterface.OnClickListener; |
29 import android.content.Intent; | 28 import android.content.Intent; |
30 import android.content.SharedPreferences; | 29 import android.content.SharedPreferences; |
31 import android.net.Uri; | 30 import android.net.Uri; |
32 import android.os.Bundle; | 31 import android.os.Bundle; |
33 import android.preference.PreferenceActivity; | 32 import android.preference.PreferenceActivity; |
34 import android.preference.PreferenceManager; | 33 import android.preference.PreferenceManager; |
35 import android.text.Html; | 34 import android.text.Html; |
36 import android.util.Log; | 35 import android.util.Log; |
| 36 import android.view.Gravity; |
| 37 import android.widget.Button; |
| 38 import android.widget.LinearLayout; |
37 | 39 |
38 public class MainPreferences extends PreferenceActivity implements | 40 public class MainPreferences extends PreferenceActivity implements |
39 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC
hangeListener | 41 EngineService.OnEngineCreatedCallback, SharedPreferences.OnSharedPreferenceC
hangeListener |
40 { | 42 { |
41 private static final String TAG = MainPreferences.class.getSimpleName(); | 43 private static final String TAG = MainPreferences.class.getSimpleName(); |
42 private Engine engine = null; | 44 private Engine engine = null; |
43 private Dialog dialog; | 45 private AlertDialog dialog; |
44 private int dialogTitleResId; | 46 private int dialogTitleResId; |
45 | 47 |
46 private SharedPreferences getSharedPreferences() | 48 private SharedPreferences getSharedPreferences() |
47 { | 49 { |
48 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont
ext()); | 50 return PreferenceManager.getDefaultSharedPreferences(this.getApplicationCont
ext()); |
49 } | 51 } |
50 | 52 |
51 @Override | 53 @Override |
52 public void onCreate(Bundle savedInstanceState) | 54 public void onCreate(Bundle savedInstanceState) |
53 { | 55 { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener() | 192 .setNeutralButton(R.string.setup_dialog_button, new OnClickListener() |
191 { | 193 { |
192 @Override | 194 @Override |
193 public void onClick(DialogInterface dialog, int which) | 195 public void onClick(DialogInterface dialog, int which) |
194 { | 196 { |
195 Engine.openSBrowserSettings(MainPreferences.this); | 197 Engine.openSBrowserSettings(MainPreferences.this); |
196 } | 198 } |
197 }) | 199 }) |
198 .create(); | 200 .create(); |
199 this.dialog.show(); | 201 this.dialog.show(); |
| 202 |
| 203 final Button btNeutral = this.dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
; |
| 204 final LinearLayout.LayoutParams btNeutralLayoutParams = (LinearLayout.Layo
utParams) btNeutral.getLayoutParams(); |
| 205 btNeutralLayoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; |
| 206 btNeutralLayoutParams.gravity = Gravity.CENTER; |
| 207 btNeutral.setLayoutParams(btNeutralLayoutParams); |
200 } | 208 } |
201 } | 209 } |
202 | 210 |
203 @Override | 211 @Override |
204 public void onEngineCreated(Engine engine, boolean success) | 212 public void onEngineCreated(Engine engine, boolean success) |
205 { | 213 { |
206 Log.d(TAG, "onEngineCreated: " + success); | 214 Log.d(TAG, "onEngineCreated: " + success); |
207 this.engine = success ? engine : null; | 215 this.engine = success ? engine : null; |
208 if (this.dialogTitleResId == R.string.initialization_title) | 216 if (this.dialogTitleResId == R.string.initialization_title) |
209 { | 217 { |
(...skipping 19 matching lines...) Expand all Loading... |
229 } | 237 } |
230 else if (this.getString(R.string.key_application_activated).equals(key)) | 238 else if (this.getString(R.string.key_application_activated).equals(key)) |
231 { | 239 { |
232 if (this.dialogTitleResId == R.string.setup_dialog_title) | 240 if (this.dialogTitleResId == R.string.setup_dialog_title) |
233 { | 241 { |
234 this.dismissDialog(); | 242 this.dismissDialog(); |
235 } | 243 } |
236 } | 244 } |
237 } | 245 } |
238 } | 246 } |
OLD | NEW |