rename Alarm -> Alert
This commit is contained in:
parent
ca31195b15
commit
725db13776
4 changed files with 26 additions and 28 deletions
|
@ -63,9 +63,9 @@
|
||||||
<service
|
<service
|
||||||
android:name=".Services.DataService"
|
android:name=".Services.DataService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<!-- Service showing alarm on screen -->
|
<!-- Service showing alert on screen -->
|
||||||
<service
|
<service
|
||||||
android:name=".Services.AlarmService"
|
android:name=".Services.AlertService"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Services.AlarmService;
|
import info.nightscout.androidaps.Services.AlertService;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
|
@ -163,7 +163,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
REQUEST_CODE_ASK_PERMISSIONS
|
REQUEST_CODE_ASK_PERMISSIONS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Intent alarmServiceIntent = new Intent(getApplicationContext(), AlarmService.class);
|
Intent alarmServiceIntent = new Intent(getApplicationContext(), AlertService.class);
|
||||||
alarmServiceIntent.putExtra("alarmText", getString(R.string.nav_test_alarm));
|
alarmServiceIntent.putExtra("alarmText", getString(R.string.nav_test_alarm));
|
||||||
getApplicationContext().startService(alarmServiceIntent);
|
getApplicationContext().startService(alarmServiceIntent);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.graphics.Typeface;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.SoundPool;
|
import android.media.SoundPool;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -19,12 +18,11 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class AlarmMessage {
|
public class AlertMessage {
|
||||||
private static Logger log = LoggerFactory.getLogger(AlarmMessage.class);
|
private static Logger log = LoggerFactory.getLogger(AlertMessage.class);
|
||||||
|
|
||||||
private static boolean displayed = false;
|
private static boolean displayed = false;
|
||||||
|
|
||||||
|
@ -39,7 +37,7 @@ public class AlarmMessage {
|
||||||
private static int mSoundID;
|
private static int mSoundID;
|
||||||
private static int mPlayingId;
|
private static int mPlayingId;
|
||||||
private Runnable mOnDismiss;
|
private Runnable mOnDismiss;
|
||||||
private String mAlarmText = "Alarm";
|
private String mAlertText = "Alarm";
|
||||||
PowerManager.WakeLock mWakeLock;
|
PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -47,10 +45,10 @@ public class AlarmMessage {
|
||||||
mSoundID = mSoundPool.load(MainApp.instance().getApplicationContext(), R.raw.beep_beep, 1);
|
mSoundID = mSoundPool.load(MainApp.instance().getApplicationContext(), R.raw.beep_beep, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlarmMessage(Context mApplicationContext) {
|
public AlertMessage(Context mApplicationContext) {
|
||||||
this.mApplicationContext = mApplicationContext;
|
this.mApplicationContext = mApplicationContext;
|
||||||
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
|
PowerManager powerManager = (PowerManager) mApplicationContext.getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "AlarmMessage");
|
mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "AlertMessage");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMessage() {
|
public void showMessage() {
|
||||||
|
@ -100,7 +98,7 @@ public class AlarmMessage {
|
||||||
mFloatingTextView = new TextView(getApplicationContext());
|
mFloatingTextView = new TextView(getApplicationContext());
|
||||||
mLinLayout.addView(mFloatingTextView);
|
mLinLayout.addView(mFloatingTextView);
|
||||||
|
|
||||||
mFloatingTextView.setText(mAlarmText);
|
mFloatingTextView.setText(mAlertText);
|
||||||
mFloatingTextView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
|
mFloatingTextView.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));
|
||||||
mFloatingTextView.setTextSize(24.0F);
|
mFloatingTextView.setTextSize(24.0F);
|
||||||
mFloatingTextView.setGravity(Gravity.CENTER);
|
mFloatingTextView.setGravity(Gravity.CENTER);
|
||||||
|
@ -119,7 +117,7 @@ public class AlarmMessage {
|
||||||
mButtonDismis.setOnClickListener(new View.OnClickListener() {
|
mButtonDismis.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
AlarmMessage.this.dismis();
|
AlertMessage.this.dismis();
|
||||||
if (mOnDismiss != null) {
|
if (mOnDismiss != null) {
|
||||||
mOnDismiss.run();
|
mOnDismiss.run();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +143,7 @@ public class AlarmMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setText(String text) {
|
public void setText(String text) {
|
||||||
mAlarmText = text;
|
mAlertText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnDismiss(Runnable runnable) {
|
public void setOnDismiss(Runnable runnable) {
|
|
@ -13,8 +13,8 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
|
||||||
public class AlarmService extends Service {
|
public class AlertService extends Service {
|
||||||
private static Logger log = LoggerFactory.getLogger(AlarmService.class);
|
private static Logger log = LoggerFactory.getLogger(AlertService.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
@ -22,40 +22,40 @@ public class AlarmService extends Service {
|
||||||
log.debug("onStartCommand");
|
log.debug("onStartCommand");
|
||||||
|
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
long lastAlarm = preferences.getLong("lastAlarm", 0);
|
long lastAlert = preferences.getLong("lastAlert", 0);
|
||||||
long currentTime = new Date().getTime();
|
long currentTime = new Date().getTime();
|
||||||
|
|
||||||
//if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("masterSwitch", false)) {
|
//if (!PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("masterSwitch", false)) {
|
||||||
// stopSelf(startId);
|
// stopSelf(startId);
|
||||||
// log.debug("Alarm posponed - master switch disabled");
|
// log.debug("Alert posponed - master switch disabled");
|
||||||
//} else
|
//} else
|
||||||
//if ((currentTime - lastAlarm) < 15 * 60 * 1000) {
|
//if ((currentTime - lastAlert) < 15 * 60 * 1000) {
|
||||||
// stopSelf(startId);
|
// stopSelf(startId);
|
||||||
// log.debug("Alarm posponed");
|
// log.debug("Alert posponed");
|
||||||
//} else
|
//} else
|
||||||
{
|
{
|
||||||
|
|
||||||
AlarmMessage alarm = new AlarmMessage(getApplicationContext());
|
AlertMessage alert = new AlertMessage(getApplicationContext());
|
||||||
|
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
String alarmText = intent.getStringExtra("alarmText");
|
String alertText = intent.getStringExtra("alertText");
|
||||||
if (alarmText != null) {
|
if (alertText != null) {
|
||||||
alarm.setText(alarmText);
|
alert.setText(alertText);
|
||||||
}
|
}
|
||||||
|
|
||||||
alarm.setOnDismiss(new Runnable() {
|
alert.setOnDismiss(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
SharedPreferences.Editor editor = preferences.edit();
|
SharedPreferences.Editor editor = preferences.edit();
|
||||||
editor.putLong("lastAlarm", new Date().getTime());
|
editor.putLong("lastAlert", new Date().getTime());
|
||||||
editor.commit();
|
editor.commit();
|
||||||
AlarmService.this.stopSelf();
|
AlertService.this.stopSelf();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
alarm.showMessage();
|
alert.showMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Config.logFunctionCalls)
|
if (Config.logFunctionCalls)
|
Loading…
Reference in a new issue