Bug 1459864 - Modify <Product and feature tips> setting summary when disabled; r=jchen
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 19 Oct 2018 14:25:57 +0000
changeset 490535 6eaed80ae36ffeaffe0bad1e969e5c92e1c9922c
parent 490534 cc4cf78044586c9eb1932686d453835824c67e46
child 490536 0ffed4de7dc0a1ba399a33168e657549d8c559b5
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjchen
bugs1459864
milestone64.0a1
Bug 1459864 - Modify <Product and feature tips> setting summary when disabled; r=jchen Inform the user about why is this feature disabled and what to do to enable it. Differential Revision: https://phabricator.services.mozilla.com/D8545
mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/strings.xml.in
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -14,16 +14,17 @@ import android.app.FragmentManager;
 import android.app.NotificationManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.content.res.Configuration;
+import android.graphics.Typeface;
 import android.os.Bundle;
 import android.preference.CheckBoxPreference;
 import android.preference.EditTextPreference;
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.Preference.OnPreferenceChangeListener;
 import android.preference.Preference.OnPreferenceClickListener;
 import android.preference.PreferenceActivity;
@@ -32,18 +33,22 @@ import android.preference.SwitchPreferen
 import android.preference.TwoStatePreference;
 import android.support.annotation.NonNull;
 import android.support.design.widget.Snackbar;
 import android.support.design.widget.TextInputLayout;
 import android.support.v4.content.LocalBroadcastManager;
 import android.support.v7.app.ActionBar;
 import android.text.Editable;
 import android.text.InputType;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
 import android.text.TextUtils;
 import android.text.TextWatcher;
+import android.text.style.StyleSpan;
 import android.util.Log;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.EditText;
 import android.widget.LinearLayout;
 import android.widget.ListAdapter;
 import android.widget.ListView;
@@ -849,16 +854,37 @@ public class GeckoPreferences
                         continue;
                     }
 
                     // Mma can only work if Health Report is enabled
                     boolean isHealthReportEnabled = isHealthReportEnabled(this);
                     if (!isHealthReportEnabled) {
                         ((SwitchPreference) pref).setChecked(isHealthReportEnabled);
                         pref.setEnabled(isHealthReportEnabled);
+
+                        // Instruct the user on how to enable Health Report
+                        final String RIGHT_CHEVRON_SPACE_PADDED = " > ";
+                        StringBuilder healthReportSettingPath = new StringBuilder()
+                                .append(getString(R.string.pref_category_privacy_short))
+                                .append(RIGHT_CHEVRON_SPACE_PADDED)
+                                .append(getString(R.string.pref_category_datareporting))
+                                .append(RIGHT_CHEVRON_SPACE_PADDED)
+                                .append(getString(R.string.datareporting_fhr_title));
+                        SpannableString boldSettingsLocation = new SpannableString(healthReportSettingPath);
+                        boldSettingsLocation.setSpan(new StyleSpan(Typeface.BOLD),
+                                0, healthReportSettingPath.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
+
+                        SpannableStringBuilder summaryTextBuilder = new SpannableStringBuilder()
+                                .append(getString(R.string.pref_feature_tips_notification_summary))
+                                .append("\n\n")
+                                .append(getString(R.string.pref_feature_tips_notification_enabling_hint))
+                                .append(" ")
+                                .append(boldSettingsLocation);
+
+                        pref.setSummary(summaryTextBuilder);
                     }
                 }
 
                 // Some Preference UI elements are not actually preferences,
                 // but they require a key to work correctly. For example,
                 // "Clear private data" requires a key for its state to be
                 // saved when the orientation changes. It uses the
                 // "android.not_a_preference.privacy.clear" key - which doesn't
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -285,16 +285,20 @@
 <!ENTITY pref_whats_new_notification_summary "Learn about new features after an update">
 
 <!-- Localization note (pref_feature_tips_notification): Title of a new toggleable setting in Settings-Notifications screen.
      Similar to the already existing "pref_whats_new_notification"-->
 <!ENTITY pref_feature_tips_notification "Product and feature tips">
 <!-- Localization note (pref_feature_tips_notification_summary): Description of a new toggleable setting in Settings-Notifications screen.
      Similar to the already existing "pref_whats_new_notification_summary"-->
 <!ENTITY pref_feature_tips_notification_summary "Learn more about using &brandShortName; and other &vendorShortName; products">
+<!-- Localization note (pref_feature_tips_notification_enabling_hint):
+     Describe the action the user should do to enable this preference
+     Will be used in the context "<Turn on> ... to enable this feature" -->
+<!ENTITY pref_feature_tips_notification_enabling_hint "Turn on">
 
 <!-- Localization note (pref_category_experimental): Title of a sub category in the 'advanced' category
      for experimental features. -->
 <!ENTITY pref_category_experimental "Experimental features">
 
 <!-- Custom Tabs is an Android API for allowing third-party apps to open URLs in a customized UI.
      Instead of switching to the browser it appears as if the user stays in the third-party app.
      For more see: https://developer.chrome.com/multidevice/android/customtabs -->
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -219,16 +219,17 @@
   <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_feature_tips_notification">&pref_feature_tips_notification;</string>
   <string name="pref_feature_tips_notification_summary">&pref_feature_tips_notification_summary;</string>
+  <string name="pref_feature_tips_notification_enabling_hint">&pref_feature_tips_notification_enabling_hint;</string>
 
   <string name="pref_category_experimental">&pref_category_experimental;</string>
 
   <string name="pref_custom_tabs">&pref_custom_tabs2;</string>
   <string name="pref_custom_tabs_summary">&pref_custom_tabs_summary4;</string>
 
   <string name="custom_tabs_menu_item_open_in">&custom_tabs_menu_item_open_in;</string>
   <string name="custom_tabs_menu_footer">&custom_tabs_menu_footer;</string>