Migrate from kotlin synthetics to View binding
This commit is contained in:
parent
3e1675d579
commit
0c01e607bb
36 changed files with 1139 additions and 1083 deletions
|
|
@ -8,34 +8,40 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.ArchivedConversationsAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityArchivedConversationsBinding
|
||||
import com.simplemobiletools.smsmessenger.extensions.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.models.Conversation
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import kotlinx.android.synthetic.main.activity_archived_conversations.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class ArchivedConversationsActivity : SimpleActivity() {
|
||||
private var bus: EventBus? = null
|
||||
private val binding by viewBinding(ActivityArchivedConversationsBinding::inflate)
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_archived_conversations)
|
||||
setContentView(binding.root)
|
||||
setupOptionsMenu()
|
||||
|
||||
updateMaterialActivityViews(archive_coordinator, conversations_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(conversations_list, archive_toolbar)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.archiveCoordinator,
|
||||
nestedView = binding.conversationsList,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.conversationsList, toolbar = binding.archiveToolbar)
|
||||
|
||||
loadArchivedConversations()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(archive_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.archiveToolbar, NavigationIcon.Arrow)
|
||||
updateMenuColors()
|
||||
|
||||
loadArchivedConversations()
|
||||
|
|
@ -47,9 +53,8 @@ class ArchivedConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
archive_toolbar.inflateMenu(R.menu.archive_menu)
|
||||
|
||||
archive_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.archiveToolbar.inflateMenu(R.menu.archive_menu)
|
||||
binding.archiveToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.empty_archive -> removeAll()
|
||||
else -> return@setOnMenuItemClickListener false
|
||||
|
|
@ -59,7 +64,7 @@ class ArchivedConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateOptionsMenu(conversations: ArrayList<Conversation>) {
|
||||
archive_toolbar.menu.apply {
|
||||
binding.archiveToolbar.menu.apply {
|
||||
findItem(R.id.empty_archive).isVisible = conversations.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +89,7 @@ class ArchivedConversationsActivity : SimpleActivity() {
|
|||
bus = EventBus.getDefault()
|
||||
try {
|
||||
bus!!.register(this)
|
||||
} catch (e: Exception) {
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,19 +102,19 @@ class ArchivedConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getOrCreateConversationsAdapter(): ArchivedConversationsAdapter {
|
||||
var currAdapter = conversations_list.adapter
|
||||
var currAdapter = binding.conversationsList.adapter
|
||||
if (currAdapter == null) {
|
||||
hideKeyboard()
|
||||
currAdapter = ArchivedConversationsAdapter(
|
||||
activity = this,
|
||||
recyclerView = conversations_list,
|
||||
recyclerView = binding.conversationsList,
|
||||
onRefresh = { notifyDatasetChanged() },
|
||||
itemClick = { handleConversationClick(it) }
|
||||
)
|
||||
|
||||
conversations_list.adapter = currAdapter
|
||||
binding.conversationsList.adapter = currAdapter
|
||||
if (areSystemAnimationsEnabled) {
|
||||
conversations_list.scheduleLayoutAnimation()
|
||||
binding.conversationsList.scheduleLayoutAnimation()
|
||||
}
|
||||
}
|
||||
return currAdapter as ArchivedConversationsAdapter
|
||||
|
|
@ -133,9 +138,9 @@ class ArchivedConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun showOrHidePlaceholder(show: Boolean) {
|
||||
conversations_fastscroller.beGoneIf(show)
|
||||
no_conversations_placeholder.beVisibleIf(show)
|
||||
no_conversations_placeholder.text = getString(R.string.no_archived_conversations)
|
||||
binding.conversationsFastscroller.beGoneIf(show)
|
||||
binding.noConversationsPlaceholder.beVisibleIf(show)
|
||||
binding.noConversationsPlaceholder.text = getString(R.string.no_archived_conversations)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
|
|
|||
|
|
@ -2,20 +2,17 @@ package com.simplemobiletools.smsmessenger.activities
|
|||
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.getProperTextColor
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityConversationDetailsBinding
|
||||
import com.simplemobiletools.smsmessenger.dialogs.RenameConversationDialog
|
||||
import com.simplemobiletools.smsmessenger.extensions.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.THREAD_ID
|
||||
import com.simplemobiletools.smsmessenger.models.Conversation
|
||||
import kotlinx.android.synthetic.main.activity_conversation_details.*
|
||||
|
||||
class ConversationDetailsActivity : SimpleActivity() {
|
||||
|
||||
|
|
@ -23,13 +20,20 @@ class ConversationDetailsActivity : SimpleActivity() {
|
|||
private var conversation: Conversation? = null
|
||||
private lateinit var participants: ArrayList<SimpleContact>
|
||||
|
||||
private val binding by viewBinding(ActivityConversationDetailsBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_conversation_details)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(conversation_details_coordinator, participants_recyclerview, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(participants_recyclerview, conversation_details_toolbar)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.conversationDetailsCoordinator,
|
||||
nestedView = binding.participantsRecyclerview,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.participantsRecyclerview, toolbar = binding.conversationDetailsToolbar)
|
||||
|
||||
threadId = intent.getLongExtra(THREAD_ID, 0L)
|
||||
ensureBackgroundThread {
|
||||
|
|
@ -49,16 +53,16 @@ class ConversationDetailsActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(conversation_details_toolbar, NavigationIcon.Arrow)
|
||||
updateTextColors(conversation_details_holder)
|
||||
setupToolbar(binding.conversationDetailsToolbar, NavigationIcon.Arrow)
|
||||
updateTextColors(binding.conversationDetailsHolder)
|
||||
|
||||
val primaryColor = getProperPrimaryColor()
|
||||
conversation_name_heading.setTextColor(primaryColor)
|
||||
members_heading.setTextColor(primaryColor)
|
||||
binding.conversationNameHeading.setTextColor(primaryColor)
|
||||
binding.membersHeading.setTextColor(primaryColor)
|
||||
}
|
||||
|
||||
private fun setupTextViews() {
|
||||
conversation_name.apply {
|
||||
binding.conversationName.apply {
|
||||
ResourcesCompat.getDrawable(resources, R.drawable.ic_edit_vector, theme)?.apply {
|
||||
applyColorFilter(getProperTextColor())
|
||||
setCompoundDrawablesWithIntrinsicBounds(null, null, this, null)
|
||||
|
|
@ -77,7 +81,7 @@ class ConversationDetailsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupParticipants() {
|
||||
val adapter = ContactsAdapter(this, participants, participants_recyclerview) {
|
||||
val adapter = ContactsAdapter(this, participants, binding.participantsRecyclerview) {
|
||||
val contact = it as SimpleContact
|
||||
val address = contact.phoneNumbers.first().normalizedNumber
|
||||
getContactFromAddress(address) { simpleContact ->
|
||||
|
|
@ -86,6 +90,6 @@ class ConversationDetailsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
participants_recyclerview.adapter = adapter
|
||||
binding.participantsRecyclerview.adapter = adapter
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ import com.simplemobiletools.smsmessenger.BuildConfig
|
|||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.ConversationsAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.SearchResultsAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityMainBinding
|
||||
import com.simplemobiletools.smsmessenger.extensions.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.models.Conversation
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import com.simplemobiletools.smsmessenger.models.Message
|
||||
import com.simplemobiletools.smsmessenger.models.SearchResult
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
|
@ -41,16 +41,23 @@ class MainActivity : SimpleActivity() {
|
|||
private var bus: EventBus? = null
|
||||
private var wasProtectionHandled = false
|
||||
|
||||
private val binding by viewBinding(ActivityMainBinding::inflate)
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
setContentView(binding.root)
|
||||
appLaunched(BuildConfig.APPLICATION_ID)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(main_coordinator, conversations_list, useTransparentNavigation = true, useTopSearchMenu = true)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.mainCoordinator,
|
||||
nestedView = binding.conversationsList,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = true
|
||||
)
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
checkAndDeleteOldRecycleBinMessages()
|
||||
|
|
@ -88,17 +95,17 @@ class MainActivity : SimpleActivity() {
|
|||
updateDrafts()
|
||||
}
|
||||
|
||||
updateTextColors(main_coordinator)
|
||||
search_holder.setBackgroundColor(getProperBackgroundColor())
|
||||
updateTextColors(binding.mainCoordinator)
|
||||
binding.searchHolder.setBackgroundColor(getProperBackgroundColor())
|
||||
|
||||
val properPrimaryColor = getProperPrimaryColor()
|
||||
no_conversations_placeholder_2.setTextColor(properPrimaryColor)
|
||||
no_conversations_placeholder_2.underlineText()
|
||||
conversations_fastscroller.updateColors(properPrimaryColor)
|
||||
conversations_progress_bar.setIndicatorColor(properPrimaryColor)
|
||||
conversations_progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||
binding.noConversationsPlaceholder2.setTextColor(properPrimaryColor)
|
||||
binding.noConversationsPlaceholder2.underlineText()
|
||||
binding.conversationsFastscroller.updateColors(properPrimaryColor)
|
||||
binding.conversationsProgressBar.setIndicatorColor(properPrimaryColor)
|
||||
binding.conversationsProgressBar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||
checkShortcut()
|
||||
(conversations_fab?.layoutParams as? CoordinatorLayout.LayoutParams)?.bottomMargin =
|
||||
(binding.conversationsFab.layoutParams as? CoordinatorLayout.LayoutParams)?.bottomMargin =
|
||||
navigationBarHeight + resources.getDimension(R.dimen.activity_margin).toInt()
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +120,8 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (main_menu.isSearchOpen) {
|
||||
main_menu.closeSearch()
|
||||
if (binding.mainMenu.isSearchOpen) {
|
||||
binding.mainMenu.closeSearch()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
|
@ -144,18 +151,18 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
main_menu.getToolbar().inflateMenu(R.menu.menu_main)
|
||||
main_menu.toggleHideOnScroll(true)
|
||||
main_menu.setupMenu()
|
||||
binding.mainMenu.getToolbar().inflateMenu(R.menu.menu_main)
|
||||
binding.mainMenu.toggleHideOnScroll(true)
|
||||
binding.mainMenu.setupMenu()
|
||||
|
||||
main_menu.onSearchClosedListener = {
|
||||
binding.mainMenu.onSearchClosedListener = {
|
||||
fadeOutSearch()
|
||||
}
|
||||
|
||||
main_menu.onSearchTextChangedListener = { text ->
|
||||
binding.mainMenu.onSearchTextChangedListener = { text ->
|
||||
if (text.isNotEmpty()) {
|
||||
if (search_holder.alpha < 1f) {
|
||||
search_holder.fadeIn()
|
||||
if (binding.searchHolder.alpha < 1f) {
|
||||
binding.searchHolder.fadeIn()
|
||||
}
|
||||
} else {
|
||||
fadeOutSearch()
|
||||
|
|
@ -163,7 +170,7 @@ class MainActivity : SimpleActivity() {
|
|||
searchTextChanged(text)
|
||||
}
|
||||
|
||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||
binding.mainMenu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||
R.id.show_recycle_bin -> launchRecycleBin()
|
||||
|
|
@ -177,7 +184,7 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun refreshMenuItems() {
|
||||
main_menu.getToolbar().menu.apply {
|
||||
binding.mainMenu.getToolbar().menu.apply {
|
||||
findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations)
|
||||
findItem(R.id.show_recycle_bin).isVisible = config.useRecycleBin
|
||||
}
|
||||
|
|
@ -201,7 +208,7 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
private fun updateMenuColors() {
|
||||
updateStatusbarColor(getProperBackgroundColor())
|
||||
main_menu.updateColors()
|
||||
binding.mainMenu.updateColors()
|
||||
}
|
||||
|
||||
private fun loadMessages() {
|
||||
|
|
@ -249,7 +256,7 @@ class MainActivity : SimpleActivity() {
|
|||
bus = EventBus.getDefault()
|
||||
try {
|
||||
bus!!.register(this)
|
||||
} catch (e: Exception) {
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -267,11 +274,11 @@ class MainActivity : SimpleActivity() {
|
|||
storeStateVariables()
|
||||
getCachedConversations()
|
||||
|
||||
no_conversations_placeholder_2.setOnClickListener {
|
||||
binding.noConversationsPlaceholder2.setOnClickListener {
|
||||
launchNewConversation()
|
||||
}
|
||||
|
||||
conversations_fab.setOnClickListener {
|
||||
binding.conversationsFab.setOnClickListener {
|
||||
launchNewConversation()
|
||||
}
|
||||
}
|
||||
|
|
@ -364,19 +371,19 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getOrCreateConversationsAdapter(): ConversationsAdapter {
|
||||
var currAdapter = conversations_list.adapter
|
||||
var currAdapter = binding.conversationsList.adapter
|
||||
if (currAdapter == null) {
|
||||
hideKeyboard()
|
||||
currAdapter = ConversationsAdapter(
|
||||
activity = this,
|
||||
recyclerView = conversations_list,
|
||||
recyclerView = binding.conversationsList,
|
||||
onRefresh = { notifyDatasetChanged() },
|
||||
itemClick = { handleConversationClick(it) }
|
||||
)
|
||||
|
||||
conversations_list.adapter = currAdapter
|
||||
binding.conversationsList.adapter = currAdapter
|
||||
if (areSystemAnimationsEnabled) {
|
||||
conversations_list.scheduleLayoutAnimation()
|
||||
binding.conversationsList.scheduleLayoutAnimation()
|
||||
}
|
||||
}
|
||||
return currAdapter as ConversationsAdapter
|
||||
|
|
@ -410,25 +417,25 @@ class MainActivity : SimpleActivity() {
|
|||
|
||||
private fun showOrHideProgress(show: Boolean) {
|
||||
if (show) {
|
||||
conversations_progress_bar.show()
|
||||
no_conversations_placeholder.beVisible()
|
||||
no_conversations_placeholder.text = getString(R.string.loading_messages)
|
||||
binding.conversationsProgressBar.show()
|
||||
binding.noConversationsPlaceholder.beVisible()
|
||||
binding.noConversationsPlaceholder.text = getString(R.string.loading_messages)
|
||||
} else {
|
||||
conversations_progress_bar.hide()
|
||||
no_conversations_placeholder.beGone()
|
||||
binding.conversationsProgressBar.hide()
|
||||
binding.noConversationsPlaceholder.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOrHidePlaceholder(show: Boolean) {
|
||||
conversations_fastscroller.beGoneIf(show)
|
||||
no_conversations_placeholder.beVisibleIf(show)
|
||||
no_conversations_placeholder.text = getString(R.string.no_conversations_found)
|
||||
no_conversations_placeholder_2.beVisibleIf(show)
|
||||
binding.conversationsFastscroller.beGoneIf(show)
|
||||
binding.noConversationsPlaceholder.beVisibleIf(show)
|
||||
binding.noConversationsPlaceholder.text = getString(R.string.no_conversations_found)
|
||||
binding.noConversationsPlaceholder2.beVisibleIf(show)
|
||||
}
|
||||
|
||||
private fun fadeOutSearch() {
|
||||
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
||||
search_holder.beGone()
|
||||
binding.searchHolder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
||||
binding.searchHolder.beGone()
|
||||
searchTextChanged("", true)
|
||||
}.start()
|
||||
}
|
||||
|
|
@ -488,12 +495,12 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun searchTextChanged(text: String, forceUpdate: Boolean = false) {
|
||||
if (!main_menu.isSearchOpen && !forceUpdate) {
|
||||
if (!binding.mainMenu.isSearchOpen && !forceUpdate) {
|
||||
return
|
||||
}
|
||||
|
||||
lastSearchedText = text
|
||||
search_placeholder_2.beGoneIf(text.length >= 2)
|
||||
binding.searchPlaceholder2.beGoneIf(text.length >= 2)
|
||||
if (text.length >= 2) {
|
||||
ensureBackgroundThread {
|
||||
val searchQuery = "%$text%"
|
||||
|
|
@ -504,8 +511,8 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
search_placeholder.beVisible()
|
||||
search_results_list.beGone()
|
||||
binding.searchPlaceholder.beVisible()
|
||||
binding.searchResultsList.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -530,12 +537,12 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
runOnUiThread {
|
||||
search_results_list.beVisibleIf(searchResults.isNotEmpty())
|
||||
search_placeholder.beVisibleIf(searchResults.isEmpty())
|
||||
binding.searchResultsList.beVisibleIf(searchResults.isNotEmpty())
|
||||
binding.searchPlaceholder.beVisibleIf(searchResults.isEmpty())
|
||||
|
||||
val currAdapter = search_results_list.adapter
|
||||
val currAdapter = binding.searchResultsList.adapter
|
||||
if (currAdapter == null) {
|
||||
SearchResultsAdapter(this, searchResults, search_results_list, searchedText) {
|
||||
SearchResultsAdapter(this, searchResults, binding.searchResultsList, searchedText) {
|
||||
hideKeyboard()
|
||||
Intent(this, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, (it as SearchResult).threadId)
|
||||
|
|
@ -544,7 +551,7 @@ class MainActivity : SimpleActivity() {
|
|||
startActivity(this)
|
||||
}
|
||||
}.apply {
|
||||
search_results_list.adapter = this
|
||||
binding.searchResultsList.adapter = this
|
||||
}
|
||||
} else {
|
||||
(currAdapter as SearchResultsAdapter).updateItems(searchResults, searchedText)
|
||||
|
|
|
|||
|
|
@ -6,35 +6,43 @@ import com.simplemobiletools.commons.extensions.beVisibleIf
|
|||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||
import com.simplemobiletools.commons.extensions.underlineText
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.viewBinding
|
||||
import com.simplemobiletools.commons.helpers.APP_ICON_IDS
|
||||
import com.simplemobiletools.commons.helpers.APP_LAUNCHER_NAME
|
||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityManageBlockedKeywordsBinding
|
||||
import com.simplemobiletools.smsmessenger.dialogs.AddBlockedKeywordDialog
|
||||
import com.simplemobiletools.smsmessenger.dialogs.ManageBlockedKeywordsAdapter
|
||||
import com.simplemobiletools.smsmessenger.extensions.config
|
||||
import com.simplemobiletools.smsmessenger.extensions.toArrayList
|
||||
import kotlinx.android.synthetic.main.activity_manage_blocked_keywords.*
|
||||
|
||||
class ManageBlockedKeywordsActivity : BaseSimpleActivity(), RefreshRecyclerViewListener {
|
||||
override fun getAppIconIDs() = intent.getIntegerArrayListExtra(APP_ICON_IDS) ?: ArrayList()
|
||||
|
||||
override fun getAppLauncherName() = intent.getStringExtra(APP_LAUNCHER_NAME) ?: ""
|
||||
|
||||
private val binding by viewBinding(ActivityManageBlockedKeywordsBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manage_blocked_keywords)
|
||||
setContentView(binding.root)
|
||||
updateBlockedKeywords()
|
||||
setupOptionsMenu()
|
||||
|
||||
updateMaterialActivityViews(block_keywords_coordinator, manage_blocked_keywords_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(manage_blocked_keywords_list, block_keywords_toolbar)
|
||||
updateTextColors(manage_blocked_keywords_wrapper)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.blockKeywordsCoordinator,
|
||||
nestedView = binding.manageBlockedKeywordsList,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.manageBlockedKeywordsList, toolbar = binding.blockKeywordsToolbar)
|
||||
updateTextColors(binding.manageBlockedKeywordsWrapper)
|
||||
|
||||
manage_blocked_keywords_placeholder_2.apply {
|
||||
binding.manageBlockedKeywordsPlaceholder2.apply {
|
||||
underlineText()
|
||||
setTextColor(getProperPrimaryColor())
|
||||
setOnClickListener {
|
||||
|
|
@ -45,11 +53,11 @@ class ManageBlockedKeywordsActivity : BaseSimpleActivity(), RefreshRecyclerViewL
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(block_keywords_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.blockKeywordsToolbar, NavigationIcon.Arrow)
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
block_keywords_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.blockKeywordsToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.add_blocked_keyword -> {
|
||||
addOrEditBlockedKeyword()
|
||||
|
|
@ -69,14 +77,14 @@ class ManageBlockedKeywordsActivity : BaseSimpleActivity(), RefreshRecyclerViewL
|
|||
ensureBackgroundThread {
|
||||
val blockedKeywords = config.blockedKeywords
|
||||
runOnUiThread {
|
||||
ManageBlockedKeywordsAdapter(this, blockedKeywords.toArrayList(), this, manage_blocked_keywords_list) {
|
||||
ManageBlockedKeywordsAdapter(this, blockedKeywords.toArrayList(), this, binding.manageBlockedKeywordsList) {
|
||||
addOrEditBlockedKeyword(it as String)
|
||||
}.apply {
|
||||
manage_blocked_keywords_list.adapter = this
|
||||
binding.manageBlockedKeywordsList.adapter = this
|
||||
}
|
||||
|
||||
manage_blocked_keywords_placeholder.beVisibleIf(blockedKeywords.isEmpty())
|
||||
manage_blocked_keywords_placeholder_2.beVisibleIf(blockedKeywords.isEmpty())
|
||||
binding.manageBlockedKeywordsPlaceholder.beVisibleIf(blockedKeywords.isEmpty())
|
||||
binding.manageBlockedKeywordsPlaceholder2.beVisibleIf(blockedKeywords.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,31 +14,38 @@ import com.simplemobiletools.commons.models.RadioItem
|
|||
import com.simplemobiletools.commons.models.SimpleContact
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.ContactsAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityNewConversationBinding
|
||||
import com.simplemobiletools.smsmessenger.databinding.ItemSuggestedContactBinding
|
||||
import com.simplemobiletools.smsmessenger.extensions.getSuggestedContacts
|
||||
import com.simplemobiletools.smsmessenger.extensions.getThreadId
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.messaging.isShortCodeWithLetters
|
||||
import kotlinx.android.synthetic.main.activity_new_conversation.*
|
||||
import kotlinx.android.synthetic.main.item_suggested_contact.view.*
|
||||
import java.net.URLDecoder
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
class NewConversationActivity : SimpleActivity() {
|
||||
private var allContacts = ArrayList<SimpleContact>()
|
||||
private var privateContacts = ArrayList<SimpleContact>()
|
||||
|
||||
private val binding by viewBinding(ActivityNewConversationBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_new_conversation)
|
||||
setContentView(binding.root)
|
||||
title = getString(R.string.new_conversation)
|
||||
updateTextColors(new_conversation_holder)
|
||||
updateTextColors(binding.newConversationHolder)
|
||||
|
||||
updateMaterialActivityViews(new_conversation_coordinator, contacts_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(contacts_list, new_conversation_toolbar)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.newConversationCoordinator,
|
||||
nestedView = binding.contactsList,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.contactsList, toolbar = binding.newConversationToolbar)
|
||||
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
new_conversation_address.requestFocus()
|
||||
binding.newConversationAddress.requestFocus()
|
||||
|
||||
// READ_CONTACTS permission is not mandatory, but without it we won't be able to show any suggestions during typing
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
|
|
@ -48,10 +55,10 @@ class NewConversationActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(new_conversation_toolbar, NavigationIcon.Arrow)
|
||||
no_contacts_placeholder_2.setTextColor(getProperPrimaryColor())
|
||||
no_contacts_placeholder_2.underlineText()
|
||||
suggestions_label.setTextColor(getProperPrimaryColor())
|
||||
setupToolbar(binding.newConversationToolbar, NavigationIcon.Arrow)
|
||||
binding.noContactsPlaceholder2.setTextColor(getProperPrimaryColor())
|
||||
binding.noContactsPlaceholder2.underlineText()
|
||||
binding.suggestionsLabel.setTextColor(getProperPrimaryColor())
|
||||
}
|
||||
|
||||
private fun initContacts() {
|
||||
|
|
@ -60,7 +67,7 @@ class NewConversationActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
fetchContacts()
|
||||
new_conversation_address.onTextChangeListener { searchString ->
|
||||
binding.newConversationAddress.onTextChangeListener { searchString ->
|
||||
val filteredContacts = ArrayList<SimpleContact>()
|
||||
allContacts.forEach { contact ->
|
||||
if (contact.phoneNumbers.any { it.normalizedNumber.contains(searchString, true) } ||
|
||||
|
|
@ -74,21 +81,21 @@ class NewConversationActivity : SimpleActivity() {
|
|||
filteredContacts.sortWith(compareBy { !it.name.startsWith(searchString, true) })
|
||||
setupAdapter(filteredContacts)
|
||||
|
||||
new_conversation_confirm.beVisibleIf(searchString.length > 2)
|
||||
binding.newConversationConfirm.beVisibleIf(searchString.length > 2)
|
||||
}
|
||||
|
||||
new_conversation_confirm.applyColorFilter(getProperTextColor())
|
||||
new_conversation_confirm.setOnClickListener {
|
||||
val number = new_conversation_address.value
|
||||
binding.newConversationConfirm.applyColorFilter(getProperTextColor())
|
||||
binding.newConversationConfirm.setOnClickListener {
|
||||
val number = binding.newConversationAddress.value
|
||||
if (isShortCodeWithLetters(number)) {
|
||||
new_conversation_address.setText("")
|
||||
binding.newConversationAddress.setText("")
|
||||
toast(R.string.invalid_short_code, length = Toast.LENGTH_LONG)
|
||||
return@setOnClickListener
|
||||
}
|
||||
launchThreadActivity(number, number)
|
||||
}
|
||||
|
||||
no_contacts_placeholder_2.setOnClickListener {
|
||||
binding.noContactsPlaceholder2.setOnClickListener {
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
if (it) {
|
||||
fetchContacts()
|
||||
|
|
@ -97,11 +104,11 @@ class NewConversationActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
val properPrimaryColor = getProperPrimaryColor()
|
||||
contacts_letter_fastscroller.textColor = getProperTextColor().getColorStateList()
|
||||
contacts_letter_fastscroller.pressedTextColor = properPrimaryColor
|
||||
contacts_letter_fastscroller_thumb.setupWithFastScroller(contacts_letter_fastscroller)
|
||||
contacts_letter_fastscroller_thumb?.textColor = properPrimaryColor.getContrastColor()
|
||||
contacts_letter_fastscroller_thumb?.thumbColor = properPrimaryColor.getColorStateList()
|
||||
binding.contactsLetterFastscroller.textColor = getProperTextColor().getColorStateList()
|
||||
binding.contactsLetterFastscroller.pressedTextColor = properPrimaryColor
|
||||
binding.contactsLetterFastscrollerThumb.setupWithFastScroller(binding.contactsLetterFastscroller)
|
||||
binding.contactsLetterFastscrollerThumb.textColor = properPrimaryColor.getContrastColor()
|
||||
binding.contactsLetterFastscrollerThumb.thumbColor = properPrimaryColor.getColorStateList()
|
||||
}
|
||||
|
||||
private fun isThirdPartyIntent(): Boolean {
|
||||
|
|
@ -133,18 +140,18 @@ class NewConversationActivity : SimpleActivity() {
|
|||
|
||||
private fun setupAdapter(contacts: ArrayList<SimpleContact>) {
|
||||
val hasContacts = contacts.isNotEmpty()
|
||||
contacts_list.beVisibleIf(hasContacts)
|
||||
no_contacts_placeholder.beVisibleIf(!hasContacts)
|
||||
no_contacts_placeholder_2.beVisibleIf(!hasContacts && !hasPermission(PERMISSION_READ_CONTACTS))
|
||||
binding.contactsList.beVisibleIf(hasContacts)
|
||||
binding.noContactsPlaceholder.beVisibleIf(!hasContacts)
|
||||
binding.noContactsPlaceholder2.beVisibleIf(!hasContacts && !hasPermission(PERMISSION_READ_CONTACTS))
|
||||
|
||||
if (!hasContacts) {
|
||||
val placeholderText = if (hasPermission(PERMISSION_READ_CONTACTS)) R.string.no_contacts_found else R.string.no_access_to_contacts
|
||||
no_contacts_placeholder.text = getString(placeholderText)
|
||||
binding.noContactsPlaceholder.text = getString(placeholderText)
|
||||
}
|
||||
|
||||
val currAdapter = contacts_list.adapter
|
||||
val currAdapter = binding.contactsList.adapter
|
||||
if (currAdapter == null) {
|
||||
ContactsAdapter(this, contacts, contacts_list) {
|
||||
ContactsAdapter(this, contacts, binding.contactsList) {
|
||||
hideKeyboard()
|
||||
val contact = it as SimpleContact
|
||||
val phoneNumbers = contact.phoneNumbers
|
||||
|
|
@ -167,11 +174,11 @@ class NewConversationActivity : SimpleActivity() {
|
|||
launchThreadActivity(phoneNumbers.first().normalizedNumber, contact.name)
|
||||
}
|
||||
}.apply {
|
||||
contacts_list.adapter = this
|
||||
binding.contactsList.adapter = this
|
||||
}
|
||||
|
||||
if (areSystemAnimationsEnabled) {
|
||||
contacts_list.scheduleLayoutAnimation()
|
||||
binding.contactsList.scheduleLayoutAnimation()
|
||||
}
|
||||
} else {
|
||||
(currAdapter as ContactsAdapter).updateContacts(contacts)
|
||||
|
|
@ -186,23 +193,23 @@ class NewConversationActivity : SimpleActivity() {
|
|||
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||
val suggestions = getSuggestedContacts(privateContacts)
|
||||
runOnUiThread {
|
||||
suggestions_holder.removeAllViews()
|
||||
binding.suggestionsHolder.removeAllViews()
|
||||
if (suggestions.isEmpty()) {
|
||||
suggestions_label.beGone()
|
||||
suggestions_scrollview.beGone()
|
||||
binding.suggestionsLabel.beGone()
|
||||
binding.suggestionsScrollview.beGone()
|
||||
} else {
|
||||
suggestions_label.beVisible()
|
||||
suggestions_scrollview.beVisible()
|
||||
binding.suggestionsLabel.beVisible()
|
||||
binding.suggestionsScrollview.beVisible()
|
||||
suggestions.forEach {
|
||||
val contact = it
|
||||
layoutInflater.inflate(R.layout.item_suggested_contact, null).apply {
|
||||
suggested_contact_name.text = contact.name
|
||||
suggested_contact_name.setTextColor(getProperTextColor())
|
||||
ItemSuggestedContactBinding.inflate(layoutInflater).apply {
|
||||
suggestedContactName.text = contact.name
|
||||
suggestedContactName.setTextColor(getProperTextColor())
|
||||
|
||||
if (!isDestroyed) {
|
||||
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggested_contact_image, contact.name)
|
||||
suggestions_holder.addView(this)
|
||||
setOnClickListener {
|
||||
SimpleContactsHelper(this@NewConversationActivity).loadContactImage(contact.photoUri, suggestedContactImage, contact.name)
|
||||
binding.suggestionsHolder.addView(root)
|
||||
root.setOnClickListener {
|
||||
launchThreadActivity(contact.phoneNumbers.first().normalizedNumber, contact.name)
|
||||
}
|
||||
}
|
||||
|
|
@ -215,11 +222,11 @@ class NewConversationActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupLetterFastscroller(contacts: ArrayList<SimpleContact>) {
|
||||
contacts_letter_fastscroller.setupWithRecyclerView(contacts_list, { position ->
|
||||
binding.contactsLetterFastscroller.setupWithRecyclerView(binding.contactsList, { position ->
|
||||
try {
|
||||
val name = contacts[position].name
|
||||
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
|
||||
FastScrollItemIndicator.Text(character.toUpperCase(Locale.getDefault()).normalizeString())
|
||||
FastScrollItemIndicator.Text(character.uppercase(Locale.getDefault()).normalizeString())
|
||||
} catch (e: Exception) {
|
||||
FastScrollItemIndicator.Text("")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,36 +7,41 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.ConversationsAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.RecycleBinConversationsAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityRecycleBinConversationsBinding
|
||||
import com.simplemobiletools.smsmessenger.extensions.*
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.models.Conversation
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import kotlinx.android.synthetic.main.activity_recycle_bin_conversations.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
class RecycleBinConversationsActivity : SimpleActivity() {
|
||||
private var bus: EventBus? = null
|
||||
private val binding by viewBinding(ActivityRecycleBinConversationsBinding::inflate)
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_recycle_bin_conversations)
|
||||
setContentView(binding.root)
|
||||
setupOptionsMenu()
|
||||
|
||||
updateMaterialActivityViews(recycle_bin_coordinator, conversations_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(conversations_list, recycle_bin_toolbar)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.recycleBinCoordinator,
|
||||
nestedView = binding.conversationsList,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.conversationsList, toolbar = binding.recycleBinToolbar)
|
||||
|
||||
loadRecycleBinConversations()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(recycle_bin_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.recycleBinToolbar, NavigationIcon.Arrow)
|
||||
updateMenuColors()
|
||||
|
||||
loadRecycleBinConversations()
|
||||
|
|
@ -48,9 +53,8 @@ class RecycleBinConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
recycle_bin_toolbar.inflateMenu(R.menu.recycle_bin_menu)
|
||||
|
||||
recycle_bin_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.recycleBinToolbar.inflateMenu(R.menu.recycle_bin_menu)
|
||||
binding.recycleBinToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.empty_recycle_bin -> removeAll()
|
||||
else -> return@setOnMenuItemClickListener false
|
||||
|
|
@ -60,7 +64,7 @@ class RecycleBinConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateOptionsMenu(conversations: ArrayList<Conversation>) {
|
||||
recycle_bin_toolbar.menu.apply {
|
||||
binding.recycleBinToolbar.menu.apply {
|
||||
findItem(R.id.empty_recycle_bin).isVisible = conversations.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
|
@ -85,7 +89,7 @@ class RecycleBinConversationsActivity : SimpleActivity() {
|
|||
bus = EventBus.getDefault()
|
||||
try {
|
||||
bus!!.register(this)
|
||||
} catch (e: Exception) {
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,19 +103,19 @@ class RecycleBinConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getOrCreateConversationsAdapter(): RecycleBinConversationsAdapter {
|
||||
var currAdapter = conversations_list.adapter
|
||||
var currAdapter = binding.conversationsList.adapter
|
||||
if (currAdapter == null) {
|
||||
hideKeyboard()
|
||||
currAdapter = RecycleBinConversationsAdapter(
|
||||
activity = this,
|
||||
recyclerView = conversations_list,
|
||||
recyclerView = binding.conversationsList,
|
||||
onRefresh = { notifyDatasetChanged() },
|
||||
itemClick = { handleConversationClick(it) }
|
||||
)
|
||||
|
||||
conversations_list.adapter = currAdapter
|
||||
binding.conversationsList.adapter = currAdapter
|
||||
if (areSystemAnimationsEnabled) {
|
||||
conversations_list.scheduleLayoutAnimation()
|
||||
binding.conversationsList.scheduleLayoutAnimation()
|
||||
}
|
||||
}
|
||||
return currAdapter as RecycleBinConversationsAdapter
|
||||
|
|
@ -135,9 +139,9 @@ class RecycleBinConversationsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun showOrHidePlaceholder(show: Boolean) {
|
||||
conversations_fastscroller.beGoneIf(show)
|
||||
no_conversations_placeholder.beVisibleIf(show)
|
||||
no_conversations_placeholder.text = getString(R.string.no_conversations_found)
|
||||
binding.conversationsFastscroller.beGoneIf(show)
|
||||
binding.noConversationsPlaceholder.beVisibleIf(show)
|
||||
binding.noConversationsPlaceholder.text = getString(R.string.no_conversations_found)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ import com.simplemobiletools.commons.extensions.*
|
|||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivitySettingsBinding
|
||||
import com.simplemobiletools.smsmessenger.dialogs.ExportMessagesDialog
|
||||
import com.simplemobiletools.smsmessenger.extensions.config
|
||||
import com.simplemobiletools.smsmessenger.extensions.emptyMessagesRecycleBin
|
||||
import com.simplemobiletools.smsmessenger.extensions.messagesDB
|
||||
import com.simplemobiletools.smsmessenger.helpers.*
|
||||
import com.simplemobiletools.smsmessenger.models.*
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.util.*
|
||||
|
|
@ -30,18 +30,25 @@ class SettingsActivity : SimpleActivity() {
|
|||
private val messagesFileType = "application/json"
|
||||
private val messageImportFileTypes = listOf("application/json", "application/xml", "text/xml")
|
||||
|
||||
private val binding by viewBinding(ActivitySettingsBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_settings)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
||||
updateMaterialActivityViews(
|
||||
mainCoordinatorLayout = binding.settingsCoordinator,
|
||||
nestedView = binding.settingsHolder,
|
||||
useTransparentNavigation = true,
|
||||
useTopSearchMenu = false
|
||||
)
|
||||
setupMaterialScrollListener(scrollingView = binding.settingsNestedScrollview, toolbar = binding.settingsToolbar)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupPurchaseThankYou()
|
||||
setupCustomizeColors()
|
||||
|
|
@ -65,20 +72,20 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupAppPasswordProtection()
|
||||
setupMessagesExport()
|
||||
setupMessagesImport()
|
||||
updateTextColors(settings_nested_scrollview)
|
||||
updateTextColors(binding.settingsNestedScrollview)
|
||||
|
||||
if (blockedNumbersAtPause != -1 && blockedNumbersAtPause != getBlockedNumbers().hashCode()) {
|
||||
refreshMessages()
|
||||
}
|
||||
|
||||
arrayOf(
|
||||
settings_color_customization_section_label,
|
||||
settings_general_settings_label,
|
||||
settings_outgoing_messages_label,
|
||||
settings_notifications_label,
|
||||
settings_recycle_bin_label,
|
||||
settings_security_label,
|
||||
settings_migrating_label
|
||||
binding.settingsColorCustomizationSectionLabel,
|
||||
binding.settingsGeneralSettingsLabel,
|
||||
binding.settingsOutgoingMessagesLabel,
|
||||
binding.settingsNotificationsLabel,
|
||||
binding.settingsEmptyRecycleBinLabel,
|
||||
binding.settingsSecurityLabel,
|
||||
binding.settingsMigratingLabel
|
||||
).forEach {
|
||||
it.setTextColor(getProperPrimaryColor())
|
||||
}
|
||||
|
|
@ -98,7 +105,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupMessagesExport() {
|
||||
settings_export_messages_holder.setOnClickListener {
|
||||
binding.settingsExportMessagesHolder.setOnClickListener {
|
||||
ExportMessagesDialog(this) { fileName ->
|
||||
saveDocument.launch(fileName)
|
||||
}
|
||||
|
|
@ -106,7 +113,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupMessagesImport() {
|
||||
settings_import_messages_holder.setOnClickListener {
|
||||
binding.settingsImportMessagesHolder.setOnClickListener {
|
||||
getContent.launch(messageImportFileTypes.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
|
@ -139,87 +146,87 @@ class SettingsActivity : SimpleActivity() {
|
|||
blockedNumbersAtPause = getBlockedNumbers().hashCode()
|
||||
}
|
||||
|
||||
private fun setupPurchaseThankYou() {
|
||||
settings_purchase_thank_you_holder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settings_purchase_thank_you_holder.setOnClickListener {
|
||||
private fun setupPurchaseThankYou() = binding.apply {
|
||||
settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||
settingsPurchaseThankYouHolder.setOnClickListener {
|
||||
launchPurchaseThankYouIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeColors() {
|
||||
settings_color_customization_label.text = getCustomizeColorsString()
|
||||
settings_color_customization_holder.setOnClickListener {
|
||||
private fun setupCustomizeColors() = binding.apply {
|
||||
settingsColorCustomizationLabel.text = getCustomizeColorsString()
|
||||
settingsColorCustomizationHolder.setOnClickListener {
|
||||
handleCustomizeColorsClick()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCustomizeNotifications() {
|
||||
settings_customize_notifications_holder.beVisibleIf(isOreoPlus())
|
||||
settings_customize_notifications_holder.setOnClickListener {
|
||||
private fun setupCustomizeNotifications() = binding.apply {
|
||||
settingsCustomizeNotificationsHolder.beVisibleIf(isOreoPlus())
|
||||
settingsCustomizeNotificationsHolder.setOnClickListener {
|
||||
launchCustomizeNotificationsIntent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseEnglish() {
|
||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settings_use_english.isChecked = config.useEnglish
|
||||
settings_use_english_holder.setOnClickListener {
|
||||
settings_use_english.toggle()
|
||||
config.useEnglish = settings_use_english.isChecked
|
||||
private fun setupUseEnglish() = binding.apply {
|
||||
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||
settingsUseEnglish.isChecked = config.useEnglish
|
||||
settingsUseEnglishHolder.setOnClickListener {
|
||||
settingsUseEnglish.toggle()
|
||||
config.useEnglish = settingsUseEnglish.isChecked
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLanguage() {
|
||||
settings_language.text = Locale.getDefault().displayLanguage
|
||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
||||
settings_language_holder.setOnClickListener {
|
||||
private fun setupLanguage() = binding.apply {
|
||||
settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||
settingsLanguageHolder.setOnClickListener {
|
||||
launchChangeAppLanguageIntent()
|
||||
}
|
||||
}
|
||||
|
||||
// support for device-wise blocking came on Android 7, rely only on that
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
private fun setupManageBlockedNumbers() {
|
||||
settings_manage_blocked_numbers.text = addLockedLabelIfNeeded(R.string.manage_blocked_numbers)
|
||||
settings_manage_blocked_numbers_holder.beVisibleIf(isNougatPlus())
|
||||
private fun setupManageBlockedNumbers() = binding.apply {
|
||||
settingsManageBlockedNumbers.text = addLockedLabelIfNeeded(R.string.manage_blocked_numbers)
|
||||
settingsManageBlockedNumbersHolder.beVisibleIf(isNougatPlus())
|
||||
|
||||
settings_manage_blocked_numbers_holder.setOnClickListener {
|
||||
settingsManageBlockedNumbersHolder.setOnClickListener {
|
||||
if (isOrWasThankYouInstalled()) {
|
||||
Intent(this, ManageBlockedNumbersActivity::class.java).apply {
|
||||
Intent(this@SettingsActivity, ManageBlockedNumbersActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
} else {
|
||||
FeatureLockedDialog(this) { }
|
||||
FeatureLockedDialog(this@SettingsActivity) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupManageBlockedKeywords() {
|
||||
settings_manage_blocked_keywords.text = addLockedLabelIfNeeded(R.string.manage_blocked_keywords)
|
||||
private fun setupManageBlockedKeywords() = binding.apply {
|
||||
settingsManageBlockedKeywords.text = addLockedLabelIfNeeded(R.string.manage_blocked_keywords)
|
||||
|
||||
settings_manage_blocked_keywords_holder.setOnClickListener {
|
||||
settingsManageBlockedKeywordsHolder.setOnClickListener {
|
||||
if (isOrWasThankYouInstalled()) {
|
||||
Intent(this, ManageBlockedKeywordsActivity::class.java).apply {
|
||||
Intent(this@SettingsActivity, ManageBlockedKeywordsActivity::class.java).apply {
|
||||
startActivity(this)
|
||||
}
|
||||
} else {
|
||||
FeatureLockedDialog(this) { }
|
||||
FeatureLockedDialog(this@SettingsActivity) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupChangeDateTimeFormat() {
|
||||
settings_change_date_time_format_holder.setOnClickListener {
|
||||
ChangeDateTimeFormatDialog(this) {
|
||||
private fun setupChangeDateTimeFormat() = binding.apply {
|
||||
settingsChangeDateTimeFormatHolder.setOnClickListener {
|
||||
ChangeDateTimeFormatDialog(this@SettingsActivity) {
|
||||
refreshMessages()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFontSize() {
|
||||
settings_font_size.text = getFontSizeText()
|
||||
settings_font_size_holder.setOnClickListener {
|
||||
private fun setupFontSize() = binding.apply {
|
||||
settingsFontSize.text = getFontSizeText()
|
||||
settingsFontSizeHolder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
||||
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
||||
|
|
@ -229,62 +236,62 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
||||
config.fontSize = it as Int
|
||||
settings_font_size.text = getFontSizeText()
|
||||
settingsFontSize.text = getFontSizeText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowCharacterCounter() {
|
||||
settings_show_character_counter.isChecked = config.showCharacterCounter
|
||||
settings_show_character_counter_holder.setOnClickListener {
|
||||
settings_show_character_counter.toggle()
|
||||
config.showCharacterCounter = settings_show_character_counter.isChecked
|
||||
private fun setupShowCharacterCounter() = binding.apply {
|
||||
settingsShowCharacterCounter.isChecked = config.showCharacterCounter
|
||||
settingsShowCharacterCounterHolder.setOnClickListener {
|
||||
settingsShowCharacterCounter.toggle()
|
||||
config.showCharacterCounter = settingsShowCharacterCounter.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseSimpleCharacters() {
|
||||
settings_use_simple_characters.isChecked = config.useSimpleCharacters
|
||||
settings_use_simple_characters_holder.setOnClickListener {
|
||||
settings_use_simple_characters.toggle()
|
||||
config.useSimpleCharacters = settings_use_simple_characters.isChecked
|
||||
private fun setupUseSimpleCharacters() = binding.apply {
|
||||
settingsUseSimpleCharacters.isChecked = config.useSimpleCharacters
|
||||
settingsUseSimpleCharactersHolder.setOnClickListener {
|
||||
settingsUseSimpleCharacters.toggle()
|
||||
config.useSimpleCharacters = settingsUseSimpleCharacters.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSendOnEnter() {
|
||||
settings_send_on_enter.isChecked = config.sendOnEnter
|
||||
settings_send_on_enter_holder.setOnClickListener {
|
||||
settings_send_on_enter.toggle()
|
||||
config.sendOnEnter = settings_send_on_enter.isChecked
|
||||
private fun setupSendOnEnter() = binding.apply {
|
||||
settingsSendOnEnter.isChecked = config.sendOnEnter
|
||||
settingsSendOnEnterHolder.setOnClickListener {
|
||||
settingsSendOnEnter.toggle()
|
||||
config.sendOnEnter = settingsSendOnEnter.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupEnableDeliveryReports() {
|
||||
settings_enable_delivery_reports.isChecked = config.enableDeliveryReports
|
||||
settings_enable_delivery_reports_holder.setOnClickListener {
|
||||
settings_enable_delivery_reports.toggle()
|
||||
config.enableDeliveryReports = settings_enable_delivery_reports.isChecked
|
||||
private fun setupEnableDeliveryReports() = binding.apply {
|
||||
settingsEnableDeliveryReports.isChecked = config.enableDeliveryReports
|
||||
settingsEnableDeliveryReportsHolder.setOnClickListener {
|
||||
settingsEnableDeliveryReports.toggle()
|
||||
config.enableDeliveryReports = settingsEnableDeliveryReports.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSendLongMessageAsMMS() {
|
||||
settings_send_long_message_mms.isChecked = config.sendLongMessageMMS
|
||||
settings_send_long_message_mms_holder.setOnClickListener {
|
||||
settings_send_long_message_mms.toggle()
|
||||
config.sendLongMessageMMS = settings_send_long_message_mms.isChecked
|
||||
private fun setupSendLongMessageAsMMS() = binding.apply {
|
||||
settingsSendLongMessageMms.isChecked = config.sendLongMessageMMS
|
||||
settingsSendLongMessageMmsHolder.setOnClickListener {
|
||||
settingsSendLongMessageMms.toggle()
|
||||
config.sendLongMessageMMS = settingsSendLongMessageMms.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupGroupMessageAsMMS() {
|
||||
settings_send_group_message_mms.isChecked = config.sendGroupMessageMMS
|
||||
settings_send_group_message_mms_holder.setOnClickListener {
|
||||
settings_send_group_message_mms.toggle()
|
||||
config.sendGroupMessageMMS = settings_send_group_message_mms.isChecked
|
||||
private fun setupGroupMessageAsMMS() = binding.apply {
|
||||
settingsSendGroupMessageMms.isChecked = config.sendGroupMessageMMS
|
||||
settingsSendGroupMessageMmsHolder.setOnClickListener {
|
||||
settingsSendGroupMessageMms.toggle()
|
||||
config.sendGroupMessageMMS = settingsSendGroupMessageMms.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupLockScreenVisibility() {
|
||||
settings_lock_screen_visibility.text = getLockScreenVisibilityText()
|
||||
settings_lock_screen_visibility_holder.setOnClickListener {
|
||||
private fun setupLockScreenVisibility() = binding.apply {
|
||||
settingsLockScreenVisibility.text = getLockScreenVisibilityText()
|
||||
settingsLockScreenVisibilityHolder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(LOCK_SCREEN_SENDER_MESSAGE, getString(R.string.sender_and_message)),
|
||||
RadioItem(LOCK_SCREEN_SENDER, getString(R.string.sender_only)),
|
||||
|
|
@ -293,7 +300,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
RadioGroupDialog(this@SettingsActivity, items, config.lockScreenVisibilitySetting) {
|
||||
config.lockScreenVisibilitySetting = it as Int
|
||||
settings_lock_screen_visibility.text = getLockScreenVisibilityText()
|
||||
settingsLockScreenVisibility.text = getLockScreenVisibilityText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -306,9 +313,9 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
)
|
||||
|
||||
private fun setupMMSFileSizeLimit() {
|
||||
settings_mms_file_size_limit.text = getMMSFileLimitText()
|
||||
settings_mms_file_size_limit_holder.setOnClickListener {
|
||||
private fun setupMMSFileSizeLimit() = binding.apply {
|
||||
settingsMmsFileSizeLimit.text = getMMSFileLimitText()
|
||||
settingsMmsFileSizeLimitHolder.setOnClickListener {
|
||||
val items = arrayListOf(
|
||||
RadioItem(7, getString(R.string.mms_file_size_limit_none), FILE_SIZE_NONE),
|
||||
RadioItem(6, getString(R.string.mms_file_size_limit_2mb), FILE_SIZE_2_MB),
|
||||
|
|
@ -322,58 +329,58 @@ class SettingsActivity : SimpleActivity() {
|
|||
val checkedItemId = items.find { it.value == config.mmsFileSizeLimit }?.id ?: 7
|
||||
RadioGroupDialog(this@SettingsActivity, items, checkedItemId) {
|
||||
config.mmsFileSizeLimit = it as Long
|
||||
settings_mms_file_size_limit.text = getMMSFileLimitText()
|
||||
settingsMmsFileSizeLimit.text = getMMSFileLimitText()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUseRecycleBin() {
|
||||
private fun setupUseRecycleBin() = binding.apply {
|
||||
updateRecycleBinButtons()
|
||||
settings_use_recycle_bin.isChecked = config.useRecycleBin
|
||||
settings_use_recycle_bin_holder.setOnClickListener {
|
||||
settings_use_recycle_bin.toggle()
|
||||
config.useRecycleBin = settings_use_recycle_bin.isChecked
|
||||
settingsUseRecycleBin.isChecked = config.useRecycleBin
|
||||
settingsUseRecycleBinHolder.setOnClickListener {
|
||||
settingsUseRecycleBin.toggle()
|
||||
config.useRecycleBin = settingsUseRecycleBin.isChecked
|
||||
updateRecycleBinButtons()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateRecycleBinButtons() {
|
||||
settings_empty_recycle_bin_holder.beVisibleIf(config.useRecycleBin)
|
||||
private fun updateRecycleBinButtons() = binding.apply {
|
||||
settingsEmptyRecycleBinHolder.beVisibleIf(config.useRecycleBin)
|
||||
}
|
||||
|
||||
private fun setupEmptyRecycleBin() {
|
||||
private fun setupEmptyRecycleBin() = binding.apply {
|
||||
ensureBackgroundThread {
|
||||
recycleBinMessages = messagesDB.getArchivedCount()
|
||||
runOnUiThread {
|
||||
settings_empty_recycle_bin_size.text =
|
||||
settingsEmptyRecycleBinSize.text =
|
||||
resources.getQuantityString(R.plurals.delete_messages, recycleBinMessages, recycleBinMessages)
|
||||
}
|
||||
}
|
||||
|
||||
settings_empty_recycle_bin_holder.setOnClickListener {
|
||||
settingsEmptyRecycleBinHolder.setOnClickListener {
|
||||
if (recycleBinMessages == 0) {
|
||||
toast(R.string.recycle_bin_empty)
|
||||
} else {
|
||||
ConfirmationDialog(this, "", R.string.empty_recycle_bin_messages_confirmation, R.string.yes, R.string.no) {
|
||||
ConfirmationDialog(this@SettingsActivity, "", R.string.empty_recycle_bin_messages_confirmation, R.string.yes, R.string.no) {
|
||||
ensureBackgroundThread {
|
||||
emptyMessagesRecycleBin()
|
||||
}
|
||||
recycleBinMessages = 0
|
||||
settings_empty_recycle_bin_size.text =
|
||||
settingsEmptyRecycleBinSize.text =
|
||||
resources.getQuantityString(R.plurals.delete_messages, recycleBinMessages, recycleBinMessages)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupAppPasswordProtection() {
|
||||
settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn
|
||||
settings_app_password_protection_holder.setOnClickListener {
|
||||
private fun setupAppPasswordProtection() = binding.apply {
|
||||
settingsAppPasswordProtection.isChecked = config.isAppPasswordProtectionOn
|
||||
settingsAppPasswordProtectionHolder.setOnClickListener {
|
||||
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
||||
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
||||
SecurityDialog(this@SettingsActivity, config.appPasswordHash, tabToShow) { hash, type, success ->
|
||||
if (success) {
|
||||
val hasPasswordProtection = config.isAppPasswordProtectionOn
|
||||
settings_app_password_protection.isChecked = !hasPasswordProtection
|
||||
settingsAppPasswordProtection.isChecked = !hasPasswordProtection
|
||||
config.isAppPasswordProtectionOn = !hasPasswordProtection
|
||||
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
||||
config.appProtectionType = type
|
||||
|
|
@ -381,7 +388,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
if (config.isAppPasswordProtectionOn) {
|
||||
val confirmationTextId = if (config.appProtectionType == PROTECTION_FINGERPRINT)
|
||||
R.string.fingerprint_setup_successfully else R.string.protection_setup_successfully
|
||||
ConfirmationDialog(this, "", confirmationTextId, R.string.ok, 0) { }
|
||||
ConfirmationDialog(this@SettingsActivity, "", confirmationTextId, R.string.ok, 0) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ import com.simplemobiletools.smsmessenger.R
|
|||
import com.simplemobiletools.smsmessenger.adapters.AttachmentsAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter
|
||||
import com.simplemobiletools.smsmessenger.adapters.ThreadAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityThreadBinding
|
||||
import com.simplemobiletools.smsmessenger.databinding.ItemSelectedContactBinding
|
||||
import com.simplemobiletools.smsmessenger.databinding.LayoutThreadSendMessageHolderBinding
|
||||
import com.simplemobiletools.smsmessenger.dialogs.InvalidNumberDialog
|
||||
import com.simplemobiletools.smsmessenger.dialogs.RenameConversationDialog
|
||||
import com.simplemobiletools.smsmessenger.dialogs.ScheduleMessageDialog
|
||||
|
|
@ -66,11 +69,6 @@ import com.simplemobiletools.smsmessenger.helpers.*
|
|||
import com.simplemobiletools.smsmessenger.messaging.*
|
||||
import com.simplemobiletools.smsmessenger.models.*
|
||||
import com.simplemobiletools.smsmessenger.models.ThreadItem.*
|
||||
import kotlinx.android.synthetic.main.activity_thread.*
|
||||
import kotlinx.android.synthetic.main.item_selected_contact.view.*
|
||||
import kotlinx.android.synthetic.main.layout_attachment_picker.*
|
||||
import kotlinx.android.synthetic.main.layout_invalid_short_code_info.*
|
||||
import kotlinx.android.synthetic.main.layout_thread_send_message_holder.*
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
|
@ -114,6 +112,9 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private var isAttachmentPickerVisible = false
|
||||
|
||||
private val binding by viewBinding(ActivityThreadBinding::inflate)
|
||||
private lateinit var messageHolderBinding: LayoutThreadSendMessageHolderBinding
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
finish()
|
||||
|
|
@ -123,12 +124,13 @@ class ThreadActivity : SimpleActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_thread)
|
||||
messageHolderBinding = binding.threadSendMessageHolder
|
||||
setContentView(binding.root)
|
||||
setupOptionsMenu()
|
||||
refreshMenuItems()
|
||||
|
||||
updateMaterialActivityViews(thread_coordinator, null, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(null, thread_toolbar)
|
||||
updateMaterialActivityViews(binding.threadCoordinator, null, useTransparentNavigation = false, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(null, binding.threadToolbar)
|
||||
|
||||
val extras = intent.extras
|
||||
if (extras == null) {
|
||||
|
|
@ -140,7 +142,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
clearAllMessagesIfNeeded()
|
||||
threadId = intent.getLongExtra(THREAD_ID, 0L)
|
||||
intent.getStringExtra(THREAD_TITLE)?.let {
|
||||
thread_toolbar.title = it
|
||||
binding.threadToolbar.title = it
|
||||
}
|
||||
isRecycleBin = intent.getBooleanExtra(IS_RECYCLE_BIN, false)
|
||||
wasProtectionHandled = intent.getBooleanExtra(WAS_PROTECTION_HANDLED, false)
|
||||
|
|
@ -171,11 +173,11 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(thread_toolbar, NavigationIcon.Arrow, statusBarColor = getProperBackgroundColor())
|
||||
setupToolbar(binding.threadToolbar, NavigationIcon.Arrow, statusBarColor = getProperBackgroundColor())
|
||||
|
||||
val smsDraft = getSmsDraft(threadId)
|
||||
if (smsDraft != null) {
|
||||
thread_type_message.setText(smsDraft)
|
||||
messageHolderBinding.threadTypeMessage.setText(smsDraft)
|
||||
}
|
||||
isActivityVisible = true
|
||||
|
||||
|
|
@ -192,16 +194,16 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
val bottomBarColor = getBottomBarColor()
|
||||
thread_send_message_holder.setBackgroundColor(bottomBarColor)
|
||||
reply_disabled_info_holder.setBackgroundColor(bottomBarColor)
|
||||
messageHolderBinding.root.setBackgroundColor(bottomBarColor)
|
||||
binding.shortCodeHolder.root.setBackgroundColor(bottomBarColor)
|
||||
updateNavigationBarColor(bottomBarColor)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
|
||||
if (thread_type_message.value != "" && getAttachmentSelections().isEmpty()) {
|
||||
saveSmsDraft(thread_type_message.value, threadId)
|
||||
if (messageHolderBinding.threadTypeMessage.value != "" && getAttachmentSelections().isEmpty()) {
|
||||
saveSmsDraft(messageHolderBinding.threadTypeMessage.value, threadId)
|
||||
} else {
|
||||
deleteSmsDraft(threadId)
|
||||
}
|
||||
|
|
@ -212,7 +214,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
override fun onBackPressed() {
|
||||
isAttachmentPickerVisible = false
|
||||
if (attachment_picker_holder.isVisible()) {
|
||||
if (messageHolderBinding.attachmentPickerHolder.isVisible()) {
|
||||
hideAttachmentPicker()
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
|
|
@ -249,7 +251,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun refreshMenuItems() {
|
||||
val firstPhoneNumber = participants.firstOrNull()?.phoneNumbers?.firstOrNull()?.value
|
||||
thread_toolbar.menu.apply {
|
||||
binding.threadToolbar.menu.apply {
|
||||
findItem(R.id.delete).isVisible = threadItems.isNotEmpty()
|
||||
findItem(R.id.restore).isVisible = threadItems.isNotEmpty() && isRecycleBin
|
||||
findItem(R.id.archive).isVisible = threadItems.isNotEmpty() && conversation?.isArchived == false && !isRecycleBin
|
||||
|
|
@ -270,7 +272,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
thread_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.threadToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
if (participants.isEmpty()) {
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
|
|
@ -339,7 +341,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
runOnUiThread {
|
||||
if (messages.isEmpty()) {
|
||||
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
thread_type_message.requestFocus()
|
||||
messageHolderBinding.threadTypeMessage.requestFocus()
|
||||
}
|
||||
|
||||
setupThreadTitle()
|
||||
|
|
@ -360,7 +362,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
messages = getMessages(threadId, true)
|
||||
if (config.useRecycleBin) {
|
||||
val recycledMessages = messagesDB.getThreadMessagesFromRecycleBin(threadId).map { it.id }
|
||||
messages = messages.filter { !recycledMessages.contains(it.id) }.toMutableList() as ArrayList<Message>
|
||||
messages = messages.filter { !recycledMessages.contains(it.id) }.toMutableList() as ArrayList<Message>
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -426,18 +428,18 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getOrCreateThreadAdapter(): ThreadAdapter {
|
||||
var currAdapter = thread_messages_list.adapter
|
||||
var currAdapter = binding.threadMessagesList.adapter
|
||||
if (currAdapter == null) {
|
||||
currAdapter = ThreadAdapter(
|
||||
activity = this,
|
||||
recyclerView = thread_messages_list,
|
||||
recyclerView = binding.threadMessagesList,
|
||||
itemClick = { handleItemClick(it) },
|
||||
isRecycleBin = isRecycleBin,
|
||||
deleteMessages = { messages, toRecycleBin, fromRecycleBin -> deleteMessages(messages, toRecycleBin, fromRecycleBin) }
|
||||
deleteMessages = { messages, toRecycleBin, fromRecycleBin -> deleteMessages(messages, toRecycleBin, fromRecycleBin) }
|
||||
)
|
||||
|
||||
thread_messages_list.adapter = currAdapter
|
||||
thread_messages_list.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
|
||||
binding.threadMessagesList.adapter = currAdapter
|
||||
binding.threadMessagesList.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener {
|
||||
override fun updateBottom() {}
|
||||
|
||||
override fun updateTop() {
|
||||
|
|
@ -454,7 +456,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
runOnUiThread {
|
||||
refreshMenuItems()
|
||||
getOrCreateThreadAdapter().apply {
|
||||
val layoutManager = thread_messages_list.layoutManager as LinearLayoutManager
|
||||
val layoutManager = binding.threadMessagesList.layoutManager as LinearLayoutManager
|
||||
val lastPosition = itemCount - 1
|
||||
val lastVisiblePosition = layoutManager.findLastVisibleItemPosition()
|
||||
val shouldScrollToBottom = currentList.lastOrNull() != threadItems.lastOrNull() && lastPosition - lastVisiblePosition == 1
|
||||
|
|
@ -466,23 +468,23 @@ class ThreadActivity : SimpleActivity() {
|
|||
contacts.addAll(privateContacts)
|
||||
runOnUiThread {
|
||||
val adapter = AutoCompleteTextViewAdapter(this, contacts)
|
||||
add_contact_or_number.setAdapter(adapter)
|
||||
add_contact_or_number.imeOptions = EditorInfo.IME_ACTION_NEXT
|
||||
add_contact_or_number.setOnItemClickListener { _, _, position, _ ->
|
||||
val currContacts = (add_contact_or_number.adapter as AutoCompleteTextViewAdapter).resultList
|
||||
binding.addContactOrNumber.setAdapter(adapter)
|
||||
binding.addContactOrNumber.imeOptions = EditorInfo.IME_ACTION_NEXT
|
||||
binding.addContactOrNumber.setOnItemClickListener { _, _, position, _ ->
|
||||
val currContacts = (binding.addContactOrNumber.adapter as AutoCompleteTextViewAdapter).resultList
|
||||
val selectedContact = currContacts[position]
|
||||
addSelectedContact(selectedContact)
|
||||
}
|
||||
|
||||
add_contact_or_number.onTextChangeListener {
|
||||
confirm_inserted_number.beVisibleIf(it.length > 2)
|
||||
binding.addContactOrNumber.onTextChangeListener {
|
||||
binding.confirmInsertedNumber.beVisibleIf(it.length > 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
confirm_inserted_number?.setOnClickListener {
|
||||
val number = add_contact_or_number.value
|
||||
binding.confirmInsertedNumber.setOnClickListener {
|
||||
val number = binding.addContactOrNumber.value
|
||||
val phoneNumber = PhoneNumber(number, 0, "", number)
|
||||
val contact = SimpleContact(number.hashCode(), number.hashCode(), number, "", arrayListOf(phoneNumber), ArrayList(), ArrayList())
|
||||
addSelectedContact(contact)
|
||||
|
|
@ -493,21 +495,21 @@ class ThreadActivity : SimpleActivity() {
|
|||
private fun scrollToBottom() {
|
||||
val position = getOrCreateThreadAdapter().currentList.lastIndex
|
||||
if (position >= 0) {
|
||||
thread_messages_list.smoothScrollToPosition(position)
|
||||
binding.threadMessagesList.smoothScrollToPosition(position)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupScrollFab() {
|
||||
thread_messages_list.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
binding.threadMessagesList.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
val layoutManager = thread_messages_list.layoutManager as LinearLayoutManager
|
||||
val layoutManager = binding.threadMessagesList.layoutManager as LinearLayoutManager
|
||||
val lastVisibleItemPosition = layoutManager.findLastCompletelyVisibleItemPosition()
|
||||
val isCloseToBottom = lastVisibleItemPosition >= getOrCreateThreadAdapter().itemCount - SCROLL_TO_BOTTOM_FAB_LIMIT
|
||||
if (isCloseToBottom) {
|
||||
scroll_to_bottom_fab.hide()
|
||||
binding.scrollToBottomFab.hide()
|
||||
} else {
|
||||
scroll_to_bottom_fab.show()
|
||||
binding.scrollToBottomFab.show()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -517,7 +519,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
when {
|
||||
any is Message && any.isScheduled -> showScheduledMessageInfo(any)
|
||||
any is ThreadError -> {
|
||||
thread_type_message.setText(any.messageText)
|
||||
messageHolderBinding.threadTypeMessage.setText(any.messageText)
|
||||
messageToResend = any.messageId
|
||||
}
|
||||
}
|
||||
|
|
@ -616,7 +618,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
if (searchedMessageId != -1L) {
|
||||
val index = threadItems.indexOfFirst { (it as? Message)?.id == searchedMessageId }
|
||||
if (index != -1) {
|
||||
thread_messages_list.smoothScrollToPosition(index)
|
||||
binding.threadMessagesList.smoothScrollToPosition(index)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -635,118 +637,120 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupButtons() {
|
||||
updateTextColors(thread_holder)
|
||||
private fun setupButtons() = binding.apply {
|
||||
updateTextColors(threadHolder)
|
||||
val textColor = getProperTextColor()
|
||||
thread_send_message.apply {
|
||||
setTextColor(textColor)
|
||||
compoundDrawables.forEach {
|
||||
it?.applyColorFilter(textColor)
|
||||
}
|
||||
}
|
||||
|
||||
confirm_manage_contacts.applyColorFilter(textColor)
|
||||
thread_add_attachment.applyColorFilter(textColor)
|
||||
|
||||
val properPrimaryColor = getProperPrimaryColor()
|
||||
thread_messages_fastscroller.updateColors(properPrimaryColor)
|
||||
|
||||
thread_character_counter.beVisibleIf(config.showCharacterCounter)
|
||||
thread_character_counter.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||
|
||||
thread_type_message.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||
thread_send_message.setOnClickListener {
|
||||
sendMessage()
|
||||
}
|
||||
|
||||
thread_send_message.setOnLongClickListener {
|
||||
if (!isScheduledMessage) {
|
||||
launchScheduleSendDialog()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
thread_send_message.isClickable = false
|
||||
thread_type_message.onTextChangeListener {
|
||||
messageToResend = null
|
||||
checkSendMessageAvailability()
|
||||
val messageString = if (config.useSimpleCharacters) {
|
||||
it.normalizeString()
|
||||
} else {
|
||||
it
|
||||
}
|
||||
val messageLength = SmsMessage.calculateLength(messageString, false)
|
||||
thread_character_counter.text = "${messageLength[2]}/${messageLength[0]}"
|
||||
}
|
||||
|
||||
if (config.sendOnEnter) {
|
||||
thread_type_message.inputType = EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||
thread_type_message.imeOptions = EditorInfo.IME_ACTION_SEND
|
||||
|
||||
thread_type_message.setOnEditorActionListener { _, action, _ ->
|
||||
if (action == EditorInfo.IME_ACTION_SEND) {
|
||||
dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER))
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
thread_type_message.setOnKeyListener { _, keyCode, event ->
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
|
||||
sendMessage()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
confirm_manage_contacts.setOnClickListener {
|
||||
hideKeyboard()
|
||||
thread_add_contacts.beGone()
|
||||
|
||||
val numbers = HashSet<String>()
|
||||
participants.forEach { contact ->
|
||||
contact.phoneNumbers.forEach {
|
||||
numbers.add(it.normalizedNumber)
|
||||
messageHolderBinding.apply {
|
||||
threadSendMessage.apply {
|
||||
setTextColor(textColor)
|
||||
compoundDrawables.forEach {
|
||||
it?.applyColorFilter(textColor)
|
||||
}
|
||||
}
|
||||
val newThreadId = getThreadId(numbers)
|
||||
if (threadId != newThreadId) {
|
||||
|
||||
confirmManageContacts.applyColorFilter(textColor)
|
||||
threadAddAttachment.applyColorFilter(textColor)
|
||||
|
||||
val properPrimaryColor = getProperPrimaryColor()
|
||||
threadMessagesFastscroller.updateColors(properPrimaryColor)
|
||||
|
||||
threadCharacterCounter.beVisibleIf(config.showCharacterCounter)
|
||||
threadCharacterCounter.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||
|
||||
threadTypeMessage.setTextSize(TypedValue.COMPLEX_UNIT_PX, getTextSize())
|
||||
threadSendMessage.setOnClickListener {
|
||||
sendMessage()
|
||||
}
|
||||
|
||||
threadSendMessage.setOnLongClickListener {
|
||||
if (!isScheduledMessage) {
|
||||
launchScheduleSendDialog()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
threadSendMessage.isClickable = false
|
||||
threadTypeMessage.onTextChangeListener {
|
||||
messageToResend = null
|
||||
checkSendMessageAvailability()
|
||||
val messageString = if (config.useSimpleCharacters) {
|
||||
it.normalizeString()
|
||||
} else {
|
||||
it
|
||||
}
|
||||
val messageLength = SmsMessage.calculateLength(messageString, false)
|
||||
threadCharacterCounter.text = "${messageLength[2]}/${messageLength[0]}"
|
||||
}
|
||||
|
||||
if (config.sendOnEnter) {
|
||||
threadTypeMessage.inputType = EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||
threadTypeMessage.imeOptions = EditorInfo.IME_ACTION_SEND
|
||||
threadTypeMessage.setOnEditorActionListener { _, action, _ ->
|
||||
if (action == EditorInfo.IME_ACTION_SEND) {
|
||||
dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER))
|
||||
return@setOnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
threadTypeMessage.setOnKeyListener { _, keyCode, event ->
|
||||
if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
|
||||
sendMessage()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
confirmManageContacts.setOnClickListener {
|
||||
hideKeyboard()
|
||||
Intent(this, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, newThreadId)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
startActivity(this)
|
||||
threadAddContacts.beGone()
|
||||
|
||||
val numbers = HashSet<String>()
|
||||
participants.forEach { contact ->
|
||||
contact.phoneNumbers.forEach {
|
||||
numbers.add(it.normalizedNumber)
|
||||
}
|
||||
}
|
||||
val newThreadId = getThreadId(numbers)
|
||||
if (threadId != newThreadId) {
|
||||
hideKeyboard()
|
||||
Intent(this@ThreadActivity, ThreadActivity::class.java).apply {
|
||||
putExtra(THREAD_ID, newThreadId)
|
||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thread_type_message.setText(intent.getStringExtra(THREAD_TEXT))
|
||||
thread_add_attachment.setOnClickListener {
|
||||
if (attachment_picker_holder.isVisible()) {
|
||||
isAttachmentPickerVisible = false
|
||||
WindowCompat.getInsetsController(window, thread_type_message).show(WindowInsetsCompat.Type.ime())
|
||||
} else {
|
||||
isAttachmentPickerVisible = true
|
||||
showOrHideAttachmentPicker()
|
||||
WindowCompat.getInsetsController(window, thread_type_message).hide(WindowInsetsCompat.Type.ime())
|
||||
threadTypeMessage.setText(intent.getStringExtra(THREAD_TEXT))
|
||||
threadAddAttachment.setOnClickListener {
|
||||
if (attachmentPickerHolder.isVisible()) {
|
||||
isAttachmentPickerVisible = false
|
||||
WindowCompat.getInsetsController(window, threadTypeMessage).show(WindowInsetsCompat.Type.ime())
|
||||
} else {
|
||||
isAttachmentPickerVisible = true
|
||||
showOrHideAttachmentPicker()
|
||||
WindowCompat.getInsetsController(window, threadTypeMessage).hide(WindowInsetsCompat.Type.ime())
|
||||
}
|
||||
window.decorView.requestApplyInsets()
|
||||
}
|
||||
window.decorView.requestApplyInsets()
|
||||
}
|
||||
|
||||
if (intent.extras?.containsKey(THREAD_ATTACHMENT_URI) == true) {
|
||||
val uri = Uri.parse(intent.getStringExtra(THREAD_ATTACHMENT_URI))
|
||||
addAttachment(uri)
|
||||
} else if (intent.extras?.containsKey(THREAD_ATTACHMENT_URIS) == true) {
|
||||
(intent.getSerializableExtra(THREAD_ATTACHMENT_URIS) as? ArrayList<Uri>)?.forEach {
|
||||
addAttachment(it)
|
||||
if (intent.extras?.containsKey(THREAD_ATTACHMENT_URI) == true) {
|
||||
val uri = Uri.parse(intent.getStringExtra(THREAD_ATTACHMENT_URI))
|
||||
addAttachment(uri)
|
||||
} else if (intent.extras?.containsKey(THREAD_ATTACHMENT_URIS) == true) {
|
||||
(intent.getSerializableExtra(THREAD_ATTACHMENT_URIS) as? ArrayList<Uri>)?.forEach {
|
||||
addAttachment(it)
|
||||
}
|
||||
}
|
||||
scrollToBottomFab.setOnClickListener {
|
||||
scrollToBottom()
|
||||
}
|
||||
scrollToBottomFab.backgroundTintList = ColorStateList.valueOf(getBottomBarColor())
|
||||
scrollToBottomFab.applyColorFilter(textColor)
|
||||
}
|
||||
scroll_to_bottom_fab.setOnClickListener {
|
||||
scrollToBottom()
|
||||
}
|
||||
scroll_to_bottom_fab.backgroundTintList = ColorStateList.valueOf(getBottomBarColor())
|
||||
scroll_to_bottom_fab.applyColorFilter(textColor)
|
||||
|
||||
setupScheduleSendUi()
|
||||
}
|
||||
|
|
@ -822,11 +826,11 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun maybeDisableShortCodeReply() {
|
||||
if (isSpecialNumber() && !isRecycleBin) {
|
||||
thread_send_message_holder.beGone()
|
||||
reply_disabled_info_holder.beVisible()
|
||||
messageHolderBinding.root.beGone()
|
||||
binding.shortCodeHolder.root.beVisible()
|
||||
val textColor = getProperTextColor()
|
||||
reply_disabled_text.setTextColor(textColor)
|
||||
reply_disabled_info.apply {
|
||||
binding.shortCodeHolder.replyDisabledText.setTextColor(textColor)
|
||||
binding.shortCodeHolder.replyDisabledInfo.apply {
|
||||
applyColorFilter(textColor)
|
||||
setOnClickListener {
|
||||
InvalidNumberDialog(
|
||||
|
|
@ -843,7 +847,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun setupThreadTitle() {
|
||||
val title = conversation?.title
|
||||
thread_toolbar.title = if (!title.isNullOrEmpty()) {
|
||||
binding.threadToolbar.title = if (!title.isNullOrEmpty()) {
|
||||
title
|
||||
} else {
|
||||
participants.getThreadTitle()
|
||||
|
|
@ -875,15 +879,15 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
currentSIMCardIndex = getProperSimIndex(availableSIMs, numbers)
|
||||
thread_select_sim_icon.applyColorFilter(getProperTextColor())
|
||||
thread_select_sim_icon.beVisible()
|
||||
thread_select_sim_number.beVisible()
|
||||
messageHolderBinding.threadSelectSimIcon.applyColorFilter(getProperTextColor())
|
||||
messageHolderBinding.threadSelectSimIcon.beVisible()
|
||||
messageHolderBinding.threadSelectSimNumber.beVisible()
|
||||
|
||||
if (availableSIMCards.isNotEmpty()) {
|
||||
thread_select_sim_icon.setOnClickListener {
|
||||
messageHolderBinding.threadSelectSimIcon.setOnClickListener {
|
||||
currentSIMCardIndex = (currentSIMCardIndex + 1) % availableSIMCards.size
|
||||
val currentSIMCard = availableSIMCards[currentSIMCardIndex]
|
||||
thread_select_sim_number.text = currentSIMCard.id.toString()
|
||||
messageHolderBinding.threadSelectSimNumber.text = currentSIMCard.id.toString()
|
||||
val currentSubscriptionId = currentSIMCard.subscriptionId
|
||||
numbers.forEach {
|
||||
config.saveUseSIMIdAtNumber(it, currentSubscriptionId)
|
||||
|
|
@ -892,9 +896,9 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
thread_select_sim_number.setTextColor(getProperTextColor().getContrastColor())
|
||||
messageHolderBinding.threadSelectSimNumber.setTextColor(getProperTextColor().getContrastColor())
|
||||
try {
|
||||
thread_select_sim_number.text = (availableSIMCards[currentSIMCardIndex].id).toString()
|
||||
messageHolderBinding.threadSelectSimNumber.text = (availableSIMCards[currentSIMCardIndex].id).toString()
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
|
|
@ -1002,14 +1006,14 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun managePeople() {
|
||||
if (thread_add_contacts.isVisible()) {
|
||||
if (binding.threadAddContacts.isVisible()) {
|
||||
hideKeyboard()
|
||||
thread_add_contacts.beGone()
|
||||
binding.threadAddContacts.beGone()
|
||||
} else {
|
||||
showSelectedContacts()
|
||||
thread_add_contacts.beVisible()
|
||||
add_contact_or_number.requestFocus()
|
||||
showKeyboard(add_contact_or_number)
|
||||
binding.threadAddContacts.beVisible()
|
||||
binding.addContactOrNumber.requestFocus()
|
||||
showKeyboard(binding.addContactOrNumber)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1018,28 +1022,28 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
val views = ArrayList<View>()
|
||||
participants.forEach { contact ->
|
||||
layoutInflater.inflate(R.layout.item_selected_contact, null).apply {
|
||||
ItemSelectedContactBinding.inflate(layoutInflater).apply {
|
||||
val selectedContactBg = resources.getDrawable(R.drawable.item_selected_contact_background)
|
||||
(selectedContactBg as LayerDrawable).findDrawableByLayerId(R.id.selected_contact_bg).applyColorFilter(properPrimaryColor)
|
||||
selected_contact_holder.background = selectedContactBg
|
||||
selectedContactHolder.background = selectedContactBg
|
||||
|
||||
selected_contact_name.text = contact.name
|
||||
selected_contact_name.setTextColor(properPrimaryColor.getContrastColor())
|
||||
selected_contact_remove.applyColorFilter(properPrimaryColor.getContrastColor())
|
||||
selectedContactName.text = contact.name
|
||||
selectedContactName.setTextColor(properPrimaryColor.getContrastColor())
|
||||
selectedContactRemove.applyColorFilter(properPrimaryColor.getContrastColor())
|
||||
|
||||
selected_contact_remove.setOnClickListener {
|
||||
selectedContactRemove.setOnClickListener {
|
||||
if (contact.rawId != participants.first().rawId) {
|
||||
removeSelectedContact(contact.rawId)
|
||||
}
|
||||
}
|
||||
views.add(this)
|
||||
views.add(root)
|
||||
}
|
||||
}
|
||||
showSelectedContact(views)
|
||||
}
|
||||
|
||||
private fun addSelectedContact(contact: SimpleContact) {
|
||||
add_contact_or_number.setText("")
|
||||
binding.addContactOrNumber.setText("")
|
||||
if (participants.map { it.rawId }.contains(contact.rawId)) {
|
||||
return
|
||||
}
|
||||
|
|
@ -1234,7 +1238,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun getAttachmentsAdapter(): AttachmentsAdapter? {
|
||||
val adapter = thread_attachments_recyclerview.adapter
|
||||
val adapter = messageHolderBinding.threadAttachmentsRecyclerview.adapter
|
||||
return adapter as? AttachmentsAdapter
|
||||
}
|
||||
|
||||
|
|
@ -1268,17 +1272,17 @@ class ThreadActivity : SimpleActivity() {
|
|||
if (adapter == null) {
|
||||
adapter = AttachmentsAdapter(
|
||||
activity = this,
|
||||
recyclerView = thread_attachments_recyclerview,
|
||||
recyclerView = messageHolderBinding.threadAttachmentsRecyclerview,
|
||||
onAttachmentsRemoved = {
|
||||
thread_attachments_recyclerview.beGone()
|
||||
messageHolderBinding.threadAttachmentsRecyclerview.beGone()
|
||||
checkSendMessageAvailability()
|
||||
},
|
||||
onReady = { checkSendMessageAvailability() }
|
||||
)
|
||||
thread_attachments_recyclerview.adapter = adapter
|
||||
messageHolderBinding.threadAttachmentsRecyclerview.adapter = adapter
|
||||
}
|
||||
|
||||
thread_attachments_recyclerview.beVisible()
|
||||
messageHolderBinding.threadAttachmentsRecyclerview.beVisible()
|
||||
val attachment = AttachmentSelection(
|
||||
id = id,
|
||||
uri = uri,
|
||||
|
|
@ -1311,20 +1315,23 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun checkSendMessageAvailability() {
|
||||
if (thread_type_message.text!!.isNotEmpty() || (getAttachmentSelections().isNotEmpty() && !getAttachmentSelections().any { it.isPending })) {
|
||||
thread_send_message.isEnabled = true
|
||||
thread_send_message.isClickable = true
|
||||
thread_send_message.alpha = 0.9f
|
||||
} else {
|
||||
thread_send_message.isEnabled = false
|
||||
thread_send_message.isClickable = false
|
||||
thread_send_message.alpha = 0.4f
|
||||
messageHolderBinding.apply {
|
||||
if (threadTypeMessage.text!!.isNotEmpty() || (getAttachmentSelections().isNotEmpty() && !getAttachmentSelections().any { it.isPending })) {
|
||||
threadSendMessage.isEnabled = true
|
||||
threadSendMessage.isClickable = true
|
||||
threadSendMessage.alpha = 0.9f
|
||||
} else {
|
||||
threadSendMessage.isEnabled = false
|
||||
threadSendMessage.isClickable = false
|
||||
threadSendMessage.alpha = 0.4f
|
||||
}
|
||||
}
|
||||
|
||||
updateMessageType()
|
||||
}
|
||||
|
||||
private fun sendMessage() {
|
||||
var text = thread_type_message.value
|
||||
var text = messageHolderBinding.threadTypeMessage.value
|
||||
if (text.isEmpty() && getAttachmentSelections().isEmpty()) {
|
||||
showErrorToast(getString(R.string.unknown_error_occurred))
|
||||
return
|
||||
|
|
@ -1403,7 +1410,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun clearCurrentMessage() {
|
||||
thread_type_message.setText("")
|
||||
messageHolderBinding.threadTypeMessage.setText("")
|
||||
getAttachmentsAdapter()?.clear()
|
||||
checkSendMessageAvailability()
|
||||
}
|
||||
|
|
@ -1430,12 +1437,12 @@ class ThreadActivity : SimpleActivity() {
|
|||
// show selected contacts, properly split to new lines when appropriate
|
||||
// based on https://stackoverflow.com/a/13505029/1967672
|
||||
private fun showSelectedContact(views: ArrayList<View>) {
|
||||
selected_contacts.removeAllViews()
|
||||
binding.selectedContacts.removeAllViews()
|
||||
var newLinearLayout = LinearLayout(this)
|
||||
newLinearLayout.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
||||
newLinearLayout.orientation = LinearLayout.HORIZONTAL
|
||||
|
||||
val sideMargin = (selected_contacts.layoutParams as RelativeLayout.LayoutParams).leftMargin
|
||||
val sideMargin = (binding.selectedContacts.layoutParams as RelativeLayout.LayoutParams).leftMargin
|
||||
val mediumMargin = resources.getDimension(R.dimen.medium_margin).toInt()
|
||||
val parentWidth = realScreenSize.x - sideMargin * 2
|
||||
val firstRowWidth = parentWidth - resources.getDimension(R.dimen.normal_icon_size).toInt() + sideMargin / 2
|
||||
|
|
@ -1458,7 +1465,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
val checkWidth = if (isFirstRow) firstRowWidth else parentWidth
|
||||
if (widthSoFar >= checkWidth) {
|
||||
isFirstRow = false
|
||||
selected_contacts.addView(newLinearLayout)
|
||||
binding.selectedContacts.addView(newLinearLayout)
|
||||
newLinearLayout = LinearLayout(this)
|
||||
newLinearLayout.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
||||
newLinearLayout.orientation = LinearLayout.HORIZONTAL
|
||||
|
|
@ -1473,7 +1480,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
newLinearLayout.addView(layout)
|
||||
}
|
||||
}
|
||||
selected_contacts.addView(newLinearLayout)
|
||||
binding.selectedContacts.addView(newLinearLayout)
|
||||
}
|
||||
|
||||
private fun removeSelectedContact(id: Int) {
|
||||
|
|
@ -1579,13 +1586,13 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun updateMessageType() {
|
||||
val text = thread_type_message.text.toString()
|
||||
val text = messageHolderBinding.threadTypeMessage.text.toString()
|
||||
val stringId = if (isMmsMessage(text)) {
|
||||
R.string.mms
|
||||
} else {
|
||||
R.string.sms
|
||||
}
|
||||
thread_send_message.setText(stringId)
|
||||
messageHolderBinding.threadSendMessage.setText(stringId)
|
||||
}
|
||||
|
||||
private fun showScheduledMessageInfo(message: Message) {
|
||||
|
|
@ -1620,7 +1627,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
private fun editScheduledMessage(message: Message) {
|
||||
scheduledMessage = message
|
||||
clearCurrentMessage()
|
||||
thread_type_message.setText(message.body)
|
||||
messageHolderBinding.threadTypeMessage.setText(message.body)
|
||||
extractAttachments(message)
|
||||
scheduledDateTime = DateTime(message.millis())
|
||||
showScheduleMessageDialog()
|
||||
|
|
@ -1645,18 +1652,18 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupScheduleSendUi() {
|
||||
private fun setupScheduleSendUi() = messageHolderBinding.apply {
|
||||
val textColor = getProperTextColor()
|
||||
scheduled_message_holder.background.applyColorFilter(getProperPrimaryColor().darkenColor())
|
||||
scheduled_message_icon.applyColorFilter(textColor)
|
||||
scheduled_message_button.apply {
|
||||
scheduledMessageHolder.background.applyColorFilter(getProperPrimaryColor().darkenColor())
|
||||
scheduledMessageIcon.applyColorFilter(textColor)
|
||||
scheduledMessageButton.apply {
|
||||
setTextColor(textColor)
|
||||
setOnClickListener {
|
||||
launchScheduleSendDialog(scheduledDateTime)
|
||||
}
|
||||
}
|
||||
|
||||
discard_scheduled_message.apply {
|
||||
discardScheduledMessage.apply {
|
||||
applyColorFilter(textColor)
|
||||
setOnClickListener {
|
||||
hideScheduleSendUi()
|
||||
|
|
@ -1671,11 +1678,11 @@ class ThreadActivity : SimpleActivity() {
|
|||
private fun showScheduleMessageDialog() {
|
||||
isScheduledMessage = true
|
||||
updateSendButtonDrawable()
|
||||
scheduled_message_holder.beVisible()
|
||||
messageHolderBinding.scheduledMessageHolder.beVisible()
|
||||
|
||||
val dateTime = scheduledDateTime
|
||||
val millis = dateTime.millis
|
||||
scheduled_message_button.text = if (dateTime.yearOfCentury().get() > DateTime.now().yearOfCentury().get()) {
|
||||
messageHolderBinding.scheduledMessageButton.text = if (dateTime.yearOfCentury().get() > DateTime.now().yearOfCentury().get()) {
|
||||
millis.formatDate(this)
|
||||
} else {
|
||||
val flags = FORMAT_SHOW_TIME or FORMAT_SHOW_DATE or FORMAT_NO_YEAR
|
||||
|
|
@ -1685,7 +1692,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
private fun hideScheduleSendUi() {
|
||||
isScheduledMessage = false
|
||||
scheduled_message_holder.beGone()
|
||||
messageHolderBinding.scheduledMessageHolder.beGone()
|
||||
updateSendButtonDrawable()
|
||||
}
|
||||
|
||||
|
|
@ -1697,7 +1704,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
ResourcesCompat.getDrawable(resources, drawableResId, theme)?.apply {
|
||||
applyColorFilter(getProperTextColor())
|
||||
thread_send_message.setCompoundDrawablesWithIntrinsicBounds(null, this, null, null)
|
||||
messageHolderBinding.threadSendMessage.setCompoundDrawablesWithIntrinsicBounds(null, this, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1726,7 +1733,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
.map { Attachment(null, messageId, it.uri.toString(), it.mimetype, 0, 0, it.filename) }
|
||||
.toArrayList()
|
||||
|
||||
private fun setupAttachmentPickerView() {
|
||||
private fun setupAttachmentPickerView() = messageHolderBinding.attachmentPicker.apply {
|
||||
val buttonColors = arrayOf(
|
||||
R.color.md_red_500,
|
||||
R.color.md_brown_500,
|
||||
|
|
@ -1738,14 +1745,14 @@ class ThreadActivity : SimpleActivity() {
|
|||
R.color.md_blue_500
|
||||
).map { ResourcesCompat.getColor(resources, it, theme) }
|
||||
arrayOf(
|
||||
choose_photo_icon,
|
||||
choose_video_icon,
|
||||
take_photo_icon,
|
||||
record_video_icon,
|
||||
record_audio_icon,
|
||||
pick_file_icon,
|
||||
pick_contact_icon,
|
||||
schedule_message_icon
|
||||
choosePhotoIcon,
|
||||
chooseVideoIcon,
|
||||
takePhotoIcon,
|
||||
recordVideoIcon,
|
||||
recordAudioIcon,
|
||||
pickFileIcon,
|
||||
pickContactIcon,
|
||||
scheduleMessageIcon
|
||||
).forEachIndexed { index, icon ->
|
||||
val iconColor = buttonColors[index]
|
||||
icon.background.applyColorFilter(iconColor)
|
||||
|
|
@ -1754,38 +1761,38 @@ class ThreadActivity : SimpleActivity() {
|
|||
|
||||
val textColor = getProperTextColor()
|
||||
arrayOf(
|
||||
choose_photo_text,
|
||||
choose_video_text,
|
||||
take_photo_text,
|
||||
record_video_text,
|
||||
record_audio_text,
|
||||
pick_file_text,
|
||||
pick_contact_text,
|
||||
schedule_message_text
|
||||
choosePhotoText,
|
||||
chooseVideoText,
|
||||
takePhotoText,
|
||||
recordVideoText,
|
||||
recordAudioText,
|
||||
pickFileText,
|
||||
pickContactText,
|
||||
scheduleMessageText
|
||||
).forEach { it.setTextColor(textColor) }
|
||||
|
||||
choose_photo.setOnClickListener {
|
||||
choosePhoto.setOnClickListener {
|
||||
launchGetContentIntent(arrayOf("image/*"), PICK_PHOTO_INTENT)
|
||||
}
|
||||
choose_video.setOnClickListener {
|
||||
chooseVideo.setOnClickListener {
|
||||
launchGetContentIntent(arrayOf("video/*"), PICK_VIDEO_INTENT)
|
||||
}
|
||||
take_photo.setOnClickListener {
|
||||
takePhoto.setOnClickListener {
|
||||
launchCapturePhotoIntent()
|
||||
}
|
||||
record_video.setOnClickListener {
|
||||
recordVideo.setOnClickListener {
|
||||
launchCaptureVideoIntent()
|
||||
}
|
||||
record_audio.setOnClickListener {
|
||||
recordAudio.setOnClickListener {
|
||||
launchCaptureAudioIntent()
|
||||
}
|
||||
pick_file.setOnClickListener {
|
||||
pickFile.setOnClickListener {
|
||||
launchGetContentIntent(arrayOf("*/*"), PICK_DOCUMENT_INTENT)
|
||||
}
|
||||
pick_contact.setOnClickListener {
|
||||
pickContact.setOnClickListener {
|
||||
launchPickContactIntent()
|
||||
}
|
||||
schedule_message.setOnClickListener {
|
||||
scheduleMessage.setOnClickListener {
|
||||
if (isScheduledMessage) {
|
||||
launchScheduleSendDialog(scheduledDateTime)
|
||||
} else {
|
||||
|
|
@ -1795,20 +1802,20 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun showAttachmentPicker() {
|
||||
attachment_picker_divider.showWithAnimation()
|
||||
attachment_picker_holder.showWithAnimation()
|
||||
messageHolderBinding.attachmentPickerDivider.showWithAnimation()
|
||||
messageHolderBinding.attachmentPickerHolder.showWithAnimation()
|
||||
animateAttachmentButton(rotation = -135f)
|
||||
}
|
||||
|
||||
private fun maybeSetupRecycleBinView() {
|
||||
if (isRecycleBin) {
|
||||
thread_send_message_holder.beGone()
|
||||
messageHolderBinding.root.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideAttachmentPicker() {
|
||||
attachment_picker_divider.beGone()
|
||||
attachment_picker_holder.apply {
|
||||
messageHolderBinding.attachmentPickerDivider.beGone()
|
||||
messageHolderBinding.attachmentPickerHolder.apply {
|
||||
beGone()
|
||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
height = config.keyboardHeight
|
||||
|
|
@ -1818,7 +1825,7 @@ class ThreadActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun animateAttachmentButton(rotation: Float) {
|
||||
thread_add_attachment.animate()
|
||||
messageHolderBinding.threadAddAttachment.animate()
|
||||
.rotation(rotation)
|
||||
.setDuration(500L)
|
||||
.setInterpolator(OvershootInterpolator())
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import com.simplemobiletools.commons.extensions.normalizePhoneNumber
|
||||
import com.simplemobiletools.commons.extensions.sendEmailIntent
|
||||
import com.simplemobiletools.commons.extensions.viewBinding
|
||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.adapters.VCardViewerAdapter
|
||||
import com.simplemobiletools.smsmessenger.databinding.ActivityVcardViewerBinding
|
||||
import com.simplemobiletools.smsmessenger.extensions.dialNumber
|
||||
import com.simplemobiletools.smsmessenger.helpers.EXTRA_VCARD_URI
|
||||
import com.simplemobiletools.smsmessenger.helpers.parseVCardFromUri
|
||||
|
|
@ -16,17 +18,18 @@ import com.simplemobiletools.smsmessenger.models.VCardWrapper
|
|||
import ezvcard.VCard
|
||||
import ezvcard.property.Email
|
||||
import ezvcard.property.Telephone
|
||||
import kotlinx.android.synthetic.main.activity_vcard_viewer.*
|
||||
|
||||
class VCardViewerActivity : SimpleActivity() {
|
||||
|
||||
private val binding by viewBinding(ActivityVcardViewerBinding::inflate)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
isMaterialActivity = true
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_vcard_viewer)
|
||||
setContentView(binding.root)
|
||||
|
||||
updateMaterialActivityViews(vcard_viewer_coordinator, contacts_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(contacts_list, vcard_toolbar)
|
||||
updateMaterialActivityViews(binding.vcardViewerCoordinator, binding.contactsList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
setupMaterialScrollListener(binding.contactsList, binding.vcardToolbar)
|
||||
|
||||
val vCardUri = intent.getParcelableExtra(EXTRA_VCARD_URI) as? Uri
|
||||
if (vCardUri != null) {
|
||||
|
|
@ -41,11 +44,11 @@ class VCardViewerActivity : SimpleActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setupToolbar(vcard_toolbar, NavigationIcon.Arrow)
|
||||
setupToolbar(binding.vcardToolbar, NavigationIcon.Arrow)
|
||||
}
|
||||
|
||||
private fun setupOptionsMenu(vCardUri: Uri) {
|
||||
vcard_toolbar.setOnMenuItemClickListener { menuItem ->
|
||||
binding.vcardToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
R.id.add_contact -> {
|
||||
val intent = Intent(Intent.ACTION_VIEW).apply {
|
||||
|
|
@ -55,6 +58,7 @@ class VCardViewerActivity : SimpleActivity() {
|
|||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
else -> return@setOnMenuItemClickListener false
|
||||
}
|
||||
return@setOnMenuItemClickListener true
|
||||
|
|
@ -69,7 +73,7 @@ class VCardViewerActivity : SimpleActivity() {
|
|||
handleClick(item)
|
||||
}
|
||||
}
|
||||
contacts_list.adapter = adapter
|
||||
binding.contactsList.adapter = adapter
|
||||
}
|
||||
|
||||
private fun handleClick(property: VCardPropertyWrapper) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue