adding an Attendees field at events

This commit is contained in:
tibbi 2019-03-13 13:48:28 +01:00
parent ba6e957ac8
commit f55900f3da
7 changed files with 85 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.WindowManager import android.view.WindowManager
import android.widget.ImageView import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import com.simplemobiletools.calendar.pro.R import com.simplemobiletools.calendar.pro.R
import com.simplemobiletools.calendar.pro.dialogs.* import com.simplemobiletools.calendar.pro.dialogs.*
@ -25,8 +26,10 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.MyEditText
import kotlinx.android.synthetic.main.activity_event.* import kotlinx.android.synthetic.main.activity_event.*
import kotlinx.android.synthetic.main.activity_event.view.* import kotlinx.android.synthetic.main.activity_event.view.*
import kotlinx.android.synthetic.main.item_attendee.view.*
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.* import java.util.*
import java.util.regex.Pattern import java.util.regex.Pattern
@ -58,7 +61,8 @@ class EventActivity : SimpleActivity() {
private var mDialogTheme = 0 private var mDialogTheme = 0
private var mEventOccurrenceTS = 0L private var mEventOccurrenceTS = 0L
private var mEventCalendarId = STORED_LOCALLY_ONLY private var mEventCalendarId = STORED_LOCALLY_ONLY
private var wasActivityInitialized = false private var mWasActivityInitialized = false
private var mAttendeeViews = ArrayList<MyEditText>()
private lateinit var mEventStartDateTime: DateTime private lateinit var mEventStartDateTime: DateTime
private lateinit var mEventEndDateTime: DateTime private lateinit var mEventEndDateTime: DateTime
@ -123,6 +127,7 @@ class EventActivity : SimpleActivity() {
updateTexts() updateTexts()
updateEventType() updateEventType()
updateCalDAVCalendar() updateCalDAVCalendar()
updateAttendees()
} }
event_show_on_map.setOnClickListener { showOnMap() } event_show_on_map.setOnClickListener { showOnMap() }
@ -181,12 +186,12 @@ class EventActivity : SimpleActivity() {
updateTextColors(event_scrollview) updateTextColors(event_scrollview)
updateIconColors() updateIconColors()
wasActivityInitialized = true mWasActivityInitialized = true
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_event, menu) menuInflater.inflate(R.menu.menu_event, menu)
if (wasActivityInitialized) { if (mWasActivityInitialized) {
menu.findItem(R.id.delete).isVisible = mEvent.id != null menu.findItem(R.id.delete).isVisible = mEvent.id != null
menu.findItem(R.id.share).isVisible = mEvent.id != null menu.findItem(R.id.share).isVisible = mEvent.id != null
menu.findItem(R.id.duplicate).isVisible = mEvent.id != null menu.findItem(R.id.duplicate).isVisible = mEvent.id != null
@ -207,7 +212,7 @@ class EventActivity : SimpleActivity() {
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
if (!wasActivityInitialized) { if (!mWasActivityInitialized) {
return return
} }
@ -258,6 +263,7 @@ class EventActivity : SimpleActivity() {
updateTexts() updateTexts()
updateEventType() updateEventType()
updateCalDAVCalendar() updateCalDAVCalendar()
updateAttendees()
} }
private fun updateTexts() { private fun updateTexts() {
@ -860,6 +866,7 @@ class EventActivity : SimpleActivity() {
flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY) flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY)
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
repeatRule = mRepeatRule repeatRule = mRepeatRule
attendees = mAttendeeViews.map { it.value }.filter { it.isNotEmpty() }.toMutableList() as ArrayList<String>
eventType = newEventType eventType = newEventType
lastUpdated = System.currentTimeMillis() lastUpdated = System.currentTimeMillis()
source = newSource source = newSource
@ -1075,6 +1082,24 @@ class EventActivity : SimpleActivity() {
} }
} }
private fun updateAttendees() {
addAttendee()
event_attendees_image.layoutParams.height = event_repetition_image.height
}
private fun addAttendee() {
val attendeeHolder = layoutInflater.inflate(R.layout.item_attendee, event_attendees_holder, false) as RelativeLayout
mAttendeeViews.add(attendeeHolder.event_attendee)
attendeeHolder.event_attendee.onTextChangeListener {
if (mAttendeeViews.none { it.value.isEmpty() }) {
addAttendee()
}
}
event_attendees_holder.addView(attendeeHolder)
attendeeHolder.event_attendee.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor)
}
private fun updateIconColors() { private fun updateIconColors() {
val textColor = config.textColor val textColor = config.textColor
event_time_image.applyColorFilter(textColor) event_time_image.applyColorFilter(textColor)
@ -1086,5 +1111,6 @@ class EventActivity : SimpleActivity() {
event_reminder_1_type.applyColorFilter(textColor) event_reminder_1_type.applyColorFilter(textColor)
event_reminder_2_type.applyColorFilter(textColor) event_reminder_2_type.applyColorFilter(textColor)
event_reminder_3_type.applyColorFilter(textColor) event_reminder_3_type.applyColorFilter(textColor)
event_attendees_image.applyColorFilter(textColor)
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

View File

@ -380,10 +380,40 @@
android:importantForAccessibility="no"/> android:importantForAccessibility="no"/>
<ImageView <ImageView
android:id="@+id/event_caldav_calendar_image" android:id="@+id/event_attendees_image"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@+id/event_repetition_divider" android:layout_below="@+id/event_repetition_divider"
android:layout_alignTop="@+id/event_attendees_holder"
android:layout_marginStart="@dimen/normal_margin"
android:layout_marginTop="@dimen/small_margin"
android:alpha="0.8"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_people"/>
<LinearLayout
android:id="@+id/event_attendees_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/event_repetition_divider"
android:layout_marginTop="@dimen/medium_margin"
android:layout_toEndOf="@+id/event_attendees_image"
android:orientation="vertical"/>
<ImageView
android:id="@+id/event_attendees_divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_below="@+id/event_attendees_holder"
android:layout_marginTop="@dimen/medium_margin"
android:background="@color/divider_grey"
android:importantForAccessibility="no"/>
<ImageView
android:id="@+id/event_caldav_calendar_image"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@+id/event_attendees_divider"
android:layout_alignTop="@+id/event_caldav_calendar_holder" android:layout_alignTop="@+id/event_caldav_calendar_holder"
android:layout_alignBottom="@+id/event_caldav_calendar_holder" android:layout_alignBottom="@+id/event_caldav_calendar_holder"
android:layout_marginStart="@dimen/normal_margin" android:layout_marginStart="@dimen/normal_margin"
@ -396,7 +426,7 @@
android:id="@+id/event_caldav_calendar_holder" android:id="@+id/event_caldav_calendar_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/event_repetition_divider" android:layout_below="@+id/event_attendees_divider"
android:layout_toEndOf="@+id/event_caldav_calendar_image" android:layout_toEndOf="@+id/event_caldav_calendar_image"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:visibility="gone"> android:visibility="gone">

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_attendee_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin">
<com.simplemobiletools.commons.views.MyEditText
android:id="@+id/event_attendee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/activity_margin"
android:hint="@string/add_another_attendee"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size"/>
</RelativeLayout>