Bug 1247788 - Add setting for "What's new?" notification. r=margaret
MozReview-Commit-ID: 3eewsc0ILDM
--- a/mobile/android/base/java/org/mozilla/gecko/notifications/WhatsNewReceiver.java
+++ b/mobile/android/base/java/org/mozilla/gecko/notifications/WhatsNewReceiver.java
@@ -12,20 +12,22 @@ import android.content.BroadcastReceiver
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.util.Log;
import com.keepsafe.switchboard.SwitchBoard;
import org.mozilla.gecko.AppConstants;
+import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.Locales;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
+import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.util.Experiments;
import java.util.Locale;
public class WhatsNewReceiver extends BroadcastReceiver {
public static final String EXTRA_WHATSNEW_NOTIFICATION = "whatsnew_notification";
private static final String ACTION_NOTIFICATION_CANCELLED = "notification_cancelled";
@@ -37,19 +39,29 @@ public class WhatsNewReceiver extends Br
return;
}
final String dataString = intent.getDataString();
if (TextUtils.isEmpty(dataString) || !dataString.contains(AppConstants.ANDROID_PACKAGE_NAME)){
return;
}
- if (SwitchBoard.isInExperiment(context, Experiments.WHATSNEW_NOTIFICATION)) {
- showWhatsNewNotification(context);
+ if (!SwitchBoard.isInExperiment(context, Experiments.WHATSNEW_NOTIFICATION)) {
+ return;
+ }
+
+ if (!isPreferenceEnabled(context)) {
+ return;
}
+
+ showWhatsNewNotification(context);
+ }
+
+ private boolean isPreferenceEnabled(Context context) {
+ return GeckoSharedPrefs.forApp(context).getBoolean(GeckoPreferences.PREFS_NOTIFICATIONS_WHATS_NEW, true);
}
private void showWhatsNewNotification(Context context) {
final Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(context.getString(R.string.whatsnew_notification_title))
.setContentText(context.getString(R.string.whatsnew_notification_summary))
.setSmallIcon(R.drawable.ic_status_logo)
.setAutoCancel(true)
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -152,16 +152,17 @@ OnSharedPreferenceChangeListener
private static final String PREFS_CLEAR_PRIVATE_DATA = NON_PREF_PREFIX + "privacy.clear";
private static final String PREFS_CLEAR_PRIVATE_DATA_EXIT = NON_PREF_PREFIX + "history.clear_on_exit";
private static final String PREFS_SCREEN_ADVANCED = NON_PREF_PREFIX + "advanced_screen";
public static final String PREFS_HOMEPAGE = NON_PREF_PREFIX + "homepage";
public static final String PREFS_HISTORY_SAVED_SEARCH = NON_PREF_PREFIX + "search.search_history.enabled";
private static final String PREFS_FAQ_LINK = NON_PREF_PREFIX + "faq.link";
private static final String PREFS_FEEDBACK_LINK = NON_PREF_PREFIX + "feedback.link";
public static final String PREFS_NOTIFICATIONS_CONTENT = NON_PREF_PREFIX + "notifications.content";
+ public static final String PREFS_NOTIFICATIONS_WHATS_NEW = NON_PREF_PREFIX + "notifications.whats_new";
private static final String ACTION_STUMBLER_UPLOAD_PREF = AppConstants.ANDROID_PACKAGE_NAME + ".STUMBLER_PREF";
// This isn't a Gecko pref, even if it looks like one.
private static final String PREFS_BROWSER_LOCALE = "locale";
public static final String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3";
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -161,17 +161,17 @@
search providers.
The &formatI; in the string will be replaced by a small image of the icon described, and can be moved to wherever
it is applicable. -->
<!ENTITY pref_search_hint2 "TIP: Add any website to your list of search providers by long-pressing on its search field and then touching the &formatI; icon.">
<!ENTITY pref_category_advanced "Advanced">
<!ENTITY pref_category_advanced_summary2 "Restore tabs, plugins, developer tools">
<!ENTITY pref_category_notifications "Notifications">
<!ENTITY pref_content_notifications "Website updates">
-<!ENTITY pref_content_notifications_summary "Allow notifications for supported sites">
+<!ENTITY pref_content_notifications_summary2 "Discover new content from supported sites">
<!ENTITY pref_developer_remotedebugging_usb "Remote debugging via USB">
<!ENTITY pref_developer_remotedebugging_wifi "Remote debugging via Wi-Fi">
<!ENTITY pref_developer_remotedebugging_wifi_disabled_summary "Wi-Fi debugging requires your device to have a QR code reader app installed.">
<!ENTITY pref_remember_signons2 "Remember logins">
<!ENTITY pref_manage_logins "Manage logins">
<!ENTITY pref_category_home "Home">
<!ENTITY pref_category_home_summary "Customize your homepage">
@@ -224,16 +224,19 @@
<!ENTITY pref_tracking_protection_summary3 "Enabled in Private Browsing">
<!ENTITY pref_donottrack_title "Do not track">
<!ENTITY pref_donottrack_summary "&brandShortName; will tell sites that you do not want to be tracked">
<!ENTITY pref_tracking_protection_enabled "Enabled">
<!ENTITY pref_tracking_protection_enabled_pb "Enabled in Private Browsing">
<!ENTITY pref_tracking_protection_disabled "Disabled">
+<!ENTITY pref_whats_new_notification "What\'s new in &brandShortName;">
+<!ENTITY pref_whats_new_notification_summary "Learn about changes and new features after an update">
+
<!ENTITY tracking_protection_prompt_title "Now with Tracking Protection">
<!ENTITY tracking_protection_prompt_text "Actively block tracking elements so you don\'t have to worry.">
<!ENTITY tracking_protection_prompt_tip_text "Visit Privacy settings to learn more">
<!ENTITY tracking_protection_prompt_action_button "Got it!">
<!ENTITY tab_queue_toast_message3 "Tab saved in &brandShortName;">
<!ENTITY tab_queue_toast_action "Open now">
<!ENTITY tab_queue_prompt_title "Opening multiple links?">
--- a/mobile/android/base/resources/xml/preferences_notifications.xml
+++ b/mobile/android/base/resources/xml/preferences_notifications.xml
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:key="android.not_a_preference.notifications.content"
android:title="@string/pref_content_notifications"
android:summary="@string/pref_content_notifications_summary"
android:defaultValue="true" />
+ <CheckBoxPreference android:key="android.not_a_preference.notifications.whats_new"
+ android:title="@string/pref_whats_new_notification"
+ android:summary="@string/pref_whats_new_notification_summary"
+ android:defaultValue="true" />
</PreferenceScreen>
\ No newline at end of file
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -161,17 +161,17 @@
<string name="pref_category_advanced">&pref_category_advanced;</string>
<string name="pref_category_advanced_summary">&pref_category_advanced_summary2;</string>
<string name="pref_developer_remotedebugging_usb">&pref_developer_remotedebugging_usb;</string>
<string name="pref_developer_remotedebugging_wifi">&pref_developer_remotedebugging_wifi;</string>
<string name="pref_developer_remotedebugging_wifi_disabled_summary">&pref_developer_remotedebugging_wifi_disabled_summary;</string>
<string name="pref_category_notifications">&pref_category_notifications;</string>
<string name="pref_content_notifications">&pref_content_notifications;</string>
- <string name="pref_content_notifications_summary">&pref_content_notifications_summary;</string>
+ <string name="pref_content_notifications_summary">&pref_content_notifications_summary2;</string>
<string name="pref_category_home">&pref_category_home;</string>
<string name="pref_category_home_summary">&pref_category_home_summary;</string>
<string name="pref_category_home_panels">&pref_category_home_panels;</string>
<string name="pref_home_updates_wifi">&pref_home_updates_wifi;</string>
<string name="pref_category_home_add_ons">&pref_category_home_add_ons;</string>
<string name="pref_home_updates">&pref_home_updates2;</string>
<string name="pref_home_updates_enabled">&pref_home_updates_enabled;</string>
@@ -211,16 +211,19 @@
<string name="pref_tracking_protection_summary">&pref_tracking_protection_summary3;</string>
<string name="pref_donottrack_title">&pref_donottrack_title;</string>
<string name="pref_donottrack_summary">&pref_donottrack_summary;</string>
<string name="pref_tracking_protection_enabled">&pref_tracking_protection_enabled;</string>
<string name="pref_tracking_protection_enabled_pb">&pref_tracking_protection_enabled_pb;</string>
<string name="pref_tracking_protection_disabled">&pref_tracking_protection_disabled;</string>
+ <string name="pref_whats_new_notification">&pref_whats_new_notification;</string>
+ <string name="pref_whats_new_notification_summary">&pref_whats_new_notification_summary;</string>
+
<string name="pref_char_encoding">&pref_char_encoding;</string>
<string name="pref_char_encoding_on">&pref_char_encoding_on;</string>
<string name="pref_char_encoding_off">&pref_char_encoding_off;</string>
<string name="pref_clear_private_data_now">&pref_clear_private_data2;</string>
<string name="pref_clear_private_data_now_tablet">&pref_clear_private_data_now_tablet;</string>
<string name="pref_clear_on_exit_title">&pref_clear_on_exit_title3;</string>
<string name="pref_clear_on_exit_summary2">&pref_clear_on_exit_summary2;</string>
<string name="pref_clear_on_exit_dialog_title">&pref_clear_on_exit_dialog_title;</string>