updating to Android Studio 3

This commit is contained in:
tibbi 2017-11-07 16:38:58 +01:00
parent db7306a647
commit a8e9c798c4
9 changed files with 76 additions and 75 deletions

View File

@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
android { android {
compileSdkVersion 26 compileSdkVersion 27
buildToolsVersion "26.0.2" buildToolsVersion "27.0.1"
defaultConfig { defaultConfig {
applicationId "com.simplemobiletools.calendar" applicationId "com.simplemobiletools.calendar"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 26 targetSdkVersion 27
versionCode 100 versionCode 100
versionName "2.9.2" versionName "2.9.2"
multiDexEnabled true multiDexEnabled true
@ -40,16 +40,16 @@ android {
} }
ext { ext {
leakCanaryVersion = '1.5.2' leakCanaryVersion = '1.5.4'
} }
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.36.2' compile 'com.simplemobiletools:commons:2.37.1'
compile 'joda-time:joda-time:2.9.1' compile 'joda-time:joda-time:2.9.9'
compile 'com.facebook.stetho:stetho:1.4.1' compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2' compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:multidex:1.0.2'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.2'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"

View File

@ -14,7 +14,7 @@ import android.graphics.Color
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.support.v7.app.NotificationCompat import android.support.v4.app.NotificationCompat
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -96,10 +96,11 @@ fun Context.scheduleEventIn(notifTS: Long, event: Event) {
val pendingIntent = getNotificationIntent(applicationContext, event) val pendingIntent = getNotificationIntent(applicationContext, event)
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
if (isKitkatPlus()) if (isKitkatPlus()) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent) alarmManager.setExact(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
else } else {
alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent) alarmManager.set(AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
}
} }
fun Context.cancelNotification(id: Int) { fun Context.cancelNotification(id: Int) {

View File

@ -46,8 +46,8 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
mRes = resources mRes = resources
mHolder = view.day_holder mHolder = view.day_holder
mDayCode = arguments.getString(DAY_CODE) mDayCode = arguments!!.getString(DAY_CODE)
val day = Formatter.getDayTitle(activity.applicationContext, mDayCode) val day = Formatter.getDayTitle(context!!, mDayCode)
mHolder.top_value.apply { mHolder.top_value.apply {
text = day text = day
setOnClickListener { pickDay() } setOnClickListener { pickDay() }
@ -64,7 +64,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
} }
private fun setupButtons() { private fun setupButtons() {
mTextColor = context.config.textColor mTextColor = context!!.config.textColor
mHolder.apply { mHolder.apply {
top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP) top_left_arrow.drawable.mutate().setColorFilter(mTextColor, PorterDuff.Mode.SRC_ATOP)
@ -83,14 +83,14 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
} }
private fun pickDay() { private fun pickDay() {
activity.setTheme(context.getAppropriateTheme()) activity!!.setTheme(context!!.getAppropriateTheme())
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
val dateTime = Formatter.getDateTimeFromCode(mDayCode) val dateTime = Formatter.getDateTimeFromCode(mDayCode)
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, dateTime.dayOfMonth, null)
AlertDialog.Builder(context) AlertDialog.Builder(context!!)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.create().apply { .create().apply {
@ -109,7 +109,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
fun checkEvents() { fun checkEvents() {
val startTS = Formatter.getDayStartTS(mDayCode) val startTS = Formatter.getDayStartTS(mDayCode)
val endTS = Formatter.getDayEndTS(mDayCode) val endTS = Formatter.getDayEndTS(mDayCode)
DBHelper.newInstance(context, this).getEvents(startTS, endTS) { DBHelper.newInstance(context!!, this).getEvents(startTS, endTS) {
receivedEvents(it) receivedEvents(it)
} }
} }
@ -121,7 +121,7 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
} }
lastHash = newHash lastHash = newHash
val replaceDescription = context.config.replaceDescription val replaceDescription = context!!.config.replaceDescription
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { val sorted = ArrayList<Event>(events.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, {
if (replaceDescription) it.location else it.description if (replaceDescription) it.location else it.description
}))) })))
@ -142,13 +142,13 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
} }
mHolder.day_events.adapter = eventsAdapter mHolder.day_events.adapter = eventsAdapter
DividerItemDecoration(context, DividerItemDecoration.VERTICAL).apply { DividerItemDecoration(context, DividerItemDecoration.VERTICAL).apply {
setDrawable(context.resources.getDrawable(R.drawable.divider)) setDrawable(context!!.resources.getDrawable(R.drawable.divider))
mHolder.day_events.addItemDecoration(this) mHolder.day_events.addItemDecoration(this)
} }
} }
private fun editEvent(event: Event) { private fun editEvent(event: Event) {
Intent(activity.applicationContext, EventActivity::class.java).apply { Intent(context, EventActivity::class.java).apply {
putExtra(EVENT_ID, event.id) putExtra(EVENT_ID, event.id)
putExtra(EVENT_OCCURRENCE_TS, event.startTS) putExtra(EVENT_OCCURRENCE_TS, event.startTS)
startActivity(this) startActivity(this)
@ -157,12 +157,12 @@ class DayFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEventsListen
override fun deleteItems(ids: ArrayList<Int>) { override fun deleteItems(ids: ArrayList<Int>) {
val eventIDs = Array(ids.size, { i -> (ids[i].toString()) }) val eventIDs = Array(ids.size, { i -> (ids[i].toString()) })
DBHelper.newInstance(activity.applicationContext, this).deleteEvents(eventIDs, true) DBHelper.newInstance(context!!, this).deleteEvents(eventIDs, true)
} }
override fun addEventRepeatException(parentIds: ArrayList<Int>, timestamps: ArrayList<Int>) { override fun addEventRepeatException(parentIds: ArrayList<Int>, timestamps: ArrayList<Int>) {
parentIds.forEachIndexed { index, value -> parentIds.forEachIndexed { index, value ->
context.dbHelper.addEventRepeatException(parentIds[index], timestamps[index]) context!!.dbHelper.addEventRepeatException(parentIds[index], timestamps[index])
} }
(activity as DayActivity).recheckEvents() (activity as DayActivity).recheckEvents()
} }

View File

@ -35,8 +35,8 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
private var lastHash = 0 private var lastHash = 0
lateinit var mView: View lateinit var mView: View
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater!!.inflate(R.layout.fragment_event_list, container, false) mView = inflater.inflate(R.layout.fragment_event_list, container, false)
val placeholderText = String.format(getString(R.string.two_string_placeholder), "${getString(R.string.no_upcoming_events)}\n", getString(R.string.add_some_events)) val placeholderText = String.format(getString(R.string.two_string_placeholder), "${getString(R.string.no_upcoming_events)}\n", getString(R.string.add_some_events))
mView.calendar_empty_list_placeholder.text = placeholderText mView.calendar_empty_list_placeholder.text = placeholderText
return mView return mView
@ -48,9 +48,9 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
} }
private fun checkEvents() { private fun checkEvents() {
val fromTS = DateTime().seconds() - context.config.displayPastEvents * 60 val fromTS = DateTime().seconds() - context!!.config.displayPastEvents * 60
val toTS = DateTime().plusYears(1).seconds() val toTS = DateTime().plusYears(1).seconds()
context.dbHelper.getEvents(fromTS, toTS) { context!!.dbHelper.getEvents(fromTS, toTS) {
receivedEvents(it) receivedEvents(it)
} }
} }
@ -69,7 +69,7 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
} }
lastHash = newHash lastHash = newHash
val filtered = context.getFilteredEvents(events) val filtered = context!!.getFilteredEvents(events)
val hash = filtered.hashCode() val hash = filtered.hashCode()
if (prevEventsHash == hash) if (prevEventsHash == hash)
return return
@ -77,14 +77,14 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
prevEventsHash = hash prevEventsHash = hash
mEvents = filtered mEvents = filtered
val listItems = ArrayList<ListItem>(mEvents.size) val listItems = ArrayList<ListItem>(mEvents.size)
val replaceDescription = context.config.replaceDescription val replaceDescription = context!!.config.replaceDescription
val sorted = mEvents.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description })) val sorted = mEvents.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
val sublist = sorted.subList(0, Math.min(sorted.size, 100)) val sublist = sorted.subList(0, Math.min(sorted.size, 100))
var prevCode = "" var prevCode = ""
sublist.forEach { sublist.forEach {
val code = Formatter.getDayCodeFromTS(it.startTS) val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode) { if (code != prevCode) {
val day = Formatter.getDayTitle(context, code) val day = Formatter.getDayTitle(context!!, code)
listItems.add(ListSection(day)) listItems.add(ListSection(day))
prevCode = code prevCode = code
} }
@ -106,11 +106,11 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
mView.calendar_empty_list_placeholder.beVisibleIf(mEvents.isEmpty()) mView.calendar_empty_list_placeholder.beVisibleIf(mEvents.isEmpty())
mView.calendar_events_list.beGoneIf(mEvents.isEmpty()) mView.calendar_events_list.beGoneIf(mEvents.isEmpty())
if (activity != null) if (activity != null)
mView.calendar_empty_list_placeholder.setTextColor(activity.config.textColor) mView.calendar_empty_list_placeholder.setTextColor(activity!!.config.textColor)
} }
private fun editEvent(event: ListEvent) { private fun editEvent(event: ListEvent) {
Intent(activity.applicationContext, EventActivity::class.java).apply { Intent(context, EventActivity::class.java).apply {
putExtra(EVENT_ID, event.id) putExtra(EVENT_ID, event.id)
putExtra(EVENT_OCCURRENCE_TS, event.startTS) putExtra(EVENT_OCCURRENCE_TS, event.startTS)
startActivity(this) startActivity(this)
@ -119,12 +119,12 @@ class EventListFragment : Fragment(), DBHelper.EventUpdateListener, DeleteEvents
override fun deleteItems(ids: ArrayList<Int>) { override fun deleteItems(ids: ArrayList<Int>) {
val eventIDs = Array(ids.size, { i -> (ids[i].toString()) }) val eventIDs = Array(ids.size, { i -> (ids[i].toString()) })
DBHelper.newInstance(activity.applicationContext, this).deleteEvents(eventIDs, true) DBHelper.newInstance(context!!, this).deleteEvents(eventIDs, true)
} }
override fun addEventRepeatException(parentIds: ArrayList<Int>, timestamps: ArrayList<Int>) { override fun addEventRepeatException(parentIds: ArrayList<Int>, timestamps: ArrayList<Int>) {
parentIds.forEachIndexed { index, value -> parentIds.forEachIndexed { index, value ->
context.dbHelper.addEventRepeatException(value, timestamps[index]) context!!.dbHelper.addEventRepeatException(value, timestamps[index])
} }
checkEvents() checkEvents()
} }

View File

@ -48,20 +48,20 @@ class MonthFragment : Fragment(), MonthlyCalendar {
lateinit var mConfig: Config lateinit var mConfig: Config
lateinit var mCalendar: MonthlyCalendarImpl lateinit var mCalendar: MonthlyCalendarImpl
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater!!.inflate(R.layout.fragment_month, container, false) val view = inflater.inflate(R.layout.fragment_month, container, false)
mRes = resources mRes = resources
mPackageName = activity.packageName mPackageName = activity!!.packageName
mHolder = view.calendar_holder mHolder = view.calendar_holder
mDayCode = arguments.getString(DAY_CODE) mDayCode = arguments!!.getString(DAY_CODE)
mConfig = context.config mConfig = context!!.config
mSundayFirst = mConfig.isSundayFirst mSundayFirst = mConfig.isSundayFirst
setupButtons() setupButtons()
setupLabels() setupLabels()
mCalendar = MonthlyCalendarImpl(this, context) mCalendar = MonthlyCalendarImpl(this, context!!)
return view return view
} }
@ -125,15 +125,15 @@ class MonthFragment : Fragment(), MonthlyCalendar {
} }
private fun showMonthDialog() { private fun showMonthDialog() {
activity.setTheme(context.getAppropriateTheme()) activity!!.setTheme(context!!.getAppropriateTheme())
val view = getLayoutInflater(arguments).inflate(R.layout.date_picker, null) val view = layoutInflater.inflate(R.layout.date_picker, null)
val datePicker = view.findViewById<DatePicker>(R.id.date_picker) val datePicker = view.findViewById<DatePicker>(R.id.date_picker)
datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone() datePicker.findViewById<View>(Resources.getSystem().getIdentifier("day", "id", "android")).beGone()
val dateTime = DateTime(mCalendar.mTargetDate.toString()) val dateTime = DateTime(mCalendar.mTargetDate.toString())
datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null) datePicker.init(dateTime.year, dateTime.monthOfYear - 1, 1, null)
AlertDialog.Builder(context) AlertDialog.Builder(context!!)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) } .setPositiveButton(R.string.ok) { dialog, which -> positivePressed(dateTime, datePicker) }
.create().apply { .create().apply {

View File

@ -59,10 +59,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
this.inflater = inflater this.inflater = inflater
mRowHeight = (context.resources.getDimension(R.dimen.weekly_view_row_height)).toInt() mRowHeight = (context!!.resources.getDimension(R.dimen.weekly_view_row_height)).toInt()
minScrollY = mRowHeight * context.config.startWeeklyAt minScrollY = mRowHeight * context!!.config.startWeeklyAt
mWeekTimestamp = arguments.getInt(WEEK_START_TIMESTAMP) mWeekTimestamp = arguments!!.getInt(WEEK_START_TIMESTAMP)
primaryColor = context.config.primaryColor primaryColor = context!!.config.primaryColor
mRes = resources mRes = resources
allDayRows.add(HashSet()) allDayRows.add(HashSet())
@ -84,7 +84,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
(0..6).map { inflater.inflate(R.layout.stroke_vertical_divider, mView.week_vertical_grid_holder) } (0..6).map { inflater.inflate(R.layout.stroke_vertical_divider, mView.week_vertical_grid_holder) }
(0..23).map { inflater.inflate(R.layout.stroke_horizontal_divider, mView.week_horizontal_grid_holder) } (0..23).map { inflater.inflate(R.layout.stroke_horizontal_divider, mView.week_horizontal_grid_holder) }
mCalendar = WeeklyCalendarImpl(this, context) mCalendar = WeeklyCalendarImpl(this, context!!)
wasFragmentInit = true wasFragmentInit = true
return mView return mView
} }
@ -114,8 +114,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
return return
mView.week_events_scrollview.viewTreeObserver.removeOnGlobalLayoutListener(this) mView.week_events_scrollview.viewTreeObserver.removeOnGlobalLayoutListener(this)
minScrollY = mRowHeight * context.config.startWeeklyAt minScrollY = mRowHeight * context!!.config.startWeeklyAt
maxScrollY = mRowHeight * context.config.endWeeklyAt maxScrollY = mRowHeight * context!!.config.endWeeklyAt
val bounds = Rect() val bounds = Rect()
week_events_holder.getGlobalVisibleRect(bounds) week_events_holder.getGlobalVisibleRect(bounds)
@ -130,12 +130,12 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private fun setupDayLabels() { private fun setupDayLabels() {
var curDay = Formatter.getDateTimeFromTS(mWeekTimestamp) var curDay = Formatter.getDateTimeFromTS(mWeekTimestamp)
val textColor = context.config.textColor val textColor = context!!.config.textColor
val todayCode = Formatter.getDayCodeFromDateTime(DateTime()) val todayCode = Formatter.getDayCodeFromDateTime(DateTime())
for (i in 0..6) { for (i in 0..6) {
val dayCode = Formatter.getDayCodeFromDateTime(curDay) val dayCode = Formatter.getDayCodeFromDateTime(curDay)
val dayLetter = getDayLetter(curDay.dayOfWeek) val dayLetter = getDayLetter(curDay.dayOfWeek)
mView.findViewById<TextView>(mRes.getIdentifier("week_day_label_$i", "id", context.packageName)).apply { mView.findViewById<TextView>(mRes.getIdentifier("week_day_label_$i", "id", context!!.packageName)).apply {
text = "$dayLetter\n${curDay.dayOfMonth}" text = "$dayLetter\n${curDay.dayOfMonth}"
setTextColor(if (todayCode == dayCode) primaryColor else textColor) setTextColor(if (todayCode == dayCode) primaryColor else textColor)
if (todayCode == dayCode) if (todayCode == dayCode)
@ -229,19 +229,19 @@ class WeekFragment : Fragment(), WeeklyCalendar {
if (mWasDestroyed) if (mWasDestroyed)
return return
activity.runOnUiThread { activity!!.runOnUiThread {
if (context != null && isAdded) if (context != null && isAdded)
addEvents() addEvents()
} }
} }
private fun addEvents() { private fun addEvents() {
val filtered = context.getFilteredEvents(events) val filtered = context!!.getFilteredEvents(events)
initGrid() initGrid()
allDayHolders.clear() allDayHolders.clear()
allDayRows.clear() allDayRows.clear()
allDayRows.add(HashSet<Int>()) allDayRows.add(HashSet())
week_all_day_holder?.removeAllViews() week_all_day_holder?.removeAllViews()
addNewLine() addNewLine()
@ -251,7 +251,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val minimalHeight = mRes.getDimension(R.dimen.weekly_view_minimal_event_height).toInt() val minimalHeight = mRes.getDimension(R.dimen.weekly_view_minimal_event_height).toInt()
var hadAllDayEvent = false var hadAllDayEvent = false
val replaceDescription = context.config.replaceDescription val replaceDescription = context!!.config.replaceDescription
val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description })) val sorted = filtered.sortedWith(compareBy({ it.startTS }, { it.endTS }, { it.title }, { if (replaceDescription) it.location else it.description }))
for (event in sorted) { for (event in sorted) {
if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) { if (event.getIsAllDay() || Formatter.getDayCodeFromTS(event.startTS) != Formatter.getDayCodeFromTS(event.endTS)) {
@ -260,7 +260,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
} else { } else {
val startDateTime = Formatter.getDateTimeFromTS(event.startTS) val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
val endDateTime = Formatter.getDateTimeFromTS(event.endTS) val endDateTime = Formatter.getDateTimeFromTS(event.endTS)
val dayOfWeek = startDateTime.plusDays(if (context.config.isSundayFirst) 1 else 0).dayOfWeek - 1 val dayOfWeek = startDateTime.plusDays(if (context!!.config.isSundayFirst) 1 else 0).dayOfWeek - 1
val layout = getColumnWithId(dayOfWeek) val layout = getColumnWithId(dayOfWeek)
val startMinutes = startDateTime.minuteOfDay val startMinutes = startDateTime.minuteOfDay
@ -278,7 +278,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
minHeight = if (event.startTS == event.endTS) minimalHeight else (duration * minuteHeight).toInt() - 1 minHeight = if (event.startTS == event.endTS) minimalHeight else (duration * minuteHeight).toInt() - 1
} }
setOnClickListener { setOnClickListener {
Intent(activity.applicationContext, EventActivity::class.java).apply { Intent(context, EventActivity::class.java).apply {
putExtra(EVENT_ID, event.id) putExtra(EVENT_ID, event.id)
putExtra(EVENT_OCCURRENCE_TS, event.startTS) putExtra(EVENT_OCCURRENCE_TS, event.startTS)
startActivity(this) startActivity(this)
@ -394,7 +394,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
calculateExtraHeight() calculateExtraHeight()
setOnClickListener { setOnClickListener {
Intent(activity.applicationContext, EventActivity::class.java).apply { Intent(context, EventActivity::class.java).apply {
putExtra(EVENT_ID, event.id) putExtra(EVENT_ID, event.id)
putExtra(EVENT_OCCURRENCE_TS, event.startTS) putExtra(EVENT_OCCURRENCE_TS, event.startTS)
startActivity(this) startActivity(this)
@ -427,7 +427,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
mWasDestroyed = true mWasDestroyed = true
} }
private fun getColumnWithId(id: Int) = mView.findViewById<ViewGroup>(mRes.getIdentifier("week_column_$id", "id", context.packageName)) private fun getColumnWithId(id: Int) = mView.findViewById<ViewGroup>(mRes.getIdentifier("week_column_$id", "id", context!!.packageName))
fun updateScrollY(y: Int) { fun updateScrollY(y: Int) {
if (wasFragmentInit) if (wasFragmentInit)

View File

@ -30,20 +30,20 @@ class YearFragment : Fragment(), YearlyCalendar {
lateinit var mView: View lateinit var mView: View
lateinit var mCalendar: YearlyCalendarImpl lateinit var mCalendar: YearlyCalendarImpl
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater!!.inflate(R.layout.fragment_year, container, false) mView = inflater.inflate(R.layout.fragment_year, container, false)
mYear = arguments.getInt(YEAR_LABEL) mYear = arguments!!.getInt(YEAR_LABEL)
context.updateTextColors(mView.calendar_holder) context!!.updateTextColors(mView.calendar_holder)
setupMonths() setupMonths()
mCalendar = YearlyCalendarImpl(this, context, mYear) mCalendar = YearlyCalendarImpl(this, context!!, mYear)
return mView return mView
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
val sundayFirst = context.config.isSundayFirst val sundayFirst = context!!.config.isSundayFirst
if (sundayFirst != mSundayFirst) { if (sundayFirst != mSundayFirst) {
mSundayFirst = sundayFirst mSundayFirst = sundayFirst
setupMonths() setupMonths()
@ -64,7 +64,7 @@ class YearFragment : Fragment(), YearlyCalendar {
markCurrentMonth(res) markCurrentMonth(res)
for (i in 1..12) { for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_" + i, "id", activity.packageName)) val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_" + i, "id", context!!.packageName))
var dayOfWeek = dateTime.withMonthOfYear(i).dayOfWeek().get() var dayOfWeek = dateTime.withMonthOfYear(i).dayOfWeek().get()
if (!mSundayFirst) if (!mSundayFirst)
dayOfWeek-- dayOfWeek--
@ -79,10 +79,10 @@ class YearFragment : Fragment(), YearlyCalendar {
private fun markCurrentMonth(res: Resources) { private fun markCurrentMonth(res: Resources) {
val now = DateTime() val now = DateTime()
if (now.year == mYear) { if (now.year == mYear) {
val monthLabel = mView.findViewById<TextView>(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) val monthLabel = mView.findViewById<TextView>(res.getIdentifier("month_${now.monthOfYear}_label", "id", context!!.packageName))
monthLabel.setTextColor(context.config.primaryColor) monthLabel.setTextColor(context!!.config.primaryColor)
val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_${now.monthOfYear}", "id", activity.packageName)) val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_${now.monthOfYear}", "id", context!!.packageName))
monthView.todaysId = now.dayOfMonth monthView.todaysId = now.dayOfMonth
} }
} }
@ -97,7 +97,7 @@ class YearFragment : Fragment(), YearlyCalendar {
lastHash = hashCode lastHash = hashCode
val res = resources val res = resources
for (i in 1..12) { for (i in 1..12) {
val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_$i", "id", context.packageName)) val monthView = mView.findViewById<SmallMonthView>(res.getIdentifier("month_$i", "id", context!!.packageName))
monthView.setEvents(events.get(i)) monthView.setEvents(events.get(i))
} }
} }

View File

@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

View File

@ -1,6 +1,6 @@
#Fri Mar 03 23:10:59 CET 2017 #Tue Nov 07 14:52:59 CET 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip