Search in sources :

Example 36 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

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();
        }
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) Time(com.android.calendarcommon2.Time) Map(java.util.Map)

Example 37 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

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();
}
Also used : Time(com.android.calendarcommon2.Time)

Example 38 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

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;
}
Also used : Time(com.android.calendarcommon2.Time)

Example 39 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

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;
}
Also used : ViewHolder(com.android.calendar.agenda.AgendaAdapter.ViewHolder) ViewHolder(com.android.calendar.agenda.AgendaAdapter.ViewHolder) Time(com.android.calendarcommon2.Time) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 40 with org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time

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();
}
Also used : Handler(android.os.Handler) Time(com.android.calendarcommon2.Time) DeleteEventHelper(com.android.calendar.DeleteEventHelper)

Aggregations

Time (com.android.calendarcommon2.Time)178 Paint (android.graphics.Paint)20 ArrayList (java.util.ArrayList)15 Time (org.bouncycastle.asn1.x509.Time)15 Intent (android.content.Intent)12 Uri (android.net.Uri)12 TextPaint (android.text.TextPaint)12 TextView (android.widget.TextView)12 Resources (android.content.res.Resources)10 ContentValues (android.content.ContentValues)8 Context (android.content.Context)8 Cursor (android.database.Cursor)8 View (android.view.View)8 AccessibilityEvent (android.view.accessibility.AccessibilityEvent)8 EventRecurrence (com.android.calendarcommon2.EventRecurrence)8 DERSequence (org.bouncycastle.asn1.DERSequence)8 Date (java.util.Date)7 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)7 MotionEvent (android.view.MotionEvent)6 Calendar (java.util.Calendar)5