From 1ffd9403ebe769149ac5469fcd5bbc094103984f Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 27 Nov 2022 10:19:56 +0100 Subject: [PATCH] add a button for managing event types to the event type picker --- app/build.gradle | 2 +- .../calendar/pro/activities/EventActivity.kt | 11 ++++- .../pro/activities/SettingsActivity.kt | 2 +- .../calendar/pro/activities/TaskActivity.kt | 3 +- .../pro/dialogs/ImportEventsDialog.kt | 2 +- .../pro/dialogs/SelectEventTypeDialog.kt | 15 +++++-- .../res/layout/dialog_select_event_type.xml | 41 +++++++++++++++++++ 7 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 app/src/main/res/layout/dialog_select_event_type.xml diff --git a/app/build.gradle b/app/build.gradle index a4a5c8504..3aafa62d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -70,7 +70,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:92e9ea7598' + implementation 'com.github.SimpleMobileTools:Simple-Commons:9795366108' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt index 8ec102fee..548efdef0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/EventActivity.kt @@ -799,7 +799,16 @@ class EventActivity : SimpleActivity() { private fun showEventTypeDialog() { hideKeyboard() - SelectEventTypeDialog(this, mEventTypeId, false, true, false, true) { + + SelectEventTypeDialog( + activity = this, + currEventType = mEventTypeId, + showCalDAVCalendars = false, + showNewEventTypeOption = true, + addLastUsedOneAsFirstOption = false, + showOnlyWritable = true, + showManageEventTypes = true + ) { mEventTypeId = it.id!! updateEventType() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt index 71fff089e..1c985c3ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/SettingsActivity.kt @@ -834,7 +834,7 @@ class SettingsActivity : SimpleActivity() { updateDefaultEventTypeText() settings_default_event_type.text = getString(R.string.last_used_one) settings_default_event_type_holder.setOnClickListener { - SelectEventTypeDialog(this, config.defaultEventTypeId, true, false, true, true) { + SelectEventTypeDialog(this, config.defaultEventTypeId, true, false, true, true, false) { config.defaultEventTypeId = it.id!! updateDefaultEventTypeText() } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt index 7e83e5df4..bedf9b6b7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/activities/TaskActivity.kt @@ -705,7 +705,8 @@ class TaskActivity : SimpleActivity() { showCalDAVCalendars = false, showNewEventTypeOption = true, addLastUsedOneAsFirstOption = false, - showOnlyWritable = true + showOnlyWritable = true, + showManageEventTypes = true ) { mEventTypeId = it.id!! updateEventType() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt index c819e3538..4e7082a55 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/ImportEventsDialog.kt @@ -51,7 +51,7 @@ class ImportEventsDialog(val activity: SimpleActivity, val path: String, val cal val view = (activity.layoutInflater.inflate(R.layout.dialog_import_events, null) as ViewGroup).apply { updateEventType(this) import_event_type_title.setOnClickListener { - SelectEventTypeDialog(activity, currEventTypeId, true, true, false, true) { + SelectEventTypeDialog(activity, currEventTypeId, true, true, false, true, false) { currEventTypeId = it.id!! currEventTypeCalDAVCalendarId = it.caldavCalendarId diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SelectEventTypeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SelectEventTypeDialog.kt index 4fdf43155..e179867ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SelectEventTypeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/dialogs/SelectEventTypeDialog.kt @@ -1,21 +1,23 @@ package com.simplemobiletools.calendar.pro.dialogs import android.app.Activity +import android.content.Intent import android.graphics.Color import android.view.ViewGroup import android.widget.RadioGroup import androidx.appcompat.app.AlertDialog import com.simplemobiletools.calendar.pro.R +import com.simplemobiletools.calendar.pro.activities.ManageEventTypesActivity import com.simplemobiletools.calendar.pro.extensions.eventsHelper import com.simplemobiletools.calendar.pro.models.EventType import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.views.MyCompatRadioButton -import kotlinx.android.synthetic.main.dialog_select_radio_group.view.* +import kotlinx.android.synthetic.main.dialog_select_event_type.view.* import kotlinx.android.synthetic.main.radio_button_with_color.view.* class SelectEventTypeDialog( val activity: Activity, val currEventType: Long, val showCalDAVCalendars: Boolean, val showNewEventTypeOption: Boolean, - val addLastUsedOneAsFirstOption: Boolean, val showOnlyWritable: Boolean, val callback: (eventType: EventType) -> Unit + val addLastUsedOneAsFirstOption: Boolean, val showOnlyWritable: Boolean, var showManageEventTypes: Boolean, val callback: (eventType: EventType) -> Unit ) { private val NEW_EVENT_TYPE_ID = -2L private val LAST_USED_EVENT_TYPE_ID = -1L @@ -26,8 +28,15 @@ class SelectEventTypeDialog( private var eventTypes = ArrayList() init { - val view = activity.layoutInflater.inflate(R.layout.dialog_select_radio_group, null) as ViewGroup + val view = activity.layoutInflater.inflate(R.layout.dialog_select_event_type, null) as ViewGroup radioGroup = view.dialog_radio_group + view.dialog_manage_event_types.apply { + beVisibleIf(showManageEventTypes) + setOnClickListener { + activity.startActivity(Intent(activity, ManageEventTypesActivity::class.java)) + dialog?.dismiss() + } + } activity.eventsHelper.getEventTypes(activity, showOnlyWritable) { eventTypes = it diff --git a/app/src/main/res/layout/dialog_select_event_type.xml b/app/src/main/res/layout/dialog_select_event_type.xml new file mode 100644 index 000000000..b7d7cc637 --- /dev/null +++ b/app/src/main/res/layout/dialog_select_event_type.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + +