From f55900f3daf00c4e441c32fc6fb65aa07dce4a9f Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 13 Mar 2019 13:48:28 +0100 Subject: [PATCH] adding an Attendees field at events --- .../calendar/pro/activities/EventActivity.kt | 34 +++++++++++++++--- app/src/main/res/drawable-hdpi/ic_people.png | Bin 0 -> 260 bytes app/src/main/res/drawable-xhdpi/ic_people.png | Bin 0 -> 313 bytes .../main/res/drawable-xxhdpi/ic_people.png | Bin 0 -> 425 bytes .../main/res/drawable-xxxhdpi/ic_people.png | Bin 0 -> 554 bytes app/src/main/res/layout/activity_event.xml | 34 ++++++++++++++++-- app/src/main/res/layout/item_attendee.xml | 23 ++++++++++++ 7 files changed, 85 insertions(+), 6 deletions(-) create mode 100755 app/src/main/res/drawable-hdpi/ic_people.png create mode 100755 app/src/main/res/drawable-xhdpi/ic_people.png create mode 100755 app/src/main/res/drawable-xxhdpi/ic_people.png create mode 100755 app/src/main/res/drawable-xxxhdpi/ic_people.png create mode 100644 app/src/main/res/layout/item_attendee.xml 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 18ad13563..ff23682e7 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 @@ -10,6 +10,7 @@ import android.view.Menu import android.view.MenuItem import android.view.WindowManager import android.widget.ImageView +import android.widget.RelativeLayout import androidx.core.app.NotificationManagerCompat import com.simplemobiletools.calendar.pro.R 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.helpers.* 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.view.* +import kotlinx.android.synthetic.main.item_attendee.view.* import org.joda.time.DateTime import java.util.* import java.util.regex.Pattern @@ -58,7 +61,8 @@ class EventActivity : SimpleActivity() { private var mDialogTheme = 0 private var mEventOccurrenceTS = 0L private var mEventCalendarId = STORED_LOCALLY_ONLY - private var wasActivityInitialized = false + private var mWasActivityInitialized = false + private var mAttendeeViews = ArrayList() private lateinit var mEventStartDateTime: DateTime private lateinit var mEventEndDateTime: DateTime @@ -123,6 +127,7 @@ class EventActivity : SimpleActivity() { updateTexts() updateEventType() updateCalDAVCalendar() + updateAttendees() } event_show_on_map.setOnClickListener { showOnMap() } @@ -181,12 +186,12 @@ class EventActivity : SimpleActivity() { updateTextColors(event_scrollview) updateIconColors() - wasActivityInitialized = true + mWasActivityInitialized = true } override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_event, menu) - if (wasActivityInitialized) { + if (mWasActivityInitialized) { menu.findItem(R.id.delete).isVisible = mEvent.id != null menu.findItem(R.id.share).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) { super.onSaveInstanceState(outState) - if (!wasActivityInitialized) { + if (!mWasActivityInitialized) { return } @@ -258,6 +263,7 @@ class EventActivity : SimpleActivity() { updateTexts() updateEventType() updateCalDAVCalendar() + updateAttendees() } private fun updateTexts() { @@ -860,6 +866,7 @@ class EventActivity : SimpleActivity() { flags = mEvent.flags.addBitIf(event_all_day.isChecked, FLAG_ALL_DAY) repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit repeatRule = mRepeatRule + attendees = mAttendeeViews.map { it.value }.filter { it.isNotEmpty() }.toMutableList() as ArrayList eventType = newEventType lastUpdated = System.currentTimeMillis() 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() { val textColor = config.textColor event_time_image.applyColorFilter(textColor) @@ -1086,5 +1111,6 @@ class EventActivity : SimpleActivity() { event_reminder_1_type.applyColorFilter(textColor) event_reminder_2_type.applyColorFilter(textColor) event_reminder_3_type.applyColorFilter(textColor) + event_attendees_image.applyColorFilter(textColor) } } diff --git a/app/src/main/res/drawable-hdpi/ic_people.png b/app/src/main/res/drawable-hdpi/ic_people.png new file mode 100755 index 0000000000000000000000000000000000000000..26691bec827eed8b9fbbe5e5b9b903b8990999ff GIT binary patch literal 260 zcmV+f0sH=mP) zF_zfdvE)Eb&XJ|qe-Rco4jvv3_VX>+XkEq%mm3wjiYqRwdNIT|bRARnlt@Z;%+zkg z-PCKW$!U|bR@<$)E1c=#QXjzB6$-j2)OKv{3LQ!7&p*`b{hbG%8)r2idh+}L0000< KMNUMnLSTXndu`PK literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_people.png b/app/src/main/res/drawable-xhdpi/ic_people.png new file mode 100755 index 0000000000000000000000000000000000000000..93f23280cfa6b2d3c4bd40d4162c165999be0525 GIT binary patch literal 313 zcmV-90mlA`P)uc|!O1F%tWwd?k%L@YBi=(a^-b&B4D={9k7jk%0zJlwd5&W}z_WR}u^!;lJRh+h zU?e?|?xnBjA==A6@=>e@sCzQ2s~+tEw)9NvX~uhqhPE6GbTk6}|EO58>&%r`00Y-f z?OD!#ux~uulPo!OV{AS~ZXH<4ChYi1^l55Zh9ZVqQ-8yGs!v#VkGMMIEgG&+`Wcs(}SjsZ_oJVz)}TpYPoV00000 LNkvXXu0mjf6+(i- literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_people.png b/app/src/main/res/drawable-xxhdpi/ic_people.png new file mode 100755 index 0000000000000000000000000000000000000000..6695583fe3cc6852e1d59c1004dbdc9d618f7310 GIT binary patch literal 425 zcmV;a0apHrP)^nbBa7A8VnfFphV8l+p$5Nzv`?RdJDGb5#^mtd#}bS z9VY3JwDxM$n5JUwmDokHZRypxLsGW%YCIu%F!Xv1k#r5c9-m0MhF*_nBrQX)$1Rd; zL$AjUlAOLb;ht%##$J!4{3+1)CZy>RrAOM{$9aCN+j|4@T*wEP+&kyy9?N7YQl&6ln5a zO$saoA>8Qt5E9g}s*?!KT;x&iBaxv?9J*vea}Ra>53&r2%aCm7F?d7n!&sqDocgQ; zzc|(PW0WzF{!ls4^<%scx7X0Yrs~ItAE7r*#_Sdv^M!mNUufeGS{%h^n zWRS@SRDMYAM=PJA%;c4V=T ztAO1#7Lu8ifmXb;_6Ag99(O6PyUe3fQVQCTm%cZkIxG2z%12g~_LoI}V;@H)R*;Qa zHY-YglI%6~arEU4Kg%2XmU!`zZRpF!C{zr0U@SKGC1Wghf)%Jro?r#~@vHPt0&F+; zA*%42U*$Dbg6X5peTcdIN^^thEzEt0OQ;!cV5nv8LuB(SWe3wMnEMdFSb69B0tUW- sFCgFx_yTIaz<`F1W;Owh5Bw6OaK4?07*qoM6N<$f*=3}KL7v# literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/activity_event.xml b/app/src/main/res/layout/activity_event.xml index 05c2e4403..7b1bfe893 100644 --- a/app/src/main/res/layout/activity_event.xml +++ b/app/src/main/res/layout/activity_event.xml @@ -380,10 +380,40 @@ android:importantForAccessibility="no"/> + + + + + + diff --git a/app/src/main/res/layout/item_attendee.xml b/app/src/main/res/layout/item_attendee.xml new file mode 100644 index 000000000..5eb797fcf --- /dev/null +++ b/app/src/main/res/layout/item_attendee.xml @@ -0,0 +1,23 @@ + + + + + +