update Commons to 5.1.0, min Android OS version to 5 + adapter changes

This commit is contained in:
tibbi 2018-10-16 13:03:29 +02:00
parent 01b9aec7cd
commit a9e7dec84f
44 changed files with 137 additions and 196 deletions

View file

@ -8,7 +8,7 @@ android {
defaultConfig {
applicationId "com.simplemobiletools.calendar"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 28
versionCode 129
versionName "4.2.1"
@ -42,10 +42,10 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:4.8.8'
implementation 'com.simplemobiletools:commons:5.1.0'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.multidex:multidex:2.0.0'
}
Properties props = new Properties()

View file

@ -184,7 +184,7 @@
</receiver>
<provider
android:name="android.support.v4.content.FileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">

View file

@ -1,6 +1,6 @@
package com.simplemobiletools.calendar
import android.support.multidex.MultiDexApplication
import androidx.multidex.MultiDexApplication
import com.facebook.stetho.Stetho
import com.simplemobiletools.commons.extensions.checkUseEnglish

View file

@ -6,11 +6,11 @@ import android.app.TimePickerDialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.support.v4.app.NotificationManagerCompat
import android.text.method.LinkMovementMethod
import android.view.Menu
import android.view.MenuItem
import android.view.WindowManager
import androidx.core.app.NotificationManagerCompat
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.dialogs.*
import com.simplemobiletools.calendar.extensions.*
@ -863,10 +863,7 @@ class EventActivity : SimpleActivity() {
val datepicker = DatePickerDialog(this, mDialogTheme, startDateSetListener, mEventStartDateTime.year, mEventStartDateTime.monthOfYear - 1,
mEventStartDateTime.dayOfMonth)
if (isLollipopPlus()) {
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
}
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
datepicker.show()
}
@ -881,10 +878,7 @@ class EventActivity : SimpleActivity() {
val datepicker = DatePickerDialog(this, mDialogTheme, endDateSetListener, mEventEndDateTime.year, mEventEndDateTime.monthOfYear - 1,
mEventEndDateTime.dayOfMonth)
if (isLollipopPlus()) {
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
}
datepicker.datePicker.firstDayOfWeek = if (config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
datepicker.show()
}

View file

@ -11,11 +11,11 @@ import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.provider.ContactsContract
import android.support.v4.view.MenuItemCompat
import android.support.v7.widget.SearchView
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import androidx.appcompat.widget.SearchView
import androidx.core.view.MenuItemCompat
import com.simplemobiletools.calendar.BuildConfig
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.adapters.EventListAdapter
@ -612,7 +612,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun refreshViewPager() {
runOnUiThread {
if (!isActivityDestroyed()) {
if (!isDestroyed) {
currentFragments.last().refreshEvents()
}
}
@ -695,7 +695,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
private fun launchAbout() {
val licenses = LICENSE_JODA or LICENSE_STETHO or LICENSE_MULTISELECT or LICENSE_LEAK_CANARY
val licenses = LICENSE_JODA or LICENSE_STETHO or LICENSE_LEAK_CANARY
val faqItems = arrayListOf(
FAQItem(R.string.faq_1_title_commons, R.string.faq_1_text_commons),

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.activities
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.extensions.dbHelper
import com.simplemobiletools.calendar.extensions.rescheduleReminder

View file

@ -38,12 +38,6 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun prepareActionMode(menu: Menu) {}
override fun prepareItemSelection(viewHolder: ViewHolder) {}
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
viewHolder?.itemView?.event_item_frame?.isSelected = select
}
override fun actionItemPressed(id: Int) {
when (id) {
R.id.cab_share -> shareEvents()
@ -55,6 +49,10 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun getIsItemSelectable(position: Int) = true
override fun getItemSelectionKey(position: Int) = events.getOrNull(position)?.id
override fun getItemKeyPosition(key: Int) = events.indexOfFirst { it.id == key }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder {
val layoutId = when (viewType) {
ITEM_EVENT -> R.layout.event_item_day_view
@ -65,10 +63,10 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val event = events[position]
val view = holder.bindView(event, true, true) { itemView, layoutPosition ->
holder.bindView(event, true, true) { itemView, layoutPosition ->
setupView(itemView, event)
}
bindViewHolder(holder, position, view)
bindViewHolder(holder)
}
override fun getItemCount() = events.size
@ -85,6 +83,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
private fun setupView(view: View, event: Event) {
view.apply {
event_item_frame.isSelected = selectedKeys.contains(event.id)
event_item_title.text = event.title
event_item_description?.text = if (replaceDescriptionWithLocation) event.location else event.description
event_item_start.text = if (event.getIsAllDay()) allDayString else Formatter.getTimeFromTS(context, event.startTS)
@ -121,27 +120,16 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
}
}
private fun shareEvents() {
val eventIds = ArrayList<Int>(selectedPositions.size)
selectedPositions.forEach {
eventIds.add(events[it].id)
}
activity.shareEvents(eventIds.distinct())
}
private fun shareEvents() = activity.shareEvents(selectedKeys.distinct())
private fun askConfirmDelete() {
val eventIds = ArrayList<Int>(selectedPositions.size)
val timestamps = ArrayList<Int>(selectedPositions.size)
val eventsToDelete = ArrayList<Event>(selectedPositions.size)
selectedPositions.forEach {
val event = events[it]
eventsToDelete.add(event)
eventIds.add(event.id)
timestamps.add(event.startTS)
}
val eventIds = selectedKeys.toList()
val eventsToDelete = events.filter { selectedKeys.contains(it.id) }
val timestamps = eventsToDelete.map { it.startTS }
val positions = getSelectedItemPositions()
val hasRepeatableEvent = eventsToDelete.any { it.repeatInterval > 0 }
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) { it ->
events.removeAll(eventsToDelete)
val nonRepeatingEventIDs = eventsToDelete.filter { it.repeatInterval == 0 }.map { it.id.toString() }.toTypedArray()
@ -149,7 +137,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
val repeatingEventIDs = eventsToDelete.filter { it.repeatInterval != 0 }.map { it.id }
activity.handleEventDeleting(repeatingEventIDs, timestamps, it)
removeSelectedItems()
removeSelectedItems(positions)
}
}
}

View file

@ -38,6 +38,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
private var currentItemsHash = listItems.hashCode()
init {
setupDragListener(true)
var firstNonPastSectionIndex = -1
listItems.forEachIndexed { index, listItem ->
if (firstNonPastSectionIndex == -1 && listItem is ListSection) {
@ -58,12 +59,6 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun prepareActionMode(menu: Menu) {}
override fun prepareItemSelection(viewHolder: ViewHolder) {}
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
viewHolder?.itemView?.event_item_frame?.isSelected = select
}
override fun actionItemPressed(id: Int) {
when (id) {
R.id.cab_share -> shareEvents()
@ -75,6 +70,10 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun getIsItemSelectable(position: Int) = listItems[position] is ListEvent
override fun getItemSelectionKey(position: Int) = (listItems.getOrNull(position) as? ListEvent)?.id
override fun getItemKeyPosition(key: Int) = listItems.indexOfFirst { (it as? ListEvent)?.id == key }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyRecyclerViewAdapter.ViewHolder {
val layoutId = when (viewType) {
ITEM_EVENT -> R.layout.event_list_item
@ -86,14 +85,14 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
val listItem = listItems[position]
val view = holder.bindView(listItem, true, allowLongClick) { itemView, layoutPosition ->
holder.bindView(listItem, true, allowLongClick) { itemView, layoutPosition ->
if (listItem is ListSection) {
setupListSection(itemView, listItem, position)
} else if (listItem is ListEvent) {
setupListEvent(itemView, listItem)
}
}
bindViewHolder(holder, position, view)
bindViewHolder(holder)
}
override fun getItemCount() = listItems.size
@ -127,6 +126,7 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
private fun setupListEvent(view: View, listEvent: ListEvent) {
view.apply {
event_item_frame.isSelected = selectedKeys.contains(listEvent.id)
event_item_title.text = listEvent.title
event_item_description?.text = if (replaceDescription) listEvent.location else listEvent.description
event_item_start.text = if (listEvent.isAllDay) allDayString else Formatter.getTimeFromTS(context, listEvent.startTS)
@ -185,30 +185,12 @@ class EventListAdapter(activity: SimpleActivity, var listItems: ArrayList<ListIt
}
}
private fun shareEvents() {
val eventIds = ArrayList<Int>(selectedPositions.size)
selectedPositions.forEach {
val item = listItems[it]
if (item is ListEvent) {
eventIds.add(item.id)
}
}
activity.shareEvents(eventIds.distinct())
}
private fun shareEvents() = activity.shareEvents(selectedKeys.distinct())
private fun askConfirmDelete() {
val eventIds = ArrayList<Int>(selectedPositions.size)
val timestamps = ArrayList<Int>(selectedPositions.size)
val eventsToDelete = ArrayList<ListEvent>(selectedPositions.size)
selectedPositions.sortedDescending().forEach {
val item = listItems[it]
if (item is ListEvent) {
eventIds.add(item.id)
timestamps.add(item.startTS)
eventsToDelete.add(item)
}
}
val eventIds = selectedKeys.toList()
val eventsToDelete = listItems.filter { selectedKeys.contains((it as? ListEvent)?.id) } as List<ListEvent>
val timestamps = eventsToDelete.map { (it as? ListEvent)?.startTS }.filterNotNull()
val hasRepeatableEvent = eventsToDelete.any { it.isRepeatable }
DeleteEventDialog(activity, eventIds, hasRepeatableEvent) {

View file

@ -1,87 +1,69 @@
package com.simplemobiletools.calendar.adapters
import android.support.v7.widget.RecyclerView
import android.util.SparseArray
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.models.EventType
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.setFillWithStroke
import com.simplemobiletools.commons.interfaces.MyAdapterListener
import kotlinx.android.synthetic.main.filter_event_type_view.view.*
import java.util.*
class FilterEventTypeAdapter(val activity: SimpleActivity, val eventTypes: List<EventType>, val displayEventTypes: Set<String>) :
RecyclerView.Adapter<FilterEventTypeAdapter.ViewHolder>() {
private val itemViews = SparseArray<View>()
private val selectedPositions = HashSet<Int>()
private val selectedKeys = HashSet<Int>()
init {
eventTypes.forEachIndexed { index, eventType ->
if (displayEventTypes.contains(eventType.id.toString())) {
selectedPositions.add(index)
selectedKeys.add(eventType.id)
}
}
}
private fun toggleItemSelection(select: Boolean, pos: Int) {
private fun toggleItemSelection(select: Boolean, eventType: EventType, pos: Int) {
if (select) {
if (itemViews[pos] != null) {
selectedPositions.add(pos)
}
selectedKeys.add(eventType.id)
} else {
selectedPositions.remove(pos)
selectedKeys.remove(eventType.id)
}
itemViews[pos]?.filter_event_type_checkbox?.isChecked = select
notifyItemChanged(pos)
}
private val adapterListener = object : MyAdapterListener {
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
toggleItemSelection(select, position)
}
override fun getSelectedPositions() = selectedPositions
override fun itemLongClicked(position: Int) {}
}
fun getSelectedItemsSet(): HashSet<String> {
val selectedItemsSet = HashSet<String>(selectedPositions.size)
selectedPositions.forEach { selectedItemsSet.add(eventTypes[it].id.toString()) }
return selectedItemsSet
}
fun getSelectedItemsSet() = selectedKeys.asSequence().map { it.toString() }.toHashSet()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = activity.layoutInflater.inflate(R.layout.filter_event_type_view, parent, false)
return ViewHolder(view, adapterListener, activity)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val eventType = eventTypes[position]
itemViews.put(position, holder.bindView(eventType))
toggleItemSelection(selectedPositions.contains(position), position)
holder.bindView(eventType)
}
override fun getItemCount() = eventTypes.size
class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity) : RecyclerView.ViewHolder(view) {
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bindView(eventType: EventType): View {
val isSelected = selectedKeys.contains(eventType.id)
itemView.apply {
filter_event_type_checkbox.isChecked = isSelected
filter_event_type_checkbox.setColors(activity.config.textColor, activity.getAdjustedPrimaryColor(), activity.config.backgroundColor)
filter_event_type_checkbox.text = eventType.getDisplayTitle()
filter_event_type_color.setFillWithStroke(eventType.color, activity.config.backgroundColor)
filter_event_type_holder.setOnClickListener { viewClicked(!filter_event_type_checkbox.isChecked) }
filter_event_type_holder.setOnClickListener { viewClicked(!isSelected, eventType) }
}
return itemView
}
private fun viewClicked(select: Boolean) {
adapterListener.toggleItemSelectionAdapter(select, adapterPosition)
private fun viewClicked(select: Boolean, eventType: EventType) {
toggleItemSelection(select, eventType, adapterPosition)
}
}
}

View file

@ -31,12 +31,6 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis
override fun prepareActionMode(menu: Menu) {}
override fun prepareItemSelection(viewHolder: ViewHolder) {}
override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {
viewHolder?.itemView?.event_item_frame?.isSelected = select
}
override fun actionItemPressed(id: Int) {
when (id) {
R.id.cab_delete -> askConfirmDelete()
@ -47,20 +41,29 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis
override fun getIsItemSelectable(position: Int) = true
override fun getItemSelectionKey(position: Int) = eventTypes.getOrNull(position)?.id
override fun getItemKeyPosition(key: Int) = eventTypes.indexOfFirst { it.id == key }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_event_type, parent)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val eventType = eventTypes[position]
val view = holder.bindView(eventType, true, true) { itemView, layoutPosition ->
holder.bindView(eventType, true, true) { itemView, layoutPosition ->
setupView(itemView, eventType)
}
bindViewHolder(holder, position, view)
bindViewHolder(holder)
}
override fun getItemCount() = eventTypes.size
private fun getItemWithKey(key: Int): EventType? = eventTypes.firstOrNull { it.id == key }
private fun getSelectedItems() = eventTypes.filter { selectedKeys.contains(it.id) } as ArrayList<EventType>
private fun setupView(view: View, eventType: EventType) {
view.apply {
event_item_frame.isSelected = selectedKeys.contains(eventType.id)
event_type_title.text = eventType.getDisplayTitle()
event_type_color.setFillWithStroke(eventType.color, activity.config.backgroundColor)
event_type_title.setTextColor(textColor)
@ -68,8 +71,7 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis
}
private fun askConfirmDelete() {
val eventTypes = ArrayList<EventType>(selectedPositions.size)
selectedPositions.forEach { eventTypes.add(this.eventTypes[it]) }
val eventTypes = eventTypes.filter { selectedKeys.contains(it.id) } as ArrayList<EventType>
if (activity.dbHelper.doEventTypesContainEvent(eventTypes)) {
val MOVE_EVENTS = 0
@ -90,25 +92,22 @@ class ManageEventTypesAdapter(activity: SimpleActivity, val eventTypes: ArrayLis
}
private fun deleteEventTypes(deleteEvents: Boolean) {
val eventTypesToDelete = ArrayList<EventType>(selectedPositions.size)
val eventTypesToDelete = getSelectedItems()
for (pos in selectedPositions) {
if (eventTypes[pos].id == DBHelper.REGULAR_EVENT_TYPE_ID) {
for (key in selectedKeys) {
val type = getItemWithKey(key) ?: continue
if (type.id == DBHelper.REGULAR_EVENT_TYPE_ID) {
activity.toast(R.string.cannot_delete_default_type)
selectedPositions.remove(pos)
toggleItemSelection(false, pos)
eventTypesToDelete.remove(type)
toggleItemSelection(false, getItemKeyPosition(type.id))
break
}
}
selectedPositions.sortedDescending().forEach {
val eventType = eventTypes[it]
eventTypesToDelete.add(eventType)
}
eventTypes.removeAll(eventTypesToDelete)
if (listener?.deleteEventTypes(eventTypesToDelete, deleteEvents) == true) {
removeSelectedItems()
val positions = getSelectedItemPositions()
eventTypes.removeAll(eventTypesToDelete)
removeSelectedItems(positions)
}
}
}

View file

@ -1,10 +1,10 @@
package com.simplemobiletools.calendar.adapters
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.util.SparseArray
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.simplemobiletools.calendar.fragments.DayFragment
import com.simplemobiletools.calendar.helpers.DAY_CODE
import com.simplemobiletools.calendar.interfaces.NavigationListener

View file

@ -1,10 +1,10 @@
package com.simplemobiletools.calendar.adapters
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.util.SparseArray
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.simplemobiletools.calendar.fragments.MonthFragment
import com.simplemobiletools.calendar.helpers.DAY_CODE
import com.simplemobiletools.calendar.interfaces.NavigationListener

View file

@ -1,10 +1,10 @@
package com.simplemobiletools.calendar.adapters
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.util.SparseArray
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.simplemobiletools.calendar.fragments.WeekFragment
import com.simplemobiletools.calendar.helpers.WEEK_START_TIMESTAMP
import com.simplemobiletools.calendar.interfaces.WeekFragmentListener

View file

@ -1,10 +1,10 @@
package com.simplemobiletools.calendar.adapters
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.util.SparseArray
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import com.simplemobiletools.calendar.fragments.YearFragment
import com.simplemobiletools.calendar.helpers.YEAR_LABEL

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.helpers.DAY

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.helpers.DELETE_ALL_OCCURRENCES

View file

@ -1,6 +1,6 @@
package com.simplemobiletools.calendar.dialogs
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity

View file

@ -1,8 +1,8 @@
package com.simplemobiletools.calendar.dialogs
import android.support.v7.app.AlertDialog
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.adapters.FilterEventTypeAdapter
@ -21,7 +21,7 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal
activity.dbHelper.getEventTypes {
val eventTypes = HashSet<String>()
it.mapTo(eventTypes, { it.id.toString() })
it.mapTo(eventTypes) { it.id.toString() }
activity.runOnUiThread {
export_events_types_list.adapter = FilterEventTypeAdapter(activity, it, eventTypes)

View file

@ -1,6 +1,6 @@
package com.simplemobiletools.calendar.dialogs
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity
import com.simplemobiletools.calendar.adapters.FilterEventTypeAdapter
@ -19,7 +19,7 @@ class FilterEventTypesDialog(val activity: SimpleActivity, val callback: () -> U
view.filter_event_types_list.adapter = FilterEventTypeAdapter(activity, eventTypes, displayEventTypes)
dialog = AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, { dialogInterface, i -> confirmEventTypes() })
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmEventTypes() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.filter_events_by_type)

View file

@ -1,6 +1,6 @@
package com.simplemobiletools.calendar.dialogs
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.SimpleActivity

View file

@ -3,8 +3,8 @@ package com.simplemobiletools.calendar.dialogs
import android.annotation.SuppressLint
import android.app.Activity
import android.app.DatePickerDialog
import android.support.v7.app.AlertDialog
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.calendar.extensions.seconds
@ -13,7 +13,6 @@ import com.simplemobiletools.calendar.helpers.getNowSeconds
import com.simplemobiletools.commons.extensions.getDialogTheme
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.commons.helpers.isLollipopPlus
import kotlinx.android.synthetic.main.dialog_repeat_limit_type_picker.view.*
import org.joda.time.DateTime
import java.util.*
@ -86,10 +85,7 @@ class RepeatLimitTypePickerDialog(val activity: Activity, var repeatLimit: Int,
val datepicker = DatePickerDialog(activity, activity.getDialogTheme(), repetitionLimitDateSetListener, repeatLimitDateTime.year,
repeatLimitDateTime.monthOfYear - 1, repeatLimitDateTime.dayOfMonth)
if (isLollipopPlus()) {
datepicker.datePicker.firstDayOfWeek = if (activity.config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
}
datepicker.datePicker.firstDayOfWeek = if (activity.config.isSundayFirst) Calendar.SUNDAY else Calendar.MONDAY
datepicker.show()
}

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config
import com.simplemobiletools.commons.extensions.setupDialogStuff

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.dialogs
import android.support.v7.app.AlertDialog
import android.support.v7.widget.SwitchCompat
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.SwitchCompat
import android.text.TextUtils
import android.view.ViewGroup
import android.widget.RelativeLayout

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.graphics.Color
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import android.widget.RadioButton
import android.widget.RadioGroup

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.graphics.Color
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import android.widget.RadioButton
import android.widget.RadioGroup

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.graphics.Color
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.view.ViewGroup
import android.widget.RadioGroup
import com.simplemobiletools.calendar.R

View file

@ -1,7 +1,7 @@
package com.simplemobiletools.calendar.dialogs
import android.app.Activity
import android.support.v7.app.AlertDialog
import androidx.appcompat.app.AlertDialog
import android.widget.ImageView
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.extensions.config

View file

@ -55,9 +55,9 @@ fun Activity.showEventRepeatIntervalDialog(curSeconds: Int, callback: (minutes:
}
val items = ArrayList<RadioItem>(seconds.size + 1)
seconds.mapIndexedTo(items, { index, value ->
seconds.mapIndexedTo(items) { index, value ->
RadioItem(index, getRepetitionText(value), value)
})
}
var selectedIndex = 0
seconds.forEachIndexed { index, value ->

View file

@ -14,13 +14,13 @@ import android.media.AudioAttributes
import android.net.Uri
import android.os.Bundle
import android.provider.CalendarContract
import android.support.v4.app.AlarmManagerCompat
import android.support.v4.app.NotificationCompat
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.app.AlarmManagerCompat
import androidx.core.app.NotificationCompat
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.EventActivity
import com.simplemobiletools.calendar.activities.SimpleActivity

View file

@ -2,13 +2,13 @@ package com.simplemobiletools.calendar.fragments
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.DatePicker
import android.widget.RelativeLayout
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.EventActivity
import com.simplemobiletools.calendar.activities.SimpleActivity

View file

@ -2,10 +2,10 @@ package com.simplemobiletools.calendar.fragments
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.view.ViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.calendar.R
import com.simplemobiletools.calendar.activities.MainActivity
import com.simplemobiletools.calendar.adapters.MyDayPagerAdapter

View file

@ -3,8 +3,8 @@ package com.simplemobiletools.calendar.fragments
import android.content.Context
import android.content.res.Resources
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.appcompat.app.AlertDialog
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.view.ViewPager
import androidx.viewpager.widget.ViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

View file

@ -1,6 +1,6 @@
package com.simplemobiletools.calendar.fragments
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
abstract class MyFragmentHolder : Fragment() {
abstract fun goToToday()

View file

@ -5,7 +5,7 @@ import android.content.res.Resources
import android.graphics.Rect
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.util.SparseIntArray
import android.view.*
import android.widget.ImageView

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.view.ViewPager
import androidx.viewpager.widget.ViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments
import android.content.res.Resources
import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.util.SparseArray
import android.view.LayoutInflater
import android.view.View

View file

@ -2,7 +2,7 @@ package com.simplemobiletools.calendar.fragments
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.view.ViewPager
import androidx.viewpager.widget.ViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/day_coordinator"
@ -22,4 +22,4 @@
app:backgroundTint="@color/color_primary"
app:rippleColor="@color/pressed_item_foreground"/>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calendar_coordinator"
@ -65,4 +65,4 @@
app:layoutManager="com.simplemobiletools.commons.views.MyLinearLayoutManager"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -12,8 +12,8 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin">
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/export_events_folder_label"
@ -26,11 +26,11 @@
android:id="@+id/export_events_folder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginLeft="@dimen/activity_margin"
android:paddingBottom="@dimen/small_margin"
android:layout_marginBottom="@dimen/activity_margin"
android:paddingTop="@dimen/small_margin"
android:paddingRight="@dimen/small_margin"
android:paddingTop="@dimen/small_margin"/>
android:paddingBottom="@dimen/small_margin"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/export_events_filename_label"
@ -43,18 +43,18 @@
android:id="@+id/export_events_filename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_margin"
android:layout_marginLeft="@dimen/activity_margin"
android:paddingRight="@dimen/small_margin"
android:layout_marginBottom="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingRight="@dimen/small_margin"
android:textSize="@dimen/normal_text_size"/>
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
android:id="@+id/export_events_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/small_margin"
android:paddingTop="@dimen/small_margin"
android:paddingBottom="@dimen/small_margin"
android:text="@string/export_past_events_too"/>
<LinearLayout
@ -68,8 +68,8 @@
android:id="@+id/export_events_divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginBottom="@dimen/medium_margin"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:background="@color/divider_grey"
android:importantForAccessibility="no"/>
@ -80,7 +80,7 @@
android:text="@string/include_event_types"
android:textSize="@dimen/smaller_text_size"/>
<android.support.v7.widget.RecyclerView
<com.simplemobiletools.commons.views.MyRecyclerView
android:id="@+id/export_events_types_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
<com.simplemobiletools.commons.views.MyRecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/filter_event_types_list"

View file

@ -5,7 +5,7 @@
android:id="@+id/search"
android:icon="@drawable/ic_search"
android:title="@string/search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|ifRoom"/>
<item
android:id="@+id/go_to_today"

View file

@ -9,7 +9,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong