use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class AlertUtils method flushOldAlertsFromInternalStorage.
/**
* Scans and flushes the internal storage of old alerts. Looks up the previous flush
* time in SharedPrefs, and performs the flush if overdue. Otherwise, no-op.
*/
static void flushOldAlertsFromInternalStorage(Context context) {
if (BYPASS_DB) {
SharedPreferences prefs = getFiredAlertsTable(context);
// Only flush if it hasn't been done in a while.
long nowTime = System.currentTimeMillis();
long lastFlushTimeMs = prefs.getLong(KEY_LAST_FLUSH_TIME_MS, 0);
if (nowTime - lastFlushTimeMs > FLUSH_INTERVAL_MS) {
if (DEBUG) {
Log.d(TAG, "Flushing old alerts from shared prefs table");
}
// Scan through all fired alert entries, removing old ones.
SharedPreferences.Editor editor = prefs.edit();
Time timeObj = new Time();
for (Map.Entry<String, ?> entry : prefs.getAll().entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.startsWith(KEY_FIRED_ALERT_PREFIX)) {
long alertTime;
if (value instanceof Long) {
alertTime = (Long) value;
} else {
// Should never occur.
Log.e(TAG, "SharedPrefs key " + key + " did not have Long value: " + value);
continue;
}
if (nowTime - alertTime >= FLUSH_INTERVAL_MS) {
editor.remove(key);
if (DEBUG) {
int ageInDays = getIntervalInDays(alertTime, nowTime, timeObj);
Log.d(TAG, "SharedPrefs key " + key + ": removed (" + ageInDays + " days old)");
}
} else {
if (DEBUG) {
int ageInDays = getIntervalInDays(alertTime, nowTime, timeObj);
Log.d(TAG, "SharedPrefs key " + key + ": keep (" + ageInDays + " days old)");
}
}
}
}
editor.putLong(KEY_LAST_FLUSH_TIME_MS, nowTime);
editor.apply();
}
}
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class AlertUtils method formatTimeLocation.
/**
* Format the second line which shows time and location for single alert or the
* number of events for multiple alerts
* 1) Show time only for non-all day events
* 2) No date for today
* 3) Show "tomorrow" for tomorrow
* 4) Show date for days beyond that
*/
static String formatTimeLocation(Context context, long startMillis, boolean allDay, String location) {
String tz = Utils.getTimeZone(context, null);
Time time = new Time(tz);
time.set(System.currentTimeMillis());
int today = Time.getJulianDay(time.toMillis(), time.getGmtOffset());
time.set(startMillis);
int eventDay = Time.getJulianDay(time.toMillis(), allDay ? 0 : time.getGmtOffset());
int flags = DateUtils.FORMAT_ABBREV_ALL;
if (!allDay) {
flags |= DateUtils.FORMAT_SHOW_TIME;
if (DateFormat.is24HourFormat(context)) {
flags |= DateUtils.FORMAT_24HOUR;
}
} else {
flags |= DateUtils.FORMAT_UTC;
}
if (eventDay < today || eventDay > today + 1) {
flags |= DateUtils.FORMAT_SHOW_DATE;
}
StringBuilder sb = new StringBuilder(Utils.formatDateRange(context, startMillis, startMillis, flags));
if (!allDay && tz != Utils.getCurrentTimezone()) {
// Assumes time was set to the current tz
time.set(startMillis);
sb.append(" ").append(TimeZone.getTimeZone(tz).getDisplayName(false, TimeZone.SHORT, Locale.getDefault()));
}
if (eventDay == today + 1) {
// Tomorrow
sb.append(", ");
sb.append(context.getString(R.string.tomorrow));
}
String loc;
if (location != null && !TextUtils.isEmpty(loc = location.trim())) {
sb.append(", ");
sb.append(loc);
}
return sb.toString();
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class AlertService method getNextRefreshTime.
private static long getNextRefreshTime(NotificationInfo info, long currentTime) {
long startAdjustedForAllDay = info.startMillis;
long endAdjustedForAllDay = info.endMillis;
if (info.allDay) {
Time t = new Time();
startAdjustedForAllDay = Utils.convertAlldayUtcToLocal(t, info.startMillis, Utils.getCurrentTimezone());
endAdjustedForAllDay = Utils.convertAlldayUtcToLocal(t, info.startMillis, Utils.getCurrentTimezone());
}
// We change an event's priority bucket at 15 minutes into the event or 1/4 event duration.
long nextRefreshTime = Long.MAX_VALUE;
long gracePeriodCutoff = startAdjustedForAllDay + getGracePeriodMs(startAdjustedForAllDay, endAdjustedForAllDay, info.allDay);
if (gracePeriodCutoff > currentTime) {
nextRefreshTime = Math.min(nextRefreshTime, gracePeriodCutoff);
}
// ... and at the end (so expiring ones drop into a digest).
if (endAdjustedForAllDay > currentTime && endAdjustedForAllDay > gracePeriodCutoff) {
nextRefreshTime = Math.min(nextRefreshTime, endAdjustedForAllDay);
}
return nextRefreshTime;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class AgendaListView method updatePastEvents.
// Go over all visible views and checks if all past events are grayed out.
// Returns true is there is at least one event that ended and it is not
// grayed out.
private boolean updatePastEvents() {
int childCount = getChildCount();
boolean needUpdate = false;
long now = System.currentTimeMillis();
Time time = new Time(mTimeZone);
time.set(now);
int todayJulianDay = Time.getJulianDay(now, time.getGmtOffset());
// Go over views in list
for (int i = 0; i < childCount; ++i) {
View listItem = getChildAt(i);
Object o = listItem.getTag();
if (o instanceof AgendaByDayAdapter.ViewHolder) {
// day view - check if day in the past and not grayed yet
AgendaByDayAdapter.ViewHolder holder = (AgendaByDayAdapter.ViewHolder) o;
if (holder.julianDay <= todayJulianDay && !holder.grayed) {
needUpdate = true;
break;
}
} else if (o instanceof AgendaAdapter.ViewHolder) {
// meeting view - check if event in the past or started already and not grayed yet
// All day meetings for a day are grayed out
AgendaAdapter.ViewHolder holder = (AgendaAdapter.ViewHolder) o;
if (!holder.grayed && ((!holder.allDay && holder.startTimeMilli <= now) || (holder.allDay && holder.julianDay <= todayJulianDay))) {
needUpdate = true;
break;
}
}
}
return needUpdate;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class AgendaListView method initView.
private void initView(Context context) {
mContext = context;
mTimeZone = Utils.getTimeZone(context, mTZUpdater);
mTime = new Time(mTimeZone);
setOnItemClickListener(this);
setVerticalScrollBarEnabled(false);
mWindowAdapter = new AgendaWindowAdapter(context, this, Utils.getConfigBool(context, R.bool.show_event_details_with_agenda));
mWindowAdapter.setSelectedInstanceId(-1);
setAdapter(mWindowAdapter);
setCacheColorHint(context.getResources().getColor(R.color.agenda_item_not_selected));
mDeleteEventHelper = new DeleteEventHelper(context, null, false);
mShowEventDetailsWithAgenda = Utils.getConfigBool(mContext, R.bool.show_event_details_with_agenda);
// Hide ListView dividers, they are done in the item views themselves
setDivider(null);
setDividerHeight(0);
mHandler = new Handler();
}
Aggregations