Update DND strings
Fixes: 120497233 Bug: 111475013 Test: manually flash and check strings Test: make RunSettingsRoboTests -j40 Change-Id: I0a8971226a485f8ec41d83c167e51dac1a9c8107
This commit is contained in:
@@ -73,8 +73,7 @@ public class ZenModeAutomaticRulesPreferenceController extends
|
||||
// 2. rule was added or deleted, so reload the entire list
|
||||
if (Objects.equals(pref.mId, sortedRules[i].getKey())) {
|
||||
AutomaticZenRule rule = sortedRules[i].getValue();
|
||||
pref.setName(rule.getName());
|
||||
pref.setChecked(rule.isEnabled());
|
||||
pref.updatePreference(rule);
|
||||
} else {
|
||||
reloadAllRules(sortedRules);
|
||||
break;
|
||||
|
@@ -250,15 +250,17 @@ public class ZenModeBackend {
|
||||
}
|
||||
}
|
||||
|
||||
protected int getAlarmsTotalSilenceCallsMessagesSummary(int category) {
|
||||
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
return R.string.zen_mode_from_none_messages;
|
||||
} else if (category == NotificationManager.Policy.PRIORITY_CATEGORY_CALLS){
|
||||
return R.string.zen_mode_from_none_calls;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getContactsSummary(int category) {
|
||||
int contactType = -1;
|
||||
|
||||
// SOURCE_NONE can be used when in total silence or alarms only
|
||||
// (policy is based on user's preferences but the UI displayed is based on zenMode)
|
||||
if (category == SOURCE_NONE) {
|
||||
return R.string.zen_mode_from_none;
|
||||
}
|
||||
|
||||
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
if (isPriorityCategoryEnabled(category)) {
|
||||
contactType = getPriorityMessageSenders();
|
||||
@@ -273,12 +275,16 @@ public class ZenModeBackend {
|
||||
case NotificationManager.Policy.PRIORITY_SENDERS_ANY:
|
||||
return R.string.zen_mode_from_anyone;
|
||||
case NotificationManager.Policy.PRIORITY_SENDERS_CONTACTS:
|
||||
return R.string.zen_mode_from_contacts;
|
||||
return R.string.zen_mode_from_contacts;
|
||||
case NotificationManager.Policy.PRIORITY_SENDERS_STARRED:
|
||||
return R.string.zen_mode_from_starred;
|
||||
return R.string.zen_mode_from_starred;
|
||||
case SOURCE_NONE:
|
||||
default:
|
||||
return R.string.zen_mode_from_none;
|
||||
if (category == NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
return R.string.zen_mode_from_none_messages;
|
||||
} else {
|
||||
return R.string.zen_mode_from_none_calls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,11 +18,11 @@ package com.android.settings.notification;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public class ZenModeMessagesPreferenceController extends
|
||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||
|
||||
@@ -48,6 +48,7 @@ public class ZenModeMessagesPreferenceController extends
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
// TODO: (b/111475013 - beverlyt) set messages summary
|
||||
|
||||
preference.setSummary(mSummaryBuilder.getMessagesSettingSummary(getPolicy()));
|
||||
}
|
||||
}
|
||||
|
@@ -21,14 +21,14 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class ZenModePriorityCallsPreferenceController extends AbstractZenModePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -80,7 +80,8 @@ public class ZenModePriorityCallsPreferenceController extends AbstractZenModePre
|
||||
case Settings.Global.ZEN_MODE_ALARMS:
|
||||
mPreference.setEnabled(false);
|
||||
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
|
||||
mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
|
||||
mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
|
||||
NotificationManager.Policy.PRIORITY_CATEGORY_CALLS));
|
||||
break;
|
||||
default:
|
||||
preference.setEnabled(true);
|
||||
|
@@ -21,14 +21,14 @@ import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class ZenModePriorityMessagesPreferenceController extends AbstractZenModePreferenceController
|
||||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
@@ -80,7 +80,8 @@ public class ZenModePriorityMessagesPreferenceController extends AbstractZenMode
|
||||
case Settings.Global.ZEN_MODE_ALARMS:
|
||||
mPreference.setEnabled(false);
|
||||
mPreference.setValue(ZenModeBackend.ZEN_MODE_FROM_NONE);
|
||||
mPreference.setSummary(mBackend.getContactsSummary(ZenModeBackend.SOURCE_NONE));
|
||||
mPreference.setSummary(mBackend.getAlarmsTotalSilenceCallsMessagesSummary(
|
||||
NotificationManager.Policy.PRIORITY_CATEGORY_MESSAGES));
|
||||
break;
|
||||
default:
|
||||
preference.setEnabled(true);
|
||||
|
@@ -145,7 +145,7 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
|| PRIORITY_CATEGORY_REPEAT_CALLERS == category, false);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
return mContext.getString(R.string.zen_mode_from_none_calls);
|
||||
} else if (numCategories == 1) {
|
||||
return mContext.getString(R.string.zen_mode_calls_summary_one,
|
||||
enabledCategories.get(0));
|
||||
@@ -156,34 +156,14 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
}
|
||||
}
|
||||
|
||||
String getMsgEventReminderSettingSummary(Policy policy) {
|
||||
String getMessagesSettingSummary(Policy policy) {
|
||||
List<String> enabledCategories = getEnabledCategories(policy,
|
||||
category -> PRIORITY_CATEGORY_EVENTS == category
|
||||
|| PRIORITY_CATEGORY_REMINDERS == category
|
||||
|| PRIORITY_CATEGORY_MESSAGES == category, true);
|
||||
category -> PRIORITY_CATEGORY_MESSAGES == category, false);
|
||||
int numCategories = enabledCategories.size();
|
||||
if (numCategories == 0) {
|
||||
return mContext.getString(R.string.zen_mode_no_exceptions);
|
||||
} else if (numCategories == 1) {
|
||||
return enabledCategories.get(0);
|
||||
} else if (numCategories == 2) {
|
||||
return mContext.getString(R.string.join_two_items, enabledCategories.get(0),
|
||||
enabledCategories.get(1));
|
||||
} else if (numCategories == 3){
|
||||
final List<String> summaries = new ArrayList<>();
|
||||
summaries.add(enabledCategories.get(0));
|
||||
summaries.add(enabledCategories.get(1));
|
||||
summaries.add(enabledCategories.get(2));
|
||||
|
||||
return ListFormatter.getInstance().format(summaries);
|
||||
return mContext.getString(R.string.zen_mode_from_none_messages);
|
||||
} else {
|
||||
final List<String> summaries = new ArrayList<>();
|
||||
summaries.add(enabledCategories.get(0));
|
||||
summaries.add(enabledCategories.get(1));
|
||||
summaries.add(enabledCategories.get(2));
|
||||
summaries.add(mContext.getString(R.string.zen_mode_other_options));
|
||||
|
||||
return ListFormatter.getInstance().format(summaries);
|
||||
return enabledCategories.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,17 +272,11 @@ public class ZenModeSettings extends ZenModeSettingsBase {
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_MESSAGES) {
|
||||
if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_ANY) {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_all_messages);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_all_messages_list);
|
||||
}
|
||||
return mContext.getString(R.string.zen_mode_from_anyone);
|
||||
} else if (policy.priorityMessageSenders == Policy.PRIORITY_SENDERS_CONTACTS){
|
||||
return mContext.getString(R.string.zen_mode_from_contacts);
|
||||
} else {
|
||||
if (isFirst) {
|
||||
return mContext.getString(R.string.zen_mode_selected_messages);
|
||||
} else {
|
||||
return mContext.getString(R.string.zen_mode_selected_messages_list);
|
||||
}
|
||||
return mContext.getString(R.string.zen_mode_from_starred);
|
||||
}
|
||||
} else if (category == Policy.PRIORITY_CATEGORY_EVENTS) {
|
||||
if (isFirst) {
|
||||
|
@@ -31,6 +31,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.utils.ManagedServiceSettings;
|
||||
import com.android.settings.utils.ZenServiceListing;
|
||||
@@ -122,17 +123,17 @@ public class ZenRulePreference extends TwoTargetPreference {
|
||||
return mChecked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
mChecked = checked;
|
||||
if (mCheckBox != null) {
|
||||
mCheckBox.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
if (!Objects.equals(mName, name)) {
|
||||
mName = name;
|
||||
public void updatePreference(AutomaticZenRule rule) {
|
||||
if (!mRule.getName().equals(rule.getName())) {
|
||||
mName = rule.getName();
|
||||
setTitle(mName);
|
||||
mRule.setName(mName.toString());
|
||||
}
|
||||
|
||||
if (mRule.isEnabled() != rule.isEnabled()) {
|
||||
mRule.setEnabled(rule.isEnabled());
|
||||
setChecked(mRule.isEnabled());
|
||||
setSummary(computeRuleSummary(mRule));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +142,13 @@ public class ZenRulePreference extends TwoTargetPreference {
|
||||
mOnCheckBoxClickListener.onClick(null);
|
||||
}
|
||||
|
||||
private void setChecked(boolean checked) {
|
||||
mChecked = checked;
|
||||
if (mCheckBox != null) {
|
||||
mCheckBox.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
private View.OnClickListener mOnCheckBoxClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -159,7 +167,7 @@ public class ZenRulePreference extends TwoTargetPreference {
|
||||
|
||||
try {
|
||||
ApplicationInfo info = mPm.getApplicationInfo(rule.getOwner().getPackageName(), 0);
|
||||
setSummary(computeRuleSummary(rule, mIsSystemRule, info.loadLabel(mPm)));
|
||||
setSummary(computeRuleSummary(rule));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
appExists = false;
|
||||
return;
|
||||
@@ -179,8 +187,7 @@ public class ZenRulePreference extends TwoTargetPreference {
|
||||
setKey(mId);
|
||||
}
|
||||
|
||||
private String computeRuleSummary(AutomaticZenRule rule, boolean isSystemRule,
|
||||
CharSequence providerLabel) {
|
||||
private String computeRuleSummary(AutomaticZenRule rule) {
|
||||
return (rule == null || !rule.isEnabled())
|
||||
? mContext.getResources().getString(R.string.switch_off_text)
|
||||
: mContext.getResources().getString(R.string.switch_on_text);
|
||||
|
Reference in New Issue
Block a user