| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 if (subscriptions.length > 0) | 146 if (subscriptions.length > 0) |
| 147 { | 147 { |
| 148 current = subscriptions[0]; | 148 current = subscriptions[0]; |
| 149 } | 149 } |
| 150 | 150 |
| 151 boolean firstRun = firstRunActionsPending && application.isFirstRun(); | 151 boolean firstRun = firstRunActionsPending && application.isFirstRun(); |
| 152 firstRunActionsPending = false; | 152 firstRunActionsPending = false; |
| 153 | 153 |
| 154 if (firstRun && current != null) | 154 if (firstRun && current != null) |
| 155 { | 155 { |
| 156 final String url = application.getAcceptableAdsUrl(); | 156 showNotificationDialog(getString(R.string.install_name), |
| 157 final String rawMessage = String.format(getString(R.string.msg_subscriptio n_offer, current.title)); | 157 String.format(getString(R.string.msg_subscription_offer, current.title )), |
| 158 final String message = TextUtils.htmlEncode(rawMessage) | 158 application.getAcceptableAdsUrl()); |
| 159 .replaceAll("<a>(.*?)</a>", "<a href=\"" + url + "\">$1</a >"); | 159 application.setNotifiedAboutAcceptableAds(true); |
| 160 final TextView messageView = new TextView(this); | 160 application.setAcceptableAdsEnabled(true); |
| 161 messageView.setText(Html.fromHtml(message)); | 161 } |
| 162 messageView.setMovementMethod(LinkMovementMethod.getInstance()); | 162 else if (!application.isNotifiedAboutAcceptableAds()) |
|
Wladimir Palant
2013/11/26 11:01:02
Shouldn't you check whether acceptable ads are alr
Felix Dahlke
2013/11/26 13:59:31
Why? Even if they were, we want to notify every us
| |
| 163 final int padding = 10; | 163 { |
| 164 messageView.setPadding(padding, padding, padding, padding); | 164 showNotificationDialog(getString(R.string.acceptableads_name), |
| 165 new AlertDialog.Builder(this).setTitle(R.string.install_name) | 165 getString(R.string.msg_acceptable_ads), application.getAcceptableAdsUr l()); |
|
Wladimir Palant
2013/11/26 11:01:02
Style nit: add a line break to put the last parame
Felix Dahlke
2013/11/26 13:59:31
I'm wrapping Java code to 100 columns currently, a
| |
| 166 .setView(messageView) | 166 application.setNotifiedAboutAcceptableAds(true); |
| 167 .setIcon(android.R.drawable.ic_dialog_info) | 167 application.setAcceptableAdsEnabled(true); |
| 168 .setPositiveButton(R.string.ok, null).create().show(); | |
| 169 } | 168 } |
| 170 | 169 |
| 171 // Enable manual subscription refresh | 170 // Enable manual subscription refresh |
| 172 subscriptionList.setOnRefreshClickListener(new View.OnClickListener() | 171 subscriptionList.setOnRefreshClickListener(new View.OnClickListener() |
| 173 { | 172 { |
| 174 @Override | 173 @Override |
| 175 public void onClick(View v) | 174 public void onClick(View v) |
| 176 { | 175 { |
| 177 application.refreshSubscriptions(); | 176 application.refreshSubscriptions(); |
| 178 } | 177 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 203 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled); | 202 ((SwitchPreference) findPreference(getString(R.string.pref_enabled))).setChe cked(enabled); |
| 204 | 203 |
| 205 if (enabled || firstRun) | 204 if (enabled || firstRun) |
| 206 setFilteringEnabled(true); | 205 setFilteringEnabled(true); |
| 207 if (enabled || firstRun || (proxyenabled && !autoconfigured)) | 206 if (enabled || firstRun || (proxyenabled && !autoconfigured)) |
| 208 setProxyEnabled(true); | 207 setProxyEnabled(true); |
| 209 | 208 |
| 210 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ; | 209 bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0) ; |
| 211 } | 210 } |
| 212 | 211 |
| 212 private void showNotificationDialog(String title, String message, String url) | |
| 213 { | |
| 214 message = TextUtils.htmlEncode(message) | |
| 215 .replaceAll("<a>(.*?)</a>", "<a href=\"" + url + "\">$1</a>" ); | |
|
Wladimir Palant
2013/11/26 11:01:02
Comment from previous review (encode entities in U
Felix Dahlke
2013/11/26 13:59:31
Done.
| |
| 216 final TextView messageView = new TextView(this); | |
| 217 messageView.setText(Html.fromHtml(message)); | |
| 218 messageView.setMovementMethod(LinkMovementMethod.getInstance()); | |
| 219 final int padding = 10; | |
| 220 messageView.setPadding(padding, padding, padding, padding); | |
| 221 new AlertDialog.Builder(this).setTitle(title) | |
| 222 .setView(messageView) | |
| 223 .setIcon(android.R.drawable.ic_dialog_info) | |
| 224 .setPositiveButton(R.string.ok, null).create().show(); | |
| 225 } | |
| 226 | |
| 213 @Override | 227 @Override |
| 214 public void onPause() | 228 public void onPause() |
| 215 { | 229 { |
| 216 super.onPause(); | 230 super.onPause(); |
| 217 try | 231 try |
| 218 { | 232 { |
| 219 unregisterReceiver(receiver); | 233 unregisterReceiver(receiver); |
| 220 } | 234 } |
| 221 catch (IllegalArgumentException e) | 235 catch (IllegalArgumentException e) |
| 222 { | 236 { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 showConfigurationMsg(getString(R.string.msg_configuration)); | 560 showConfigurationMsg(getString(R.string.msg_configuration)); |
| 547 } | 561 } |
| 548 | 562 |
| 549 public void onServiceDisconnected(ComponentName className) | 563 public void onServiceDisconnected(ComponentName className) |
| 550 { | 564 { |
| 551 proxyService = null; | 565 proxyService = null; |
| 552 Log.d(TAG, "Proxy service disconnected"); | 566 Log.d(TAG, "Proxy service disconnected"); |
| 553 } | 567 } |
| 554 }; | 568 }; |
| 555 } | 569 } |
| OLD | NEW |