Skip to content

Commit

Permalink
Merge tag '6.22.4'
Browse files Browse the repository at this point in the history
Conflicts:
	CHANGELOG.md
	app/build.gradle
	app/src/main/AndroidManifest.xml
	app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt
	fastlane/metadata/android/id/full_description.txt
	fastlane/metadata/android/id/short_description.txt
	fastlane/metadata/android/id/title.txt
	fastlane/metadata/android/it-IT/full_description.txt
  • Loading branch information
stephanritscher committed Jul 27, 2023
2 parents d8e34c8 + 5b71c5a commit f9c7738
Show file tree
Hide file tree
Showing 15 changed files with 481 additions and 53 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
==========

Version 6.22.4.1 *(2023-07-27)*
----------------------------

* Merge upstream changes

Version 6.22.4 *(2023-06-09)*
----------------------------

* Added autocomplete to names at creating new contacts
* Added some UI, translation and stability improvements

Version 6.22.3.1 *(2023-04-20)*
----------------------------

Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ android {
applicationId "de.ritscher.simplemobiletools.contacts.pro"
minSdkVersion 23
targetSdkVersion 33
versionCode 106
versionName "6.22.3.1"
versionCode 107
versionName "6.22.4.1"
setProperty("archivesBaseName", "contacts")
}

Expand Down Expand Up @@ -64,7 +64,7 @@ android {
}

dependencies {
implementation 'com.github.stephanritscher:Simple-Commons:6dd0f2746d'
implementation 'com.github.stephanritscher:Simple-Commons:86371a5696'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
android:appCategory="social"
android:icon="@mipmap/ic_launcher_green"
android:label="@string/app_launcher_name"
android:localeConfig="@xml/locale_config"
android:roundIcon="@mipmap/ic_launcher_green"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Expand Down Expand Up @@ -119,7 +120,8 @@
android:configChanges="orientation"
android:exported="true"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/TranslucentTheme">
android:theme="@style/TranslucentTheme"
android:windowSoftInputMode="adjustResize">

<intent-filter>
<action android:name="android.intent.action.EDIT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.media.AudioManager
import android.media.RingtoneManager
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.provider.ContactsContract.CommonDataKinds
import android.provider.ContactsContract.CommonDataKinds.*
import android.provider.MediaStore
Expand All @@ -22,6 +23,8 @@ import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.widget.doAfterTextChanged
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.dialogs.SelectAlarmSoundDialog
Expand All @@ -33,13 +36,20 @@ import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.commons.models.contacts.Email
import com.simplemobiletools.commons.models.contacts.Event
import com.simplemobiletools.commons.models.contacts.Organization
import com.simplemobiletools.commons.views.MyAutoCompleteTextView
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.adapters.AutoCompleteTextViewAdapter
import com.simplemobiletools.contacts.pro.dialogs.CustomLabelDialog
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
import com.simplemobiletools.contacts.pro.dialogs.MyDatePickerDialog
import com.simplemobiletools.contacts.pro.dialogs.SelectGroupsDialog
import com.simplemobiletools.contacts.pro.extensions.*
import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.extensions.getCachePhotoUri
import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker
import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER
import com.simplemobiletools.contacts.pro.helpers.IS_FROM_SIMPLE_CONTACTS
import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL
import com.simplemobiletools.contacts.pro.helpers.KEY_NAME
import kotlinx.android.synthetic.main.activity_edit_contact.*
import kotlinx.android.synthetic.main.item_edit_address.view.*
import kotlinx.android.synthetic.main.item_edit_email.view.*
Expand All @@ -60,6 +70,8 @@ class EditContactActivity : ContactActivity() {
private val CHOOSE_PHOTO = 2
private val REMOVE_PHOTO = 3

private val AUTO_COMPLETE_DELAY = 5000L

private var mLastSavePromptTS = 0L
private var wasActivityInitialized = false
private var lastPhotoIntentUri: Uri? = null
Expand All @@ -85,6 +97,7 @@ class EditContactActivity : ContactActivity() {
}

contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
setupInsets()
setupMenu()

val action = intent.action
Expand Down Expand Up @@ -256,6 +269,11 @@ class EditContactActivity : ContactActivity() {
setOnLongClickListener { toast(R.string.toggle_favorite); true; }
}

val nameTextViews = arrayOf(contact_first_name, contact_middle_name, contact_surname).filter { it.isVisible() }
if (nameTextViews.isNotEmpty()) {
setupAutoComplete(nameTextViews)
}

updateTextColors(contact_scrollview)
numberViewToColor?.setTextColor(properPrimaryColor)
emailViewToColor?.setTextColor(properPrimaryColor)
Expand Down Expand Up @@ -283,6 +301,17 @@ class EditContactActivity : ContactActivity() {
}
}

private fun setupInsets() {
contact_wrapper.setOnApplyWindowInsetsListener { _, insets ->
val windowInsets = WindowInsetsCompat.toWindowInsetsCompat(insets)
val imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime())
contact_scrollview.run {
setPadding(paddingLeft, paddingTop, paddingRight, imeInsets.bottom)
}
insets
}
}

private fun setupMenu() {
(contact_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
contact_toolbar.menu.apply {
Expand Down Expand Up @@ -1605,4 +1634,33 @@ class EditContactActivity : ContactActivity() {
getString(R.string.jabber) -> Im.PROTOCOL_JABBER
else -> Im.PROTOCOL_CUSTOM
}

private fun setupAutoComplete(nameTextViews: List<MyAutoCompleteTextView>) {
ContactsHelper(this).getContacts { contacts ->
val adapter = AutoCompleteTextViewAdapter(this, contacts)
val handler = Handler(mainLooper)
nameTextViews.forEach { view ->
view.setAdapter(adapter)
view.setOnItemClickListener { _, _, position, _ ->
val selectedContact = adapter.resultList[position]

if (contact_first_name.isVisible()) {
contact_first_name.setText(selectedContact.firstName)
}
if (contact_middle_name.isVisible()) {
contact_middle_name.setText(selectedContact.middleName)
}
if (contact_surname.isVisible()) {
contact_surname.setText(selectedContact.surname)
}
}
view.doAfterTextChanged {
handler.postDelayed({
adapter.autoComplete = true
adapter.filter.filter(it)
}, AUTO_COMPLETE_DELAY)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
checkWhatsNewDialog()

if (isPackageInstalled("com.simplemobiletools.contacts")) {
val dialogText = getString(R.string.upgraded_to_pro_contacts, getString(R.string.phone_storage_hidden))
val dialogText = getString(R.string.upgraded_from_free_contacts, getString(R.string.phone_storage_hidden))
ConfirmationDialog(this, dialogText, 0, R.string.ok, 0, false) {}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.simplemobiletools.contacts.pro.adapters

import android.graphics.drawable.BitmapDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Filter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions
import com.simplemobiletools.commons.extensions.beGone
import com.simplemobiletools.commons.extensions.getProperBackgroundColor
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.normalizeString
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.models.contacts.Contact
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_image
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_name
import kotlinx.android.synthetic.main.item_autocomplete_name_number.view.item_autocomplete_number

class AutoCompleteTextViewAdapter(
val activity: SimpleActivity,
val contacts: ArrayList<Contact>,
var autoComplete: Boolean = false
) : ArrayAdapter<Contact>(activity, 0, contacts) {
var resultList = ArrayList<Contact>()

override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val contact = resultList[position]
var listItem = convertView
val nameToUse = contact.getNameToDisplay()
if (listItem == null || listItem.tag != nameToUse.isNotEmpty()) {
listItem = LayoutInflater.from(activity).inflate(R.layout.item_autocomplete_name_number, parent, false)
}

val placeholder = BitmapDrawable(activity.resources, SimpleContactsHelper(context).getContactLetterIcon(nameToUse))
listItem!!.apply {
setBackgroundColor(context.getProperBackgroundColor())
item_autocomplete_name.setTextColor(context.getProperTextColor())
item_autocomplete_number.setTextColor(context.getProperTextColor())

tag = nameToUse.isNotEmpty()
item_autocomplete_name.text = nameToUse
contact.phoneNumbers.apply {
val phoneNumber = firstOrNull { it.isPrimary }?.normalizedNumber ?: firstOrNull()?.normalizedNumber
if (phoneNumber.isNullOrEmpty()) {
item_autocomplete_number.beGone()
} else {
item_autocomplete_number.text = phoneNumber
}
}

val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.error(placeholder)
.centerCrop()

Glide.with(context)
.load(contact.photoUri)
.transition(DrawableTransitionOptions.withCrossFade())
.placeholder(placeholder)
.apply(options)
.apply(RequestOptions.circleCropTransform())
.into(item_autocomplete_image)
}

return listItem
}

override fun getFilter() = object : Filter() {
override fun performFiltering(constraint: CharSequence?): FilterResults {
val filterResults = FilterResults()
if (constraint != null && autoComplete) {
val searchString = constraint.toString().normalizeString()
val results = mutableListOf<Contact>()
contacts.forEach {
if (it.getNameToDisplay().contains(searchString, true)) {
results.add(it)
}
}

results.sortWith(compareBy<Contact>
{ it.name.startsWith(searchString, true) }.thenBy
{ it.name.contains(searchString, true) })
results.reverse()

filterResults.values = results
filterResults.count = results.size
}
return filterResults
}

override fun publishResults(constraint: CharSequence?, results: FilterResults?) {
if (results != null && results.count > 0) {
resultList.clear()
@Suppress("UNCHECKED_CAST")
resultList.addAll(results.values as List<Contact>)
notifyDataSetChanged()
} else {
notifyDataSetInvalidated()
}
}

override fun convertResultToString(resultValue: Any?) = (resultValue as? Contact)?.name
}

override fun getItem(index: Int) = resultList[index]

override fun getCount() = resultList.size
}
13 changes: 9 additions & 4 deletions app/src/main/res/layout/activity_edit_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
android:id="@+id/contact_scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:scrollbars="none"
android:visibility="gone">
android:visibility="gone"
tools:visibility="visible">

<RelativeLayout
android:id="@+id/contact_holder"
Expand Down Expand Up @@ -90,7 +92,7 @@
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size" />

<com.simplemobiletools.commons.views.MyEditText
<com.simplemobiletools.commons.views.MyAutoCompleteTextView
android:id="@+id/contact_first_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -99,6 +101,7 @@
android:layout_marginEnd="@dimen/activity_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_toEndOf="@+id/contact_name_image"
android:completionThreshold="2"
android:hint="@string/first_name"
android:inputType="textCapWords"
android:lines="1"
Expand All @@ -107,7 +110,7 @@
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size" />

<com.simplemobiletools.commons.views.MyEditText
<com.simplemobiletools.commons.views.MyAutoCompleteTextView
android:id="@+id/contact_middle_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -116,6 +119,7 @@
android:layout_marginEnd="@dimen/activity_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_toEndOf="@+id/contact_name_image"
android:completionThreshold="2"
android:hint="@string/middle_name"
android:inputType="textCapWords"
android:lines="1"
Expand All @@ -124,7 +128,7 @@
android:textCursorDrawable="@null"
android:textSize="@dimen/bigger_text_size" />

<com.simplemobiletools.commons.views.MyEditText
<com.simplemobiletools.commons.views.MyAutoCompleteTextView
android:id="@+id/contact_surname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -133,6 +137,7 @@
android:layout_marginEnd="@dimen/activity_margin"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_toEndOf="@+id/contact_name_image"
android:completionThreshold="2"
android:hint="@string/surname"
android:inputType="textCapWords"
android:lines="1"
Expand Down
Loading

0 comments on commit f9c7738

Please sign in to comment.