diff options
18 files changed, 226 insertions, 226 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.kt b/src/com/android/calendar/AllInOneActivity.kt index 6c2e825f..550bc548 100644 --- a/src/com/android/calendar/AllInOneActivity.kt +++ b/src/com/android/calendar/AllInOneActivity.kt @@ -305,7 +305,7 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe res.getDimension(R.dimen.max_portrait_calendar_controls_width).toInt() ) } - mControlsAnimateHeight = res?.getDimension(R.dimen.calendar_controls_height).toInt() + mControlsAnimateHeight = res.getDimension(R.dimen.calendar_controls_height).toInt() mHideControls = true mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config) mIsTabletConfig = Utils.getConfigBool(this, R.bool.tablet_config) @@ -356,18 +356,18 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe private fun parseViewAction(intent: Intent?): Long { var timeMillis: Long = -1 val data: Uri? = intent?.getData() - if (data != null && data?.isHierarchical()) { + if (data != null && data.isHierarchical()) { val path = data.getPathSegments() - if (path?.size == 2 && path!![0].equals("events")) { + if (path?.size == 2 && path[0].equals("events")) { try { mViewEventId = data.getLastPathSegment()?.toLong() as Long if (mViewEventId != -1L) { - mIntentEventStartMillis = intent?.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0) - mIntentEventEndMillis = intent?.getLongExtra(EXTRA_EVENT_END_TIME, 0) - mIntentAttendeeResponse = intent?.getIntExtra( + mIntentEventStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0) + mIntentEventEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0) + mIntentAttendeeResponse = intent.getIntExtra( ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE ) - mIntentAllDay = intent?.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false) + mIntentAllDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false) as Boolean timeMillis = mIntentEventStartMillis } @@ -413,7 +413,7 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe } val cancelItem: MenuItem? = mOptionsMenu?.findItem(R.id.action_cancel) if (cancelItem != null) { - cancelItem?.setVisible(false) + cancelItem.setVisible(false) } } @@ -541,7 +541,7 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe val data: Uri? = intent.getData() if (data != null) { try { - eventId = data?.getLastPathSegment()?.toLong() as Long + eventId = data.getLastPathSegment()?.toLong() as Long } catch (e: NumberFormatException) { if (DEBUG) { Log.d(TAG, "Create new event") @@ -554,12 +554,12 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe val end: Long = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1) info = EventInfo() if (end != -1L) { - info?.endTime = Time() - info?.endTime?.set(end) + info.endTime = Time() + info.endTime?.set(end) } if (begin != -1L) { - info?.startTime = Time() - info?.startTime?.set(begin) + info.startTime = Time() + info.startTime?.set(begin) } info.id = eventId // We set the viewtype so if the user presses back when they are @@ -810,10 +810,10 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe if (event.eventType != EventType.UPDATE_TITLE || mActionBar == null) { return } - val start: Long? = event?.startTime?.toMillis(false /* use isDst */) + val start: Long? = event.startTime?.toMillis(false /* use isDst */) val end: Long? end = if (event.endTime != null) { - event?.endTime?.toMillis(false /* use isDst */) + event.endTime?.toMillis(false /* use isDst */) } else { start } @@ -824,8 +824,8 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe ) val oldDate: CharSequence? = mDateRange?.getText() mDateRange?.setText(msg) - updateSecondaryTitleFields(if (event?.selectedTime != null) - event?.selectedTime?.toMillis(true) as Long else start) + updateSecondaryTitleFields(if (event.selectedTime != null) + event.selectedTime?.toMillis(true) as Long else start) if (!TextUtils.equals(oldDate, msg)) { mDateRange?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) if (mShowWeekNum && mWeekTextView != null) { @@ -907,23 +907,23 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe override fun handleEvent(event: EventInfo?) { var displayTime: Long = -1 if (event?.eventType == EventType.GO_TO) { - if (event?.extraLong and CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS != 0L) { + if (event.extraLong and CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS != 0L) { mBackToPreviousView = true - } else if (event?.viewType != mController?.previousViewType && - event?.viewType != ViewType.EDIT + } else if (event.viewType != mController?.previousViewType && + event.viewType != ViewType.EDIT ) { // Clear the flag is change to a different view type mBackToPreviousView = false } setMainPane( - null, R.id.main_pane, event?.viewType, event?.startTime?.toMillis(false) + null, R.id.main_pane, event.viewType, event.startTime?.toMillis(false) as Long, false ) if (mShowCalendarControls) { val animationSize = if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) mControlsAnimateWidth else mControlsAnimateHeight - val noControlsView = event?.viewType == ViewType.MONTH + val noControlsView = event.viewType == ViewType.MONTH if (mControlsMenu != null) { mControlsMenu?.setVisible(!noControlsView) mControlsMenu?.setEnabled(!noControlsView) @@ -965,8 +965,8 @@ class AllInOneActivity : Activity(), EventHandler, OnSharedPreferenceChangeListe } } displayTime = - if (event?.selectedTime != null) event?.selectedTime?.toMillis(true) as Long - else event?.startTime?.toMillis(true) as Long + if (event.selectedTime != null) event.selectedTime?.toMillis(true) as Long + else event.startTime?.toMillis(true) as Long if (!mIsTabletConfig) { mActionBarMenuSpinnerAdapter?.setTime(displayTime) } diff --git a/src/com/android/calendar/CalendarController.kt b/src/com/android/calendar/CalendarController.kt index 16ee8fdd..41984bf7 100644 --- a/src/com/android/calendar/CalendarController.kt +++ b/src/com/android/calendar/CalendarController.kt @@ -440,7 +440,7 @@ class CalendarController private constructor(context: Context?) { // Set mTime if selectedTime is set val temp1 = event.selectedTime - if (temp1 != null && temp1?.toMillis(false) != 0L) { + if (temp1 != null && temp1.toMillis(false) != 0L) { mTime?.set(event.selectedTime) } else { if (startMillis != 0L) { @@ -450,7 +450,7 @@ class CalendarController private constructor(context: Context?) { val temp2 = event.endTime if (mtimeMillis < startMillis || temp2 != null && mtimeMillis > temp2.toMillis(false)) { - mTime?.set(event.startTime) + mTime.set(event.startTime) } } event.selectedTime = mTime diff --git a/src/com/android/calendar/CalendarViewAdapter.kt b/src/com/android/calendar/CalendarViewAdapter.kt index 2fe10272..44590b8f 100644 --- a/src/com/android/calendar/CalendarViewAdapter.kt +++ b/src/com/android/calendar/CalendarViewAdapter.kt @@ -133,7 +133,7 @@ class CalendarViewAdapter(context: Context, viewType: Int, showDate: Boolean) : v = convertView } val weekDay: TextView = v?.findViewById(R.id.top_button_weekday) as TextView - val date: TextView = v?.findViewById(R.id.top_button_date) as TextView + val date: TextView = v.findViewById(R.id.top_button_date) as TextView when (mCurrentMainView) { ViewType.DAY -> { weekDay.setVisibility(View.VISIBLE) diff --git a/src/com/android/calendar/DayFragment.kt b/src/com/android/calendar/DayFragment.kt index 39e92f5b..36413cde 100644 --- a/src/com/android/calendar/DayFragment.kt +++ b/src/com/android/calendar/DayFragment.kt @@ -154,7 +154,7 @@ class DayFragment : Fragment, CalendarController.EventHandler, ViewFactory { val diff: Int = currentView?.compareToVisibleTimeRange(goToTime as Time) as Int if (diff == 0) { // In visible range. No need to switch view - currentView?.setSelected(goToTime, ignoreTime, animateToday) + currentView.setSelected(goToTime, ignoreTime, animateToday) } else { // Figure out which way to animate if (diff > 0) { @@ -214,8 +214,8 @@ class DayFragment : Fragment, CalendarController.EventHandler, ViewFactory { // TODO support a range of time // TODO support event_id // TODO support select message - goTo(msg?.selectedTime, msg?.extraLong and CalendarController.EXTRA_GOTO_DATE != 0L, - msg?.extraLong and CalendarController.EXTRA_GOTO_TODAY != 0L) + goTo(msg.selectedTime, msg.extraLong and CalendarController.EXTRA_GOTO_DATE != 0L, + msg.extraLong and CalendarController.EXTRA_GOTO_TODAY != 0L) } else if (msg?.eventType == CalendarController.EventType.EVENTS_CHANGED) { eventsChanged() } diff --git a/src/com/android/calendar/DayView.kt b/src/com/android/calendar/DayView.kt index 42621638..84ad5833 100644 --- a/src/com/android/calendar/DayView.kt +++ b/src/com/android/calendar/DayView.kt @@ -150,7 +150,7 @@ class DayView( @Override override fun run() { if (mClickedEvent != null) { - mController?.sendEventRelatedEvent( + mController.sendEventRelatedEvent( this as Object?, EventType.VIEW_EVENT, mClickedEvent!!.id, mClickedEvent!!.startMillis, mClickedEvent!!.endMillis, this@DayView.getWidth() / 2, mClickedYLocation, @@ -835,8 +835,8 @@ class DayView( if (diff < 0) { diff += 7 } - time!!.monthDay -= diff - time?.normalize(true /* ignore isDst */) + time.monthDay -= diff + time.normalize(true /* ignore isDst */) } } @@ -1135,7 +1135,7 @@ class DayView( b.append(PERIOD_SPACE) val `when`: String? var flags: Int = DateUtils.FORMAT_SHOW_DATE - if (calEvent!!.allDay) { + if (calEvent.allDay) { flags = flags or (DateUtils.FORMAT_UTC or DateUtils.FORMAT_SHOW_WEEKDAY) } else { flags = flags or DateUtils.FORMAT_SHOW_TIME @@ -1143,7 +1143,7 @@ class DayView( flags = flags or DateUtils.FORMAT_24HOUR } } - `when` = Utils.formatDateRange(mContext, calEvent!!.startMillis, calEvent!!.endMillis, + `when` = Utils.formatDateRange(mContext, calEvent.startMillis, calEvent.endMillis, flags) b.append(`when`) b.append(PERIOD_SPACE) @@ -2058,7 +2058,7 @@ class DayView( if (i < 0 || i >= layouts!!.size) { return null } - var layout: StaticLayout? = layouts!![i] + var layout: StaticLayout? = layouts[i] // Check if we have already initialized the StaticLayout and that // the width hasn't changed (due to vertical resizing which causes // re-layout of events at min height) @@ -2117,16 +2117,16 @@ class DayView( x = mHoursWidth.toFloat() p.setStrokeWidth(GRID_LINE_INNER_WIDTH) // Line bounding the top of the all day area - mLines!![linesIndex++] = GRID_LINE_LEFT_MARGIN - mLines!![linesIndex++] = startY - mLines!![linesIndex++] = computeDayLeftPosition(mNumDays).toFloat() - mLines!![linesIndex++] = startY + mLines[linesIndex++] = GRID_LINE_LEFT_MARGIN + mLines[linesIndex++] = startY + mLines[linesIndex++] = computeDayLeftPosition(mNumDays).toFloat() + mLines[linesIndex++] = startY for (day in 0..mNumDays) { x = computeDayLeftPosition(day).toFloat() - mLines!![linesIndex++] = x - mLines!![linesIndex++] = startY - mLines!![linesIndex++] = x - mLines!![linesIndex++] = stopY + mLines[linesIndex++] = x + mLines[linesIndex++] = startY + mLines[linesIndex++] = x + mLines[linesIndex++] = stopY } p.setAntiAlias(false) canvas.drawLines(mLines, 0, linesIndex, p) @@ -2160,7 +2160,7 @@ class DayView( var alpha: Int = eventTextPaint.getAlpha() eventTextPaint.setAlpha(mEventsAlpha) for (i in 0 until numEvents) { - val event: Event = events!!.get(i) + val event: Event = events.get(i) var startDay: Int = event.startDay var endDay: Int = event.endDay if (startDay > lastDay || endDay < firstDay) { @@ -2897,15 +2897,15 @@ class DayView( } private fun cancelAnimation() { - val `in`: Animation? = mViewSwitcher?.getInAnimation() + val `in`: Animation? = mViewSwitcher.getInAnimation() if (`in` != null) { // cancel() doesn't terminate cleanly. - `in`?.scaleCurrentDuration(0f) + `in`.scaleCurrentDuration(0f) } - val out: Animation? = mViewSwitcher?.getOutAnimation() + val out: Animation? = mViewSwitcher.getOutAnimation() if (out != null) { // cancel() doesn't terminate cleanly. - out?.scaleCurrentDuration(0f) + out.scaleCurrentDuration(0f) } } @@ -3276,14 +3276,14 @@ class DayView( events = mAllDayEvents numEvents = events!!.size for (i in 0 until numEvents) { - val event: Event? = events?.get(i) + val event: Event? = events.get(i) if (!event!!.drawAsAllday() || - !mShowAllAllDayEvents && event!!.getColumn() >= maxUnexpandedColumn + !mShowAllAllDayEvents && event.getColumn() >= maxUnexpandedColumn ) { // Don't check non-allday events or events that aren't shown continue } - if (event!!.startDay <= mSelectionDay && event!!.endDay >= mSelectionDay) { + if (event.startDay <= mSelectionDay && event.endDay >= mSelectionDay) { val numRectangles = if (mShowAllAllDayEvents) mMaxAlldayEvents.toFloat() else mMaxUnexpandedAlldayEventCount.toFloat() @@ -3291,7 +3291,7 @@ class DayView( if (height > MAX_HEIGHT_OF_ONE_ALLDAY_EVENT) { height = MAX_HEIGHT_OF_ONE_ALLDAY_EVENT.toFloat() } - val eventTop: Float = yOffset + height * event?.getColumn() + val eventTop: Float = yOffset + height * event.getColumn() val eventBottom = eventTop + height if (eventTop < y && eventBottom > y) { // If the touch is inside the event rectangle, then @@ -3328,7 +3328,7 @@ class DayView( region.bottom = y + 10 val geometry: EventGeometry = mEventGeometry for (i in 0 until numEvents) { - val event: Event? = events?.get(i) + val event: Event? = events.get(i) // Compute the event rectangle. if (!geometry.computeEventRect(date, left, top, cellWidth, event as Event)) { continue @@ -3348,7 +3348,7 @@ class DayView( var closestEvent: Event? = null var minDist = (mViewWidth + mViewHeight).toFloat() // some large distance for (index in 0 until len) { - val ev: Event? = mSelectedEvents?.get(index) + val ev: Event? = mSelectedEvents.get(index) val dist: Float = geometry.pointToEvent(x.toFloat(), y.toFloat(), ev as Event) if (dist < minDist) { minDist = dist diff --git a/src/com/android/calendar/EventInfoFragment.kt b/src/com/android/calendar/EventInfoFragment.kt index fcc27fc8..139da7bb 100644 --- a/src/com/android/calendar/EventInfoFragment.kt +++ b/src/com/android/calendar/EventInfoFragment.kt @@ -353,20 +353,20 @@ class EventInfoFragment : DialogFragment, OnCheckedChangeListener, CalendarContr window?.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND) val a: WindowManager.LayoutParams? = window?.getAttributes() a!!.dimAmount = .4f - a!!.width = mDialogWidth - a!!.height = mDialogHeight + a.width = mDialogWidth + a.height = mDialogHeight // On tablets , do smart positioning of dialog // On phones , use the whole screen if (mX != -1 || mY != -1) { - a!!.x = mX - mDialogWidth / 2 - a!!.y = mY - mDialogHeight / 2 - if (a!!.y < mMinTop) { - a!!.y = mMinTop + DIALOG_TOP_MARGIN + a.x = mX - mDialogWidth / 2 + a.y = mY - mDialogHeight / 2 + if (a.y < mMinTop) { + a.y = mMinTop + DIALOG_TOP_MARGIN } - a!!.gravity = Gravity.LEFT or Gravity.TOP + a.gravity = Gravity.LEFT or Gravity.TOP } - window?.setAttributes(a) + window.setAttributes(a) } fun setDialogParams(x: Int, y: Int, minTop: Int) { @@ -637,7 +637,7 @@ class EventInfoFragment : DialogFragment, OnCheckedChangeListener, CalendarContr resources.getColor(R.color.event_info_headline_transparent_color) ) sb.setSpan( - transparentColorSpan, timezoneIndex, displayedDatetime!!.length, + transparentColorSpan, timezoneIndex, displayedDatetime.length, Spannable.SPAN_INCLUSIVE_INCLUSIVE ) setTextCommon(view, R.id.when_datetime, sb) @@ -681,7 +681,7 @@ class EventInfoFragment : DialogFragment, OnCheckedChangeListener, CalendarContr if (mResponseRadioGroup?.getVisibility() == View.VISIBLE) { val id: Int = mResponseRadioGroup!!.getCheckedRadioButtonId() if (id != View.NO_ID) { - text.add((getView()?.findViewById(R.id.response_label) as TextView)?.getText()) + text.add((getView()?.findViewById(R.id.response_label) as TextView).getText()) text.add( (mResponseRadioGroup?.findViewById(id) as RadioButton) .getText().toString() + PERIOD_SPACE diff --git a/src/com/android/calendar/EventLoader.kt b/src/com/android/calendar/EventLoader.kt index a05e8a2e..4795773a 100644 --- a/src/com/android/calendar/EventLoader.kt +++ b/src/com/android/calendar/EventLoader.kt @@ -128,7 +128,7 @@ class EventLoader(context: Context) { // Check if we are still the most recent request. if (id == eventLoader?.mSequenceNumber?.get()) { - eventLoader?.mHandler?.post(successCallback) + eventLoader.mHandler.post(successCallback) } else { eventLoader?.mHandler?.post(cancelCallback) } diff --git a/src/com/android/calendar/GeneralPreferences.kt b/src/com/android/calendar/GeneralPreferences.kt index dd4c9550..9406eff6 100644 --- a/src/com/android/calendar/GeneralPreferences.kt +++ b/src/com/android/calendar/GeneralPreferences.kt @@ -248,8 +248,8 @@ class GeneralPreferences : PreferenceFragment(), OnSharedPreferenceChangeListene mVibrate?.setChecked(Utils.getDefaultVibrate(getActivity(), prefs)) // If needed, migrate the old alerts type settin - if (prefs?.contains(KEY_ALERTS) == false && prefs?.contains(KEY_ALERTS_TYPE) == true) { - val type: String? = prefs?.getString(KEY_ALERTS_TYPE, ALERT_TYPE_STATUS_BAR) + if (prefs?.contains(KEY_ALERTS) == false && prefs.contains(KEY_ALERTS_TYPE) == true) { + val type: String? = prefs.getString(KEY_ALERTS_TYPE, ALERT_TYPE_STATUS_BAR) if (type.equals(ALERT_TYPE_OFF)) { mAlert?.setChecked(false) mPopup?.setChecked(false) @@ -264,7 +264,7 @@ class GeneralPreferences : PreferenceFragment(), OnSharedPreferenceChangeListene mPopup?.setEnabled(true) } // clear out the old setting - prefs?.edit().remove(KEY_ALERTS_TYPE).commit() + prefs.edit().remove(KEY_ALERTS_TYPE).commit() } } diff --git a/src/com/android/calendar/Utils.kt b/src/com/android/calendar/Utils.kt index ef780485..52af887c 100644 --- a/src/com/android/calendar/Utils.kt +++ b/src/com/android/calendar/Utils.kt @@ -186,13 +186,13 @@ object Utils { return ViewType.EDIT } if (extras != null) { - if (extras?.getBoolean(INTENT_KEY_DETAIL_VIEW, false)) { + if (extras.getBoolean(INTENT_KEY_DETAIL_VIEW, false)) { // This is the "detail" view which is either agenda or day view return prefs?.getInt( GeneralPreferences.KEY_DETAILED_VIEW, GeneralPreferences.DEFAULT_DETAILED_VIEW ) as Int - } else if (INTENT_VALUE_VIEW_TYPE_DAY.equals(extras?.getString(INTENT_KEY_VIEW_TYPE))) { + } else if (INTENT_VALUE_VIEW_TYPE_DAY.equals(extras.getString(INTENT_KEY_VIEW_TYPE))) { // Not sure who uses this. This logic came from LaunchActivity return ViewType.DAY } @@ -275,12 +275,12 @@ object Utils { // // silent and never -> off // always -> on - val vibrateWhen: String? = prefs?.getString(KEY_ALERTS_VIBRATE_WHEN, null) + val vibrateWhen: String? = prefs.getString(KEY_ALERTS_VIBRATE_WHEN, null) vibrate = vibrateWhen != null && vibrateWhen.equals( context .getString(R.string.prefDefault_alerts_vibrate_true) ) - prefs?.edit().remove(KEY_ALERTS_VIBRATE_WHEN).commit() + prefs.edit().remove(KEY_ALERTS_VIBRATE_WHEN).commit() Log.d( TAG, "Migrating KEY_ALERTS_VIBRATE_WHEN(" + vibrateWhen + ") to KEY_ALERTS_VIBRATE = " + vibrate @@ -302,8 +302,8 @@ object Utils { val prefs: SharedPreferences? = GeneralPreferences.getSharedPreferences(context) val ss = prefs?.getStringSet(key, null) if (ss != null) { - val strings = arrayOfNulls<String>(ss?.size) - return ss?.toTypedArray() + val strings = arrayOfNulls<String>(ss.size) + return ss.toTypedArray() } return defaultValue } @@ -463,11 +463,11 @@ object Utils { // time. val data: Uri? = intent?.getData() var millis: Long? = intent?.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1)?.toLong() - if (millis == -1L && data != null && data?.isHierarchical()) { - val path: List<String> = data?.getPathSegments() as List<String> + if (millis == -1L && data != null && data.isHierarchical()) { + val path: List<String> = data.getPathSegments() as List<String> if (path.size == 2 && path[0].equals("time")) { try { - millis = (data?.getLastPathSegment()?.toLong()) + millis = (data.getLastPathSegment()?.toLong()) } catch (e: NumberFormatException) { Log.i( "Calendar", "timeFromIntentInMillis: Data existed but no valid time " + @@ -818,8 +818,8 @@ object Utils { } val res: Resources? = context?.getResources() CONFLICT_COLOR = res?.getColor(R.color.month_dna_conflict_time_color) as Int - WORK_DAY_START_MINUTES = res?.getInteger(R.integer.work_start_minutes) as Int - WORK_DAY_END_MINUTES = res?.getInteger(R.integer.work_end_minutes) as Int + WORK_DAY_START_MINUTES = res.getInteger(R.integer.work_start_minutes) as Int + WORK_DAY_END_MINUTES = res.getInteger(R.integer.work_end_minutes) as Int WORK_DAY_END_LENGTH = DAY_IN_MINUTES - WORK_DAY_END_MINUTES WORK_DAY_MINUTES = WORK_DAY_END_MINUTES - WORK_DAY_START_MINUTES mMinutesLoaded = true @@ -1085,7 +1085,7 @@ object Utils { val strandIterator = strands.values.iterator() while (strandIterator.hasNext()) { val strand = strandIterator.next() - if (strand?.count < 1 && strand.allDays == null) { + if (strand.count < 1 && strand.allDays == null) { strandIterator.remove() continue } @@ -1115,17 +1115,17 @@ object Utils { " for " + dayStartMinute.toString() + " " + dayEndMinute ) } - strand?.points!![strand?.position] = x.toFloat() - strand?.position = strand?.position?.inc() as Int + strand?.points!![strand.position] = x.toFloat() + strand.position = strand.position.inc() as Int - strand?.points!![strand?.position] = y0.toFloat() - strand?.position = strand?.position?.inc() as Int + strand.points!![strand.position] = y0.toFloat() + strand.position = strand.position.inc() as Int - strand?.points!![strand?.position] = x.toFloat() - strand?.position = strand?.position.inc() as Int + strand.points!![strand.position] = x.toFloat() + strand.position = strand.position.inc() as Int - strand?.points!![strand?.position] = y1.toFloat() - strand?.position = strand?.position.inc() as Int + strand.points!![strand.position] = y1.toFloat() + strand.position = strand.position.inc() as Int } } @@ -1221,9 +1221,9 @@ object Utils { var strand: DNAStrand? = strands.get(color) if (strand == null) { strand = DNAStrand() - strand?.color = color - strand?.count = 0 - strands?.put(strand?.color, strand) + strand.color = color + strand.count = 0 + strands.put(strand.color, strand) } return strand } diff --git a/src/com/android/calendar/alerts/DismissAlarmsService.kt b/src/com/android/calendar/alerts/DismissAlarmsService.kt index 88683d3a..f18cb0b7 100644 --- a/src/com/android/calendar/alerts/DismissAlarmsService.kt +++ b/src/com/android/calendar/alerts/DismissAlarmsService.kt @@ -84,7 +84,7 @@ class DismissAlarmsService : IntentService("DismissAlarmsService") { getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager nm.cancel(notificationId as Int) } - if (SHOW_ACTION.equals(intent?.getAction())) { + if (SHOW_ACTION.equals(intent.getAction())) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. val i: Intent = AlertUtils.buildEventViewIntent(this, eventId as Long, diff --git a/src/com/android/calendar/alerts/QuickResponseActivity.kt b/src/com/android/calendar/alerts/QuickResponseActivity.kt index afccaffd..cbe86366 100644 --- a/src/com/android/calendar/alerts/QuickResponseActivity.kt +++ b/src/com/android/calendar/alerts/QuickResponseActivity.kt @@ -43,7 +43,7 @@ class QuickResponseActivity : ListActivity(), OnItemClickListener { finish() return } - mEventId = intent?.getLongExtra(EXTRA_EVENT_ID, -1) as Long + mEventId = intent.getLongExtra(EXTRA_EVENT_ID, -1) as Long if (mEventId == -1L) { finish() return diff --git a/src/com/android/calendar/month/MonthByWeekAdapter.kt b/src/com/android/calendar/month/MonthByWeekAdapter.kt index c67b3562..90daa976 100644 --- a/src/com/android/calendar/month/MonthByWeekAdapter.kt +++ b/src/com/android/calendar/month/MonthByWeekAdapter.kt @@ -262,7 +262,7 @@ class MonthByWeekAdapter(context: Context?, params: HashMap<String?, Int?>) : if (v !is MonthWeekEventsView) { return super.onTouch(v, event) } - val action: Int = event!!.getAction() + val action: Int = event.getAction() // Event was tapped - switch to the detailed view making sure the click animation // is done first. @@ -330,7 +330,7 @@ class MonthByWeekAdapter(context: Context?, params: HashMap<String?, Int?>) : // Clear the visual cues of the click animation and related running code. private fun clearClickedView(v: MonthWeekEventsView?) { mListView?.removeCallbacks(mDoClick) - synchronized(v as Any) { v?.clearClickedDay() } + synchronized(v as Any) { v.clearClickedDay() } mClickedView = null } diff --git a/src/com/android/calendar/month/MonthByWeekFragment.kt b/src/com/android/calendar/month/MonthByWeekFragment.kt index 9fe9fe49..b6882b74 100644 --- a/src/com/android/calendar/month/MonthByWeekFragment.kt +++ b/src/com/android/calendar/month/MonthByWeekFragment.kt @@ -131,7 +131,7 @@ class MonthByWeekFragment @JvmOverloads constructor( private fun updateUri(): Uri { val child: SimpleWeekView? = mListView?.getChildAt(0) as? SimpleWeekView if (child != null) { - val julianDay: Int = child?.getFirstJulianDay() + val julianDay: Int = child.getFirstJulianDay() mFirstLoadedJulianDay = julianDay } // -1 to ensure we get all day events from any time zone @@ -156,8 +156,8 @@ class MonthByWeekFragment @JvmOverloads constructor( if (size <= 2) { return } - val first: Long = (pathSegments!![size - 2])?.toLong() as Long - val last: Long = (pathSegments!![size - 1])?.toLong() as Long + val first: Long = (pathSegments[size - 2])?.toLong() as Long + val last: Long = (pathSegments[size - 1])?.toLong() as Long mTempTime.set(first) mFirstLoadedJulianDay = Time.getJulianDay(first, mTempTime.gmtoff) mTempTime.set(last) @@ -222,11 +222,11 @@ class MonthByWeekFragment @JvmOverloads constructor( mFirstDayOfWeek = Utils.getFirstDayOfWeek(mContext) mShowWeekNumber = Utils.getShowWeekNumber(mContext) val weekParams = HashMap<String?, Int?>() - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_NUM_WEEKS, mNumWeeks) - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_SHOW_WEEK, if (mShowWeekNumber) 1 else 0) - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_WEEK_START, mFirstDayOfWeek) - weekParams?.put(MonthByWeekAdapter.WEEK_PARAMS_IS_MINI, if (mIsMiniMonth) 1 else 0) - weekParams?.put( + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_NUM_WEEKS, mNumWeeks) + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_SHOW_WEEK, if (mShowWeekNumber) 1 else 0) + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_WEEK_START, mFirstDayOfWeek) + weekParams.put(MonthByWeekAdapter.WEEK_PARAMS_IS_MINI, if (mIsMiniMonth) 1 else 0) + weekParams.put( SimpleWeeksAdapter.WEEK_PARAMS_JULIAN_DAY, Time.getJulianDay(mSelectedDay.toMillis(true), mSelectedDay.gmtoff) ) @@ -383,21 +383,21 @@ class MonthByWeekFragment @JvmOverloads constructor( if (event?.eventType === EventType.GO_TO) { var animate = true if (mDaysPerWeek * mNumWeeks * 2 < Math.abs( - Time.getJulianDay(event?.selectedTime?.toMillis(true) as Long, - event?.selectedTime?.gmtoff as Long) - - Time.getJulianDay(mFirstVisibleDay?.toMillis(true) as Long, - mFirstVisibleDay?.gmtoff as Long) - + Time.getJulianDay(event.selectedTime?.toMillis(true) as Long, + event.selectedTime?.gmtoff as Long) - + Time.getJulianDay(mFirstVisibleDay.toMillis(true) as Long, + mFirstVisibleDay.gmtoff as Long) - mDaysPerWeek * mNumWeeks / 2L ) ) { animate = false } - mDesiredDay.set(event?.selectedTime) + mDesiredDay.set(event.selectedTime) mDesiredDay.normalize(true) - val animateToday = event?.extraLong and + val animateToday = event.extraLong and CalendarController.EXTRA_GOTO_TODAY.toLong() != 0L val delayAnimation: Boolean = - goTo(event?.selectedTime?.toMillis(true)?.toLong() as Long, + goTo(event.selectedTime?.toMillis(true)?.toLong() as Long, animate, true, false) if (animateToday) { // If we need to flash today start the animation after any diff --git a/src/com/android/calendar/month/MonthWeekEventsView.kt b/src/com/android/calendar/month/MonthWeekEventsView.kt index e4b15494..b8cdbb6e 100644 --- a/src/com/android/calendar/month/MonthWeekEventsView.kt +++ b/src/com/android/calendar/month/MonthWeekEventsView.kt @@ -215,7 +215,7 @@ class MonthWeekEventsView effectiveWidth -= SPACING_WEEK_NUMBER } DNA_ALL_DAY_WIDTH = effectiveWidth / numDays - 2 * DNA_SIDE_PADDING - mDNAAllDayPaint?.setStrokeWidth(DNA_ALL_DAY_WIDTH.toFloat()) + mDNAAllDayPaint.setStrokeWidth(DNA_ALL_DAY_WIDTH.toFloat()) mDayXs = IntArray(numDays) for (day in 0 until numDays) { mDayXs!![day] = computeDayLeftPosition(day) + DNA_WIDTH / 2 + DNA_SIDE_PADDING @@ -322,20 +322,20 @@ class MonthWeekEventsView loadColors(getContext()) // TODO modify paint properties depending on isMini mMonthNumPaint = Paint() - mMonthNumPaint?.setFakeBoldText(false) - mMonthNumPaint?.setAntiAlias(true) - mMonthNumPaint?.setTextSize(TEXT_SIZE_MONTH_NUMBER.toFloat()) - mMonthNumPaint?.setColor(mMonthNumColor) - mMonthNumPaint?.setStyle(Style.FILL) - mMonthNumPaint?.setTextAlign(Align.RIGHT) - mMonthNumPaint?.setTypeface(Typeface.DEFAULT) - mMonthNumAscentHeight = (-mMonthNumPaint!!.ascent() + 0.5f).toInt() - mMonthNumHeight = (mMonthNumPaint!!.descent() - mMonthNumPaint!!.ascent() + 0.5f).toInt() + mMonthNumPaint.setFakeBoldText(false) + mMonthNumPaint.setAntiAlias(true) + mMonthNumPaint.setTextSize(TEXT_SIZE_MONTH_NUMBER.toFloat()) + mMonthNumPaint.setColor(mMonthNumColor) + mMonthNumPaint.setStyle(Style.FILL) + mMonthNumPaint.setTextAlign(Align.RIGHT) + mMonthNumPaint.setTypeface(Typeface.DEFAULT) + mMonthNumAscentHeight = (-mMonthNumPaint.ascent() + 0.5f).toInt() + mMonthNumHeight = (mMonthNumPaint.descent() - mMonthNumPaint.ascent() + 0.5f).toInt() mEventPaint = TextPaint() - mEventPaint?.setFakeBoldText(true) - mEventPaint?.setAntiAlias(true) - mEventPaint?.setTextSize(TEXT_SIZE_EVENT_TITLE.toFloat()) - mEventPaint?.setColor(mMonthEventColor) + mEventPaint.setFakeBoldText(true) + mEventPaint.setAntiAlias(true) + mEventPaint.setTextSize(TEXT_SIZE_EVENT_TITLE.toFloat()) + mEventPaint.setColor(mMonthEventColor) mSolidBackgroundEventPaint = TextPaint(mEventPaint) mSolidBackgroundEventPaint?.setColor(EVENT_TEXT_COLOR) mFramedEventPaint = TextPaint(mSolidBackgroundEventPaint) @@ -347,13 +347,13 @@ class MonthWeekEventsView mEventAscentHeight = (-mEventPaint.ascent() + 0.5f).toInt() mEventHeight = (mEventPaint.descent() - mEventPaint.ascent() + 0.5f).toInt() mEventExtrasPaint = TextPaint() - mEventExtrasPaint?.setFakeBoldText(false) - mEventExtrasPaint?.setAntiAlias(true) - mEventExtrasPaint?.setStrokeWidth(EVENT_SQUARE_BORDER.toFloat()) - mEventExtrasPaint?.setTextSize(TEXT_SIZE_EVENT.toFloat()) - mEventExtrasPaint?.setColor(mMonthEventExtraColor) - mEventExtrasPaint?.setStyle(Style.FILL) - mEventExtrasPaint?.setTextAlign(Align.LEFT) + mEventExtrasPaint.setFakeBoldText(false) + mEventExtrasPaint.setAntiAlias(true) + mEventExtrasPaint.setStrokeWidth(EVENT_SQUARE_BORDER.toFloat()) + mEventExtrasPaint.setTextSize(TEXT_SIZE_EVENT.toFloat()) + mEventExtrasPaint.setColor(mMonthEventExtraColor) + mEventExtrasPaint.setStyle(Style.FILL) + mEventExtrasPaint.setTextAlign(Align.LEFT) mExtrasHeight = (mEventExtrasPaint.descent() - mEventExtrasPaint.ascent() + 0.5f).toInt() mExtrasAscentHeight = (-mEventExtrasPaint.ascent() + 0.5f).toInt() mExtrasDescent = (mEventExtrasPaint.descent() + 0.5f).toInt() @@ -388,11 +388,11 @@ class MonthWeekEventsView mEventSquarePaint.setAntiAlias(false) if (DEBUG_LAYOUT) { Log.d("EXTRA", "mScale=$mScale") - Log.d("EXTRA", "mMonthNumPaint ascent=" + mMonthNumPaint?.ascent() - ?.toString() + " descent=" + mMonthNumPaint?.descent()?.toString() + + Log.d("EXTRA", "mMonthNumPaint ascent=" + mMonthNumPaint.ascent() + .toString() + " descent=" + mMonthNumPaint.descent().toString() + " int height=" + mMonthNumHeight) - Log.d("EXTRA", "mEventPaint ascent=" + mEventPaint?.ascent() - ?.toString() + " descent=" + mEventPaint.descent().toString() + + Log.d("EXTRA", "mEventPaint ascent=" + mEventPaint.ascent() + .toString() + " descent=" + mEventPaint.descent().toString() + " int height=" + mEventHeight .toString() + " int ascent=" + mEventAscentHeight) Log.d("EXTRA", "mEventExtrasPaint ascent=" + mEventExtrasPaint.ascent() @@ -544,15 +544,15 @@ class MonthWeekEventsView i++ offset++ } - if (!mOddMonth!!.get(i)) { - while (++i < mOddMonth!!.size && !mOddMonth!!.get(i)); + if (!mOddMonth.get(i)) { + while (++i < mOddMonth.size && !mOddMonth.get(i)); r.right = computeDayLeftPosition(i - offset) r.left = 0 p.setColor(mMonthBGOtherColor) canvas.drawRect(r, p) // compute left edge for i, set up r, draw - } else if (!mOddMonth!!.get(mOddMonth!!.size - 1.also { i = it })) { - while (--i >= offset && !mOddMonth!!.get(i)); + } else if (!mOddMonth.get(mOddMonth.size - 1.also { i = it })) { + while (--i >= offset && !mOddMonth.get(i)); i++ // compute left edge for i, set up r, draw r.right = mWidth @@ -601,27 +601,27 @@ class MonthWeekEventsView offset++ } y = mMonthNumAscentHeight + TOP_PADDING_MONTH_NUMBER - var isFocusMonth: Boolean = mFocusDay!!.get(i) + var isFocusMonth: Boolean = mFocusDay.get(i) var isBold = false - mMonthNumPaint?.setColor(if (isFocusMonth) mMonthNumColor else mMonthNumOtherColor) + mMonthNumPaint.setColor(if (isFocusMonth) mMonthNumColor else mMonthNumOtherColor) while (i < numCount) { if (mHasToday && todayIndex == i) { - mMonthNumPaint?.setColor(mMonthNumTodayColor) - mMonthNumPaint?.setFakeBoldText(true.also { isBold = it }) + mMonthNumPaint.setColor(mMonthNumTodayColor) + mMonthNumPaint.setFakeBoldText(true.also { isBold = it }) if (i + 1 < numCount) { // Make sure the color will be set back on the next // iteration - isFocusMonth = !mFocusDay!!.get(i + 1) + isFocusMonth = !mFocusDay.get(i + 1) } - } else if (mFocusDay?.get(i) !== isFocusMonth) { - isFocusMonth = mFocusDay!!.get(i) - mMonthNumPaint?.setColor(if (isFocusMonth) mMonthNumColor else mMonthNumOtherColor) + } else if (mFocusDay.get(i) !== isFocusMonth) { + isFocusMonth = mFocusDay.get(i) + mMonthNumPaint.setColor(if (isFocusMonth) mMonthNumColor else mMonthNumOtherColor) } x = computeDayLeftPosition(i - offset) - SIDE_PADDING_MONTH_NUMBER canvas.drawText(mDayNumbers!!.get(i) as String, x.toFloat(), y.toFloat(), mMonthNumPaint as Paint) if (isBold) { - mMonthNumPaint?.setFakeBoldText(false.also { isBold = it }) + mMonthNumPaint.setFakeBoldText(false.also { isBold = it }) } i++ } @@ -857,7 +857,7 @@ class MonthWeekEventsView mEventExtrasPaint.setFakeBoldText(true) canvas.drawText(String.format(text, remainingEvents), x.toFloat(), y.toFloat(), mEventExtrasPaint as Paint) - mEventExtrasPaint!!.setFakeBoldText(false) + mEventExtrasPaint.setFakeBoldText(false) } /** @@ -875,13 +875,13 @@ class MonthWeekEventsView (strand.points as FloatArray).size === 0) { continue } - mDNATimePaint!!.setColor(strand.color) + mDNATimePaint.setColor(strand.color) canvas.drawLines(strand.points as FloatArray, mDNATimePaint as Paint) } // Draw black last to make sure it's on top val strand: Utils.DNAStrand? = mDna?.get(CONFLICT_COLOR) - if (strand != null && strand!!.points != null && strand!!.points?.size !== 0) { - mDNATimePaint!!.setColor(strand.color) + if (strand != null && strand.points != null && strand.points?.size !== 0) { + mDNATimePaint.setColor(strand.color) canvas.drawLines(strand.points as FloatArray, mDNATimePaint as Paint) } if (mDayXs == null) { @@ -889,12 +889,12 @@ class MonthWeekEventsView } val numDays = mDayXs!!.size val xOffset = (DNA_ALL_DAY_WIDTH - DNA_WIDTH) / 2 - if (strand != null && strand!!.allDays != null && strand!!.allDays?.size === numDays) { + if (strand != null && strand.allDays != null && strand.allDays?.size === numDays) { for (i in 0 until numDays) { // this adds at most 7 draws. We could sort it by color and // build an array instead but this is easier. - if (strand!!.allDays?.get(i) !== 0) { - mDNAAllDayPaint!!.setColor(strand!!.allDays!!.get(i)) + if (strand.allDays?.get(i) !== 0) { + mDNAAllDayPaint.setColor(strand.allDays!!.get(i)) canvas.drawLine(mDayXs!![i].toFloat() + xOffset.toFloat(), DNA_MARGIN.toFloat(), mDayXs!![i].toFloat() + xOffset.toFloat(), DNA_MARGIN.toFloat() + DNA_ALL_DAY_HEIGHT.toFloat(), @@ -966,7 +966,7 @@ class MonthWeekEventsView if (hover != null && (mLastHoverTime == null || Time.compare(hover, mLastHoverTime) !== 0)) { val millis: Long = hover.toMillis(true) - val date: String = Utils!!.formatDateRange(context, millis, millis, + val date: String = Utils.formatDateRange(context, millis, millis, DateUtils.FORMAT_SHOW_DATE) as String val accessEvent: AccessibilityEvent = AccessibilityEvent .obtain(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) @@ -980,7 +980,7 @@ class MonthWeekEventsView for (e in events) { text.add(e!!.titleAndLocation.toString() + ". ") var flags: Int = DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_SHOW_YEAR - if (!e!!.allDay) { + if (!e.allDay) { flags = flags or DateUtils.FORMAT_SHOW_TIME if (DateFormat.is24HourFormat(context)) { flags = flags or DateUtils.FORMAT_24HOUR @@ -988,7 +988,7 @@ class MonthWeekEventsView } else { flags = flags or DateUtils.FORMAT_UTC } - text.add(Utils.formatDateRange(context, e!!.startMillis, e!!.endMillis, + text.add(Utils.formatDateRange(context, e.startMillis, e.endMillis, flags).toString() + ". ") } } diff --git a/src/com/android/calendar/month/SimpleDayPickerFragment.kt b/src/com/android/calendar/month/SimpleDayPickerFragment.kt index 01fcbac6..c0bce5d3 100644 --- a/src/com/android/calendar/month/SimpleDayPickerFragment.kt +++ b/src/com/android/calendar/month/SimpleDayPickerFragment.kt @@ -121,7 +121,7 @@ open class SimpleDayPickerFragment(initialTime: Long) : ListFragment(), OnScroll midnight.second = 0 midnight.monthDay++ val millisToMidnight: Long = midnight.normalize(true) - currentMillis - mHandler?.postDelayed(this, millisToMidnight) + mHandler.postDelayed(this, millisToMidnight) if (mAdapter != null) { mAdapter?.notifyDataSetChanged() } @@ -133,7 +133,7 @@ open class SimpleDayPickerFragment(initialTime: Long) : ListFragment(), OnScroll @Override override fun onChanged() { val day: Time? = mAdapter!!.getSelectedDay() - if (day!!.year !== mSelectedDay!!.year || day!!.yearDay !== mSelectedDay.yearDay) { + if (day!!.year !== mSelectedDay.year || day!!.yearDay !== mSelectedDay.yearDay) { goTo(day!!.toMillis(true), true, true, false) } } @@ -179,10 +179,10 @@ open class SimpleDayPickerFragment(initialTime: Long) : ListFragment(), OnScroll */ protected open fun setUpAdapter() { val weekParams = HashMap<String?, Int?>() - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_NUM_WEEKS, mNumWeeks) - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_SHOW_WEEK, if (mShowWeekNumber) 1 else 0) - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_WEEK_START, mFirstDayOfWeek) - weekParams?.put(SimpleWeeksAdapter.WEEK_PARAMS_JULIAN_DAY, + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_NUM_WEEKS, mNumWeeks) + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_SHOW_WEEK, if (mShowWeekNumber) 1 else 0) + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_WEEK_START, mFirstDayOfWeek) + weekParams.put(SimpleWeeksAdapter.WEEK_PARAMS_JULIAN_DAY, Time.getJulianDay(mSelectedDay.toMillis(false), mSelectedDay.gmtoff)) if (mAdapter == null) { mAdapter = SimpleWeeksAdapter(getActivity(), weekParams) @@ -482,7 +482,7 @@ open class SimpleDayPickerFragment(initialTime: Long) : ListFragment(), OnScroll } // Figure out where we are - val offset = if (child?.getBottom() < WEEK_MIN_VISIBLE_HEIGHT) 1 else 0 + val offset = if (child.getBottom() < WEEK_MIN_VISIBLE_HEIGHT) 1 else 0 // Use some hysteresis for checking which month to highlight. This // causes the month to transition when two full weeks of a month are // visible. @@ -494,9 +494,9 @@ open class SimpleDayPickerFragment(initialTime: Long) : ListFragment(), OnScroll // Find out which month we're moving into val month: Int month = if (mIsScrollingUp) { - child?.getFirstMonth() + child.getFirstMonth() } else { - child?.getLastMonth() + child.getLastMonth() } // And how it relates to our current highlighted month diff --git a/src/com/android/calendar/month/SimpleWeekView.kt b/src/com/android/calendar/month/SimpleWeekView.kt index 4d1298d4..cd8eb84c 100644 --- a/src/com/android/calendar/month/SimpleWeekView.kt +++ b/src/com/android/calendar/month/SimpleWeekView.kt @@ -207,11 +207,11 @@ open class SimpleWeekView(context: Context) : View(context) { if (time.monthDay === 1) { firstMonth = time.month } - mOddMonth!![i] = time.month % 2 === 1 + mOddMonth[i] = time.month % 2 === 1 if (time.month === focusMonth) { - mFocusDay!![i] = true + mFocusDay[i] = true } else { - mFocusDay!![i] = false + mFocusDay[i] = false } if (time.year === today.year && time.yearDay === today.yearDay) { mHasToday = true @@ -241,12 +241,12 @@ open class SimpleWeekView(context: Context) : View(context) { p.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE.toFloat()) p.setStyle(Style.FILL) mMonthNumPaint = Paint() - mMonthNumPaint?.setFakeBoldText(true) - mMonthNumPaint?.setAntiAlias(true) - mMonthNumPaint?.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE.toFloat()) - mMonthNumPaint?.setColor(mFocusMonthColor) - mMonthNumPaint?.setStyle(Style.FILL) - mMonthNumPaint?.setTextAlign(Align.CENTER) + mMonthNumPaint.setFakeBoldText(true) + mMonthNumPaint.setAntiAlias(true) + mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE.toFloat()) + mMonthNumPaint.setColor(mFocusMonthColor) + mMonthNumPaint.setStyle(Style.FILL) + mMonthNumPaint.setTextAlign(Align.CENTER) } /** @@ -359,24 +359,24 @@ open class SimpleWeekView(context: Context) : View(context) { canvas.drawText(mDayNumbers!![0] as String, x.toFloat(), y.toFloat(), p) i++ } - var isFocusMonth = mFocusDay!![i] - mMonthNumPaint?.setColor(if (isFocusMonth) mFocusMonthColor else mOtherMonthColor) - mMonthNumPaint?.setFakeBoldText(false) + var isFocusMonth = mFocusDay[i] + mMonthNumPaint.setColor(if (isFocusMonth) mFocusMonthColor else mOtherMonthColor) + mMonthNumPaint.setFakeBoldText(false) while (i < nDays) { - if (mFocusDay!![i] != isFocusMonth) { - isFocusMonth = mFocusDay!![i] - mMonthNumPaint?.setColor(if (isFocusMonth) mFocusMonthColor else mOtherMonthColor) + if (mFocusDay[i] != isFocusMonth) { + isFocusMonth = mFocusDay[i] + mMonthNumPaint.setColor(if (isFocusMonth) mFocusMonthColor else mOtherMonthColor) } if (mHasToday && mToday == i) { - mMonthNumPaint?.setTextSize(MINI_TODAY_NUMBER_TEXT_SIZE.toFloat()) - mMonthNumPaint?.setFakeBoldText(true) + mMonthNumPaint.setTextSize(MINI_TODAY_NUMBER_TEXT_SIZE.toFloat()) + mMonthNumPaint.setFakeBoldText(true) } val x = (2 * i + 1) * (mWidth - mPadding * 2) / divisor + mPadding canvas.drawText(mDayNumbers!![i] as String, x.toFloat(), y.toFloat(), mMonthNumPaint as Paint) if (mHasToday && mToday == i) { - mMonthNumPaint?.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE.toFloat()) - mMonthNumPaint?.setFakeBoldText(false) + mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE.toFloat()) + mMonthNumPaint.setFakeBoldText(false) } i++ } diff --git a/src/com/android/calendar/widget/CalendarAppWidgetProvider.kt b/src/com/android/calendar/widget/CalendarAppWidgetProvider.kt index b3539f22..fcc5be3b 100644 --- a/src/com/android/calendar/widget/CalendarAppWidgetProvider.kt +++ b/src/com/android/calendar/widget/CalendarAppWidgetProvider.kt @@ -63,7 +63,7 @@ class CalendarAppWidgetProvider : AppWidgetProvider() { action.equals(Utils.getWidgetScheduledUpdateAction(context as Context))) ) { val service = Intent(context, CalendarAppWidgetService::class.java) - context?.startService(service) + context.startService(service) } else { super.onReceive(context, intent) } diff --git a/src/com/android/calendar/widget/CalendarAppWidgetService.kt b/src/com/android/calendar/widget/CalendarAppWidgetService.kt index 114fdf12..0d1018f3 100644 --- a/src/com/android/calendar/widget/CalendarAppWidgetService.kt +++ b/src/com/android/calendar/widget/CalendarAppWidgetService.kt @@ -232,7 +232,7 @@ class CalendarAppWidgetService : RemoteViewsService() { views.setOnClickFillInIntent(R.id.appwidget_loading, intent) return views } - if (mModel!!.mEventInfos!!.isEmpty() || mModel!!.mRowInfos!!.isEmpty()) { + if (mModel!!.mEventInfos.isEmpty() || mModel!!.mRowInfos.isEmpty()) { val views = RemoteViews( mContext?.getPackageName(), R.layout.appwidget_no_events @@ -248,12 +248,12 @@ class CalendarAppWidgetService : RemoteViewsService() { return views } val rowInfo: RowInfo? = mModel?.mRowInfos?.get(position) - return if (rowInfo!!.mType == RowInfo!!.TYPE_DAY) { + return if (rowInfo!!.mType == RowInfo.TYPE_DAY) { val views = RemoteViews( mContext?.getPackageName(), R.layout.appwidget_day ) - val dayInfo: DayInfo? = mModel?.mDayInfos?.get(rowInfo!!.mIndex) + val dayInfo: DayInfo? = mModel?.mDayInfos?.get(rowInfo.mIndex) updateTextView(views, R.id.date, View.VISIBLE, dayInfo!!.mDayLabel) views } else { @@ -267,92 +267,92 @@ class CalendarAppWidgetService : RemoteViewsService() { } else { views = RemoteViews(mContext?.getPackageName(), R.layout.widget_item) } - val displayColor: Int = Utils.getDisplayColorFromColor(eventInfo!!.color) + val displayColor: Int = Utils.getDisplayColorFromColor(eventInfo.color) val now: Long = System.currentTimeMillis() - if (!eventInfo!!.allDay && eventInfo!!.start <= now && now <= eventInfo!!.end) { - views?.setInt( + if (!eventInfo.allDay && eventInfo.start <= now && now <= eventInfo.end) { + views.setInt( R.id.widget_row, "setBackgroundResource", R.drawable.agenda_item_bg_secondary ) } else { - views?.setInt( + views.setInt( R.id.widget_row, "setBackgroundResource", R.drawable.agenda_item_bg_primary ) } - if (!eventInfo?.allDay) { - updateTextView(views, R.id.`when`, eventInfo?.visibWhen - as Int, eventInfo?.`when`) - updateTextView(views, R.id.where, eventInfo?.visibWhere - as Int, eventInfo?.where) + if (!eventInfo.allDay) { + updateTextView(views, R.id.`when`, eventInfo.visibWhen + as Int, eventInfo.`when`) + updateTextView(views, R.id.where, eventInfo.visibWhere + as Int, eventInfo.where) } - updateTextView(views, R.id.title, eventInfo?.visibTitle as Int, eventInfo?.title) + updateTextView(views, R.id.title, eventInfo.visibTitle as Int, eventInfo.title) views.setViewVisibility(R.id.agenda_item_color, View.VISIBLE) - val selfAttendeeStatus: Int = eventInfo?.selfAttendeeStatus as Int - if (eventInfo!!.allDay) { + val selfAttendeeStatus: Int = eventInfo.selfAttendeeStatus as Int + if (eventInfo.allDay) { if (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_INVITED) { - views?.setInt( + views.setInt( R.id.agenda_item_color, "setImageResource", R.drawable.widget_chip_not_responded_bg ) - views?.setInt(R.id.title, "setTextColor", displayColor) + views.setInt(R.id.title, "setTextColor", displayColor) } else { - views?.setInt( + views.setInt( R.id.agenda_item_color, "setImageResource", R.drawable.widget_chip_responded_bg ) - views?.setInt(R.id.title, "setTextColor", mAllDayColor) + views.setInt(R.id.title, "setTextColor", mAllDayColor) } if (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_DECLINED) { // 40% opacity - views?.setInt( + views.setInt( R.id.agenda_item_color, "setColorFilter", Utils.getDeclinedColorFromColor(displayColor) ) } else { - views?.setInt(R.id.agenda_item_color, "setColorFilter", displayColor) + views.setInt(R.id.agenda_item_color, "setColorFilter", displayColor) } } else if (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_DECLINED) { - views?.setInt(R.id.title, "setTextColor", mDeclinedColor) - views?.setInt(R.id.`when`, "setTextColor", mDeclinedColor) - views?.setInt(R.id.where, "setTextColor", mDeclinedColor) - views?.setInt( + views.setInt(R.id.title, "setTextColor", mDeclinedColor) + views.setInt(R.id.`when`, "setTextColor", mDeclinedColor) + views.setInt(R.id.where, "setTextColor", mDeclinedColor) + views.setInt( R.id.agenda_item_color, "setImageResource", R.drawable.widget_chip_responded_bg ) // 40% opacity - views?.setInt( + views.setInt( R.id.agenda_item_color, "setColorFilter", Utils.getDeclinedColorFromColor(displayColor) ) } else { - views?.setInt(R.id.title, "setTextColor", mStandardColor) - views?.setInt(R.id.`when`, "setTextColor", mStandardColor) - views?.setInt(R.id.where, "setTextColor", mStandardColor) + views.setInt(R.id.title, "setTextColor", mStandardColor) + views.setInt(R.id.`when`, "setTextColor", mStandardColor) + views.setInt(R.id.where, "setTextColor", mStandardColor) if (selfAttendeeStatus == Attendees.ATTENDEE_STATUS_INVITED) { - views?.setInt( + views.setInt( R.id.agenda_item_color, "setImageResource", R.drawable.widget_chip_not_responded_bg ) } else { - views?.setInt( + views.setInt( R.id.agenda_item_color, "setImageResource", R.drawable.widget_chip_responded_bg ) } - views?.setInt(R.id.agenda_item_color, "setColorFilter", displayColor) + views.setInt(R.id.agenda_item_color, "setColorFilter", displayColor) } - var start: Long = eventInfo?.start as Long - var end: Long = eventInfo?.end as Long + var start: Long = eventInfo.start as Long + var end: Long = eventInfo.end as Long // An element in ListView. - if (eventInfo!!.allDay) { + if (eventInfo.allDay) { val tz: String? = Utils.getTimeZone(mContext, null) val recycle = Time() start = Utils.convertAlldayLocalToUTC(recycle, start, tz as String) end = Utils.convertAlldayLocalToUTC(recycle, end, tz as String) } val fillInIntent: Intent = CalendarAppWidgetProvider.getLaunchFillInIntent( - mContext, eventInfo?.id, start, end, eventInfo?.allDay + mContext, eventInfo.id, start, end, eventInfo.allDay ) views.setOnClickFillInIntent(R.id.widget_row, fillInIntent) views @@ -502,10 +502,10 @@ class CalendarAppWidgetService : RemoteViewsService() { mModel = buildAppWidgetModel(mContext, matrixCursor, tz) } finally { if (matrixCursor != null) { - matrixCursor?.close() + matrixCursor.close() } if (cursor != null) { - cursor?.close() + cursor.close() } } |