moving some shared layout files into Commons

This commit is contained in:
tibbi 2020-05-08 10:23:29 +02:00
parent 0689a77a21
commit 080401bc37
11 changed files with 44 additions and 135 deletions

View file

@ -57,9 +57,8 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.27.7'
implementation 'com.simplemobiletools:commons:5.27.13'
implementation 'joda-time:joda-time:2.10.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.5'
implementation 'com.github.tibbi:IndicatorFastScroll:08f512858a'

View file

@ -16,7 +16,6 @@ import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.getContactLetterIcon
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.sendEmailIntent
@ -31,7 +30,8 @@ abstract class ContactActivity : SimpleActivity() {
protected var currentContactPhotoPath = ""
fun showPhotoPlaceholder(photoView: ImageView) {
val placeholder = BitmapDrawable(resources, getContactLetterIcon(contact?.getNameToDisplay() ?: "A"))
val placeholder = BitmapDrawable(resources, com.simplemobiletools.commons.helpers.ContactsHelper(this).getContactLetterIcon(contact?.getNameToDisplay()
?: "A"))
photoView.setImageDrawable(placeholder)
currentContactPhotoPath = ""
contact?.photo = null

View file

@ -183,7 +183,7 @@ class EditContactActivity : ContactActivity() {
if (((contact!!.id == 0 && action == Intent.ACTION_INSERT) || action == ADD_NEW_CONTACT_NUMBER) && intent.extras != null) {
val phoneNumber = getPhoneNumberFromIntent(intent)
if (phoneNumber != null) {
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "", phoneNumber.normalizeNumber()))
contact!!.phoneNumbers.add(PhoneNumber(phoneNumber, DEFAULT_PHONE_NUMBER_TYPE, "", phoneNumber.normalizePhoneNumber()))
if (phoneNumber.isNotEmpty() && action == ADD_NEW_CONTACT_NUMBER) {
highlightLastPhoneNumber = true
}

View file

@ -36,6 +36,7 @@ import com.simplemobiletools.contacts.pro.extensions.getTempFile
import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
import com.simplemobiletools.contacts.pro.models.Contact
import kotlinx.android.synthetic.main.activity_main.*
@ -71,8 +72,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
appLaunched(BuildConfig.APPLICATION_ID)
setupTabColors()
setupTabColors()
checkContactPermissions()
storeStateVariables()
checkWhatsNewDialog()

View file

@ -5,6 +5,9 @@ import android.util.TypedValue
import android.view.Menu
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
@ -12,7 +15,10 @@ import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.extensions.highlightTextPart
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.views.FastScroller
@ -25,7 +31,6 @@ import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
import com.simplemobiletools.contacts.pro.interfaces.RemoveFromGroupListener
import com.simplemobiletools.contacts.pro.models.Contact
import kotlinx.android.synthetic.main.item_contact_with_number.view.*
import java.util.*
class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Contact>, private val refreshListener: RefreshContactsListener?,
@ -255,15 +260,15 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
override fun onViewRecycled(holder: ViewHolder) {
super.onViewRecycled(holder)
if (!activity.isDestroyed && !activity.isFinishing) {
Glide.with(activity).clear(holder.itemView.contact_tmb)
Glide.with(activity).clear(holder.itemView.findViewById<ImageView>(R.id.item_contact_image))
}
}
private fun setupView(view: View, contact: Contact) {
view.apply {
contact_frame?.isSelected = selectedKeys.contains(contact.id)
findViewById<FrameLayout>(R.id.item_contact_frame)?.isSelected = selectedKeys.contains(contact.id)
val fullName = contact.getNameToDisplay()
contact_name.text = if (textToHighlight.isEmpty()) fullName else {
findViewById<TextView>(R.id.item_contact_name).text = if (textToHighlight.isEmpty()) fullName else {
if (fullName.contains(textToHighlight, true)) {
fullName.highlightTextPart(textToHighlight, adjustedPrimaryColor)
} else {
@ -271,10 +276,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
}
}
contact_name.setTextColor(textColor)
contact_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
findViewById<TextView>(R.id.item_contact_name).apply {
setTextColor(textColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
if (contact_number != null) {
if (findViewById<TextView>(R.id.item_contact_number) != null) {
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
contact.phoneNumbers.firstOrNull()
} else {
@ -282,17 +289,19 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
}
val numberText = phoneNumberToUse?.value ?: ""
contact_number.text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor, false, true)
contact_number.setTextColor(textColor)
contact_number.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
findViewById<TextView>(R.id.item_contact_number).apply {
text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor, false, true)
setTextColor(textColor)
setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
}
}
contact_tmb.beVisibleIf(showContactThumbnails)
findViewById<TextView>(R.id.item_contact_image).beVisibleIf(showContactThumbnails)
if (showContactThumbnails) {
val placeholderImage = BitmapDrawable(resources, context.getContactLetterIcon(fullName))
val placeholderImage = BitmapDrawable(resources, com.simplemobiletools.commons.helpers.ContactsHelper(context).getContactLetterIcon(fullName))
if (contact.photoUri.isEmpty() && contact.photo == null) {
contact_tmb.setImageDrawable(placeholderImage)
findViewById<ImageView>(R.id.item_contact_image).setImageDrawable(placeholderImage)
} else {
val options = RequestOptions()
.signature(ObjectKey(contact.getSignatureKey()))
@ -310,7 +319,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
.load(itemToLoad)
.apply(options)
.apply(RequestOptions.circleCropTransform())
.into(contact_tmb)
.into(findViewById<ImageView>(R.id.item_contact_image))
}
}
}

View file

@ -6,7 +6,10 @@ import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.extensions.highlightTextPart
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView
@ -167,7 +170,7 @@ class GroupsAdapter(activity: SimpleActivity, var groups: ArrayList<Group>, val
group_tmb.beVisibleIf(showContactThumbnails)
if (showContactThumbnails) {
group_tmb.setImageDrawable(activity.getColoredGroupIcon(group.title))
group_tmb.setImageDrawable(com.simplemobiletools.commons.helpers.ContactsHelper(activity).getColoredGroupIcon(group.title))
}
}
}

View file

@ -10,7 +10,11 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
import com.simplemobiletools.commons.extensions.getTextSize
import com.simplemobiletools.commons.extensions.highlightTextPart
import com.simplemobiletools.commons.helpers.ContactsHelper
import com.simplemobiletools.commons.views.FastScroller
import com.simplemobiletools.commons.views.MyRecyclerView
import com.simplemobiletools.contacts.pro.R
@ -146,7 +150,7 @@ class SelectContactsAdapter(val activity: SimpleActivity, var contacts: ArrayLis
else -> contact.firstName
}
val placeholderImage = BitmapDrawable(resources, context.getContactLetterIcon(avatarName))
val placeholderImage = BitmapDrawable(resources, ContactsHelper(context).getContactLetterIcon(avatarName))
if (contact.photoUri.isEmpty() && contact.photo == null) {
contact_tmb.setImageDrawable(placeholderImage)

View file

@ -5,8 +5,6 @@ import android.content.Context
import android.net.Uri
import android.telecom.Call
import android.telecom.VideoProfile
import com.simplemobiletools.commons.extensions.getNameFromPhoneNumber
import com.simplemobiletools.commons.extensions.getPhotoUriFromPhoneNumber
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.contacts.pro.extensions.contactsDB
import com.simplemobiletools.contacts.pro.models.CallContact
@ -61,10 +59,11 @@ class CallManager {
val uri = Uri.decode(call!!.details.handle.toString())
if (uri.startsWith("tel:")) {
val contactsHelper = com.simplemobiletools.commons.helpers.ContactsHelper(context)
val number = uri.substringAfter("tel:")
callContact.number = number
callContact.name = context.getNameFromPhoneNumber(number)
callContact.photoUri = context.getPhotoUriFromPhoneNumber(number)
callContact.name = contactsHelper.getNameFromPhoneNumber(number)
callContact.photoUri = contactsHelper.getPhotoUriFromPhoneNumber(number)
if (callContact.name == callContact.number) {
ensureBackgroundThread {

View file

@ -1,59 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector">
<RelativeLayout
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_row_height"
android:paddingStart="@dimen/tiny_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<ImageView
android:id="@+id/contact_tmb"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/small_margin"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_person_vector" />
<TextView
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@+id/contact_tmb"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/big_text_size"
tools:text="John Doe" />
<TextView
android:id="@+id/contact_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_name"
android:layout_alignStart="@+id/contact_name"
android:layout_toEndOf="@+id/contact_tmb"
android:alpha="0.6"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/big_text_size"
tools:text="0123 456 789" />
</RelativeLayout>
</FrameLayout>

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector">
<RelativeLayout
android:id="@+id/contact_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_row_height"
android:paddingStart="@dimen/tiny_margin"
android:paddingTop="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/medium_margin">
<ImageView
android:id="@+id/contact_tmb"
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_marginStart="@dimen/small_margin"
android:padding="@dimen/tiny_margin"
android:src="@drawable/ic_person_vector" />
<TextView
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/contact_tmb"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingStart="@dimen/medium_margin"
android:paddingEnd="@dimen/activity_margin"
android:textSize="@dimen/big_text_size"
tools:text="John Doe" />
</RelativeLayout>
</FrameLayout>

View file

@ -3,7 +3,6 @@
<dimen name="contact_photo_size">88dp</dimen>
<dimen name="contact_actions_size">48dp</dimen>
<dimen name="contact_icons_size">40dp</dimen>
<dimen name="min_row_height">60dp</dimen>
<dimen name="dialpad_button_size">60dp</dimen>
<dimen name="incoming_call_button_size">72dp</dimen>
<dimen name="call_notification_button_size">30dp</dimen>