Skip to content

Commit

Permalink
Format some code
Browse files Browse the repository at this point in the history
  • Loading branch information
naveensingh committed Mar 2, 2025
1 parent 0a8273f commit 8fcd792
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class MainActivity : SimpleActivity() {
private fun showSearchResults(
messages: List<Message>,
conversations: List<Conversation>,
searchedText: String
searchedText: String,
) {
val searchResults = ArrayList<SearchResult>()
conversations.forEach { conversation ->
Expand Down Expand Up @@ -637,8 +637,14 @@ class MainActivity : SimpleActivity() {
val licenses = LICENSE_EVENT_BUS or LICENSE_SMS_MMS or LICENSE_INDICATOR_FAST_SCROLL

val faqItems = arrayListOf(
FAQItem(title = R.string.faq_2_title, text = R.string.faq_2_text),
FAQItem(title = R.string.faq_3_title, text = R.string.faq_3_text),
FAQItem(
title = R.string.faq_2_title,
text = R.string.faq_2_text
),
FAQItem(
title = R.string.faq_3_title,
text = R.string.faq_3_text
),
FAQItem(
title = org.fossify.commons.R.string.faq_9_title_commons,
text = org.fossify.commons.R.string.faq_9_text_commons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ class ThreadActivity : SimpleActivity() {
private fun deleteMessages(
messagesToRemove: List<Message>,
toRecycleBin: Boolean,
fromRecycleBin: Boolean
fromRecycleBin: Boolean,
) {
val deletePosition = threadItems.indexOf(messagesToRemove.first())
messages.removeAll(messagesToRemove.toSet())
Expand Down Expand Up @@ -1069,7 +1069,7 @@ class ThreadActivity : SimpleActivity() {
@SuppressLint("MissingPermission")
private fun getProperSimIndex(
availableSIMs: MutableList<SubscriptionInfo>,
numbers: List<String>
numbers: List<String>,
): Int {
val userPreferredSimId = config.getUseSIMIdAtNumber(numbers.first())
val userPreferredSimIdx =
Expand Down Expand Up @@ -1331,7 +1331,7 @@ class ThreadActivity : SimpleActivity() {
private fun launchActivityForResult(
intent: Intent,
requestCode: Int,
@StringRes error: Int = org.fossify.commons.R.string.no_app_found
@StringRes error: Int = org.fossify.commons.R.string.no_app_found,
) {
hideKeyboard()
try {
Expand Down Expand Up @@ -1708,7 +1708,7 @@ class ThreadActivity : SimpleActivity() {

private fun fixParticipantNumbers(
participants: ArrayList<SimpleContact>,
properNumbers: ArrayList<String>
properNumbers: ArrayList<String>,
): ArrayList<SimpleContact> {
for (number in properNumbers) {
for (participant in participants) {
Expand Down Expand Up @@ -2068,7 +2068,7 @@ class ThreadActivity : SimpleActivity() {

override fun onProgress(
insets: WindowInsetsCompat,
runningAnimations: MutableList<WindowInsetsAnimationCompat>
runningAnimations: MutableList<WindowInsetsAnimationCompat>,
) = insets
}
ViewCompat.setWindowInsetsAnimationCallback(window.decorView, callback)
Expand Down
39 changes: 33 additions & 6 deletions app/src/main/kotlin/org/fossify/messages/extensions/Activity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.provider.ContactsContract
import org.fossify.commons.extensions.*
import org.fossify.commons.extensions.getMimeType
import org.fossify.commons.extensions.hideKeyboard
import org.fossify.commons.extensions.isPackageInstalled
import org.fossify.commons.extensions.launchActivityIntent
import org.fossify.commons.extensions.launchViewContactIntent
import org.fossify.commons.extensions.showErrorToast
import org.fossify.commons.extensions.toast
import org.fossify.commons.helpers.CONTACT_ID
import org.fossify.commons.helpers.IS_PRIVATE
import org.fossify.commons.helpers.SimpleContactsHelper
Expand Down Expand Up @@ -56,21 +62,42 @@ fun Activity.launchViewIntent(uri: Uri, mimetype: String, filename: String) {
fun Activity.startContactDetailsIntent(contact: SimpleContact) {
val simpleContacts = "org.fossify.contacts"
val simpleContactsDebug = "org.fossify.contacts.debug"
if (contact.rawId > 1000000 && contact.contactId > 1000000 && contact.rawId == contact.contactId &&
if (
contact.rawId > 1000000 &&
contact.contactId > 1000000 &&
contact.rawId == contact.contactId &&
(isPackageInstalled(simpleContacts) || isPackageInstalled(simpleContactsDebug))
) {
Intent().apply {
action = Intent.ACTION_VIEW
putExtra(CONTACT_ID, contact.rawId)
putExtra(IS_PRIVATE, true)
setPackage(if (isPackageInstalled(simpleContacts)) simpleContacts else simpleContactsDebug)
setDataAndType(ContactsContract.Contacts.CONTENT_LOOKUP_URI, "vnd.android.cursor.dir/person")
setPackage(
if (isPackageInstalled(simpleContacts)) {
simpleContacts
} else {
simpleContactsDebug
}
)

setDataAndType(
ContactsContract.Contacts.CONTENT_LOOKUP_URI,
"vnd.android.cursor.dir/person"
)

launchActivityIntent(this)
}
} else {
ensureBackgroundThread {
val lookupKey = SimpleContactsHelper(this).getContactLookupKey((contact).rawId.toString())
val publicUri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey)
val lookupKey = SimpleContactsHelper(this)
.getContactLookupKey(
contactId = (contact).rawId.toString()
)

val publicUri = Uri.withAppendedPath(
ContactsContract.Contacts.CONTENT_LOOKUP_URI, lookupKey
)

runOnUiThread {
launchViewContactIntent(publicUri)
}
Expand Down

0 comments on commit 8fcd792

Please sign in to comment.