forked from jens/Automation
function cleanup
This commit is contained in:
parent
d1ca9ab56b
commit
26ed906521
@ -781,6 +781,23 @@ public class Actions
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setDoNotDisturb(Context context, int desiredDndMode)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
/*
|
||||
if (!notificationManager.isNotificationPolicyAccessGranted())
|
||||
--> done externally
|
||||
*/
|
||||
|
||||
Miscellaneous.logEvent("i", context.getResources().getString(R.string.soundSettings), "Changing DND to " + String.valueOf(desiredDndMode), 4);
|
||||
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.setInterruptionFilter(desiredDndMode);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", context.getResources().getString(R.string.soundSettings), "Cannot change DND to " + String.valueOf(desiredDndMode) + ". This Android version is too and doesn\'t have that feature, yet.", 4);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
public static boolean isDoNotDisturbActive(Context context)
|
||||
{
|
||||
@ -915,18 +932,6 @@ public class Actions
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDND(Context context, int desiredDndMode)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||
{
|
||||
Miscellaneous.logEvent("i", context.getResources().getString(R.string.soundSettings), "Changing DND to " + String.valueOf(desiredDndMode), 4);
|
||||
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.setInterruptionFilter(desiredDndMode);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", context.getResources().getString(R.string.soundSettings), "Cannot change DND to " + String.valueOf(desiredDndMode) + ". This Android version is too and doesn\'t have that feature, yet.", 4);
|
||||
}
|
||||
|
||||
public void useDownloadedWebpage(String result)
|
||||
{
|
||||
// Toast.makeText(context, "Result: " + result, Toast.LENGTH_LONG).show();
|
||||
|
@ -4,12 +4,10 @@ import android.app.NotificationManager;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -509,7 +507,7 @@ public class Profile implements Comparable<Profile>
|
||||
Actions.setSound(context, soundMode);
|
||||
|
||||
if(changeDndMode)
|
||||
Actions.setDND(context, dndMode);
|
||||
Actions.setDoNotDisturb(context, dndMode);
|
||||
|
||||
if(changeVolumeMusicVideoGameMedia)
|
||||
am.setStreamVolume(AudioManager.STREAM_MUSIC, volumeMusic, AudioManager.FLAG_PLAY_SOUND);
|
||||
|
Loading…
Reference in New Issue
Block a user