From 778fe1ecec9dd8de6293c5e57fcaf8f78a203153 Mon Sep 17 00:00:00 2001 From: Alex Styl <1665273+alexstyl@users.noreply.github.com> Date: Sun, 20 Feb 2022 10:25:29 +0000 Subject: [PATCH] Remove deprecated functions and properties --- .../contactstore/test/TestContactStore.kt | 16 ---------- .../contactstore/AndroidContactStore.kt | 18 ++++------- .../java/com/alexstyl/contactstore/Contact.kt | 18 ----------- .../alexstyl/contactstore/ContactColumn.kt | 23 -------------- .../alexstyl/contactstore/ContactPredicate.kt | 31 +------------------ .../alexstyl/contactstore/ContactQueries.kt | 3 +- .../com/alexstyl/contactstore/ContactStore.kt | 6 ---- .../alexstyl/contactstore/CustomDataItem.kt | 11 ------- .../com/alexstyl/contactstore/DataClasses.kt | 6 ---- .../contactstore/MutableContactBuilder.kt | 5 --- .../contactstore/ContactStoreDSLKtTest.kt | 4 --- .../sample/ContactListActivity.kt | 3 +- 12 files changed, 9 insertions(+), 135 deletions(-) diff --git a/library-test/src/main/java/com/alexstyl/contactstore/test/TestContactStore.kt b/library-test/src/main/java/com/alexstyl/contactstore/test/TestContactStore.kt index ef006bf7..0a7e7b96 100644 --- a/library-test/src/main/java/com/alexstyl/contactstore/test/TestContactStore.kt +++ b/library-test/src/main/java/com/alexstyl/contactstore/test/TestContactStore.kt @@ -50,14 +50,6 @@ public class TestContactStore( override suspend fun execute(request: SaveRequest.() -> Unit) { val saveRequest = SaveRequest().apply(request) - executeInternal(saveRequest) - } - - override suspend fun execute(request: SaveRequest) { - executeInternal(request) - } - - private suspend fun executeInternal(saveRequest: SaveRequest) { saveRequest.requests.forEach { operation -> when (operation) { is Delete -> deleteContact(withId = operation.contactId) @@ -308,18 +300,10 @@ public class TestContactStore( } } - - @Suppress("DEPRECATION") // using deprecated to warn any consumers of the library. To be removed in 1.0.0 private fun matchesContact( predicate: ContactPredicate.ContactLookup, contact: StoredContact ): Boolean { - if (predicate.inContactIds.orEmpty().isNotEmpty()) { - System.err.println("ContactLookup.inContactIds does nothing. Use ContactLookup.contactId instead") - } - if (predicate.isFavorite != null) { - System.err.println("ContactLookup.isFavorite does nothing") - } return predicate.contactId == contact.contactId } diff --git a/library/src/main/java/com/alexstyl/contactstore/AndroidContactStore.kt b/library/src/main/java/com/alexstyl/contactstore/AndroidContactStore.kt index 3dbc04fb..504c729b 100644 --- a/library/src/main/java/com/alexstyl/contactstore/AndroidContactStore.kt +++ b/library/src/main/java/com/alexstyl/contactstore/AndroidContactStore.kt @@ -11,7 +11,6 @@ import com.alexstyl.contactstore.ContactOperation.UpdateGroup import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.withContext internal class AndroidContactStore( private val contentResolver: ContentResolver, @@ -23,19 +22,14 @@ internal class AndroidContactStore( ) : ContactStore { override suspend fun execute(request: SaveRequest.() -> Unit) { - executeInternal(SaveRequest().apply(request)) - } - - override suspend fun execute(request: SaveRequest) { - executeInternal(request) - } - - private suspend fun executeInternal(request: SaveRequest) = withContext(Dispatchers.IO) { - request.requests.map { operation -> + val apply = SaveRequest().apply(request) + apply.requests.map { operation -> when (operation) { is Update -> existingContactOperationsFactory.updateOperation(operation.contact) - is Insert -> newContactOperationsFactory.addContactsOperation(operation.account, operation.contact) - is Delete -> existingContactOperationsFactory.deleteContactOperation(operation.contactId) + is Insert -> newContactOperationsFactory + .addContactsOperation(operation.account, operation.contact) + is Delete -> existingContactOperationsFactory + .deleteContactOperation(operation.contactId) is InsertGroup -> contactGroupOperations.addGroupOperation(operation.group) is UpdateGroup -> contactGroupOperations.updateGroupOperation(operation.group) is DeleteGroup -> contactGroupOperations.deleteGroupOperation(operation.groupId) diff --git a/library/src/main/java/com/alexstyl/contactstore/Contact.kt b/library/src/main/java/com/alexstyl/contactstore/Contact.kt index e1b92bf1..ce4df5d4 100644 --- a/library/src/main/java/com/alexstyl/contactstore/Contact.kt +++ b/library/src/main/java/com/alexstyl/contactstore/Contact.kt @@ -169,15 +169,6 @@ public fun Contact.containsColumn(column: ContactColumn): Boolean { return columns.any { it == column } } -@Deprecated( - "LinkedAccountValues have been deprecated and replaced with CustomDataItem. This function will go away in 1.0.0", - ReplaceWith("false") -) -@Suppress("unused") // part of the API -public fun Contact.containsLinkedAccountColumns(): Boolean { - return false -} - /** * Creates a copy of the Contact that can have its properties modified. * @@ -249,12 +240,3 @@ public val Contact.thumbnailUri: Uri val contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId) return Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY) } - -@Deprecated( - "This function has been renamed and will be removed in 1.0.0", - ReplaceWith("thumbnailUri") -) -public val Contact.imageUri: Uri - get() { - return thumbnailUri - } diff --git a/library/src/main/java/com/alexstyl/contactstore/ContactColumn.kt b/library/src/main/java/com/alexstyl/contactstore/ContactColumn.kt index c9894529..442d7c2f 100644 --- a/library/src/main/java/com/alexstyl/contactstore/ContactColumn.kt +++ b/library/src/main/java/com/alexstyl/contactstore/ContactColumn.kt @@ -82,29 +82,6 @@ public sealed class ContactColumn { public object Relations : ContactColumn() } -@Deprecated( - "The concept of 'standard columns' is going away in 1.0.0.", - ReplaceWith("allContactColumns()") -) -public fun standardColumns(): List { - return listOf( - ContactColumn.Phones, - ContactColumn.Mails, - ContactColumn.Note, - ContactColumn.Events, - ContactColumn.PostalAddresses, - ContactColumn.Image, - ContactColumn.Names, - ContactColumn.Nickname, - ContactColumn.WebAddresses, - ContactColumn.Organization, - ContactColumn.GroupMemberships, - ContactColumn.ImAddresses, - ContactColumn.Relations, - ContactColumn.SipAddresses, - ) -} - public fun allContactColumns(): List { return listOf( ContactColumn.Phones, diff --git a/library/src/main/java/com/alexstyl/contactstore/ContactPredicate.kt b/library/src/main/java/com/alexstyl/contactstore/ContactPredicate.kt index 70bc7101..488f200c 100644 --- a/library/src/main/java/com/alexstyl/contactstore/ContactPredicate.kt +++ b/library/src/main/java/com/alexstyl/contactstore/ContactPredicate.kt @@ -1,26 +1,6 @@ package com.alexstyl.contactstore public sealed class ContactPredicate { - public companion object { - @Suppress("FunctionName") - @Deprecated( - "Use a string directly instead. This signature is going away in 1.0.0", - ReplaceWith("PhoneLookup(phoneNumber.raw)") - ) - public fun PhoneLookup(phoneNumber: PhoneNumber): ContactPredicate { - return PhoneLookup(phoneNumber.raw) - } - - @Suppress("FunctionName") - @Deprecated( - "Use a string directly instead. This signature is going away in 1.0.0", - ReplaceWith("MailLookup(mailAddress.raw)") - ) - public fun MailLookup(mailAddress: MailAddress): ContactPredicate { - return MailLookup(mailAddress.raw) - } - } - /** * Performs a contact lookup by trying to match the given string against each contact's phone numbers. */ @@ -39,14 +19,5 @@ public sealed class ContactPredicate { /** * Performs a contact lookup by trying to find a contact with the given contact id. */ - public data class ContactLookup( - val contactId: Long, - @Deprecated( - "This property does nothing and will go away in 1.0.0. Perform multiple contactFetches using ContactStore#fetchContacts() using FlowKt.combine()", - ReplaceWith("contactId") - ) - val inContactIds: List? = null, - @Deprecated("This property is not used. It will go away in 1.0.0") - val isFavorite: Boolean? = null, - ) : ContactPredicate() + public data class ContactLookup(val contactId: Long) : ContactPredicate() } diff --git a/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt b/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt index 1ba7e5d3..c111d104 100644 --- a/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt +++ b/library/src/main/java/com/alexstyl/contactstore/ContactQueries.kt @@ -410,12 +410,11 @@ internal class ContactQueries( } columnsToFetch.contains(CustomDataItems) -> { val mimeType = linkedAccountMimeTypes[mimetype] - if (mimeType != null) { + if (mimeType != null && account != null) { val id = item.getAsLong(Contacts.Data._ID) if (id != null) { val value = CustomDataItem( id = id, - accountType = account!!.type, summary = item.getAsString(mimeType.summaryColumn), detail = item.getAsString(mimeType.detailColumn), icon = mimeType.icon, diff --git a/library/src/main/java/com/alexstyl/contactstore/ContactStore.kt b/library/src/main/java/com/alexstyl/contactstore/ContactStore.kt index 5f93b5bc..a019a04e 100644 --- a/library/src/main/java/com/alexstyl/contactstore/ContactStore.kt +++ b/library/src/main/java/com/alexstyl/contactstore/ContactStore.kt @@ -14,12 +14,6 @@ import kotlinx.coroutines.flow.Flow */ public interface ContactStore { - @Deprecated( - "Prefer the version of this function that receives a lambda. This function will be removed in 1.0.0", - ReplaceWith("execute {}") - ) - public suspend fun execute(request: SaveRequest) - public suspend fun execute(request: SaveRequest.() -> Unit) /** diff --git a/library/src/main/java/com/alexstyl/contactstore/CustomDataItem.kt b/library/src/main/java/com/alexstyl/contactstore/CustomDataItem.kt index 6e7c6ab7..9cc6e100 100644 --- a/library/src/main/java/com/alexstyl/contactstore/CustomDataItem.kt +++ b/library/src/main/java/com/alexstyl/contactstore/CustomDataItem.kt @@ -2,20 +2,9 @@ package com.alexstyl.contactstore import android.graphics.drawable.Drawable -@Deprecated( - "LinkedAccountValues have been replaced with CustomDataItem and will be going away on 1.0.0", - ReplaceWith("CustomDataItem") -) -public typealias LinkedAccountValue = CustomDataItem - public data class CustomDataItem( val id: Long, val mimeType: String, - @Deprecated( - "Account type is going away in 1.0.0. Use the account property instead", - ReplaceWith("account.type") - ) - val accountType: String, val summary: String, val detail: String, val icon: Drawable, diff --git a/library/src/main/java/com/alexstyl/contactstore/DataClasses.kt b/library/src/main/java/com/alexstyl/contactstore/DataClasses.kt index 929e3d18..3d7b6e69 100644 --- a/library/src/main/java/com/alexstyl/contactstore/DataClasses.kt +++ b/library/src/main/java/com/alexstyl/contactstore/DataClasses.kt @@ -29,12 +29,6 @@ public data class PhoneNumber(val raw: String) public data class WebAddress(val raw: Uri) -@Deprecated( - "This function will be removed in 1.0.0", - ReplaceWith("WebAddress(Uri.parse(raw))", "import android.net.Uri") -) -public fun WebAddress(raw: String): WebAddress = WebAddress(Uri.parse(raw)) - public data class PostalAddress( val street: String, val poBox: String = "", diff --git a/library/src/main/java/com/alexstyl/contactstore/MutableContactBuilder.kt b/library/src/main/java/com/alexstyl/contactstore/MutableContactBuilder.kt index 51a2e55e..0d5d6428 100644 --- a/library/src/main/java/com/alexstyl/contactstore/MutableContactBuilder.kt +++ b/library/src/main/java/com/alexstyl/contactstore/MutableContactBuilder.kt @@ -111,11 +111,6 @@ public class MutableContactBuilder( ) } - @Deprecated("Use the Uri version instead. This function will be removed in version 1.0.0") - public fun webAddress(address: String, label: Label) { - _webAddresses.add(LabeledValue(WebAddress(Uri.parse(address)), label)) - } - public fun webAddress(address: Uri, label: Label) { _webAddresses.add(LabeledValue(WebAddress(address), label)) } diff --git a/library/src/test/java/com/alexstyl/contactstore/ContactStoreDSLKtTest.kt b/library/src/test/java/com/alexstyl/contactstore/ContactStoreDSLKtTest.kt index e29aa7ad..79683d92 100644 --- a/library/src/test/java/com/alexstyl/contactstore/ContactStoreDSLKtTest.kt +++ b/library/src/test/java/com/alexstyl/contactstore/ContactStoreDSLKtTest.kt @@ -122,10 +122,6 @@ internal class ContactStoreDSLKtTest { var request: SaveRequest? = null - override suspend fun execute(request: SaveRequest) { - this.request = request - } - override suspend fun execute(request: SaveRequest.() -> Unit) { this.request = SaveRequest().apply(request) } diff --git a/sample/src/main/java/com/alexstyl/contactstore/sample/ContactListActivity.kt b/sample/src/main/java/com/alexstyl/contactstore/sample/ContactListActivity.kt index c32e3ede..d8c134d1 100644 --- a/sample/src/main/java/com/alexstyl/contactstore/sample/ContactListActivity.kt +++ b/sample/src/main/java/com/alexstyl/contactstore/sample/ContactListActivity.kt @@ -25,7 +25,6 @@ import coil.annotation.ExperimentalCoilApi import coil.compose.rememberImagePainter import coil.transform.CircleCropTransformation import com.alexstyl.contactstore.Contact -import com.alexstyl.contactstore.imageUri import com.alexstyl.contactstore.sample.ContactDetailsActivity.Companion.EXTRA_CONTACT_ID import com.alexstyl.contactstore.sample.ContactListState.* import com.alexstyl.contactstore.sample.ui.SetupSystemUi @@ -176,7 +175,7 @@ fun ContactRow(contact: Contact, onClick: (Contact) -> Unit) { ) Spacer(modifier = Modifier.width(24.dp)) Text( - text = contact.displayName.orEmpty().ifEmpty { stringResource(R.string.anonymous) } + text = contact.displayName.ifEmpty { stringResource(R.string.anonymous) } ) } }