Search in sources :

Example 6 with Time

use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.

the class DayView method switchViews.

private View switchViews(boolean forward, float xOffSet, float width, float velocity) {
    mAnimationDistance = width - xOffSet;
    if (DEBUG) {
        Log.d(TAG, "switchViews(" + forward + ") O:" + xOffSet + " Dist:" + mAnimationDistance);
    }
    float progress = Math.abs(xOffSet) / width;
    if (progress > 1.0f) {
        progress = 1.0f;
    }
    float inFromXValue, inToXValue;
    float outFromXValue, outToXValue;
    if (forward) {
        inFromXValue = 1.0f - progress;
        inToXValue = 0.0f;
        outFromXValue = -progress;
        outToXValue = -1.0f;
    } else {
        inFromXValue = progress - 1.0f;
        inToXValue = 0.0f;
        outFromXValue = progress;
        outToXValue = 1.0f;
    }
    final Time start = new Time(mBaseDate.getTimezone());
    start.set(mController.getTime());
    if (forward) {
        start.setDay(start.getDay() + mNumDays);
    } else {
        start.setDay(start.getDay() - mNumDays);
    }
    mController.setTime(start.normalize());
    Time newSelected = start;
    if (mNumDays == 7) {
        newSelected = new Time();
        newSelected.set(start);
        adjustToBeginningOfWeek(start);
    }
    final Time end = new Time();
    end.set(start);
    end.setDay(end.getDay() + mNumDays - 1);
    // We have to allocate these animation objects each time we switch views
    // because that is the only way to set the animation parameters.
    TranslateAnimation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, inFromXValue, Animation.RELATIVE_TO_SELF, inToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
    TranslateAnimation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, outFromXValue, Animation.RELATIVE_TO_SELF, outToXValue, Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f);
    long duration = calculateDuration(width - Math.abs(xOffSet), width, velocity);
    inAnimation.setDuration(duration);
    inAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setInterpolator(mHScrollInterpolator);
    outAnimation.setDuration(duration);
    outAnimation.setAnimationListener(new GotoBroadcaster(start, end));
    mViewSwitcher.setInAnimation(inAnimation);
    mViewSwitcher.setOutAnimation(outAnimation);
    DayView view = (DayView) mViewSwitcher.getCurrentView();
    view.cleanup();
    mViewSwitcher.showNext();
    view = (DayView) mViewSwitcher.getCurrentView();
    view.setSelected(newSelected, true, false);
    view.requestFocus();
    view.reloadEvents();
    view.updateTitle();
    view.restartCurrentTimeUpdates();
    return view;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Time(com.android.calendarcommon2.Time)

Example 7 with Time

use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.

the class DayView method init.

private void init(Context context) {
    setFocusable(true);
    // Allow focus in touch mode so that we can do keyboard shortcuts
    // even after we've entered touch mode.
    setFocusableInTouchMode(true);
    setClickable(true);
    setOnCreateContextMenuListener(this);
    mFirstDayOfWeek = Utils.getFirstDayOfWeek(context);
    mCurrentTime = new Time(Utils.getTimeZone(context, mTZUpdater));
    long currentTime = System.currentTimeMillis();
    mCurrentTime.set(currentTime);
    mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.getGmtOffset());
    mWeek_todayColor = DynamicTheme.getColor(mContext, "week_today");
    mWeek_saturdayColor = DynamicTheme.getColor(mContext, "week_saturday");
    mWeek_sundayColor = DynamicTheme.getColor(mContext, "week_sunday");
    mCalendarDateBannerTextColor = DynamicTheme.getColor(mContext, "calendar_date_banner_text_color");
    mFutureBgColorRes = DynamicTheme.getColor(mContext, "calendar_future_bg_color");
    mBgColor = DynamicTheme.getColor(mContext, "calendar_hour_background");
    mCalendarHourLabelColor = DynamicTheme.getColor(mContext, "calendar_hour_label");
    mCalendarGridAreaSelected = DynamicTheme.getColor(mContext, "calendar_grid_area_selected");
    mCalendarGridLineInnerHorizontalColor = DynamicTheme.getColor(mContext, "calendar_grid_line_inner_horizontal_color");
    mCalendarGridLineInnerVerticalColor = DynamicTheme.getColor(mContext, "calendar_grid_line_inner_vertical_color");
    mPressedColor = DynamicTheme.getColor(mContext, "pressed");
    mClickedColor = DynamicTheme.getColor(mContext, "day_event_clicked_background_color");
    mEventTextColor = DynamicTheme.getColor(mContext, "calendar_event_text_color");
    mMoreEventsTextColor = DynamicTheme.getColor(mContext, "month_event_other_color");
    int gridLineColor = mResources.getColor(R.color.calendar_grid_line_highlight_color);
    Paint p = mSelectionPaint;
    p.setColor(gridLineColor);
    p.setStyle(Style.FILL);
    p.setAntiAlias(false);
    p = mPaint;
    p.setAntiAlias(true);
    // Allocate space for 2 weeks worth of weekday names so that we can
    // easily start the week display at any week day.
    mDayStrs = new String[14];
    // Also create an array of 2-letter abbreviations.
    mDayStrs2Letter = new String[14];
    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        int index = i - Calendar.SUNDAY;
        // e.g. Tue for Tuesday
        mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM);
        mDayStrs[index + 7] = mDayStrs[index];
        // e.g. Tu for Tuesday
        mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT);
        // If we don't have 2-letter day strings, fall back to 1-letter.
        if (mDayStrs2Letter[index].equals(mDayStrs[index])) {
            mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST);
        }
        mDayStrs2Letter[index + 7] = mDayStrs2Letter[index];
    }
    // Figure out how much space we need for the 3-letter abbrev names
    // in the worst case.
    p.setTextSize(DATE_HEADER_FONT_SIZE);
    p.setTypeface(mBold);
    String[] dateStrs = { " 28", " 30" };
    mDateStrWidth = computeMaxStringWidth(0, dateStrs, p);
    p.setTextSize(DAY_HEADER_FONT_SIZE);
    mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p);
    p.setTextSize(HOURS_TEXT_SIZE);
    p.setTypeface(null);
    handleOnResume();
    String[] timeStrs = { "12 AM", "12 PM", "22:00" };
    p.setTextSize(HOURS_TEXT_SIZE);
    mHoursWidth = HOURS_MARGIN + computeMaxStringWidth(mHoursWidth, timeStrs, p);
    GRID_LINE_LEFT_MARGIN = mHoursWidth;
    LayoutInflater inflater;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mPopupView = inflater.inflate(R.layout.bubble_event, null);
    mPopupView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    mPopup = new PopupWindow(context);
    mPopup.setContentView(mPopupView);
    Resources.Theme dialogTheme = getResources().newTheme();
    dialogTheme.applyStyle(android.R.style.Theme_Dialog, true);
    TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });
    mPopup.setBackgroundDrawable(ta.getDrawable(0));
    ta.recycle();
    // Enable touching the popup window
    mPopupView.setOnClickListener(this);
    // Catch long clicks for creating a new event
    setOnLongClickListener(this);
    mBaseDate = new Time(Utils.getTimeZone(context, mTZUpdater));
    long millis = System.currentTimeMillis();
    mBaseDate.set(millis);
    mEarliestStartHour = new int[mNumDays];
    mHasAllDayEvent = new boolean[mNumDays];
    // mLines is the array of points used with Canvas.drawLines() in
    // drawGridBackground() and drawAllDayEvents().  Its size depends
    // on the max number of lines that can ever be drawn by any single
    // drawLines() call in either of those methods.
    final int maxGridLines = // max horizontal lines we might draw
    (24 + 1) + // max vertical lines we might draw
    (mNumDays + 1);
    mLines = new float[maxGridLines * 4];
}
Also used : ViewGroup(android.view.ViewGroup) PopupWindow(android.widget.PopupWindow) Time(com.android.calendarcommon2.Time) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) LayoutInflater(android.view.LayoutInflater) TypedArray(android.content.res.TypedArray) Resources(android.content.res.Resources)

Example 8 with Time

use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.

the class DayView method getSelectedTimeForAccessibility.

Time getSelectedTimeForAccessibility() {
    Time time = new Time();
    time.set(mBaseDate);
    time.setJulianDay(mSelectionDayForAccessibility);
    time.setHour(mSelectionHourForAccessibility);
    time.normalize();
    return time;
}
Also used : Time(com.android.calendarcommon2.Time)

Example 9 with Time

use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.

the class CalendarController method sendEventRelatedEventWithExtraWithTitleWithCalendarId.

/**
 * Helper for sending New/View/Edit/Delete events
 *
 * @param sender object of the caller
 * @param eventType one of {@link EventType}
 * @param eventId event id
 * @param startMillis start time
 * @param endMillis end time
 * @param x x coordinate in the activity space
 * @param y y coordinate in the activity space
 * @param extraLong default response value for the "simple event view" and all day indication.
 *        Use Attendees.ATTENDEE_STATUS_NONE for no response.
 * @param selectedMillis The time to specify as selected
 * @param title The title of the event
 * @param calendarId The id of the calendar which the event belongs to
 */
public void sendEventRelatedEventWithExtraWithTitleWithCalendarId(Object sender, long eventType, long eventId, long startMillis, long endMillis, int x, int y, long extraLong, long selectedMillis, String title, long calendarId) {
    EventInfo info = new EventInfo();
    info.eventType = eventType;
    if (eventType == EventType.EDIT_EVENT || eventType == EventType.VIEW_EVENT_DETAILS) {
        info.viewType = ViewType.CURRENT;
    }
    info.id = eventId;
    info.startTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
    info.startTime.set(startMillis);
    if (selectedMillis != -1) {
        info.selectedTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
        info.selectedTime.set(selectedMillis);
    } else {
        info.selectedTime = info.startTime;
    }
    info.endTime = new Time(Utils.getTimeZone(mContext, mUpdateTimezone));
    info.endTime.set(endMillis);
    info.x = x;
    info.y = y;
    info.extraLong = extraLong;
    info.eventTitle = title;
    info.calendarId = calendarId;
    this.sendEvent(sender, info);
}
Also used : Time(com.android.calendarcommon2.Time)

Example 10 with Time

use of dev.hawala.xns.level4.common.Time2.Time in project android_packages_apps_Etar by LineageOS.

the class DayView method initNextView.

private boolean initNextView(int deltaX) {
    // Change the view to the previous day or week
    DayView view = (DayView) mViewSwitcher.getNextView();
    Time date = view.mBaseDate;
    date.set(mBaseDate);
    boolean switchForward;
    if (deltaX > 0) {
        date.setDay(date.getDay() - mNumDays);
        view.setSelectedDay(mSelectionDay - mNumDays);
        switchForward = false;
    } else {
        date.setDay(date.getDay() + mNumDays);
        view.setSelectedDay(mSelectionDay + mNumDays);
        switchForward = true;
    }
    date.normalize();
    initView(view);
    view.layout(getLeft(), getTop(), getRight(), getBottom());
    view.reloadEvents();
    return switchForward;
}
Also used : Time(com.android.calendarcommon2.Time)

Aggregations

Time (com.android.calendarcommon2.Time)178 Paint (android.graphics.Paint)20 ArrayList (java.util.ArrayList)16 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 IOException (java.io.IOException)6