Skip to content

Commit a65e13e

Browse files
add autocompletion for events
1 parent f3fe3f0 commit a65e13e

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

app/src/main/kotlin/org/fossify/calendar/activities/EventActivity.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import android.text.method.LinkMovementMethod
1818
import android.view.View
1919
import android.view.WindowManager
2020
import android.view.inputmethod.EditorInfo
21+
import android.widget.ArrayAdapter
2122
import android.widget.ImageView
2223
import android.widget.RelativeLayout
2324
import androidx.core.graphics.drawable.toDrawable
@@ -229,6 +230,46 @@ class EventActivity : SimpleActivity() {
229230

230231
val eventId = intent.getLongExtra(EVENT_ID, 0L)
231232
ensureBackgroundThread {
233+
val eventTitleMap = eventsDB.getAllEvents()
234+
.associateBy { it.title } as HashMap<String, Event>
235+
binding.eventTitle.setOnItemClickListener { parent, view, position, id ->
236+
val prev = eventTitleMap[parent.getItemAtPosition(position)]
237+
binding.eventLocation.setText(prev!!.location)
238+
binding.eventDescription.setText(prev.description)
239+
240+
binding.eventAllDay.isChecked = prev.getIsAllDay()
241+
mEventEndDateTime = mEventStartDateTime.plus(1000 * (prev.endTS - prev.startTS))
242+
243+
mReminder1Minutes = prev.reminder1Minutes
244+
mReminder2Minutes = prev.reminder2Minutes
245+
mReminder3Minutes = prev.reminder3Minutes
246+
247+
mReminder1Type = prev.reminder1Type
248+
mReminder2Type = prev.reminder2Type
249+
mReminder3Type = prev.reminder3Type
250+
251+
mAccessLevel = prev.accessLevel
252+
mAvailability = prev.availability
253+
mStatus = prev.status
254+
mEventColor = prev.color
255+
256+
mAttendees = prev.attendees as ArrayList<Attendee>
257+
258+
mCalendarId = prev.calendarId
259+
260+
checkRepeatTexts(mRepeatInterval)
261+
checkRepeatRule()
262+
updateTexts()
263+
updateCalendar()
264+
checkAttendees()
265+
updateActionBarTitle()
266+
}
267+
268+
runOnUiThread {
269+
val adapter = ArrayAdapter(this, R.layout.item_dropdown, eventTitleMap.keys.toList())
270+
binding.eventTitle.setAdapter(adapter)
271+
}
272+
232273
mStoredCalendars =
233274
calendarsDB.getCalendars().toMutableList() as ArrayList<CalendarEntity>
234275
val event = eventsDB.getEventWithId(eventId)

app/src/main/res/layout/activity_event.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:layout_width="match_parent"
3636
android:layout_height="wrap_content">
3737

38-
<org.fossify.commons.views.MyEditText
38+
<AutoCompleteTextView
3939
android:id="@+id/event_title"
4040
android:layout_width="match_parent"
4141
android:layout_height="wrap_content"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2006 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<!-- Copied from simple_list_item_1.xml, textColor is needed in light mode-->
17+
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:id="@android:id/text1"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:textAppearance="?android:attr/textAppearanceListItemSmall"
22+
android:gravity="center_vertical"
23+
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
24+
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
25+
android:minHeight="?android:attr/listPreferredItemHeightSmall"
26+
android:textColor="?android:attr/textColorAlertDialogListItem" />

0 commit comments

Comments
 (0)