Permalink
Browse files

Merge pull request #78 from geekarist/fix-doze

Fix Doze
  • Loading branch information...
Insti committed Jul 3, 2018
2 parents ce3f008 + 11290b3 commit 544f40f96fd34817ef46201671c3bbda00d2231f
Showing with 24 additions and 7 deletions.
  1. +6 −3 src/and/tagTime/build.gradle
  2. +18 −4 src/and/tagTime/src/main/java/bsoule/tagtime/PingService.java
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
compileSdkVersion 23
defaultConfig {
applicationId "bsoule.tagtime"
minSdkVersion 8
targetSdkVersion 21
targetSdkVersion 23
}
buildTypes {
@@ -20,5 +20,8 @@ android {
dependencies {
compile project(':library')
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile 'com.android.support:support-v4:21.0.3'
// Stay in 22 as migration to 23 requires replacing ActionBarSherlock with ActionBarCompat
//noinspection GradleDependency,GradleCompatible
compile 'com.android.support:support-v4:22.2.1'
}
@@ -12,6 +12,7 @@
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.os.Parcel;
import android.os.PowerManager;
@@ -161,22 +162,25 @@ public void sendNote(long pingtime, long rowID) {
Date ping = new Date(pingtime * 1000);
CharSequence text = getText(R.string.status_bar_notes_ping_msg);
PendingIntent contentIntent = createPendingIntent(rowID, null);
// Set the icon, scrolling text, and timestamp.
NotificationCompat.Builder noteBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.stat_ping)
.setTicker(text)
.setContentTitle("Ping!")
.setContentText(SDF.format(ping))
.setContentIntent(contentIntent)
.setWhen(ping.getTime());
addTagActions(noteBuilder, rowID);
PendingIntent contentIntent = createPendingIntent(rowID, null);
// Set the info for the views that show in the notification panel.
// note.setLatestEventInfo(context, contentTitle, contentText,
// contentIntent)
Notification note = noteBuilder.build();
note.setLatestEventInfo(this, "Ping!", SDF.format(ping), contentIntent);
boolean suppress_noises = false;
if (mPrefs.getBoolean("pingQuietCharging", false)) {
@@ -287,7 +291,17 @@ private void setAlarm(long PING) {
AlarmManager alarum = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent alit = new Intent(this, TPStartUp.class);
alit.putExtra("ThisIntentIsTPStartUpClass", true);
alarum.set(AlarmManager.RTC_WAKEUP, PING * 1000, PendingIntent.getBroadcast(this, 0, alit, 0));
assert alarum != null;
int type = AlarmManager.RTC_WAKEUP;
long trigger = PING * 1000;
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alit, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
alarum.setExactAndAllowWhileIdle(type, trigger, pendingIntent);
} else {
alarum.set(type, trigger, pendingIntent);
}
}
private static final long IA = 16807;

0 comments on commit 544f40f

Please sign in to comment.