Clean up notification settings am: 6a603e7f4b am: 2ae83f85d6

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15029783

Change-Id: Idedee8c5e89cbc1abd847f806964ba866b491f27
This commit is contained in:
Julia Reynolds
2021-06-18 20:13:36 +00:00
committed by Automerger Merge Worker
21 changed files with 231 additions and 135 deletions

View File

@@ -25,9 +25,11 @@ import android.util.Log;
import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -38,35 +40,11 @@ public class AppNotificationSettings extends NotificationSettings {
private static final String TAG = "AppNotificationSettings";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private static String KEY_ADVANCED_CATEGORY = "app_advanced";
private static String KEY_BADGE = "badge";
private static String KEY_APP_LINK = "app_link";
private static String[] LEGACY_NON_ADVANCED_KEYS = {KEY_BADGE, KEY_APP_LINK};
@Override
public int getMetricsCategory() {
return SettingsEnums.NOTIFICATION_APP_NOTIFICATION;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final PreferenceScreen screen = getPreferenceScreen();
if (mShowLegacyChannelConfig && screen != null) {
// if showing legacy settings, pull advanced settings out of the advanced category
PreferenceGroup advanced = (PreferenceGroup) findPreference(KEY_ADVANCED_CATEGORY);
removePreference(KEY_ADVANCED_CATEGORY);
if (advanced != null) {
for (String key : LEGACY_NON_ADVANCED_KEYS) {
Preference pref = advanced.findPreference(key);
advanced.removePreference(pref);
if (pref != null) {
screen.addPreference(pref);
}
}
}
}
}
@Override
public void onResume() {
@@ -78,6 +56,8 @@ public class AppNotificationSettings extends NotificationSettings {
return;
}
getActivity().setTitle(mAppRow.label);
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, null, null, mSuspendedAppsAdmin,
null);

View File

@@ -322,7 +322,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref.setIcon(getAlertingIcon());
} else {
channelPref.setIcon(null);
channelPref.setIcon(R.drawable.empty_icon);
}
channelPref.setIconSize(PrimarySwitchPreference.ICON_SIZE_SMALL);
channelPref.setTitle(channel.getName());
@@ -350,7 +350,7 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
PrimarySwitchPreference channelPref1 = (PrimarySwitchPreference) preference;
channelPref1.setIcon(null);
channelPref1.setIcon(R.drawable.empty_icon);
if (channel.getImportance() > IMPORTANCE_LOW) {
channelPref1.setIcon(getAlertingIcon());
}

View File

@@ -66,8 +66,9 @@ public class ChannelNotificationSettings extends NotificationSettings {
return;
}
if (mChannel != null && !TextUtils.isEmpty(mChannel.getConversationId())
&& !mChannel.isDemoted()) {
getActivity().setTitle(mChannel.getName());
if (!TextUtils.isEmpty(mChannel.getConversationId()) && !mChannel.isDemoted()) {
Intent intent = new SubSettingLauncher(mContext)
.setDestination(ConversationNotificationSettings.class.getName())
.setArguments(getArguments())
@@ -128,7 +129,6 @@ public class ChannelNotificationSettings extends NotificationSettings {
mDependentFieldListener, mBackend));
mControllers.add(new VibrationPreferenceController(context, mBackend));
mControllers.add(new AppLinkPreferenceController(context));
mControllers.add(new DescriptionPreferenceController(context));
mControllers.add(new VisibilityPreferenceController(context, new LockPatternUtils(context),
mBackend));
mControllers.add(new LightsPreferenceController(context, mBackend));

View File

@@ -41,11 +41,13 @@ public class ConversationNotificationSettings extends NotificationSettings {
@Override
public void onResume() {
super.onResume();
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null) {
if (mUid < 0 || TextUtils.isEmpty(mPkg) || mPkgInfo == null || mChannel == null
|| mConversationInfo == null) {
Log.w(TAG, "Missing package or uid or packageinfo or channel");
finish();
return;
}
getActivity().setTitle(mConversationInfo.getLabel());
for (NotificationPreferenceController controller : mControllers) {
controller.onResume(mAppRow, mChannel, mChannelGroup, mConversationDrawable,

View File

@@ -84,6 +84,7 @@ public class HeaderPreferenceController extends NotificationPreferenceController
pref = mHeaderController.setIcon(mAppRow.icon)
.setLabel(getLabel())
.setSummary(getSummary())
.setSecondSummary(getSecondSummary())
.setPackageName(mAppRow.pkg)
.setUid(mAppRow.uid)
.setButtonActions(EntityHeaderController.ActionType.ACTION_NOTIF_PREFERENCE,
@@ -96,25 +97,11 @@ public class HeaderPreferenceController extends NotificationPreferenceController
}
}
@Override
public CharSequence getSummary() {
public CharSequence getLabel() {
if (mChannel != null && !isDefaultChannel()) {
if (mChannelGroup != null
&& !TextUtils.isEmpty(mChannelGroup.getName())) {
final SpannableStringBuilder summary = new SpannableStringBuilder();
BidiFormatter bidi = BidiFormatter.getInstance();
summary.append(bidi.unicodeWrap(mAppRow.label.toString()));
summary.append(bidi.unicodeWrap(mContext.getText(
R.string.notification_header_divider_symbol_with_spaces)));
summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
return summary.toString();
} else {
return mAppRow.label.toString();
}
} else if (mChannelGroup != null) {
return mAppRow.label.toString();
return mChannel.getName();
} else {
return "";
return mAppRow.label;
}
}
@@ -123,11 +110,26 @@ public class HeaderPreferenceController extends NotificationPreferenceController
mStarted = true;
}
@VisibleForTesting
CharSequence getLabel() {
return (mChannel != null && !isDefaultChannel()) ? mChannel.getName()
: mChannelGroup != null
? mChannelGroup.getName()
: mAppRow.label;
@Override
public CharSequence getSummary() {
if (mChannel != null) {
if (mChannelGroup != null
&& !TextUtils.isEmpty(mChannelGroup.getName())) {
final SpannableStringBuilder summary = new SpannableStringBuilder();
BidiFormatter bidi = BidiFormatter.getInstance();
summary.append(bidi.unicodeWrap(mAppRow.label));
summary.append(bidi.unicodeWrap(mContext.getText(
R.string.notification_header_divider_symbol_with_spaces)));
summary.append(bidi.unicodeWrap(mChannelGroup.getName().toString()));
return summary.toString();
} else {
return mAppRow.label.toString();
}
}
return "";
}
public CharSequence getSecondSummary() {
return mChannel == null ? null : mChannel.getDescription();
}
}