Skip to content

Commit

Permalink
set background to null when disabled
Browse files Browse the repository at this point in the history
This was the only way I could stop the ripple.

I moved some lines around to make reading a little easier as well
  • Loading branch information
mikescamell committed Jan 27, 2025
1 parent b26daca commit 6b46744
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.common.ui.view.defaultSelectableItemBackground
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.di.scopes.ViewScope
import com.duckduckgo.navigation.api.GlobalActivityStarter
Expand Down Expand Up @@ -93,13 +95,15 @@ class ProSettingNetPView @JvmOverloads constructor(
is Disabled -> {
isVisible = true
isClickable = false
background = null
setClickListener(null)
setLeadingIconResource(R.drawable.ic_vpn_grayscale_color_24)
setStatus(isOn = false)
}
is Enabled -> {
isVisible = true
isClickable = true
background = ContextCompat.getDrawable(context, context.defaultSelectableItemBackground())
setClickListener { viewModel.onNetPSettingClicked() }
setLeadingIconResource(R.drawable.ic_vpn_color_24)
setStatus(isOn = networkProtectionEntryState.isActive)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.common.ui.view.defaultSelectableItemBackground
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.common.utils.ConflatedJob
import com.duckduckgo.common.utils.ViewViewModelFactory
Expand Down Expand Up @@ -102,14 +104,16 @@ class ItrSettingView @JvmOverloads constructor(
when (viewState.itrState) {
is ItrState.Enabled -> {
isVisible = true
setStatus(isOn = true)
setLeadingIconResource(R.drawable.ic_identity_theft_restoration_color_24)
isClickable = true
background = ContextCompat.getDrawable(context, context.defaultSelectableItemBackground())
setStatus(isOn = true)
setClickListener { viewModel.onItr() }
setLeadingIconResource(R.drawable.ic_identity_theft_restoration_color_24)
}
ItrState.Disabled -> {
isVisible = true
isClickable = false
background = null
setStatus(isOn = false)
setClickListener(null)
setLeadingIconResource(R.drawable.ic_identity_theft_restoration_grayscale_color_24)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
import androidx.core.content.ContextCompat
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.duckduckgo.anvil.annotations.InjectWith
import com.duckduckgo.common.ui.view.defaultSelectableItemBackground
import com.duckduckgo.common.ui.viewbinding.viewBinding
import com.duckduckgo.common.utils.ConflatedJob
import com.duckduckgo.common.utils.ViewViewModelFactory
Expand Down Expand Up @@ -103,16 +105,18 @@ class PirSettingView @JvmOverloads constructor(
when (viewState.pirState) {
is Enabled -> {
isVisible = true
isClickable = true
background = ContextCompat.getDrawable(context, context.defaultSelectableItemBackground())
setStatus(isOn = true)
setClickListener { viewModel.onPir() }
setLeadingIconResource(R.drawable.ic_identity_blocked_pir_color_24)
isClickable = true
binding.pirSettings.setClickListener { viewModel.onPir() }
}
is Disabled -> {
isVisible = true
isClickable = false
background = null
setStatus(isOn = false)
binding.pirSettings.setClickListener(null)
setClickListener(null)
setLeadingIconResource(R.drawable.ic_identity_blocked_pir_grayscale_color_24)
}
Hidden -> isGone = true
Expand Down

0 comments on commit 6b46744

Please sign in to comment.