Skip to content

Commit

Permalink
android widget: disable scrolling when interacting with colorpickerview
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Feb 5, 2025
1 parent 6153810 commit 42fc59e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import android.provider.Settings
import android.util.Log
import android.view.MotionEvent
import android.view.View
import android.widget.ImageView
import android.view.animation.AccelerateDecelerateInterpolator
import android.view.animation.AnimationUtils
import android.widget.LinearLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import android.app.Activity
import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import android.os.Looper
Expand All @@ -55,7 +54,6 @@ import java.io.File
import java.nio.file.Files
import kotlin.io.path.Path


/**
* The configuration screen for the [customfetch] AppWidget.
*/
Expand Down Expand Up @@ -135,6 +133,7 @@ class customfetchConfigureActivity : Activity() {
}
"custom_bg_color" -> {
binding.selectBgColor.check(R.id.radio_custom_colors)
binding.customColorSelect.visibility = View.VISIBLE
setColorPickerView()
}
}
Expand All @@ -152,6 +151,7 @@ class customfetchConfigureActivity : Activity() {
}

R.id.radio_custom_colors -> {
binding.customColorSelect.visibility = View.VISIBLE
setColorPickerView()
}
}
Expand All @@ -161,16 +161,20 @@ class customfetchConfigureActivity : Activity() {
private fun setSystemBgColor() {
val typedValue = TypedValue()
this.theme.resolveAttribute(android.R.attr.colorBackground, typedValue, true)
bgColor = typedValue.data
this.bgColor = typedValue.data
}

@SuppressLint("SetTextI18n", "ClickableViewAccessibility")
private fun setColorPickerView() {
binding.customColorSelect.visibility = View.VISIBLE
// disable scroll when interacting with the color picker
// disable scrolling when interacting with the color picker
binding.colorPickerView.setOnTouchListener { view, _ ->
view.parent.requestDisallowInterceptTouchEvent(true)
false // allow colorPickerView to handle the touch event
view.parent.requestDisallowInterceptTouchEvent(true); false
}
binding.alphaSlideBar.setOnTouchListener { view, _, ->
view.parent.requestDisallowInterceptTouchEvent(true); false
}
binding.brightnessSlideBar.setOnTouchListener { view, _, ->
view.parent.requestDisallowInterceptTouchEvent(true); false
}

val defaultColor = getAppSettingsPrefString(this, "default_custom_color")
Expand Down

0 comments on commit 42fc59e

Please sign in to comment.