Notification importance/selected sound conflict fixes.

- When you've selected "Silent" as your sound, update notification
importance messaging to match.
- When you explicitly move from a silent type of notifications to a
loud type, but have "Silent" selected as the sound, change the
sound to the default notification sound also.

Change-Id: I462785d593e1d6c7d1e87388aeee1bdcbcf6aa3d
Fixes: 63109928
Test: RunSettingsRoboTests, manual
This commit is contained in:
Alison Cichowlas
2017-09-14 15:01:29 -04:00
parent 744ff5c607
commit bff0e971ca
4 changed files with 39 additions and 10 deletions

View File

@@ -49,6 +49,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -479,13 +480,20 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
case NotificationManager.IMPORTANCE_LOW:
return getContext().getString(R.string.notification_importance_low);
case NotificationManager.IMPORTANCE_DEFAULT:
return getContext().getString(R.string.notification_importance_default);
if (hasValidSound(channel)) {
return getContext().getString(R.string.notification_importance_default);
} else { // Silent
return getContext().getString(R.string.notification_importance_low);
}
case NotificationManager.IMPORTANCE_HIGH:
case NotificationManager.IMPORTANCE_MAX:
default:
return getContext().getString(R.string.notification_importance_high);
if (hasValidSound(channel)) {
return getContext().getString(R.string.notification_importance_high);
} else { // Silent
return getContext().getString(R.string.notification_importance_high_silent);
}
}
}
private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
@@ -595,4 +603,8 @@ abstract public class NotificationSettingsBase extends SettingsPreferenceFragmen
}
return left.getId().compareTo(right.getId());
};
boolean hasValidSound(NotificationChannel channel) {
return channel.getSound() != null && !Uri.EMPTY.equals(channel.getSound());
}
}