diff options
author | Michael W <baddaemon87@gmail.com> | 2022-03-18 20:23:26 +0100 |
---|---|---|
committer | Michael W <baddaemon87@gmail.com> | 2022-04-18 10:03:08 +0200 |
commit | fa6047db25729eebf26826f738d4a4ab2327a512 (patch) | |
tree | e94535bf44d25673adbf26f9262c5a56413f8280 /src/com/android/deskclock/settings/AlarmVolumePreference.java | |
parent | 23d7064d1abf2feb41d3d1a1812038a26e836181 (diff) |
DeskClock: Remove compatibility to old APIsHEADsugisawa-mr1
* We never build on these, so the code and annotations are useless
Change-Id: I791370b531ecadcbddb63ca04d5c4c51aafe1bc1
Diffstat (limited to 'src/com/android/deskclock/settings/AlarmVolumePreference.java')
-rw-r--r-- | src/com/android/deskclock/settings/AlarmVolumePreference.java | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/com/android/deskclock/settings/AlarmVolumePreference.java b/src/com/android/deskclock/settings/AlarmVolumePreference.java index 92edd9e67..91d0accdb 100644 --- a/src/com/android/deskclock/settings/AlarmVolumePreference.java +++ b/src/com/android/deskclock/settings/AlarmVolumePreference.java @@ -16,29 +16,29 @@ package com.android.deskclock.settings; -import android.annotation.TargetApi; +import static android.content.Context.AUDIO_SERVICE; +import static android.content.Context.NOTIFICATION_SERVICE; +import static android.media.AudioManager.STREAM_ALARM; + import android.app.NotificationManager; import android.content.Context; import android.database.ContentObserver; import android.media.AudioManager; import android.os.Build; import android.provider.Settings; -import androidx.preference.Preference; -import androidx.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; import android.widget.ImageView; import android.widget.SeekBar; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + import com.android.deskclock.R; import com.android.deskclock.RingtonePreviewKlaxon; import com.android.deskclock.Utils; import com.android.deskclock.data.DataModel; -import static android.content.Context.AUDIO_SERVICE; -import static android.content.Context.NOTIFICATION_SERVICE; -import static android.media.AudioManager.STREAM_ALARM; - public class AlarmVolumePreference extends Preference { private static final long ALARM_PREVIEW_DURATION_MS = 2000; @@ -61,11 +61,12 @@ public class AlarmVolumePreference extends Preference { holder.itemView.setClickable(false); // Minimum volume for alarm is not 0, calculate it. - int maxVolume = audioManager.getStreamMaxVolume(STREAM_ALARM) - getMinVolume(audioManager); + int maxVolume = audioManager.getStreamMaxVolume(STREAM_ALARM) - + audioManager.getStreamMinVolume(STREAM_ALARM); mSeekbar = (SeekBar) holder.findViewById(R.id.seekbar); mSeekbar.setMax(maxVolume); mSeekbar.setProgress(audioManager.getStreamVolume(STREAM_ALARM) - - getMinVolume(audioManager)); + audioManager.getStreamMinVolume(STREAM_ALARM)); ((ImageView) holder.findViewById(android.R.id.icon)) .setImageResource(R.drawable.ic_alarm_small); @@ -76,7 +77,7 @@ public class AlarmVolumePreference extends Preference { public void onChange(boolean selfChange) { // Volume was changed elsewhere, update our slider. mSeekbar.setProgress(audioManager.getStreamVolume(STREAM_ALARM) - - getMinVolume(audioManager)); + audioManager.getStreamMinVolume(STREAM_ALARM)); } }; @@ -97,7 +98,7 @@ public class AlarmVolumePreference extends Preference { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (fromUser) { - int newVolume = progress + getMinVolume(audioManager); + int newVolume = progress + audioManager.getStreamMinVolume(STREAM_ALARM); audioManager.setStreamVolume(STREAM_ALARM, newVolume, 0); } onSeekbarChanged(); @@ -131,18 +132,9 @@ public class AlarmVolumePreference extends Preference { } private boolean doesDoNotDisturbAllowAlarmPlayback() { - return !Utils.isNOrLater() || doesDoNotDisturbAllowAlarmPlaybackNPlus(); - } - - @TargetApi(Build.VERSION_CODES.N) - private boolean doesDoNotDisturbAllowAlarmPlaybackNPlus() { final NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(NOTIFICATION_SERVICE); return notificationManager.getCurrentInterruptionFilter() != NotificationManager.INTERRUPTION_FILTER_NONE; } - - private int getMinVolume(AudioManager audioManager) { - return (Utils.isPOrLater()) ? audioManager.getStreamMinVolume(STREAM_ALARM) : 0; - } }
\ No newline at end of file |