| 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 = TextUtils.htmlEncode(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()) |
| 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()); |
| 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 url = TextUtils.htmlEncode(url); |
| 215 message = TextUtils.htmlEncode(message) |
| 216 .replaceAll("<a>(.*?)</a>", "<a href=\"" + url + "\">$1</a>"
); |
| 217 final TextView messageView = new TextView(this); |
| 218 messageView.setText(Html.fromHtml(message)); |
| 219 messageView.setMovementMethod(LinkMovementMethod.getInstance()); |
| 220 final int padding = 10; |
| 221 messageView.setPadding(padding, padding, padding, padding); |
| 222 new AlertDialog.Builder(this).setTitle(title) |
| 223 .setView(messageView) |
| 224 .setIcon(android.R.drawable.ic_dialog_info) |
| 225 .setPositiveButton(R.string.ok, null).create().show(); |
| 226 } |
| 227 |
| 213 @Override | 228 @Override |
| 214 public void onPause() | 229 public void onPause() |
| 215 { | 230 { |
| 216 super.onPause(); | 231 super.onPause(); |
| 217 try | 232 try |
| 218 { | 233 { |
| 219 unregisterReceiver(receiver); | 234 unregisterReceiver(receiver); |
| 220 } | 235 } |
| 221 catch (IllegalArgumentException e) | 236 catch (IllegalArgumentException e) |
| 222 { | 237 { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 showConfigurationMsg(getString(R.string.msg_configuration)); | 561 showConfigurationMsg(getString(R.string.msg_configuration)); |
| 547 } | 562 } |
| 548 | 563 |
| 549 public void onServiceDisconnected(ComponentName className) | 564 public void onServiceDisconnected(ComponentName className) |
| 550 { | 565 { |
| 551 proxyService = null; | 566 proxyService = null; |
| 552 Log.d(TAG, "Proxy service disconnected"); | 567 Log.d(TAG, "Proxy service disconnected"); |
| 553 } | 568 } |
| 554 }; | 569 }; |
| 555 } | 570 } |
| OLD | NEW |