@@ -25,6 +25,7 @@ import androidx.activity.result.contract.ActivityResultContracts
2525import androidx.appcompat.widget.PopupMenu
2626import androidx.appcompat.widget.SearchView
2727import androidx.appcompat.widget.Toolbar
28+ import androidx.core.graphics.ColorUtils
2829import androidx.core.net.toUri
2930import androidx.core.view.isGone
3031import androidx.core.view.isVisible
@@ -37,6 +38,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
3738import androidx.recyclerview.widget.RecyclerView
3839import androidx.viewpager2.adapter.FragmentStateAdapter
3940import androidx.viewpager2.widget.ViewPager2
41+ import com.google.android.material.card.MaterialCardView
4042import com.google.android.material.dialog.MaterialAlertDialogBuilder
4143import com.google.android.material.tabs.TabLayout
4244import com.google.android.material.tabs.TabLayoutMediator
@@ -1721,14 +1723,34 @@ class ConfigurationFragment @JvmOverloads constructor(
17211723 val profileStatus: TextView = view.findViewById(R .id.profile_status)
17221724
17231725 val trafficText: TextView = view.findViewById(R .id.traffic_text)
1724- val selectedView : LinearLayout = view.findViewById( R .id.selected_view)
1726+ private val card = view as MaterialCardView
17251727 val editButton: ImageView = view.findViewById(R .id.edit)
17261728 val doubleColumnMenuButton: ImageView = view.findViewById(R .id.double_column_menu)
17271729 val shareLayout: LinearLayout = view.findViewById(R .id.share)
17281730 val shareLayer: LinearLayout = view.findViewById(R .id.share_layer)
17291731 val shareButton: ImageView = view.findViewById(R .id.shareIcon)
17301732 val removeButton: ImageView = view.findViewById(R .id.remove)
17311733
1734+ private fun applySelected (selected : Boolean ) {
1735+ val ctx = card.context
1736+ val primary = ctx.getColorAttr(R .attr.colorPrimary)
1737+ val surface = ctx.getColorAttr(R .attr.colorSurface)
1738+ card.strokeWidth = ctx.resources.getDimensionPixelSize(
1739+ if (selected) R .dimen.card_stroke_width_selected else R .dimen.card_stroke_width
1740+ )
1741+ card.strokeColor =
1742+ if (selected) primary else ctx.getColour(R .color.card_stroke)
1743+ card.setCardBackgroundColor(
1744+ if (selected) {
1745+ ColorUtils .compositeColors(
1746+ ColorUtils .setAlphaComponent(primary, 26 ), surface
1747+ )
1748+ } else {
1749+ surface
1750+ }
1751+ )
1752+ }
1753+
17321754 fun bind (proxyEntity : ProxyEntity , trafficData : TrafficData ? = null) {
17331755 val pf = parentFragment as ? ConfigurationFragment ? : return
17341756
@@ -1748,7 +1770,7 @@ class ConfigurationFragment @JvmOverloads constructor(
17481770 lastSelected = DataStore .selectedProxy
17491771 DataStore .selectedProxy = proxyEntity.id
17501772 onMainDispatcher {
1751- selectedView.visibility = View . VISIBLE
1773+ applySelected( true )
17521774 }
17531775 }
17541776
@@ -1937,7 +1959,7 @@ class ConfigurationFragment @JvmOverloads constructor(
19371959 onMainDispatcher {
19381960 editButton.isEnabled = ! started
19391961 removeButton.isEnabled = ! started
1940- selectedView.visibility = if (selected) View . VISIBLE else View . INVISIBLE
1962+ applySelected (selected)
19411963 }
19421964
19431965 if (! (select || proxyEntity.type == ProxyEntity .TYPE_CHAIN )) {
0 commit comments