preliminary implementation of 'quiet time'
This commit is contained in:
parent
fb6dfb3bde
commit
15bf83bbe4
2 changed files with 60 additions and 0 deletions
|
@ -20,6 +20,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.format.Time;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebSettings;
|
||||
|
||||
|
@ -755,6 +756,58 @@ public class K9 extends Application
|
|||
mQuietTimeEnds = quietTimeEnds;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isQuietTime()
|
||||
{
|
||||
if (!mQuietTimeEnabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Time time = new Time();
|
||||
time.setToNow();
|
||||
Integer startHour = Integer.parseInt(mQuietTimeStarts.split(":")[0]);
|
||||
Integer startMinute = Integer.parseInt(mQuietTimeStarts.split(":")[1]);
|
||||
Integer endHour = Integer.parseInt(mQuietTimeEnds.split(":")[0]);
|
||||
Integer endMinute = Integer.parseInt(mQuietTimeEnds.split(":")[1]);
|
||||
|
||||
Integer now = (time.hour * 60 ) + time.minute;
|
||||
Integer quietStarts = startHour * 60 + startMinute;
|
||||
Integer quietEnds = endHour * 60 +endMinute;
|
||||
|
||||
// If start and end times are the same, we're never quiet
|
||||
if (quietStarts == quietEnds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 21:00 - 05:00 means we want to be quiet if it's after 9 or before 5
|
||||
if (quietStarts > quietEnds)
|
||||
{
|
||||
// if it's 22:00 or 03:00 but not 8:00
|
||||
if ( now >= quietStarts || now <= quietEnds)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 01:00 - 05:00
|
||||
else
|
||||
{
|
||||
|
||||
// if it' 2:00 or 4:00 but not 8:00 or 0:00
|
||||
if ( now >= quietStarts && now <= quietEnds)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean startIntegratedInbox()
|
||||
{
|
||||
return mStartIntegratedInbox;
|
||||
|
|
|
@ -4737,6 +4737,13 @@ public class MessagingController implements Runnable
|
|||
|
||||
final boolean ringAndVibrate)
|
||||
{
|
||||
|
||||
// if it's quiet time, then we shouldn't be ringing, buzzing or flashing
|
||||
if (K9.isQuietTime())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ringAndVibrate)
|
||||
{
|
||||
if (ringtone != null)
|
||||
|
|
Loading…
Reference in a new issue