Search in sources :

Example 21 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 RecurrencePickerDialog method onDateSet.

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    if (mModel.endDate == null) {
        mModel.endDate = new Time(mTime.getTimezone());
        mModel.endDate.setHour(0);
        mModel.endDate.setMinute(0);
        mModel.endDate.setSecond(0);
    }
    mModel.endDate.setYear(year);
    mModel.endDate.setMonth(monthOfYear);
    mModel.endDate.setDay(dayOfMonth);
    mModel.endDate.normalize();
    updateDialog();
}
Also used : Time(com.android.calendarcommon2.Time)

Example 22 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 CalendarAppWidgetModel method buildFromCursor.

public void buildFromCursor(Cursor cursor, String timeZone) {
    final Time recycle = new Time(timeZone);
    final ArrayList<LinkedList<RowInfo>> mBuckets = new ArrayList<LinkedList<RowInfo>>(CalendarAppWidgetService.MAX_DAYS);
    for (int i = 0; i < CalendarAppWidgetService.MAX_DAYS; i++) {
        mBuckets.add(new LinkedList<RowInfo>());
    }
    recycle.set(System.currentTimeMillis());
    mShowTZ = !TextUtils.equals(timeZone, Utils.getCurrentTimezone());
    if (mShowTZ) {
        mHomeTZName = TimeZone.getTimeZone(timeZone).getDisplayName(false, TimeZone.SHORT);
    }
    cursor.moveToPosition(-1);
    String tz = Utils.getTimeZone(mContext, null);
    while (cursor.moveToNext()) {
        final int rowId = cursor.getPosition();
        final long eventId = cursor.getLong(CalendarAppWidgetService.INDEX_EVENT_ID);
        final boolean allDay = cursor.getInt(CalendarAppWidgetService.INDEX_ALL_DAY) != 0;
        long start = cursor.getLong(CalendarAppWidgetService.INDEX_BEGIN);
        long end = cursor.getLong(CalendarAppWidgetService.INDEX_END);
        final String title = cursor.getString(CalendarAppWidgetService.INDEX_TITLE);
        final String location = cursor.getString(CalendarAppWidgetService.INDEX_EVENT_LOCATION);
        // we don't compute these ourselves because it seems to produce the
        // wrong endDay for all day events
        final int startDay = cursor.getInt(CalendarAppWidgetService.INDEX_START_DAY);
        final int endDay = cursor.getInt(CalendarAppWidgetService.INDEX_END_DAY);
        final int color = cursor.getInt(CalendarAppWidgetService.INDEX_COLOR);
        final int selfStatus = cursor.getInt(CalendarAppWidgetService.INDEX_SELF_ATTENDEE_STATUS);
        // Adjust all-day times into local timezone
        if (allDay) {
            start = Utils.convertAlldayUtcToLocal(recycle, start, tz);
            end = Utils.convertAlldayUtcToLocal(recycle, end, tz);
        }
        if (LOGD) {
            Log.d(TAG, "Row #" + rowId + " allDay:" + allDay + " start:" + start + " end:" + end + " eventId:" + eventId);
        }
        // deal with all-day events
        if (end < mNow) {
            continue;
        }
        int i = mEventInfos.size();
        mEventInfos.add(populateEventInfo(eventId, allDay, start, end, startDay, endDay, title, location, color, selfStatus));
        // populate the day buckets that this event falls into
        int from = Math.max(startDay, mTodayJulianDay);
        int to = Math.min(endDay, mMaxJulianDay);
        for (int day = from; day <= to; day++) {
            LinkedList<RowInfo> bucket = mBuckets.get(day - mTodayJulianDay);
            RowInfo rowInfo = new RowInfo(RowInfo.TYPE_MEETING, i);
            if (allDay) {
                bucket.addFirst(rowInfo);
            } else {
                bucket.add(rowInfo);
            }
        }
    }
    int day = mTodayJulianDay;
    int count = 0;
    for (LinkedList<RowInfo> bucket : mBuckets) {
        if (!bucket.isEmpty()) {
            // We don't show day header in today
            if (day != mTodayJulianDay) {
                final DayInfo dayInfo = populateDayInfo(day, recycle);
                // Add the day header
                final int dayIndex = mDayInfos.size();
                mDayInfos.add(dayInfo);
                mRowInfos.add(new RowInfo(RowInfo.TYPE_DAY, dayIndex));
            }
            // Add the event row infos
            mRowInfos.addAll(bucket);
            count += bucket.size();
        }
        day++;
        if (count >= CalendarAppWidgetService.EVENT_MIN_COUNT) {
            break;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Time(com.android.calendarcommon2.Time) LinkedList(java.util.LinkedList)

Example 23 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 CalendarAppWidgetProvider method performUpdate.

/**
 * Process and push out an update for the given appWidgetIds. This call
 * actually fires an intent to start {@link CalendarAppWidgetService} as a
 * background service which handles the actual update, to prevent ANR'ing
 * during database queries.
 *
 * @param context Context to use when starting {@link CalendarAppWidgetService}.
 * @param appWidgetIds List of specific appWidgetIds to update, or null for
 *            all.
 * @param changedEventIds Specific events known to be changed. If present,
 *            we use it to decide if an update is necessary.
 */
private void performUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, long[] changedEventIds) {
    if (!isWidgetSupported(context)) {
        return;
    }
    // Launch over to service so it can perform update
    for (int appWidgetId : appWidgetIds) {
        if (LOGD)
            Log.d(TAG, "Building widget update...");
        Intent updateIntent = new Intent(context, CalendarAppWidgetService.class);
        updateIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
        if (changedEventIds != null) {
            updateIntent.putExtra(EXTRA_EVENT_IDS, changedEventIds);
        }
        updateIntent.setData(Uri.parse(updateIntent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget);
        // Calendar header
        Time time = new Time(Utils.getTimeZone(context, null));
        time.set(System.currentTimeMillis());
        long millis = time.toMillis();
        final String dayOfWeek = DateUtils.getDayOfWeekString(time.getWeekDay() + 1, DateUtils.LENGTH_MEDIUM);
        final String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR);
        views.setTextViewText(R.id.day_of_week, dayOfWeek);
        views.setTextViewText(R.id.date, date);
        // Set widget header background based on chosen primary app color
        int headerColor = DynamicTheme.getColorId(DynamicTheme.getPrimaryColor(context));
        views.setInt(R.id.header, "setBackgroundResource", headerColor);
        // Set widget background color based on chosen app theme
        int backgroundColor = DynamicTheme.getWidgetBackgroundStyle(context);
        views.setInt(R.id.widget_background, "setBackgroundResource", backgroundColor);
        // Attach to list of events
        views.setRemoteAdapter(R.id.events_list, updateIntent);
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.events_list);
        // Launch calendar app when the user taps on the header
        final Intent launchCalendarIntent = new Intent(Intent.ACTION_VIEW);
        launchCalendarIntent.setClass(context, AllInOneActivity.class);
        launchCalendarIntent.setData(Uri.parse("content://com.android.calendar/time/" + millis));
        final PendingIntent launchCalendarPendingIntent = PendingIntent.getActivity(context, 0, /* no requestCode */
        launchCalendarIntent, Utils.PI_FLAG_IMMUTABLE);
        views.setOnClickPendingIntent(R.id.header, launchCalendarPendingIntent);
        // Open Add event option when user clicks on the add button on widget
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setClass(context, EditEventActivity.class);
        intent.putExtra(EXTRA_EVENT_ALL_DAY, false);
        intent.putExtra(CalendarContract.Events.CALENDAR_ID, -1);
        final PendingIntent addEventPendingIntent = PendingIntent.getActivity(context, 0, /* no requestCode */
        intent, PI_FLAG_IMMUTABLE);
        views.setOnClickPendingIntent(R.id.iv_add, addEventPendingIntent);
        // Each list item will call setOnClickExtra() to let the list know
        // which item
        // is selected by a user.
        final PendingIntent updateEventIntent = getLaunchPendingIntentTemplate(context);
        views.setPendingIntentTemplate(R.id.events_list, updateEventIntent);
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
}
Also used : RemoteViews(android.widget.RemoteViews) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Time(com.android.calendarcommon2.Time) PendingIntent(android.app.PendingIntent)

Example 24 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 EditEventHelper method constructDefaultStartTime.

/**
 * When we aren't given an explicit start time, we default to the next
 * upcoming half hour. So, for example, 5:01 -> 5:30, 5:30 -> 6:00, etc.
 *
 * @return a UTC time in milliseconds representing the next upcoming half
 * hour
 */
protected long constructDefaultStartTime(long now) {
    Time defaultStart = new Time();
    defaultStart.set(now);
    defaultStart.setSecond(0);
    defaultStart.setMinute(30);
    long defaultStartMillis = defaultStart.toMillis();
    if (now < defaultStartMillis) {
        return defaultStartMillis;
    } else {
        return defaultStartMillis + 30 * DateUtils.MINUTE_IN_MILLIS;
    }
}
Also used : Time(com.android.calendarcommon2.Time)

Example 25 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 setTodayIcon.

/**
 * Inserts a drawable with today's day into the today's icon in the option menu
 * @param icon - today's icon from the options menu
 */
public static void setTodayIcon(LayerDrawable icon, Context c, String timezone) {
    DayOfMonthDrawable today;
    // Reuse current drawable if possible
    Drawable currentDrawable = icon.findDrawableByLayerId(R.id.today_icon_day);
    if (currentDrawable instanceof DayOfMonthDrawable) {
        today = (DayOfMonthDrawable) currentDrawable;
    } else {
        today = new DayOfMonthDrawable(c);
    }
    // Set the day and update the icon
    Time now = new Time(timezone);
    now.set(System.currentTimeMillis());
    now.normalize();
    today.setDayOfMonth(now.getDay());
    icon.mutate();
    icon.setDrawableByLayerId(R.id.today_icon_day, today);
}
Also used : Drawable(android.graphics.drawable.Drawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Time(com.android.calendarcommon2.Time)

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