117 lines
3.7 KiB
Java
117 lines
3.7 KiB
Java
package za.org.treehouse.hypoalarm;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
|
|
//import com.triggertrap.seekarc.SeekArc;
|
|
import net.frakbot.glowpadbackport.GlowPadView;
|
|
|
|
public class AlarmAlertActivity extends Activity {
|
|
private static Intent notifyIntent;
|
|
public static Boolean alertFinished, userCancelled;
|
|
public static Activity alertActivity;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
// Self-reference so we can run finish() from outside.
|
|
alertActivity = this;
|
|
|
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
|
final Window window = getWindow();
|
|
// Set to use the full screen
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
|
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
|
|
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
|
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
|
| WindowManager.LayoutParams.FLAG_FULLSCREEN
|
|
);
|
|
|
|
if (Build.VERSION.SDK_INT >= 14) {
|
|
window.getDecorView().
|
|
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
|
|
}
|
|
|
|
setContentView(R.layout.alarm_alert);
|
|
|
|
notifyIntent = new Intent(getApplicationContext(), AlarmNotify.class);
|
|
// Disable any current notifications (if we're snoozing)
|
|
stopService(notifyIntent);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onStart() {
|
|
super.onStart();
|
|
|
|
/* CANCEL SEEKARC
|
|
final SeekArc cancelArc = (SeekArc) findViewById(R.id.cancel_dialog_seekArc);
|
|
cancelArc.setOnSeekArcChangeListener(new SeekArc.OnSeekArcChangeListener() {
|
|
volatile Boolean seekFinished = false;
|
|
@Override
|
|
public void onProgressChanged(SeekArc seekArc, int progress, boolean fromUser) {
|
|
if (progress > 98 && !seekFinished && fromUser) {
|
|
AlarmReceiver.dismissAlarm(alertActivity);
|
|
seekFinished = true;
|
|
}
|
|
}
|
|
@Override
|
|
public void onStartTrackingTouch(SeekArc seekArc) {
|
|
}
|
|
@Override
|
|
public void onStopTrackingTouch(SeekArc seekArc) {
|
|
}
|
|
});
|
|
*/
|
|
final GlowPadView cancelGlowPad = (GlowPadView) findViewById(R.id.cancel_glowpad);
|
|
cancelGlowPad.setOnTriggerListener(new GlowPadView.OnTriggerListener() {
|
|
@Override
|
|
public void onGrabbed(View v, int handle) {
|
|
// Do nothing
|
|
}
|
|
|
|
@Override
|
|
public void onReleased(View v, int handle) {
|
|
// Do nothing
|
|
}
|
|
|
|
@Override
|
|
public void onTrigger(View v, int target) {
|
|
// if (target == "")
|
|
AlarmReceiver.dismissAlarm(alertActivity);
|
|
}
|
|
|
|
@Override
|
|
public void onGrabbedStateChange(View v, int handle) {
|
|
// Do nothing
|
|
}
|
|
|
|
@Override
|
|
public void onFinishFinalAnimation() {
|
|
// Do nothing
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Handle the user pressing the back/return and home buttons
|
|
*/
|
|
@Override
|
|
public void onBackPressed() {
|
|
AlarmReceiver.setAlarmStatus(AlarmReceiver.ALARM_IGNORED);
|
|
AlarmReceiver.snoozeAlarm(this);
|
|
}
|
|
|
|
public void onUserLeaveHint() {
|
|
AlarmReceiver.setAlarmStatus(AlarmReceiver.ALARM_IGNORED);
|
|
AlarmReceiver.snoozeAlarm(this);
|
|
}
|
|
} |