Search in sources :

Example 16 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 CalendarViewAdapter 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);
    t1.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;
}
Also used : Time(com.android.calendarcommon2.Time)

Example 17 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 SimpleWeekView method setWeekParams.

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 * @param tz The time zone this view should reference times in
 */
public void setWeekParams(HashMap<String, Integer> params, String tz) {
    if (!params.containsKey(VIEW_PARAMS_WEEK)) {
        throw new InvalidParameterException("You must specify the week number for this view");
    }
    setTag(params);
    mTimeZone = tz;
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mHeight < MIN_HEIGHT) {
            mHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }
    mHasSelectedDay = mSelectedDay != -1;
    if (params.containsKey(VIEW_PARAMS_NUM_DAYS)) {
        mNumDays = params.get(VIEW_PARAMS_NUM_DAYS);
    }
    if (params.containsKey(VIEW_PARAMS_SHOW_WK_NUM)) {
        if (params.get(VIEW_PARAMS_SHOW_WK_NUM) != 0) {
            mShowWeekNum = true;
        } else {
            mShowWeekNum = false;
        }
    }
    mNumCells = mShowWeekNum ? mNumDays + 1 : mNumDays;
    // Allocate space for caching the day numbers and focus values
    mDayNumbers = new String[mNumCells];
    mFocusDay = new boolean[mNumCells];
    mOddMonth = new boolean[mNumCells];
    mWeek = params.get(VIEW_PARAMS_WEEK);
    int julianMonday = Utils.getJulianMondayFromWeeksSinceEpoch(mWeek);
    Time time = new Time(tz);
    time.setJulianDay(julianMonday);
    // If we're showing the week number calculate it based on Monday
    int i = 0;
    if (mShowWeekNum) {
        mDayNumbers[0] = NumberFormat.getInstance().format(time.getWeekNumber());
        i++;
    }
    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    }
    // Dec 27th 1969 -Jan 2nd, 1970
    if (time.getWeekDay() != mWeekStart) {
        int diff = time.getWeekDay() - mWeekStart;
        if (diff < 0) {
            diff += 7;
        }
        time.setDay(time.getDay() - diff);
        time.normalize();
    }
    mFirstJulianDay = Time.getJulianDay(time.toMillis(), time.getGmtOffset());
    mFirstMonth = time.getMonth();
    // Figure out what day today is
    Time today = new Time(tz);
    today.set(System.currentTimeMillis());
    mHasToday = false;
    mToday = -1;
    int focusMonth = params.containsKey(VIEW_PARAMS_FOCUS_MONTH) ? params.get(VIEW_PARAMS_FOCUS_MONTH) : DEFAULT_FOCUS_MONTH;
    for (; i < mNumCells; i++) {
        if (time.getDay() == 1) {
            mFirstMonth = time.getMonth();
        }
        mOddMonth[i] = (time.getMonth() % 2) == 1;
        if (time.getMonth() == focusMonth) {
            mFocusDay[i] = true;
        } else {
            mFocusDay[i] = false;
        }
        if (time.getYear() == today.getYear() && time.getYearDay() == today.getYearDay()) {
            mHasToday = true;
            mToday = i;
        }
        mDayNumbers[i] = NumberFormat.getInstance().format(time.getDay());
        time.setDay(time.getDay() + 1);
        time.normalize();
    }
    // new month undo it
    if (time.getDay() == 1) {
        time.setDay(time.getDay() - 1);
        time.normalize();
    }
    mLastMonth = time.getMonth();
    updateSelectionPositions();
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Time(com.android.calendarcommon2.Time) Paint(android.graphics.Paint)

Example 18 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 SimpleWeekView method onHoverEvent.

@Override
public boolean onHoverEvent(MotionEvent event) {
    Context context = getContext();
    // only send accessibility events if accessibility and exploration are
    // on.
    AccessibilityManager am = (AccessibilityManager) context.getSystemService(Service.ACCESSIBILITY_SERVICE);
    if (!am.isEnabled() || !am.isTouchExplorationEnabled()) {
        return super.onHoverEvent(event);
    }
    if (event.getAction() != MotionEvent.ACTION_HOVER_EXIT) {
        Time hover = getDayFromLocation(event.getX());
        if (hover != null && (mLastHoverTime == null || hover.compareTo(mLastHoverTime) != 0)) {
            Long millis = hover.toMillis();
            String date = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE);
            AccessibilityEvent accessEvent = AccessibilityEvent.obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
            accessEvent.getText().add(date);
            sendAccessibilityEventUnchecked(accessEvent);
            mLastHoverTime = hover;
        }
    }
    return true;
}
Also used : Context(android.content.Context) AccessibilityManager(android.view.accessibility.AccessibilityManager) Time(com.android.calendarcommon2.Time) AccessibilityEvent(android.view.accessibility.AccessibilityEvent)

Example 19 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 SimpleWeekView method getDayFromLocation.

/**
 * Calculates the day that the given x position is in, accounting for week
 * number. Returns a Time referencing that day or null if
 *
 * @param x The x position of the touch event
 * @return A time object for the tapped day or null if the position wasn't
 *         in a day
 */
public Time getDayFromLocation(float x) {
    int dayStart = mPadding;
    if (x < dayStart || x > mWidth - mPadding) {
        return null;
    }
    // Selection is (x - start) / (pixels/day) == (x -s) * day / pixels
    int dayPosition = (int) ((x - dayStart) * mNumDays / (mWidth - dayStart - mPadding));
    int day = mFirstJulianDay + dayPosition;
    Time time = new Time(mTimeZone);
    if (mWeek == 0) {
        // This week is weird...
        if (day < Utils.EPOCH_JULIAN_DAY) {
            day++;
        } else if (day == Utils.EPOCH_JULIAN_DAY) {
            time.set(1, 0, 1970);
            time.normalize();
            return time;
        }
    }
    time.setJulianDay(day);
    return time;
}
Also used : Time(com.android.calendarcommon2.Time) Paint(android.graphics.Paint)

Example 20 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 MonthByWeekAdapter method setDayParameters.

private void setDayParameters(Time day) {
    day.setTimezone(mHomeTimeZone);
    Time currTime = new Time(mHomeTimeZone);
    currTime.set(mController.getTime());
    day.setHour(currTime.getHour());
    day.setMinute(currTime.getMinute());
    day.setAllDay(false);
    day.normalize();
}
Also used : 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