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:
Julia Reynolds
2018-03-30 14:04:55 -04:00
parent 9fc72be6c8
commit d7815fe18f
14 changed files with 62 additions and 20 deletions

View File

@@ -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());

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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();

View File

@@ -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

View File

@@ -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) {

View File

@@ -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());
}
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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();
}