| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
| 3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 /** | 56 /** |
| 57 * Main settings UI. | 57 * Main settings UI. |
| 58 */ | 58 */ |
| 59 public class Preferences extends SummarizedPreferences | 59 public class Preferences extends SummarizedPreferences |
| 60 { | 60 { |
| 61 private static final String TAG = "Preferences"; | 61 private static final String TAG = "Preferences"; |
| 62 | 62 |
| 63 private static ProxyService proxyService = null; | 63 private static ProxyService proxyService = null; |
| 64 | 64 |
| 65 private RefreshableListPreference subscriptionList; | |
|
Felix Dahlke
2012/11/28 08:12:56
Are the changes in this file related to the fix?
Andrey Novikov
2012/11/28 08:25:01
Yes, I've just moved initialization to a proper st
| |
| 66 | |
| 65 private AboutDialog aboutDialog; | 67 private AboutDialog aboutDialog; |
| 66 private boolean showAbout = false; | 68 private boolean showAbout = false; |
| 67 private boolean trafficDetected = false; | 69 private boolean trafficDetected = false; |
| 68 private String subscriptionSummary; | 70 private String subscriptionSummary; |
| 69 | 71 |
| 70 @Override | 72 @Override |
| 71 public void onCreate(Bundle savedInstanceState) | 73 public void onCreate(Bundle savedInstanceState) |
| 72 { | 74 { |
| 73 requestWindowFeature(Window.FEATURE_NO_TITLE); | 75 requestWindowFeature(Window.FEATURE_NO_TITLE); |
| 74 | 76 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 91 copyAssets(); | 93 copyAssets(); |
| 92 SharedPreferences.Editor editor = prefs.edit(); | 94 SharedPreferences.Editor editor = prefs.edit(); |
| 93 editor.putInt(getString(R.string.pref_version), thisVersion); | 95 editor.putInt(getString(R.string.pref_version), thisVersion); |
| 94 editor.commit(); | 96 editor.commit(); |
| 95 } | 97 } |
| 96 } | 98 } |
| 97 catch (NameNotFoundException e) | 99 catch (NameNotFoundException e) |
| 98 { | 100 { |
| 99 copyAssets(); | 101 copyAssets(); |
| 100 } | 102 } |
| 103 | |
| 104 AdblockPlus application = AdblockPlus.getApplication(); | |
| 105 | |
| 106 // Initialize subscription list | |
|
Felix Dahlke
2012/11/28 08:37:37
I think it makes sense to put this part into an in
| |
| 107 subscriptionList = (RefreshableListPreference) findPreference(getString(R.st ring.pref_subscription)); | |
| 108 List<Subscription> subscriptions = application.getSubscriptions(); | |
| 109 String[] entries = new String[subscriptions.size()]; | |
| 110 String[] entryValues = new String[subscriptions.size()]; | |
| 111 int i = 0; | |
| 112 for (Subscription subscription : subscriptions) | |
| 113 { | |
| 114 entries[i] = subscription.title; | |
| 115 entryValues[i] = subscription.url; | |
| 116 i++; | |
| 117 } | |
| 118 subscriptionList.setEntries(entries); | |
| 119 subscriptionList.setEntryValues(entryValues); | |
| 101 } | 120 } |
| 102 | 121 |
| 103 @Override | 122 @Override |
| 104 protected void onStart() | 123 protected void onStart() |
| 105 { | 124 { |
| 106 super.onStart(); | 125 super.onStart(); |
| 107 AdblockPlus application = AdblockPlus.getApplication(); | 126 AdblockPlus application = AdblockPlus.getApplication(); |
| 108 application.startEngine(); | 127 application.startEngine(); |
| 109 application.startInteractive(); | 128 application.startInteractive(); |
| 110 } | 129 } |
| 111 | 130 |
| 112 @Override | 131 @Override |
| 113 public void onResume() | 132 public void onResume() |
| 114 { | 133 { |
| 115 super.onResume(); | 134 super.onResume(); |
| 116 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this ); | 135 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this ); |
| 117 | 136 |
| 118 final AdblockPlus application = AdblockPlus.getApplication(); | 137 final AdblockPlus application = AdblockPlus.getApplication(); |
| 119 | 138 |
| 120 // Construct subscription list | |
| 121 RefreshableListPreference subscriptionList = (RefreshableListPreference) fin dPreference(getString(R.string.pref_subscription)); | |
| 122 List<Subscription> subscriptions = application.getSubscriptions(); | |
| 123 String[] entries = new String[subscriptions.size()]; | |
| 124 String[] entryValues = new String[subscriptions.size()]; | |
| 125 String current = prefs.getString(getString(R.string.pref_subscription), (Str ing) null); | |
| 126 int i = 0; | |
| 127 for (Subscription subscription : subscriptions) | |
| 128 { | |
| 129 entries[i] = subscription.title; | |
| 130 entryValues[i] = subscription.url; | |
| 131 i++; | |
| 132 } | |
| 133 subscriptionList.setEntries(entries); | |
| 134 subscriptionList.setEntryValues(entryValues); | |
| 135 | |
| 136 boolean firstRun = false; | 139 boolean firstRun = false; |
| 137 | 140 |
| 141 // Get current subscription | |
| 142 String current = prefs.getString(getString(R.string.pref_subscription), (Str ing) null); | |
| 143 | |
| 138 // If there is no current subscription autoselect one | 144 // If there is no current subscription autoselect one |
| 139 if (current == null) | 145 if (current == null) |
| 140 { | 146 { |
| 141 firstRun = true; | 147 firstRun = true; |
| 142 Subscription offer = application.offerSubscription(); | 148 Subscription offer = application.offerSubscription(); |
| 143 current = offer.url; | 149 current = offer.url; |
| 144 if (offer != null) | 150 if (offer != null) |
| 145 { | 151 { |
| 146 subscriptionList.setValue(offer.url); | 152 subscriptionList.setValue(offer.url); |
| 147 application.setSubscription(offer); | 153 application.setSubscription(offer); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 showConfigurationMsg(getString(R.string.msg_configuration, proxyServic e.port)); | 508 showConfigurationMsg(getString(R.string.msg_configuration, proxyServic e.port)); |
| 503 } | 509 } |
| 504 | 510 |
| 505 public void onServiceDisconnected(ComponentName className) | 511 public void onServiceDisconnected(ComponentName className) |
| 506 { | 512 { |
| 507 proxyService = null; | 513 proxyService = null; |
| 508 Log.d(TAG, "Proxy service disconnected"); | 514 Log.d(TAG, "Proxy service disconnected"); |
| 509 } | 515 } |
| 510 }; | 516 }; |
| 511 } | 517 } |
| OLD | NEW |