Skip to content

Commit

Permalink
Remove deprecated functions and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstyl committed Feb 20, 2022
1 parent f60623f commit 778fe1e
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions library/src/main/java/com/alexstyl/contactstore/Contact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
}
23 changes: 0 additions & 23 deletions library/src/main/java/com/alexstyl/contactstore/ContactColumn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContactColumn> {
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<ContactColumn> {
return listOf(
ContactColumn.Phones,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*/
Expand All @@ -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<Long>? = 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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/**
Expand Down
11 changes: 0 additions & 11 deletions library/src/main/java/com/alexstyl/contactstore/CustomDataItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) }
)
}
}
Expand Down

0 comments on commit 778fe1e

Please sign in to comment.