Search in sources :

Example 26 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 Utils method convertAlldayUtcToLocal.

/**
 * Convert given UTC time into current local time. This assumes it is for an
 * allday event and will adjust the time to be on a midnight boundary.
 *
 * @param recycle Time object to recycle, otherwise null.
 * @param utcTime Time to convert, in UTC.
 * @param tz The time zone to convert this time to.
 */
public static long convertAlldayUtcToLocal(Time recycle, long utcTime, String tz) {
    if (recycle == null) {
        recycle = new Time();
    }
    recycle.setTimezone(Time.TIMEZONE_UTC);
    recycle.set(utcTime);
    recycle.setTimezone(tz);
    return recycle.normalize();
}
Also used : Time(com.android.calendarcommon2.Time)

Example 27 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 Utils method getDisplayedTimezone.

/**
 * Returns the timezone to display in the event info, if the local timezone is different
 * from the event timezone.  Otherwise returns null.
 */
public static String getDisplayedTimezone(long startMillis, String localTimezone, String eventTimezone) {
    String tzDisplay = null;
    if (!TextUtils.equals(localTimezone, eventTimezone)) {
        // Figure out if this is in DST
        TimeZone tz = TimeZone.getTimeZone(localTimezone);
        if (tz == null || tz.getID().equals("GMT")) {
            tzDisplay = localTimezone;
        } else {
            Time startTime = new Time(localTimezone);
            startTime.set(startMillis);
            tzDisplay = tz.getDisplayName(false, TimeZone.SHORT);
        }
    }
    return tzDisplay;
}
Also used : TimeZone(java.util.TimeZone) Time(com.android.calendarcommon2.Time) SpannableString(android.text.SpannableString)

Example 28 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 Utils method getWeekNumberFromTime.

/**
 * Given a context and a time in millis since unix epoch figures out the
 * correct week of the year for that time.
 *
 * @param millisSinceEpoch
 * @return
 */
public static int getWeekNumberFromTime(long millisSinceEpoch, Context context) {
    Time weekTime = new Time(getTimeZone(context, null));
    weekTime.set(millisSinceEpoch);
    weekTime.normalize();
    int firstDayOfWeek = getFirstDayOfWeek(context);
    // week
    if (weekTime.getWeekDay() == Time.SUNDAY && (firstDayOfWeek == Time.SUNDAY || firstDayOfWeek == Time.SATURDAY)) {
        weekTime.setDay(weekTime.getDay() + 1);
        weekTime.normalize();
    } else if (weekTime.getWeekDay() == Time.SATURDAY && firstDayOfWeek == Time.SATURDAY) {
        weekTime.setDay(weekTime.getDay() + 2);
        weekTime.normalize();
    }
    return weekTime.getWeekNumber();
}
Also used : Time(com.android.calendarcommon2.Time)

Example 29 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 Utils method getDisplayedDatetime.

/**
 * Returns a string description of the specified time interval.
 */
public static String getDisplayedDatetime(long startMillis, long endMillis, long currentMillis, String localTimezone, boolean allDay, Context context) {
    // Configure date/time formatting.
    int flagsDate = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
    int flagsTime = DateUtils.FORMAT_SHOW_TIME;
    if (DateFormat.is24HourFormat(context)) {
        flagsTime |= DateUtils.FORMAT_24HOUR;
    }
    Time currentTime = new Time(localTimezone);
    currentTime.set(currentMillis);
    Resources resources = context.getResources();
    String datetimeString = null;
    if (allDay) {
        // All day events require special timezone adjustment.
        long localStartMillis = convertAlldayUtcToLocal(null, startMillis, localTimezone);
        long localEndMillis = convertAlldayUtcToLocal(null, endMillis, localTimezone);
        if (singleDayEvent(localStartMillis, localEndMillis, currentTime.getGmtOffset())) {
            // If possible, use "Today" or "Tomorrow" instead of a full date string.
            int todayOrTomorrow = isTodayOrTomorrow(context.getResources(), localStartMillis, currentMillis, currentTime.getGmtOffset());
            if (TODAY == todayOrTomorrow) {
                datetimeString = resources.getString(R.string.today);
            } else if (TOMORROW == todayOrTomorrow) {
                datetimeString = resources.getString(R.string.tomorrow);
            }
        }
        if (datetimeString == null) {
            // For multi-day allday events or single-day all-day events that are not
            // today or tomorrow, use framework formatter.
            Formatter f = new Formatter(new StringBuilder(50), Locale.getDefault());
            datetimeString = DateUtils.formatDateRange(context, f, startMillis, endMillis, flagsDate, Time.TIMEZONE_UTC).toString();
        }
    } else {
        if (singleDayEvent(startMillis, endMillis, currentTime.getGmtOffset())) {
            // Format the time.
            String timeString = Utils.formatDateRange(context, startMillis, endMillis, flagsTime);
            // If possible, use "Today" or "Tomorrow" instead of a full date string.
            int todayOrTomorrow = isTodayOrTomorrow(context.getResources(), startMillis, currentMillis, currentTime.getGmtOffset());
            if (TODAY == todayOrTomorrow) {
                // Example: "Today at 1:00pm - 2:00 pm"
                datetimeString = resources.getString(R.string.today_at_time_fmt, timeString);
            } else if (TOMORROW == todayOrTomorrow) {
                // Example: "Tomorrow at 1:00pm - 2:00 pm"
                datetimeString = resources.getString(R.string.tomorrow_at_time_fmt, timeString);
            } else {
                // Format the full date. Example: "Thursday, April 12, 1:00pm - 2:00pm"
                String dateString = Utils.formatDateRange(context, startMillis, endMillis, flagsDate);
                datetimeString = resources.getString(R.string.date_time_fmt, dateString, timeString);
            }
        } else {
            // For multiday events, shorten day/month names.
            // Example format: "Fri Apr 6, 5:00pm - Sun, Apr 8, 6:00pm"
            int flagsDatetime = flagsDate | flagsTime | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_WEEKDAY;
            datetimeString = Utils.formatDateRange(context, startMillis, endMillis, flagsDatetime);
        }
    }
    return datetimeString;
}
Also used : Formatter(java.util.Formatter) Time(com.android.calendarcommon2.Time) Resources(android.content.res.Resources) SpannableString(android.text.SpannableString)

Example 30 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 EditEventActivity method getEventInfoFromIntent.

private EventInfo getEventInfoFromIntent(Bundle icicle) {
    EventInfo info = new EventInfo();
    long eventId = -1;
    Intent intent = getIntent();
    Uri data = intent.getData();
    if (data != null) {
        try {
            eventId = Long.parseLong(data.getLastPathSegment());
        } catch (NumberFormatException e) {
            if (DEBUG) {
                Log.d(TAG, "Create new event");
            }
        }
    } else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
        eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
    }
    boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false);
    long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
    long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
    if (end != -1) {
        info.endTime = new Time();
        if (allDay) {
            info.endTime.setTimezone(Time.TIMEZONE_UTC);
        }
        info.endTime.set(end);
    }
    if (begin != -1) {
        info.startTime = new Time();
        if (allDay) {
            info.startTime.setTimezone(Time.TIMEZONE_UTC);
        }
        info.startTime.set(begin);
    }
    info.id = eventId;
    info.eventTitle = intent.getStringExtra(Events.TITLE);
    info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1);
    if (allDay) {
        info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY;
    } else {
        info.extraLong = 0;
    }
    return info;
}
Also used : EventInfo(com.android.calendar.CalendarController.EventInfo) Intent(android.content.Intent) Time(com.android.calendarcommon2.Time) Uri(android.net.Uri)

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