Add a grayscale image for the large notification icon.
BIN
GlowPadBackport/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
GlowPadBackport/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
GlowPadBackport/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
GlowPadBackport/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 19 KiB |
@ -14,9 +14,6 @@ import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
// TODO See GlowPad.
|
||||
|
||||
// TODO sound audible alarm -- see AlarmKlaxon.java
|
||||
@ -27,11 +24,9 @@ public class AlarmAlertActivity extends Activity {
|
||||
// TODO correct alert lifetime
|
||||
private static final int ALERT_LIFE = 1000*10; //1000*60*2; // 2 minutes
|
||||
private static final long[] vPattern = {500, 500};
|
||||
private static AlarmManager graceManager;
|
||||
private static PendingIntent gracePendingIntent;
|
||||
private static Intent notifyIntent;
|
||||
private static Vibrator vibrator;
|
||||
private static Boolean userCancelled;
|
||||
private static Vibrator vibrator;
|
||||
private static Intent notifyIntent;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -57,13 +52,12 @@ public class AlarmAlertActivity extends Activity {
|
||||
// Turn off the alert activity, and switch to a notification
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
if (!userCancelled) {
|
||||
// Close the dialogue and switch to notification
|
||||
// if the Activity has not been closed by the user
|
||||
finish();
|
||||
if (!userCancelled) {
|
||||
startService(notifyIntent);
|
||||
finish();
|
||||
}
|
||||
Log.d("AlarmAlertActivity", "Started notification");
|
||||
}
|
||||
}, ALERT_LIFE);
|
||||
}
|
||||
@ -82,9 +76,37 @@ public class AlarmAlertActivity extends Activity {
|
||||
cancelButton.setOnClickListener (new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
graceManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
cancelGraceAlarm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the user pressing the back/return button
|
||||
* TODO Do we want this to cancel the alarm and grace period?
|
||||
* TODO Or do we trigger the notification and finish() right away?
|
||||
* TODO probably most intuitive to cancel the alarms...
|
||||
*/
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
cancelGraceAlarm();
|
||||
/* OR:
|
||||
// Ensure that the we don't trigger the notification a second time
|
||||
userCancelled = true;
|
||||
startService(notifyIntent);
|
||||
finish();
|
||||
*/
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
vibrator.cancel();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void cancelGraceAlarm() {
|
||||
AlarmManager graceManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
Intent graceIntent = new Intent(getApplicationContext(), GraceReceiver.class);
|
||||
gracePendingIntent = PendingIntent.getBroadcast(getApplicationContext(), MainActivity.GRACE_REQUEST, graceIntent, 0);
|
||||
PendingIntent gracePendingIntent = PendingIntent.getBroadcast(getApplicationContext(), MainActivity.GRACE_REQUEST, graceIntent, 0);
|
||||
graceManager.cancel(gracePendingIntent);
|
||||
Log.d("AlarmAlertActivity", "Cancelled grace alarm.");
|
||||
// Ensure we don't load a notification now
|
||||
@ -92,11 +114,4 @@ public class AlarmAlertActivity extends Activity {
|
||||
// Close the dialogue (stop vibration &c)
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
vibrator.cancel();
|
||||
super.onStop();
|
||||
}
|
||||
}
|
@ -9,13 +9,14 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class AlarmNotify extends Service {
|
||||
public static final int notifyID = 1;
|
||||
private volatile boolean threadRunning = false;
|
||||
@ -45,7 +46,7 @@ public class AlarmNotify extends Service {
|
||||
final long endTime = System.currentTimeMillis() + (gracePeriod * 60 * 1000);
|
||||
|
||||
//Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.alarm_notification);
|
||||
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
|
||||
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_grayscale);
|
||||
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
final Notification.Builder notification = new Notification.Builder(this)
|
||||
.setContentTitle(getString(R.string.app_name))
|
||||
@ -93,7 +94,6 @@ public class AlarmNotify extends Service {
|
||||
if (!threadRunning) {
|
||||
return;
|
||||
}
|
||||
//Log.d("AlarmNotify", "secondsLeft is "+secondsLeft+" and progress is "+progress+" (gracePeriodSeconds is "+gracePeriodSeconds+")");
|
||||
int minutesLeft = secondsLeft / 60;
|
||||
notification.setContentText(String.format(getString(R.string.notificationText), MainActivity.MinutesToGracePeriodStr(minutesLeft)));
|
||||
notification.setProgress(max, progress, false);
|
||||
@ -103,6 +103,7 @@ public class AlarmNotify extends Service {
|
||||
secondsLeft = secondsLeft - (UPDATE_INTERVAL / 1000);
|
||||
// Multiply each int by 1000 for greater progress resolution
|
||||
progress = (((gracePeriodSeconds * 1000) - (secondsLeft * 1000)) * max) / (gracePeriodSeconds * 1000);
|
||||
Log.d("AlarmNotify", "secondsLeft is "+secondsLeft+" and progress is "+progress+" (gracePeriodSeconds is "+gracePeriodSeconds+")");
|
||||
// Sleeps the thread, simulating an operation
|
||||
// that takes time
|
||||
try {
|
||||
@ -117,5 +118,4 @@ public class AlarmNotify extends Service {
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class MainActivity extends ActionBarActivity {
|
||||
|
||||
if (alarmActive) {
|
||||
// Initialise alarm, which displays a dialog and system alert, and
|
||||
// calls CountDownTimer (or AlarmManager?) with grace_period as the delay
|
||||
// calls AlarmManager with grace_period as the delay
|
||||
// which in turn, sends SMS if dialog is not exited.
|
||||
alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
|
||||
Intent alarmIntent = new Intent(getActivity(), AlarmReceiver.class);
|
||||
|
BIN
HypoAlarm/src/main/res/drawable-hdpi/ic_grayscale.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
HypoAlarm/src/main/res/drawable-mdpi/ic_grayscale.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
HypoAlarm/src/main/res/drawable-xhdpi/ic_grayscale.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
HypoAlarm/src/main/res/drawable-xxhdpi/ic_grayscale.png
Normal file
After Width: | Height: | Size: 23 KiB |