use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.
the class AllInOneActivity method onCreate.
@Override
protected void onCreate(Bundle icicle) {
setTheme(R.style.CalendarTheme_WithActionBarWallpaper);
super.onCreate(icicle);
dynamicTheme.onCreate(this);
// This needs to be created before setContentView
mController = CalendarController.getInstance(this);
// Create notification channel
AlertService.createChannels(this);
// Check and ask for most needed permissions
checkAppPermissions();
// Get time from intent or icicle
long timeMillis = -1;
int viewType = -1;
final Intent intent = getIntent();
if (icicle != null) {
timeMillis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
viewType = icicle.getInt(BUNDLE_KEY_RESTORE_VIEW, -1);
} else {
String action = intent.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
// Open EventInfo later
timeMillis = parseViewAction(intent);
}
if (timeMillis == -1) {
timeMillis = Utils.timeFromIntentInMillis(intent);
}
}
if (viewType == -1 || viewType > ViewType.MAX_VALUE) {
viewType = Utils.getViewTypeFromIntentAndSharedPref(this);
}
mTimeZone = Utils.getTimeZone(this, mHomeTimeUpdater);
Time t = new Time(mTimeZone);
t.set(timeMillis);
if (DEBUG) {
if (icicle != null && intent != null) {
Log.d(TAG, "both, icicle:" + icicle.toString() + " intent:" + intent.toString());
} else {
Log.d(TAG, "not both, icicle:" + icicle + " intent:" + intent);
}
}
Resources res = getResources();
mHideString = res.getString(R.string.hide_controls);
mShowString = res.getString(R.string.show_controls);
mOrientation = res.getConfiguration().orientation;
if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
mControlsAnimateWidth = (int) res.getDimension(R.dimen.calendar_controls_width);
if (mControlsParams == null) {
mControlsParams = new LayoutParams(mControlsAnimateWidth, 0);
}
mControlsParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
} else {
// Make sure width is in between allowed min and max width values
mControlsAnimateWidth = Math.max(res.getDisplayMetrics().widthPixels * 45 / 100, (int) res.getDimension(R.dimen.min_portrait_calendar_controls_width));
mControlsAnimateWidth = Math.min(mControlsAnimateWidth, (int) res.getDimension(R.dimen.max_portrait_calendar_controls_width));
}
mControlsAnimateHeight = (int) res.getDimension(R.dimen.calendar_controls_height);
mHideControls = !Utils.getSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, true);
mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config);
mShowAgendaWithMonth = Utils.getConfigBool(this, R.bool.show_agenda_with_month);
mShowCalendarControls = Utils.getConfigBool(this, R.bool.show_calendar_controls);
mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);
mShowEventInfoFullScreenAgenda = Utils.getConfigBool(this, R.bool.agenda_show_event_info_full_screen);
mShowEventInfoFullScreen = Utils.getConfigBool(this, R.bool.show_event_info_full_screen);
mCalendarControlsAnimationTime = res.getInteger(R.integer.calendar_controls_animation_time);
Utils.setAllowWeekForDetailView(mIsMultipane);
// setContentView must be called before configureActionBar
setContentView(R.layout.all_in_one_material);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
mFab = (FloatingActionButton) findViewById(R.id.floating_action_button);
if (mIsTabletConfig) {
mDateRange = (TextView) findViewById(R.id.date_bar);
mWeekTextView = (TextView) findViewById(R.id.week_num);
} else {
mDateRange = (TextView) getLayoutInflater().inflate(R.layout.date_range_title, null);
}
setupToolbar(viewType);
setupNavDrawer();
setupFloatingActionButton();
mHomeTime = (TextView) findViewById(R.id.home_time);
mMiniMonth = findViewById(R.id.mini_month);
if (mIsTabletConfig && mOrientation == Configuration.ORIENTATION_PORTRAIT) {
mMiniMonth.setLayoutParams(new RelativeLayout.LayoutParams(mControlsAnimateWidth, mControlsAnimateHeight));
}
mCalendarsList = findViewById(R.id.calendar_list);
mMiniMonthContainer = findViewById(R.id.mini_month_container);
mSecondaryPane = findViewById(R.id.secondary_pane);
// Must register as the first activity because this activity can modify
// the list of event handlers in it's handle method. This affects who
// the rest of the handlers the controller dispatches to are.
mController.registerFirstEventHandler(HANDLER_KEY, this);
initFragments(timeMillis, viewType, icicle);
// Listen for changes that would require this to be refreshed
SharedPreferences prefs = GeneralPreferences.Companion.getSharedPreferences(this);
prefs.registerOnSharedPreferenceChangeListener(this);
mContentResolver = getContentResolver();
}
use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.
the class DeleteEventHelper method deleteRepeatingEvent.
private void deleteRepeatingEvent(int which) {
String rRule = mModel.mRrule;
boolean allDay = mModel.mAllDay;
long dtstart = mModel.mStart;
// mCursor.getInt(mEventIndexId);
long id = mModel.mId;
// See mDeleteNormalDialogListener for more info on this
boolean isLocal = mModel.mSyncAccountType.equals(CalendarContract.ACCOUNT_TYPE_LOCAL);
Uri deleteContentUri = isLocal ? CalendarRepository.asLocalCalendarSyncAdapter(mModel.mSyncAccountName, Events.CONTENT_URI) : Events.CONTENT_URI;
switch(which) {
case DELETE_SELECTED:
{
// the start time of the recurrence.
if (dtstart == mStartMillis) {
// TODO
}
// Create a recurrence exception by creating a new event
// with the status "cancelled".
ContentValues values = new ContentValues();
// The title might not be necessary, but it makes it easier
// to find this entry in the database when there is a problem.
String title = mModel.mTitle;
values.put(Events.TITLE, title);
String timezone = mModel.mTimezone;
long calendarId = mModel.mCalendarId;
values.put(Events.EVENT_TIMEZONE, timezone);
values.put(Events.ALL_DAY, allDay ? 1 : 0);
values.put(Events.ORIGINAL_ALL_DAY, allDay ? 1 : 0);
values.put(Events.CALENDAR_ID, calendarId);
values.put(Events.DTSTART, mStartMillis);
values.put(Events.DTEND, mEndMillis);
values.put(Events.ORIGINAL_SYNC_ID, mSyncId);
values.put(Events.ORIGINAL_ID, id);
values.put(Events.ORIGINAL_INSTANCE_TIME, mStartMillis);
values.put(Events.STATUS, Events.STATUS_CANCELED);
mService.startInsert(mService.getNextToken(), null, Events.CONTENT_URI, values, Utils.UNDO_DELAY);
break;
}
case DELETE_ALL:
{
Uri uri = ContentUris.withAppendedId(deleteContentUri, id);
mService.startDelete(mService.getNextToken(), null, uri, null, null, Utils.UNDO_DELAY);
break;
}
case DELETE_ALL_FOLLOWING:
{
// following events, then delete them all.
if (dtstart == mStartMillis) {
Uri uri = ContentUris.withAppendedId(deleteContentUri, id);
mService.startDelete(mService.getNextToken(), null, uri, null, null, Utils.UNDO_DELAY);
break;
}
// Modify the repeating event to end just before this event time
EventRecurrence eventRecurrence = new EventRecurrence();
eventRecurrence.parse(rRule);
Time date = new Time();
if (allDay) {
date.setTimezone(Time.TIMEZONE_UTC);
}
date.set(mStartMillis);
date.setSecond(date.getSecond() - 1);
date.normalize();
// Google calendar seems to require the UNTIL string to be
// in UTC.
date.switchTimezone(Time.TIMEZONE_UTC);
eventRecurrence.until = date.format2445();
ContentValues values = new ContentValues();
values.put(Events.DTSTART, dtstart);
values.put(Events.RRULE, eventRecurrence.toString());
Uri uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, id);
mService.startUpdate(mService.getNextToken(), null, uri, values, null, null, Utils.UNDO_DELAY);
break;
}
}
if (mCallback != null) {
mCallback.run();
}
if (mExitWhenDone) {
mParent.finish();
}
}
use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.
the class CalendarToolbarHandler method buildWeekDate.
private String buildWeekDate() {
// Calculate the start of the week, taking into account the "first day of the week"
// setting.
Time t = new Time(mTimeZone);
t.set(mMilliTime);
int firstDayOfWeek = Utils.getFirstDayOfWeek(mContext);
int dayOfWeek = t.getWeekDay();
int diff = dayOfWeek - firstDayOfWeek;
if (diff != 0) {
if (diff < 0) {
diff += 7;
}
t.setDay(t.getDay() - diff);
t.normalize();
}
long weekStartTime = t.toMillis();
// The end of the week is 6 days after the start of the week
long weekEndTime = weekStartTime + DateUtils.WEEK_IN_MILLIS - DateUtils.DAY_IN_MILLIS;
// If week start and end is in 2 different months, use short months names
Time t1 = new Time(mTimeZone);
t.set(weekEndTime);
int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
if (t.getMonth() != t1.getMonth()) {
flags |= DateUtils.FORMAT_ABBREV_MONTH;
}
mStringBuilder.setLength(0);
String date = DateUtils.formatDateRange(mContext, mFormatter, weekStartTime, weekEndTime, flags, mTimeZone).toString();
return date;
}
use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.
the class CalendarToolbarHandler method buildDayOfWeek.
// Builds a string with the day of the week and the word yesterday/today/tomorrow
// before it if applicable.
private String buildDayOfWeek() {
Time t = new Time(mTimeZone);
t.set(mMilliTime);
long julianDay = Time.getJulianDay(mMilliTime, t.getGmtOffset());
String dayOfWeek;
mStringBuilder.setLength(0);
if (julianDay == mTodayJulianDay) {
dayOfWeek = mContext.getString(R.string.agenda_today, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else if (julianDay == mTodayJulianDay - 1) {
dayOfWeek = mContext.getString(R.string.agenda_yesterday, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else if (julianDay == mTodayJulianDay + 1) {
dayOfWeek = mContext.getString(R.string.agenda_tomorrow, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else {
dayOfWeek = DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString();
}
return dayOfWeek;
}
use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.
the class CalendarViewAdapter method buildDayOfWeek.
// Builds a string with the day of the week and the word yesterday/today/tomorrow
// before it if applicable.
private String buildDayOfWeek() {
Time t = new Time(mTimeZone);
t.set(mMilliTime);
long julianDay = Time.getJulianDay(mMilliTime, t.getGmtOffset());
String dayOfWeek = null;
mStringBuilder.setLength(0);
if (julianDay == mTodayJulianDay) {
dayOfWeek = mContext.getString(R.string.agenda_today, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else if (julianDay == mTodayJulianDay - 1) {
dayOfWeek = mContext.getString(R.string.agenda_yesterday, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else if (julianDay == mTodayJulianDay + 1) {
dayOfWeek = mContext.getString(R.string.agenda_tomorrow, DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString());
} else {
dayOfWeek = DateUtils.formatDateRange(mContext, mFormatter, mMilliTime, mMilliTime, DateUtils.FORMAT_SHOW_WEEKDAY, mTimeZone).toString();
}
return dayOfWeek.toUpperCase();
}
Aggregations