mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Refactor View.selected usage to View.activated
The View documentation recommends using activated to indicate whether or not a view is selected: https://developer.android.com/reference/android/view/View#setActivated(boolean)
This commit is contained in:
@@ -67,8 +67,8 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
val view = layoutInflater.inflate(R.layout.menu_list_item, parent, false)
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
intArrayOf(android.R.attr.state_activated),
|
||||
intArrayOf(-android.R.attr.state_activated))
|
||||
|
||||
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
|
||||
view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
|
||||
@@ -86,7 +86,7 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
|
||||
val view = holder.itemView
|
||||
|
||||
view.title.text = menuItem.title
|
||||
view.check.isSelected = (menuItem.actionId == selectedItem)
|
||||
view.check.isActivated = (menuItem.actionId == selectedItem)
|
||||
view.check.setVisible(selectedItem != null)
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
}
|
||||
|
||||
childCount.forEach { index ->
|
||||
getChildAt(index).isSelected = index == pager?.currentItem
|
||||
getChildAt(index).isActivated = index == pager?.currentItem
|
||||
}
|
||||
|
||||
pager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
childCount.forEach { index ->
|
||||
getChildAt(index).isSelected = index == position
|
||||
getChildAt(index).isActivated = index == position
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -87,8 +87,8 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
|
||||
super.onAttachedToWindow()
|
||||
|
||||
val states = arrayOf(
|
||||
intArrayOf(android.R.attr.state_selected),
|
||||
intArrayOf(-android.R.attr.state_selected))
|
||||
intArrayOf(android.R.attr.state_activated),
|
||||
intArrayOf(-android.R.attr.state_activated))
|
||||
|
||||
threadId
|
||||
.distinctUntilChanged()
|
||||
|
||||
@@ -147,7 +147,7 @@ class MessagesAdapter @Inject constructor(
|
||||
view.setOnClickListener {
|
||||
val message = getItem(adapterPosition)!!
|
||||
when (toggleSelection(message.id, false)) {
|
||||
true -> view.isSelected = isSelected(message.id)
|
||||
true -> view.isActivated = isSelected(message.id)
|
||||
false -> {
|
||||
clicks.onNext(message)
|
||||
expanded[message.id] = view.status.visibility != View.VISIBLE
|
||||
@@ -158,7 +158,7 @@ class MessagesAdapter @Inject constructor(
|
||||
view.setOnLongClickListener {
|
||||
val message = getItem(adapterPosition)!!
|
||||
toggleSelection(message.id)
|
||||
view.isSelected = isSelected(message.id)
|
||||
view.isActivated = isSelected(message.id)
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
|
||||
// Update the selected state
|
||||
view.isSelected = isSelected(message.id) || highlight == message.id
|
||||
view.isActivated = isSelected(message.id) || highlight == message.id
|
||||
|
||||
|
||||
// Bind the cancel view
|
||||
|
||||
+3
-3
@@ -64,14 +64,14 @@ class ConversationsAdapter @Inject constructor(
|
||||
view.setOnClickListener {
|
||||
val conversation = getItem(adapterPosition)!!
|
||||
when (toggleSelection(conversation.id, false)) {
|
||||
true -> view.isSelected = isSelected(conversation.id)
|
||||
true -> view.isActivated = isSelected(conversation.id)
|
||||
false -> navigator.showConversation(conversation.id)
|
||||
}
|
||||
}
|
||||
view.setOnLongClickListener {
|
||||
val conversation = getItem(adapterPosition)!!
|
||||
toggleSelection(conversation.id)
|
||||
view.isSelected = isSelected(conversation.id)
|
||||
view.isActivated = isSelected(conversation.id)
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class ConversationsAdapter @Inject constructor(
|
||||
val conversation = getItem(position)!!
|
||||
val view = viewHolder.itemView
|
||||
|
||||
view.isSelected = isSelected(conversation.id)
|
||||
view.isActivated = isSelected(conversation.id)
|
||||
|
||||
view.avatars.contacts = conversation.recipients
|
||||
view.title.text = conversation.getTitle()
|
||||
|
||||
@@ -133,7 +133,7 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
.autoDisposable(scope())
|
||||
.subscribe { theme ->
|
||||
// Set the color for the drawer icons
|
||||
val states = arrayOf(intArrayOf(android.R.attr.state_selected), intArrayOf(-android.R.attr.state_selected))
|
||||
val states = arrayOf(intArrayOf(android.R.attr.state_activated), intArrayOf(-android.R.attr.state_activated))
|
||||
resolveThemeColor(android.R.attr.textColorSecondary)
|
||||
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
|
||||
.let { tintList ->
|
||||
@@ -235,8 +235,8 @@ class MainActivity : QkThemedActivity(), MainView {
|
||||
}
|
||||
}
|
||||
|
||||
inbox.isSelected = state.page is Inbox
|
||||
archived.isSelected = state.page is Archived
|
||||
inbox.isActivated = state.page is Inbox
|
||||
archived.isActivated = state.page is Archived
|
||||
|
||||
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||
|
||||
Reference in New Issue
Block a user