Channel settings updates

- Update master switch preference to store enabled state in case
it's set before the view holder is bound
- Update master switch preference to prevent disabled switches
from being toggled
- Show an importance summary for max importance
- properly handle null notification sounds

Change-Id: I395b95b76d2a3c1c94b41d1c2720bb0cf1cae917
Fixes: 36920159
Fixes: 37421928
Fixes: 36939825
Test: RunSettingsRoboTests & manual
This commit is contained in:
Julia Reynolds
2017-04-14 09:30:30 -04:00
parent a0e617f96d
commit c68ae0b9fd
5 changed files with 52 additions and 5 deletions

View File

@@ -161,7 +161,7 @@ public class AppNotificationSettings extends NotificationSettingsBase {
final NotificationChannel channel = channels.get(i);
MasterSwitchPreference channelPref = new MasterSwitchPreference(
getPrefContext());
channelPref.setDisabledByAdmin(mSuspendedAppsAdmin);
channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && !mAppRow.systemApp);
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);

View File

@@ -175,9 +175,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
mRingtone.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Uri ringtone = Uri.parse((String) newValue);
mRingtone.setRingtone(ringtone);
mChannel.setSound(ringtone, mChannel.getAudioAttributes());
mChannel.setSound((Uri) newValue, mChannel.getAudioAttributes());
mChannel.lockFields(NotificationChannel.USER_LOCKED_SOUND);
mBackend.updateChannel(mPkg, mUid, mChannel);
return false;
@@ -238,7 +236,7 @@ public class ChannelNotificationSettings extends NotificationSettingsBase {
mImportance.setEntryValues(values.toArray(new String[0]));
mImportance.setEntries(summaries.toArray(new String[0]));
mImportance.setValue(String.valueOf(mChannel.getImportance()));
mImportance.setSummary("%s");
mImportance.setSummary(getImportanceSummary(mChannel.getImportance()));
if (mAppRow.lockedImportance) {
mImportance.setEnabled(false);
} else {

View File

@@ -2,6 +2,7 @@ package com.android.settings.notification;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
@@ -25,9 +26,21 @@ public class NotificationSoundPreference extends RingtonePreference {
public void setRingtone(Uri ringtone) {
mRingtone = ringtone;
setSummary("\u00A0");
updateRingtoneName(mRingtone);
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
setRingtone(uri);
callChangeListener(uri);
}
return true;
}
private void updateRingtoneName(final Uri uri) {
AsyncTask ringtoneNameTask = new AsyncTask<Object, Void, CharSequence>() {
@Override