com.eveningoutpost.dexdrip.EditAlertActivity Java Examples
The following examples show how to use
com.eveningoutpost.dexdrip.EditAlertActivity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlertPlayer.java From xDrip-Experimental with GNU General Public License v3.0 | 4 votes |
private void Vibrate(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)) { // boost alerts... if(profile == ALERT_PROFILE_VIBRATE_ONLY) { profile = ALERT_PROFILE_ASCENDING; } } // We use timeFromStartPlaying as a way to force vibrating/ non vibrating... if (profile != ALERT_PROFILE_ASCENDING) { // We start from the non ascending part... timeFromStartPlaying = MAX_ASCENDING; } String title = bgValue + " " + alert.name; String content = "BG LEVEL ALERT (" + dateFormat.format(new Date()) + "): " + bgValue; Intent intent = new Intent(ctx, SnoozeActivity.class); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx) .setSmallIcon(R.drawable.ic_action_communication_invert_colors_on) .setContentTitle(title) .setContentText(content) .setContentIntent(notificationIntent(ctx, intent)) .setDeleteIntent(snoozeIntent(ctx)); if (profile != ALERT_PROFILE_VIBRATE_ONLY && profile != ALERT_PROFILE_SILENT) { if (timeFromStartPlaying >= MAX_VIBRATING) { // Before this, we only vibrate... float volumeFrac = (float)(timeFromStartPlaying - MAX_VIBRATING) / (MAX_ASCENDING - MAX_VIBRATING); volumeFrac = Math.min(volumeFrac, 1); if(profile == ALERT_PROFILE_MEDIUM) { volumeFrac = (float)0.7; } Log.d(TAG, "Vibrate volumeFrac = " + volumeFrac); boolean isRingTone = EditAlertActivity.isPathRingtone(ctx, alert.mp3_file); if(isRingTone && !overrideSilent) { builder.setSound(Uri.parse(alert.mp3_file)); } else { if(overrideSilent || isLoudPhone(ctx)) { PlayFile(ctx, alert.mp3_file, volumeFrac); } } } } if (profile != ALERT_PROFILE_SILENT && alert.vibrate) { builder.setVibrate(Notifications.vibratePattern); } else { // In order to still show on all android wear watches, either a sound or a vibrate pattern // seems to be needed. This pattern basically does not vibrate: builder.setVibrate(new long[]{1, 0}); } NotificationManager mNotifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); mNotifyMgr.cancel(Notifications.exportAlertNotificationId); mNotifyMgr.notify(Notifications.exportAlertNotificationId, builder.build()); //initiate sending data to pebble that will cause it to vibrate if(PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean("broadcast_to_pebble", false) && PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean("pebble_vibe_alerts", true)) { ctx.startService(new Intent(ctx, PebbleSync.class)); } }