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();
}
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;
}
}
}
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);
}
}
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;
}
}
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);
}
Aggregations