Notification settings updates
- smaller icons - text update - fx header - fix category header Test: make -j RunSettingsRoboTests Change-Id: If822d6db31a8dccf20ee88182cda1aee34aa7675 Fixes: 77325154 Fixes: 77323406 Fixes: 77324677 Fixes: 74408368
This commit is contained in:
@@ -95,8 +95,8 @@
|
||||
android:id="@android:id/widget_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="end|center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:gravity="center"
|
||||
android:minWidth="64dp"
|
||||
android:orientation="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -7513,9 +7513,9 @@
|
||||
<string name="default_notification_assistant">Notification assistant</string>
|
||||
|
||||
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
|
||||
<string name="notifications_sent_daily">~<xliff:g id="number">%1$s</xliff:g> sent daily</string>
|
||||
<string name="notifications_sent_daily">~<xliff:g id="number">%1$s</xliff:g> per day</string>
|
||||
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
|
||||
<string name="notifications_sent_weekly">~<xliff:g id="number">%1$s</xliff:g> sent weekly</string>
|
||||
<string name="notifications_sent_weekly">~<xliff:g id="number">%1$s</xliff:g> per week</string>
|
||||
<!-- app summary of notification app list screen [CHAR LIMIT=100] -->
|
||||
<string name="notifications_sent_never">Never</string>
|
||||
|
||||
|
@@ -167,9 +167,9 @@ public class AppNotificationSettings extends NotificationSettingsBase {
|
||||
getPreferenceScreen().addPreference(groupCategory);
|
||||
mDynamicPreferences.add(groupCategory);
|
||||
if (group.getId() == null) {
|
||||
groupCategory.setTitle(mChannelGroupList.size() > 1
|
||||
? R.string.notification_channels_other
|
||||
: R.string.notification_channels);
|
||||
if (mChannelGroupList.size() > 1) {
|
||||
groupCategory.setTitle(R.string.notification_channels_other);
|
||||
}
|
||||
groupCategory.setKey(KEY_GENERAL_CATEGORY);
|
||||
} else {
|
||||
groupCategory.setTitle(group.getName());
|
||||
|
@@ -57,7 +57,7 @@ public class BadgePreferenceController extends NotificationPreferenceController
|
||||
return false;
|
||||
}
|
||||
if (mChannel != null) {
|
||||
if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())) {
|
||||
if (isDefaultChannel()) {
|
||||
return true;
|
||||
} else {
|
||||
return mAppRow.showBadge;
|
||||
|
@@ -98,8 +98,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
|
||||
// it was blocked and we are unblocking it.
|
||||
if (blocked || originalImportance == IMPORTANCE_NONE) {
|
||||
final int importance = blocked ? IMPORTANCE_NONE
|
||||
: DEFAULT_CHANNEL_ID.equals(mChannel.getId())
|
||||
? IMPORTANCE_UNSPECIFIED : IMPORTANCE_DEFAULT;
|
||||
: isDefaultChannel() ? IMPORTANCE_UNSPECIFIED : IMPORTANCE_DEFAULT;
|
||||
mChannel.setImportance(importance);
|
||||
saveChannel();
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class HeaderPreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
|
||||
@@ -72,7 +74,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
|
||||
}
|
||||
|
||||
CharSequence getLabel() {
|
||||
return mChannel != null ? mChannel.getName()
|
||||
return (mChannel != null && !isDefaultChannel()) ? mChannel.getName()
|
||||
: mChannelGroup != null
|
||||
? mChannelGroup.getName()
|
||||
: mAppRow.label;
|
||||
@@ -80,7 +82,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
|
||||
|
||||
@Override
|
||||
public CharSequence getSummary() {
|
||||
if (mChannel != null) {
|
||||
if (mChannel != null && !isDefaultChannel()) {
|
||||
if (mChannelGroup != null
|
||||
&& !TextUtils.isEmpty(mChannelGroup.getName())) {
|
||||
final SpannableStringBuilder summary = new SpannableStringBuilder();
|
||||
|
@@ -58,7 +58,7 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return !NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
|
||||
return !isDefaultChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -50,8 +50,9 @@ public class LightsPreferenceController extends NotificationPreferenceController
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && canPulseLight()
|
||||
&& !NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
|
||||
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|
||||
&& canPulseLight()
|
||||
&& !isDefaultChannel();
|
||||
}
|
||||
|
||||
public void updateState(Preference preference) {
|
||||
|
@@ -184,4 +184,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
protected boolean hasValidGroup() {
|
||||
return mChannelGroup != null;
|
||||
}
|
||||
|
||||
protected final boolean isDefaultChannel() {
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(NotificationChannel.DEFAULT_CHANNEL_ID, mChannel.getId());
|
||||
}
|
||||
}
|
||||
|
@@ -37,14 +37,13 @@ import android.util.Log;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.applications.InstalledAppCounter;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settingslib.TwoTargetPreference;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -211,6 +210,7 @@ public class RecentNotifyingAppsPreferenceController extends AbstractPreferenceC
|
||||
pref.setKey(pkgName);
|
||||
pref.setTitle(appEntry.label);
|
||||
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
|
||||
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
|
||||
pref.setSummary(StringUtil.formatRelativeTime(mContext,
|
||||
System.currentTimeMillis() - app.getLastNotified(), true));
|
||||
pref.setOrder(i);
|
||||
|
@@ -59,8 +59,7 @@ public class SoundPreferenceController extends NotificationPreferenceController
|
||||
if (mChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|
||||
&& !NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId());
|
||||
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT) && !isDefaultChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -47,7 +47,7 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
|
||||
return false;
|
||||
}
|
||||
return checkCanBeVisible(NotificationManager.IMPORTANCE_DEFAULT)
|
||||
&& !NotificationChannel.DEFAULT_CHANNEL_ID.equals(mChannel.getId())
|
||||
&& !isDefaultChannel()
|
||||
&& mVibrator != null
|
||||
&& mVibrator.hasVibrator();
|
||||
}
|
||||
|
@@ -109,6 +109,11 @@ public class HeaderPreferenceControllerTest {
|
||||
NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
|
||||
mController.onResume(appRow, channel, group, null);
|
||||
assertEquals(channel.getName(), mController.getLabel());
|
||||
|
||||
NotificationChannel defaultChannel = new NotificationChannel(
|
||||
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
|
||||
mController.onResume(appRow, defaultChannel, null, null);
|
||||
assertEquals(appRow.label, mController.getLabel());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,5 +135,10 @@ public class HeaderPreferenceControllerTest {
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.getSummary().toString().contains(group.getName()));
|
||||
assertTrue(mController.getSummary().toString().contains(appRow.label));
|
||||
|
||||
NotificationChannel defaultChannel = new NotificationChannel(
|
||||
NotificationChannel.DEFAULT_CHANNEL_ID, "", IMPORTANCE_NONE);
|
||||
mController.onResume(appRow, defaultChannel, null, null);
|
||||
assertEquals("", mController.getSummary());
|
||||
}
|
||||
}
|
||||
|
@@ -294,6 +294,30 @@ public class NotificationPreferenceControllerTest {
|
||||
assertTrue(mController.isChannelGroupBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDefaultChannel_noChannel() {
|
||||
mController.onResume(mock(NotificationBackend.AppRow.class), null, null, null);
|
||||
|
||||
assertFalse(mController.isDefaultChannel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDefaultChannel_nonDefaultChannel() {
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
|
||||
|
||||
assertFalse(mController.isDefaultChannel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDefaultChannel() {
|
||||
NotificationChannel channel = mock(NotificationChannel.class);
|
||||
when(channel.getId()).thenReturn(NotificationChannel.DEFAULT_CHANNEL_ID);
|
||||
mController.onResume(mock(NotificationBackend.AppRow.class), channel, null, null);
|
||||
|
||||
assertTrue(mController.isDefaultChannel());
|
||||
}
|
||||
|
||||
private final class TestPreferenceController extends NotificationPreferenceController {
|
||||
|
||||
private TestPreferenceController(Context context, NotificationBackend backend) {
|
||||
|
Reference in New Issue
Block a user