Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/Preferences.java

Issue 5431458994847744: Automatically enable acceptable ads and notify the user about it (Closed)
Patch Set: Created Nov. 26, 2013, 10:39 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« jni/abpEngine.cpp ('K') | « src/org/adblockplus/android/AdblockPlus.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/Preferences.java
===================================================================
--- a/src/org/adblockplus/android/Preferences.java
+++ b/src/org/adblockplus/android/Preferences.java
@@ -153,19 +153,18 @@
if (firstRun && current != null)
{
- final String url = application.getAcceptableAdsUrl();
- final String rawMessage = String.format(getString(R.string.msg_subscription_offer, current.title));
- final String message = TextUtils.htmlEncode(rawMessage)
- .replaceAll("&lt;a&gt;(.*?)&lt;/a&gt;", "<a href=\"" + url + "\">$1</a>");
- final TextView messageView = new TextView(this);
- messageView.setText(Html.fromHtml(message));
- messageView.setMovementMethod(LinkMovementMethod.getInstance());
- final int padding = 10;
- messageView.setPadding(padding, padding, padding, padding);
- new AlertDialog.Builder(this).setTitle(R.string.install_name)
- .setView(messageView)
- .setIcon(android.R.drawable.ic_dialog_info)
- .setPositiveButton(R.string.ok, null).create().show();
+ showNotificationDialog(getString(R.string.install_name),
+ String.format(getString(R.string.msg_subscription_offer, current.title)),
+ application.getAcceptableAdsUrl());
+ application.setNotifiedAboutAcceptableAds(true);
+ application.setAcceptableAdsEnabled(true);
+ }
+ 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
+ {
+ showNotificationDialog(getString(R.string.acceptableads_name),
+ getString(R.string.msg_acceptable_ads), application.getAcceptableAdsUrl());
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
+ application.setNotifiedAboutAcceptableAds(true);
+ application.setAcceptableAdsEnabled(true);
}
// Enable manual subscription refresh
@@ -210,6 +209,21 @@
bindService(new Intent(this, ProxyService.class), proxyServiceConnection, 0);
}
+ private void showNotificationDialog(String title, String message, String url)
+ {
+ message = TextUtils.htmlEncode(message)
+ .replaceAll("&lt;a&gt;(.*?)&lt;/a&gt;", "<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.
+ final TextView messageView = new TextView(this);
+ messageView.setText(Html.fromHtml(message));
+ messageView.setMovementMethod(LinkMovementMethod.getInstance());
+ final int padding = 10;
+ messageView.setPadding(padding, padding, padding, padding);
+ new AlertDialog.Builder(this).setTitle(title)
+ .setView(messageView)
+ .setIcon(android.R.drawable.ic_dialog_info)
+ .setPositiveButton(R.string.ok, null).create().show();
+ }
+
@Override
public void onPause()
{
« jni/abpEngine.cpp ('K') | « src/org/adblockplus/android/AdblockPlus.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld