mirror of https://github.com/tasks/tasks
Add audio and telephony managers
parent
916438c09b
commit
c03b8882fa
@ -0,0 +1,38 @@
|
|||||||
|
package org.tasks.notifications;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.tasks.injection.ForApplication;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class AudioManager {
|
||||||
|
|
||||||
|
private final android.media.AudioManager audioManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public AudioManager(@ForApplication Context context) {
|
||||||
|
audioManager = (android.media.AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAlarmVolume() {
|
||||||
|
return audioManager.getStreamVolume(android.media.AudioManager.STREAM_ALARM);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxAlarmVolume() {
|
||||||
|
audioManager.setStreamVolume(android.media.AudioManager.STREAM_ALARM,
|
||||||
|
audioManager.getStreamMaxVolume(android.media.AudioManager.STREAM_ALARM), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean notificationsMuted() {
|
||||||
|
return audioManager.getStreamVolume(android.media.AudioManager.STREAM_NOTIFICATION) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRingtoneMode() {
|
||||||
|
return audioManager.getMode() == android.media.AudioManager.MODE_RINGTONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlarmVolume(int volume) {
|
||||||
|
audioManager.setStreamVolume(android.media.AudioManager.STREAM_ALARM, volume, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package org.tasks.notifications;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.tasks.injection.ForApplication;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
public class TelephonyManager {
|
||||||
|
|
||||||
|
private final android.telephony.TelephonyManager telephonyManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public TelephonyManager(@ForApplication Context context) {
|
||||||
|
telephonyManager = (android.telephony.TelephonyManager)
|
||||||
|
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean callStateIdle() {
|
||||||
|
return telephonyManager.getCallState() == android.telephony.TelephonyManager.CALL_STATE_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue