add a button for managing event types to the event type picker
This commit is contained in:
parent
2a261aec18
commit
1ffd9403eb
|
@ -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'
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -705,7 +705,8 @@ class TaskActivity : SimpleActivity() {
|
|||
showCalDAVCalendars = false,
|
||||
showNewEventTypeOption = true,
|
||||
addLastUsedOneAsFirstOption = false,
|
||||
showOnlyWritable = true
|
||||
showOnlyWritable = true,
|
||||
showManageEventTypes = true
|
||||
) {
|
||||
mEventTypeId = it.id!!
|
||||
updateEventType()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<EventType>()
|
||||
|
||||
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
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/dialog_radio_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_wrapper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/dialog_radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/normal_margin" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dialog_radio_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/divider_grey"
|
||||
android:importantForAccessibility="no" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/dialog_manage_event_types"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_background"
|
||||
android:paddingStart="@dimen/big_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingEnd="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/manage_event_types" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
Loading…
Reference in New Issue