Create a new link preference for priority modes entry

Test: ZenModesSummaryHelperTest
Test: manual. Successfully search for both 'event' and 'priority'
Flag: android.app.modes_ui
Bug: 341726633
Change-Id: Ib7bd1a5c2f7b06b1728a66f7a9cef53cd45acc0b
This commit is contained in:
Julia Reynolds
2024-07-03 16:19:18 -04:00
parent bb10c9f4df
commit 4fd34aa386
6 changed files with 269 additions and 15 deletions

View File

@@ -41,8 +41,11 @@ import static android.service.notification.ZenPolicy.VISUAL_EFFECT_STATUS_BAR;
import android.content.Context;
import android.icu.text.MessageFormat;
import android.provider.Settings;
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenPolicy;
import android.util.ArrayMap;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -448,4 +451,33 @@ class ZenModeSummaryHelper {
}
return msgFormat.format(args);
}
String getSoundSummary(int zenMode, ZenModeConfig config) {
if (zenMode != Settings.Global.ZEN_MODE_OFF) {
String description = ZenModeConfig.getDescription(mContext, true, config, false);
if (description == null) {
return mContext.getString(R.string.zen_mode_sound_summary_on);
} else {
return mContext.getString(R.string.zen_mode_sound_summary_on_with_info,
description);
}
} else {
int count = 0;
final ArrayMap<String, ZenModeConfig.ZenRule> ruleMap = config.automaticRules;
if (ruleMap != null) {
for (ZenModeConfig.ZenRule rule : ruleMap.values()) {
if (rule != null && rule.enabled) {
count++;
}
}
}
MessageFormat msgFormat = new MessageFormat(
mContext.getString(R.string.modes_sound_summary_off),
Locale.getDefault());
Map<String, Object> msgArgs = new HashMap<>();
msgArgs.put("count", count);
return msgFormat.format(msgArgs);
}
}
}