show the event type color at event screen
This commit is contained in:
parent
82213b1ea5
commit
53e9f5cb79
|
@ -30,7 +30,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
private var mReminder3Minutes = 0
|
private var mReminder3Minutes = 0
|
||||||
private var mRepeatInterval = 0
|
private var mRepeatInterval = 0
|
||||||
private var mRepeatLimit = 0
|
private var mRepeatLimit = 0
|
||||||
private var mEventType = DBHelper.REGULAR_EVENT_ID
|
private var mEventTypeId = DBHelper.REGULAR_EVENT_ID
|
||||||
private var mDialogTheme = 0
|
private var mDialogTheme = 0
|
||||||
|
|
||||||
lateinit var mEventStartDateTime: DateTime
|
lateinit var mEventStartDateTime: DateTime
|
||||||
|
@ -67,7 +67,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
updateStartTime()
|
updateStartTime()
|
||||||
updateEndDate()
|
updateEndDate()
|
||||||
updateEndTime()
|
updateEndTime()
|
||||||
updateEventTypeText()
|
updateEventType()
|
||||||
|
|
||||||
mWasEndDateSet = event != null
|
mWasEndDateSet = event != null
|
||||||
mWasEndTimeSet = event != null
|
mWasEndTimeSet = event != null
|
||||||
|
@ -85,7 +85,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
event_reminder_2.setOnClickListener { showReminder2Dialog() }
|
event_reminder_2.setOnClickListener { showReminder2Dialog() }
|
||||||
event_reminder_3.setOnClickListener { showReminder3Dialog() }
|
event_reminder_3.setOnClickListener { showReminder3Dialog() }
|
||||||
|
|
||||||
event_type.setOnClickListener { showEventTypeDialog() }
|
event_type_holder.setOnClickListener { showEventTypeDialog() }
|
||||||
|
|
||||||
if (mEvent.flags and FLAG_ALL_DAY != 0)
|
if (mEvent.flags and FLAG_ALL_DAY != 0)
|
||||||
event_all_day.toggle()
|
event_all_day.toggle()
|
||||||
|
@ -106,7 +106,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
mReminder3Minutes = mEvent.reminder3Minutes
|
mReminder3Minutes = mEvent.reminder3Minutes
|
||||||
mRepeatInterval = mEvent.repeatInterval
|
mRepeatInterval = mEvent.repeatInterval
|
||||||
mRepeatLimit = mEvent.repeatLimit
|
mRepeatLimit = mEvent.repeatLimit
|
||||||
mEventType = mEvent.eventType
|
mEventTypeId = mEvent.eventType
|
||||||
checkRepeatLimit(mRepeatInterval)
|
checkRepeatLimit(mRepeatInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showEventTypeDialog() {
|
private fun showEventTypeDialog() {
|
||||||
SelectEventTypeDialog(this, mEventType) {
|
SelectEventTypeDialog(this, mEventTypeId) {
|
||||||
mEventType = it
|
mEventTypeId = it
|
||||||
updateEventTypeText()
|
updateEventType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,8 +232,12 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
event_repetition.text = getRepetitionToString(mRepeatInterval)
|
event_repetition.text = getRepetitionToString(mRepeatInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateEventTypeText() {
|
private fun updateEventType() {
|
||||||
event_type.text = DBHelper.newInstance(applicationContext).getEventTypeTitle(mEventType)
|
val eventType = DBHelper.newInstance(applicationContext).getEventType(mEventTypeId)
|
||||||
|
if (eventType != null) {
|
||||||
|
event_type.text = eventType.title
|
||||||
|
event_type_color.setBackgroundWithStroke(eventType.color, config.backgroundColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRepetitionToString(seconds: Int) = getString(when (seconds) {
|
private fun getRepetitionToString(seconds: Int) = getString(when (seconds) {
|
||||||
|
@ -252,10 +256,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
|
|
||||||
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)
|
||||||
val item = menu.findItem(R.id.cab_delete)
|
menu.findItem(R.id.cab_delete).isVisible = mEvent.id != 0
|
||||||
if (mEvent.id == 0) {
|
|
||||||
item.isVisible = false
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +306,7 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
||||||
repeatInterval = mRepeatInterval
|
repeatInterval = mRepeatInterval
|
||||||
flags = if (event_all_day.isChecked) (mEvent.flags or FLAG_ALL_DAY) else (mEvent.flags.removeFlag(FLAG_ALL_DAY))
|
flags = if (event_all_day.isChecked) (mEvent.flags or FLAG_ALL_DAY) else (mEvent.flags.removeFlag(FLAG_ALL_DAY))
|
||||||
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
|
repeatLimit = if (repeatInterval == 0) 0 else mRepeatLimit
|
||||||
eventType = mEventType
|
eventType = mEventTypeId
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEvent.id == 0) {
|
if (mEvent.id == 0) {
|
||||||
|
|
|
@ -227,20 +227,22 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getEventTypeTitle(id: Int): String {
|
fun getEventType(id: Int): EventType? {
|
||||||
val cols = arrayOf(COL_TYPE_TITLE)
|
val cols = arrayOf(COL_TYPE_TITLE, COL_TYPE_COLOR)
|
||||||
val selection = "$COL_TYPE_ID = ?"
|
val selection = "$COL_TYPE_ID = ?"
|
||||||
val selectionArgs = arrayOf(id.toString())
|
val selectionArgs = arrayOf(id.toString())
|
||||||
var cursor: Cursor? = null
|
var cursor: Cursor? = null
|
||||||
try {
|
try {
|
||||||
cursor = mDb.query(TYPES_TABLE_NAME, cols, selection, selectionArgs, null, null, null)
|
cursor = mDb.query(TYPES_TABLE_NAME, cols, selection, selectionArgs, null, null, null)
|
||||||
if (cursor?.moveToFirst() == true) {
|
if (cursor?.moveToFirst() == true) {
|
||||||
return cursor.getStringValue(COL_TYPE_TITLE)
|
val title = cursor.getStringValue(COL_TYPE_TITLE)
|
||||||
|
val color = cursor.getIntValue(COL_TYPE_COLOR)
|
||||||
|
return EventType(id, title, color)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
}
|
}
|
||||||
return context.resources.getString(R.string.regular_event)
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteEvents(ids: Array<String>) {
|
fun deleteEvents(ids: Array<String>) {
|
||||||
|
|
|
@ -280,8 +280,8 @@
|
||||||
android:id="@+id/event_type_image"
|
android:id="@+id/event_type_image"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignBottom="@+id/event_type"
|
android:layout_alignBottom="@+id/event_type_holder"
|
||||||
android:layout_alignTop="@+id/event_type"
|
android:layout_alignTop="@+id/event_type_holder"
|
||||||
android:layout_below="@+id/event_date_time_divider"
|
android:layout_below="@+id/event_date_time_divider"
|
||||||
android:layout_marginLeft="@dimen/normal_margin"
|
android:layout_marginLeft="@dimen/normal_margin"
|
||||||
android:layout_marginStart="@dimen/normal_margin"
|
android:layout_marginStart="@dimen/normal_margin"
|
||||||
|
@ -289,19 +289,36 @@
|
||||||
android:padding="@dimen/medium_margin"
|
android:padding="@dimen/medium_margin"
|
||||||
android:src="@drawable/ic_color"/>
|
android:src="@drawable/ic_color"/>
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<RelativeLayout
|
||||||
android:id="@+id/event_type"
|
android:id="@+id/event_type_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_repetition_divider"
|
||||||
android:layout_marginLeft="@dimen/small_margin"
|
|
||||||
android:layout_marginStart="@dimen/small_margin"
|
|
||||||
android:layout_toEndOf="@+id/event_type_image"
|
android:layout_toEndOf="@+id/event_type_image"
|
||||||
android:layout_toRightOf="@+id/event_type_image"
|
android:layout_toRightOf="@+id/event_type_image"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground">
|
||||||
android:paddingBottom="@dimen/normal_margin"
|
|
||||||
android:paddingTop="@dimen/normal_margin"
|
|
||||||
android:textSize="@dimen/day_text_size"/>
|
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/event_type"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/small_margin"
|
||||||
|
android:layout_marginStart="@dimen/small_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:textSize="@dimen/day_text_size"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/event_type_color"
|
||||||
|
android:layout_width="@dimen/color_sample_size"
|
||||||
|
android:layout_height="@dimen/color_sample_size"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="@dimen/normal_margin"
|
||||||
|
android:layout_marginRight="@dimen/normal_margin"
|
||||||
|
android:clickable="false"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
Loading…
Reference in New Issue