Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.text.method.LinkMovementMethod
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.RelativeLayout
import androidx.core.graphics.drawable.toDrawable
Expand Down Expand Up @@ -229,15 +230,22 @@ class EventActivity : SimpleActivity() {

val eventId = intent.getLongExtra(EVENT_ID, 0L)
ensureBackgroundThread {
mStoredCalendars =
calendarsDB.getCalendars().toMutableList() as ArrayList<CalendarEntity>
val locations = eventsDB.getAllLocations()

runOnUiThread {
val adapter = ArrayAdapter(this, R.layout.item_dropdown, locations)
binding.eventLocation.setAdapter(adapter)
}

val event = eventsDB.getEventWithId(eventId)
if (eventId != 0L && event == null) {
hideKeyboard()
finish()
return@ensureBackgroundThread
}

mStoredCalendars =
calendarsDB.getCalendars().toMutableList() as ArrayList<CalendarEntity>
val localCalendar =
mStoredCalendars.firstOrNull { it.id == config.lastUsedLocalCalendarId }
runOnUiThread {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ interface EventsDao {
@Query("SELECT * FROM events WHERE type = $TYPE_TASK")
fun getAllTasks(): List<Event>

@Query("SELECT DISTINCT location FROM events ORDER BY location COLLATE NOCASE")
fun getAllLocations(): List<String>

@Query("SELECT * FROM events WHERE event_type IN (:calendarIds) AND type = $TYPE_EVENT")
fun getAllEventsWithCalendarIds(calendarIds: List<Long>): List<Event>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
android:textCursorDrawable="@null"
android:textSize="@dimen/day_text_size" />

<org.fossify.commons.views.MyEditText
<org.fossify.commons.views.MyAutoCompleteTextView
android:id="@+id/event_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/res/layout/item_dropdown.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Copied from simple_list_item_1.xml, textColor is needed in light mode-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:textColor="?android:attr/textColorAlertDialogListItem" />
Loading