adding images to attendee suggestions

This commit is contained in:
tibbi 2019-03-14 11:44:13 +01:00
parent 236b3ef5ad
commit 4f0dc2b9c8
9 changed files with 76 additions and 24 deletions

View File

@ -60,6 +60,7 @@ dependencies {
implementation 'com.simplemobiletools:commons:5.10.10'
implementation 'joda-time:joda-time:2.10.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
kapt 'androidx.room:room-compiler:2.0.0'
implementation 'androidx.room:room-runtime:2.0.0'

View File

@ -1182,7 +1182,7 @@ class EventActivity : SimpleActivity() {
val attendeeEmails = mAttendeeViews.map { it.value }.filter { it.isNotEmpty() }.toMutableList() as ArrayList<String>
val attendees = ArrayList<Attendee>()
attendeeEmails.mapTo(attendees) {
Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED)
Attendee(0, "", it, CalendarContract.Attendees.ATTENDEE_STATUS_INVITED, "")
}
return Gson().toJson(attendees)
}
@ -1196,7 +1196,8 @@ class EventActivity : SimpleActivity() {
ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME,
ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME,
ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME,
ContactsContract.CommonDataKinds.StructuredName.SUFFIX)
ContactsContract.CommonDataKinds.StructuredName.SUFFIX,
ContactsContract.CommonDataKinds.StructuredName.PHOTO_URI)
val selection = "${ContactsContract.Data.MIMETYPE} = ?"
val selectionArgs = arrayOf(ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
@ -1212,11 +1213,12 @@ class EventActivity : SimpleActivity() {
val middleName = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME) ?: ""
val surname = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
val suffix = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.SUFFIX) ?: ""
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.PHOTO_URI) ?: ""
val names = arrayListOf(prefix, firstName, middleName, surname, suffix).filter { it.trim().isNotEmpty() }
val fullName = TextUtils.join("", names)
if (fullName.isNotEmpty()) {
val contact = Attendee(id, fullName, "", 0)
val contact = Attendee(id, fullName, "", 0, photoUri)
contacts.add(contact)
}
} while (cursor.moveToNext())
@ -1243,7 +1245,7 @@ class EventActivity : SimpleActivity() {
do {
val id = cursor.getIntValue(ContactsContract.Data.CONTACT_ID)
val email = cursor.getStringValue(ContactsContract.CommonDataKinds.Email.DATA) ?: continue
val contact = Attendee(id, "", email, 0)
val contact = Attendee(id, "", email, 0, "")
contacts.add(contact)
} while (cursor.moveToNext())
}

View File

@ -17,13 +17,16 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val contact = resultList[position]
var listItem = convertView
if (listItem == null) {
if (listItem == null || listItem.tag != contact.name.isNotEmpty()) {
val layout = if (contact.name.isNotEmpty()) R.layout.item_autocomplete_email_name else R.layout.item_autocomplete_email
listItem = LayoutInflater.from(activity).inflate(layout, parent, false)
}
listItem!!.item_autocomplete_name?.text = contact.name
listItem.item_autocomplete_email.text = contact.email
listItem!!.apply {
tag = contact.name.isNotEmpty()
item_autocomplete_name?.text = contact.name
item_autocomplete_email.text = contact.email
}
return listItem
}

View File

@ -514,7 +514,7 @@ class CalDAVHelper(val context: Context) {
val name = cursor.getStringValue(CalendarContract.Attendees.ATTENDEE_NAME)
val email = cursor.getStringValue(CalendarContract.Attendees.ATTENDEE_EMAIL)
val status = cursor.getIntValue(CalendarContract.Attendees.ATTENDEE_STATUS)
val attendee = Attendee(0, name, email, status)
val attendee = Attendee(0, name, email, status, "")
attendees.add(attendee)
} while (cursor.moveToNext())
}

View File

@ -1,5 +1,5 @@
package com.simplemobiletools.calendar.pro.models
data class Attendee(val contactId: Int, var name: String, val email: String, val status: Int) {
data class Attendee(val contactId: Int, var name: String, val email: String, val status: Int, val photoUri: String) {
fun getPublicName() = if (name.isNotEmpty()) name else email
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/color_primary"/>
</shape>

View File

@ -1,24 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_autocomplete_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/item_autocomplete_image"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_margin="@dimen/tiny_margin"
android:background="@drawable/attendee_circular_background"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_person"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/item_autocomplete_email"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/activity_margin"
android:lines="1"
android:maxLines="1"
android:padding="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toTopOf="parent"
tools:text="hello@simplemobiletools.com"/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,39 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_autocomplete_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/small_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/item_autocomplete_image"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_margin="@dimen/tiny_margin"
android:background="@drawable/attendee_circular_background"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_person"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/item_autocomplete_name"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/activity_margin"
android:lines="1"
android:maxLines="1"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:singleLine="true"
android:textSize="@dimen/bigger_text_size"
app:layout_constraintBottom_toTopOf="@+id/item_autocomplete_email"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Simple Mobile"/>
<TextView
android:id="@+id/item_autocomplete_email"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/item_autocomplete_name"
android:layout_marginEnd="@dimen/activity_margin"
android:layout_marginEnd="8dp"
android:alpha="0.8"
android:lines="1"
android:maxLines="1"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:singleLine="true"
android:textSize="@dimen/normal_text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
app:layout_constraintTop_toBottomOf="@+id/item_autocomplete_name"
tools:text="hello@simplemobiletools.com"/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -28,4 +28,6 @@
<dimen name="event_color_bar_width">4dp</dimen>
<dimen name="event_color_bar_height">100dp</dimen>
<dimen name="avatar_size">40dp</dimen>
</resources>