private static synchronized void createPlayer() { if (singletone == null) { singletone = new AlertPlayer(); } }
public static boolean isAscendingMode(Context ctx){ Log.d("Adrian", "(getAlertProfile(ctx) == ALERT_PROFILE_ASCENDING): " + (getAlertProfile(ctx) == ALERT_PROFILE_ASCENDING)); return getAlertProfile(ctx) == ALERT_PROFILE_ASCENDING; }
public static void testAlert( String name, boolean above, double threshold, boolean all_day, int minutes_between, String mp3_file, int start_time_minutes, int end_time_minutes, boolean override_silent_mode, int snooze, boolean vibrate, Context context) { AlertType at = new AlertType(); at.name = name; at.above = above; at.threshold = threshold; at.all_day = all_day; at.minutes_between = minutes_between; at.uuid = UUID.randomUUID().toString(); at.active = true; at.mp3_file = mp3_file; at.start_time_minutes = start_time_minutes; at.end_time_minutes = end_time_minutes; at.override_silent_mode = override_silent_mode; at.default_snooze = snooze; at.vibrate = vibrate; AlertPlayer.getPlayer().startAlert(context, false, at, "TEST", false); }
private void findPhone() { UserError.Log.d(TAG, "Find phone function triggered"); if (!AlertPlayer.getPlayer().OpportunisticSnooze()) { JoH.showNotification("Find Phone", "Activated from Lefun band", null, 5, true, true, false); } else { emptyQueue(); UserError.Log.ueh(TAG, "Alert snoozed by Find feature"); } }
private void VibrateAudio(Context ctx, AlertType alert, String bgValue, Boolean overrideSilent, int timeFromStartPlaying) { Log.d(TAG, "Vibrate called timeFromStartPlaying = " + timeFromStartPlaying); Log.d("ALARM", "setting vibrate alarm"); int profile = getAlertProfile(ctx); if(alert.uuid.equals(AlertType.LOW_ALERT_55)) { .setContentIntent(notificationIntent(ctx, intent)) .setDeleteIntent(snoozeIntent(ctx)); boolean isRingTone = true;//KS TODO EditAlertActivity.isPathRingtone(ctx, alert.mp3_file); if (notSilencedDueToCall()) { if (isRingTone && !overrideSilent) { builder.setSound(Uri.parse(alert.mp3_file)); } else { if (overrideSilent || isLoudPhone(ctx)) { PlayFile(ctx, alert.mp3_file, volumeFrac); if (notSilencedDueToCall()) { builder.setVibrate(Notifications.vibratePattern); } else {
if (bgReading == null) { AlertPlayer.getPlayer().stopAlert(context, true, false); return; Log.d(TAG, "FileBasedNotifications - No active notifcation exists, stopping all alerts"); AlertPlayer.getPlayer().stopAlert(context, false, true); return; AlertPlayer.getPlayer().startAlert(context, trendingToAlertEnd, newAlert, unitsConvert2Disp(doMgdl, calculated_value));//KS EditAlertActivity. return; AlertPlayer.getPlayer().ClockTick(context, trendingToAlertEnd, unitsConvert2Disp(doMgdl, calculated_value));//KS EditAlertActivity return; AlertPlayer.getPlayer().stopAlert(context, true, false); boolean trendingToAlertEnd = trendingToAlertEnd(context, true, newAlert); AlertPlayer.getPlayer().startAlert(context, trendingToAlertEnd, newAlert, unitsConvert2Disp(doMgdl, calculated_value));//KS EditAlertActivity } else { AlertPlayer.getPlayer().stopAlert(context, true, false);
public synchronized static void stop() { Sensor.stopSensor(); Inevitable.task("stop-sensor",1000, Sensor::stopSensor); AlertPlayer.getPlayer().stopAlert(xdrip.getAppContext(), true, false); JoH.static_toast_long("Sensor stopped"); JoH.clearCache(); LibreAlarmReceiver.clearSensorStats(); PluggableCalibration.invalidateAllCaches(); Ob1G5StateMachine.stopSensor(); CollectionServiceStarter.restartCollectionServiceBackground(); Home.staticRefreshBGCharts(); }
AlertPlayer.defaultSnooze(); JoH.static_toast_long("SNOOZE from Tasker"); break; AlertPlayer.getPlayer().OpportunisticSnooze(); break;
setDataSourceSucceeded = setMediaDataSource(ctx, mediaPlayer, Uri.parse(FileName)); setDataSourceSucceeded = setMediaDataSource(ctx, mediaPlayer, R.raw.default_alert); int maxVolume = manager.getStreamMaxVolume(getAlertPlayerStreamType()); volumeBeforeAlert = manager.getStreamVolume(getAlertPlayerStreamType()); volumeForThisAlert = (int) (maxVolume * VolumeFrac); manager.setStreamVolume(getAlertPlayerStreamType(), volumeForThisAlert, 0); } catch (SecurityException e) { if (JoH.ratelimit("sound volume error", 12000)) {
public synchronized void Snooze(Context ctx, int repeatTime) { Snooze(ctx, repeatTime, true); // if (Home.get_forced_wear() && Pref.getBooleanDefaultFalse("bg_notifications") ) { SendData(ctx, ListenerService.WEARABLE_SNOOZE_ALERT, ("" + repeatTime).getBytes(StandardCharsets.UTF_8)); // } }
private synchronized void revertCurrentVolume(final Context ctx) { AudioManager manager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE); int currentVolume = manager.getStreamVolume(getAlertPlayerStreamType()); Log.i(TAG, "revertCurrentVolume volumeBeforeAlert " + volumeBeforeAlert + " volumeForThisAlert " + volumeForThisAlert + " currentVolume " + currentVolume); if (volumeForThisAlert == currentVolume && (volumeBeforeAlert != -1) && (volumeForThisAlert != -1)) { // If the user has changed the volume, don't change it again. try { manager.setStreamVolume(getAlertPlayerStreamType(), volumeBeforeAlert, 0); } catch (SecurityException e) { if (JoH.ratelimit("sound volume error", 12000)) { UserError.Log.wtf(TAG, "This device does not allow us to modify the sound volume"); } } } volumeBeforeAlert = -1; volumeForThisAlert = -1; }
public long getNextAlertTime(Context ctx) { int time = minutes_between; if (time < 1 || AlertPlayer.isAscendingMode(ctx)) { time = 1; } Calendar calendar = Calendar.getInstance(); return calendar.getTimeInMillis() + (time * 60000); }
if (AlertPlayer.notSilencedDueToCall()) { if (otherAlertsOverrideSilent) { mBuilder.setSound(Uri.parse(otherAlertsSound), AudioAttributes.USAGE_ALARM);
private void VibrateNotifyMakeNoise(Context context, AlertType alert, String bgValue, Boolean overrideSilent, int minsFromStartPlaying) { Log.d(TAG, "VibrateNotifyMakeNoise called minsFromStartedPlaying = " + minsFromStartPlaying); Log.d("ALARM", "setting vibrate alarm"); int profile = getAlertProfile(context); if (alert.uuid.equals(AlertType.LOW_ALERT_55)) { .setContentTitle(title) .setContentText(content) .setContentIntent(notificationIntent(context, intent)) .setLocalOnly(localOnly) .setPriority(Pref.getBooleanDefaultFalse("high_priority_notifications") ? Notification.PRIORITY_MAX : Notification.PRIORITY_HIGH) .setDeleteIntent(snoozeIntent(context, minsFromStartPlaying)); boolean isRingTone = EditAlertActivity.isPathRingtone(context, alert.mp3_file); if (notSilencedDueToCall()) { if (isRingTone && !overrideSilent) { builder.setSound(Uri.parse(alert.mp3_file)); } else { if (overrideSilent || isLoudPhone(context)) { PlayFile(context, alert.mp3_file, volumeFrac); if (notSilencedDueToCall()) { builder.setVibrate(Notifications.vibratePattern); } else {
if (bgReading == null) { AlertPlayer.getPlayer().stopAlert(context, true, false); return; Log.d(TAG, "FileBasedNotifications - No active notifcation exists, stopping all alerts"); AlertPlayer.getPlayer().stopAlert(context, false, true); return; AlertPlayer.getPlayer().startAlert(context, trendingToAlertEnd, newAlert, EditAlertActivity.unitsConvert2Disp(doMgdl, calculated_value)); return; AlertPlayer.getPlayer().ClockTick(context, trendingToAlertEnd, EditAlertActivity.unitsConvert2Disp(doMgdl, calculated_value)); return; AlertPlayer.getPlayer().stopAlert(context, true, false); boolean trendingToAlertEnd = trendingToAlertEnd(context, true, newAlert); AlertPlayer.getPlayer().startAlert(context, trendingToAlertEnd, newAlert, EditAlertActivity.unitsConvert2Disp(doMgdl, calculated_value)); } else { AlertPlayer.getPlayer().stopAlert(context, true, false);
public synchronized static void stop() { Sensor.stopSensor(); Inevitable.task("stop-sensor",1000, Sensor::stopSensor); AlertPlayer.getPlayer().stopAlert(xdrip.getAppContext(), true, false); JoH.static_toast_long("Sensor stopped"); JoH.clearCache(); LibreAlarmReceiver.clearSensorStats(); PluggableCalibration.invalidateAllCaches(); Ob1G5StateMachine.stopSensor(); CollectionServiceStarter.restartCollectionServiceBackground(); Home.staticRefreshBGCharts(); }
public static void testAlert( String name, boolean above, double threshold, boolean all_day, int minutes_between, String mp3_file, int start_time_minutes, int end_time_minutes, boolean override_silent_mode, int snooze, boolean vibrate, Context context) { AlertType at = new AlertType(); at.name = name; at.above = above; at.threshold = threshold; at.all_day = all_day; at.minutes_between = minutes_between; at.uuid = UUID.randomUUID().toString(); at.active = true; at.mp3_file = mp3_file; at.start_time_minutes = start_time_minutes; at.end_time_minutes = end_time_minutes; at.override_silent_mode = override_silent_mode; at.default_snooze = snooze; at.vibrate = vibrate; AlertPlayer.getPlayer().startAlert(context, false, at, "TEST", false); }
private void shakeDetected() { UserError.Log.d(TAG, "Shake detected"); if (shakeToSnooze()) { AlertPlayer.getPlayer().OpportunisticSnooze(); emptyQueue(); UserError.Log.ueh(TAG, "Alert snoozed by Shake"); } }
AlertPlayer.defaultSnooze(); JoH.static_toast_long("SNOOZE from Tasker"); break; AlertPlayer.getPlayer().OpportunisticSnooze(); break;