mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-03-20 21:30:06 +01:00
use the letter avatar placeholder at attendees
This commit is contained in:
parent
4d92e2de76
commit
6e8c02aa5e
@ -5,6 +5,7 @@ import android.app.DatePickerDialog
|
||||
import android.app.TimePickerDialog
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
@ -86,7 +87,6 @@ class EventActivity : SimpleActivity() {
|
||||
private var mStoredEventTypes = ArrayList<EventType>()
|
||||
private var mOriginalTimeZone = DateTimeZone.getDefault().id
|
||||
|
||||
private lateinit var mAttendeePlaceholder: Drawable
|
||||
private lateinit var mEventStartDateTime: DateTime
|
||||
private lateinit var mEventEndDateTime: DateTime
|
||||
private lateinit var mEvent: Event
|
||||
@ -103,8 +103,6 @@ class EventActivity : SimpleActivity() {
|
||||
val intent = intent ?: return
|
||||
mDialogTheme = getDialogTheme()
|
||||
mWasContactsPermissionChecked = hasPermission(PERMISSION_READ_CONTACTS)
|
||||
mAttendeePlaceholder = resources.getDrawable(R.drawable.attendee_circular_background)
|
||||
(mAttendeePlaceholder as LayerDrawable).findDrawableByLayerId(R.id.attendee_circular_background).applyColorFilter(config.primaryColor)
|
||||
|
||||
val eventId = intent.getLongExtra(EVENT_ID, 0L)
|
||||
ensureBackgroundThread {
|
||||
@ -1347,8 +1345,14 @@ class EventActivity : SimpleActivity() {
|
||||
beVisibleIf(attendee.showStatusImage())
|
||||
}
|
||||
|
||||
event_contact_name.text = if (attendee.isMe) getString(R.string.my_status) else attendee.getPublicName()
|
||||
if (attendee.isMe) {
|
||||
(event_contact_name.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.START_OF, event_contact_me_status.id)
|
||||
}
|
||||
|
||||
val placeholder = BitmapDrawable(resources, context.getContactLetterIcon(event_contact_name.value))
|
||||
event_contact_image.apply {
|
||||
attendee.updateImage(applicationContext, this, mAttendeePlaceholder)
|
||||
attendee.updateImage(applicationContext, this, placeholder)
|
||||
beVisible()
|
||||
}
|
||||
|
||||
@ -1357,11 +1361,6 @@ class EventActivity : SimpleActivity() {
|
||||
beGoneIf(attendee.isMe)
|
||||
}
|
||||
|
||||
event_contact_name.text = if (attendee.isMe) getString(R.string.my_status) else attendee.getPublicName()
|
||||
if (attendee.isMe) {
|
||||
(event_contact_name.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.START_OF, event_contact_me_status.id)
|
||||
}
|
||||
|
||||
if (attendee.isMe) {
|
||||
updateAttendeeMe(this, attendee)
|
||||
}
|
||||
@ -1473,7 +1472,7 @@ class EventActivity : SimpleActivity() {
|
||||
val photoUri = cursor.getStringValue(ContactsContract.CommonDataKinds.StructuredName.PHOTO_THUMBNAIL_URI) ?: ""
|
||||
|
||||
val names = arrayListOf(prefix, firstName, middleName, surname, suffix).filter { it.trim().isNotEmpty() }
|
||||
val fullName = TextUtils.join("", names)
|
||||
val fullName = TextUtils.join(" ", names).trim()
|
||||
if (fullName.isNotEmpty() || photoUri.isNotEmpty()) {
|
||||
val contact = Attendee(id, fullName, "", CalendarContract.Attendees.ATTENDEE_STATUS_NONE, photoUri, false, CalendarContract.Attendees.RELATIONSHIP_NONE)
|
||||
contacts.add(contact)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.simplemobiletools.calendar.pro.adapters
|
||||
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -8,19 +8,13 @@ import android.widget.ArrayAdapter
|
||||
import android.widget.Filter
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.models.Attendee
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.getContactLetterIcon
|
||||
import com.simplemobiletools.commons.extensions.normalizeString
|
||||
import kotlinx.android.synthetic.main.item_autocomplete_email_name.view.*
|
||||
|
||||
class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: ArrayList<Attendee>) : ArrayAdapter<Attendee>(activity, 0, contacts) {
|
||||
var resultList = ArrayList<Attendee>()
|
||||
private var placeholder = activity.resources.getDrawable(R.drawable.attendee_circular_background)
|
||||
|
||||
init {
|
||||
(placeholder as LayerDrawable).findDrawableByLayerId(R.id.attendee_circular_background).applyColorFilter(activity.config.primaryColor)
|
||||
}
|
||||
|
||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||
val contact = resultList[position]
|
||||
@ -30,6 +24,13 @@ class AutoCompleteTextViewAdapter(val activity: SimpleActivity, val contacts: Ar
|
||||
listItem = LayoutInflater.from(activity).inflate(layout, parent, false)
|
||||
}
|
||||
|
||||
val nameToUse = when {
|
||||
contact.name.isNotEmpty() -> contact.name
|
||||
contact.email.isNotEmpty() -> contact.email
|
||||
else -> "S"
|
||||
}
|
||||
|
||||
val placeholder = BitmapDrawable(activity.resources, context.getContactLetterIcon(nameToUse))
|
||||
listItem!!.apply {
|
||||
tag = contact.name.isNotEmpty()
|
||||
item_autocomplete_name?.text = contact.name
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/attendee_circular_background">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/color_primary"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:bottom="@dimen/medium_margin"
|
||||
android:drawable="@drawable/ic_person_vector"
|
||||
android:left="@dimen/medium_margin"
|
||||
android:right="@dimen/medium_margin"
|
||||
android:top="@dimen/medium_margin"/>
|
||||
|
||||
</layer-list>
|
@ -1,9 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z"/>
|
||||
</vector>
|
@ -408,7 +408,7 @@
|
||||
android:layout_marginStart="@dimen/normal_margin"
|
||||
android:layout_marginTop="@dimen/small_margin"
|
||||
android:padding="@dimen/medium_margin"
|
||||
android:src="@drawable/ic_group_vector"/>
|
||||
android:src="@drawable/ic_people_vector"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/event_attendees_holder"
|
||||
|
@ -27,6 +27,7 @@
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/medium_margin"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
@ -17,7 +16,7 @@
|
||||
android:layout_height="@dimen/avatar_size"
|
||||
android:layout_margin="@dimen/tiny_margin"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_autocomplete_name"
|
||||
@ -26,6 +25,7 @@
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@dimen/medium_margin"
|
||||
android:singleLine="true"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
app:layout_constraintBottom_toTopOf="@+id/item_autocomplete_email"
|
||||
@ -33,7 +33,7 @@
|
||||
app:layout_constraintStart_toEndOf="@+id/item_autocomplete_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="Simple Mobile"/>
|
||||
tools:text="Simple Mobile" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_autocomplete_email"
|
||||
@ -45,12 +45,13 @@
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:paddingEnd="@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"/>
|
||||
tools:text="hello@simplemobiletools.com" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user