diff --git a/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt index ae83fa4b..01fdca6b 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CallListAdapter.kt @@ -2,6 +2,8 @@ package com.tutpro.baresip import android.content.Context import android.graphics.drawable.GradientDrawable +import android.support.v4.content.ContextCompat +import android.support.v7.widget.CardView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -19,18 +21,27 @@ class CallListAdapter(private val cxt: Context, private val rows: ArrayList - color = Utils.randomColor() - showTextAvatar(textAvatarView.text.toString(), color) - newAvatar = "text" + val intent = Intent(Intent.ACTION_GET_CONTENT).apply { + addCategory(Intent.CATEGORY_OPENABLE) + type = "image/*" + } + startActivityForResult(intent, READ_REQUEST_CODE) } textAvatarView.setOnLongClickListener { _ -> - val intent = Intent(Intent.ACTION_GET_CONTENT).apply { - addCategory(Intent.CATEGORY_OPENABLE) - type = "image/*" - } - - startActivityForResult(intent, READ_REQUEST_CODE) - + color = Utils.randomColor() + showTextAvatar(textAvatarView.text.toString(), color) + newAvatar = "text" true } cardAvatarView.setOnClickListener { _ -> - color = Utils.randomColor() - showTextAvatar(nameView.text.toString(), color) - newAvatar = "text" + val intent = Intent(Intent.ACTION_GET_CONTENT).apply { + addCategory(Intent.CATEGORY_OPENABLE) + type = "image/*" + } + startActivityForResult(intent, READ_REQUEST_CODE) } cardAvatarView.setOnLongClickListener { _ -> - val intent = Intent(Intent.ACTION_GET_CONTENT).apply { - addCategory(Intent.CATEGORY_OPENABLE) - type = "image/*" - } - - startActivityForResult(intent, READ_REQUEST_CODE) - + color = Utils.randomColor() + showTextAvatar(nameView.text.toString(), color) + newAvatar = "text" true } @@ -225,7 +221,7 @@ class ContactActivity : AppCompatActivity() { } } "image" -> { - contact.avatarImage = (imageAvatarView.drawable as BitmapDrawable).bitmap + contact.avatarImage = (cardImageAvatarView.drawable as BitmapDrawable).bitmap Utils.deleteFile(File(BaresipService.filesPath, "${contact.id}.png")) File(BaresipService.filesPath, "tmp.png") .renameTo(File(BaresipService.filesPath, "${contact.id}.png")) @@ -264,18 +260,13 @@ class ContactActivity : AppCompatActivity() { private fun showTextAvatar(name: String, color: Int) { textAvatarView.visibility = View.VISIBLE cardAvatarView.visibility = View.GONE - imageAvatarView.visibility = View.GONE (textAvatarView.background as GradientDrawable).setColor(color) - if (name.isNotEmpty()) - textAvatarView.text = "${name[0]}" - else - textAvatarView.text = "" + textAvatarView.text = "${name[0]}" } private fun showImageAvatar(image: Bitmap) { textAvatarView.visibility = View.GONE cardAvatarView.visibility = View.VISIBLE - imageAvatarView.visibility = View.VISIBLE - imageAvatarView.setImageBitmap(image) + cardImageAvatarView.setImageBitmap(image) } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt b/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt index dd7e5ae1..8663e4dd 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ContactListAdapter.kt @@ -7,16 +7,17 @@ import android.content.Intent import android.graphics.drawable.GradientDrawable import android.os.Bundle import android.support.v7.app.AlertDialog +import android.support.v7.widget.CardView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter import android.widget.ImageButton +import android.widget.ImageView import android.widget.TextView import java.io.File import java.io.IOException - import java.util.* class ContactListAdapter(private val cxt: Context, private val rows: ArrayList, @@ -24,16 +25,30 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList(cxt, R.layout.contact_row, rows) { override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { - val row = rows[position] + val contact = rows[position] val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater val rowView = inflater.inflate(R.layout.contact_row, parent, false) - val avatarView = rowView.findViewById(R.id.avatar) as TextView - val background = avatarView.background as GradientDrawable - background.setColor(row.color) - if (row.name.length > 0) - avatarView.text = "${row.name[0]}" + val textAvatarView = rowView.findViewById(R.id.TextAvatar) as TextView + val cardAvatarView = rowView.findViewById(R.id.CardAvatar) as CardView + val imageAvatarView = rowView.findViewById(R.id.ImageAvatar) as ImageView + val avatarImage = contact.avatarImage + if (avatarImage != null) { + textAvatarView.visibility = View.GONE + cardAvatarView.visibility = View.VISIBLE + imageAvatarView.visibility = View.VISIBLE + imageAvatarView.setImageBitmap(avatarImage) + } else { + textAvatarView.visibility = View.VISIBLE + cardAvatarView.visibility = View.GONE + imageAvatarView.visibility = View.GONE + (textAvatarView.background as GradientDrawable).setColor(contact.color) + if (contact.name.isNotEmpty()) + textAvatarView.text = "${contact.name[0]}" + else + textAvatarView.text = "" + } val nameView = rowView.findViewById(R.id.contactName) as TextView - nameView.text = row.name + nameView.text = contact.name nameView.textSize = 20f nameView.setPadding(6, 6, 0, 6) if (aor != "") { @@ -75,7 +90,6 @@ class ContactListAdapter(private val cxt: Context, private val rows: ArrayList when (which) { DialogInterface.BUTTON_POSITIVE -> { - val contact = Contact.contacts()[position] val id = contact.id val avatarFile = File(BaresipService.filesPath, "$id.img") if (avatarFile.exists()) { diff --git a/app/src/main/person-web.png b/app/src/main/person-web.png new file mode 100644 index 00000000..fdc432a7 Binary files /dev/null and b/app/src/main/person-web.png differ diff --git a/app/src/main/res/drawable/person_image.png b/app/src/main/res/drawable/person_image.png new file mode 100644 index 00000000..c2cb228f Binary files /dev/null and b/app/src/main/res/drawable/person_image.png differ diff --git a/app/src/main/res/layout/activity_calls.xml b/app/src/main/res/layout/activity_calls.xml index 17176242..a9324f85 100644 --- a/app/src/main/res/layout/activity_calls.xml +++ b/app/src/main/res/layout/activity_calls.xml @@ -13,6 +13,7 @@ android:id="@+id/account" android:layout_width="fill_parent" android:layout_height="wrap_content" + android:layout_marginBottom="10dp" android:gravity="center_horizontal" > diff --git a/app/src/main/res/layout/activity_contact.xml b/app/src/main/res/layout/activity_contact.xml index 6b2d7095..184a9fad 100644 --- a/app/src/main/res/layout/activity_contact.xml +++ b/app/src/main/res/layout/activity_contact.xml @@ -11,14 +11,13 @@ android:orientation="vertical"> @@ -34,7 +33,7 @@ diff --git a/app/src/main/res/layout/call_row.xml b/app/src/main/res/layout/call_row.xml index 28fad2a3..82f9e87e 100644 --- a/app/src/main/res/layout/call_row.xml +++ b/app/src/main/res/layout/call_row.xml @@ -1,34 +1,50 @@ + + + + + + + diff --git a/app/src/main/res/layout/chat_row.xml b/app/src/main/res/layout/chat_row.xml index 472e027b..f2188701 100644 --- a/app/src/main/res/layout/chat_row.xml +++ b/app/src/main/res/layout/chat_row.xml @@ -1,30 +1,48 @@ + + + + + + + + android:layout_marginStart="42dp" > + + + + + + + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 1a0c10e9..30455d0b 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,4 +10,5 @@ #e0e0e0 #b00020 #0ca1fd + #ffffff