diff --git a/app/build.gradle b/app/build.gradle
index 654fdf1..3934eca 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,7 +41,7 @@ android {
}
dependencies {
- implementation 'com.simplemobiletools:commons:3.18.6'
+ implementation 'com.simplemobiletools:commons:3.18.8'
implementation 'com.squareup:otto:1.3.8'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt
index 046ca46..cf5d051 100644
--- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt
@@ -3,7 +3,9 @@ package com.simplemobiletools.flashlight.activities
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.WindowManager
-
+import com.simplemobiletools.commons.dialogs.ColorPickerDialog
+import com.simplemobiletools.commons.extensions.applyColorFilter
+import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.flashlight.R
import com.simplemobiletools.flashlight.extensions.config
import kotlinx.android.synthetic.main.activity_bright_display.*
@@ -13,7 +15,19 @@ class BrightDisplayActivity : SimpleActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_bright_display)
supportActionBar?.hide()
- display_holder.background = ColorDrawable(config.brightDisplayColor)
+ setBackgroundColor(config.brightDisplayColor)
+
+ bright_display_change_color.setOnClickListener {
+ ColorPickerDialog(this, config.brightDisplayColor, true, currentColorCallback = {
+ setBackgroundColor(it)
+ }) { wasPositivePressed, color ->
+ if (wasPositivePressed) {
+ config.brightDisplayColor = color
+ } else {
+ setBackgroundColor(config.brightDisplayColor)
+ }
+ }
+ }
}
override fun onResume() {
@@ -28,6 +42,14 @@ class BrightDisplayActivity : SimpleActivity() {
toggleBrightness(false)
}
+ private fun setBackgroundColor(color: Int) {
+ bright_display.background = ColorDrawable(color)
+
+ val contrastColor = config.brightDisplayColor.getContrastColor()
+ bright_display_change_color.setTextColor(contrastColor)
+ bright_display_change_color.background.applyColorFilter(contrastColor)
+ }
+
private fun toggleBrightness(increase: Boolean) {
val layout = window.attributes
layout.screenBrightness = (if (increase) 1 else 0).toFloat()
diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetConfigureActivity.kt
index a0c8580..89b2525 100644
--- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetConfigureActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/WidgetConfigureActivity.kt
@@ -65,9 +65,11 @@ class WidgetConfigureActivity : SimpleActivity() {
}
private fun pickBackgroundColor() {
- ColorPickerDialog(this, mWidgetColorWithoutTransparency) {
- mWidgetColorWithoutTransparency = it
- updateColors()
+ ColorPickerDialog(this, mWidgetColorWithoutTransparency) { wasPositivePressed, color ->
+ if (wasPositivePressed) {
+ mWidgetColorWithoutTransparency = color
+ updateColors()
+ }
}
}
diff --git a/app/src/main/res/layout/activity_bright_display.xml b/app/src/main/res/layout/activity_bright_display.xml
index 447f4df..b81a52d 100644
--- a/app/src/main/res/layout/activity_bright_display.xml
+++ b/app/src/main/res/layout/activity_bright_display.xml
@@ -1,7 +1,25 @@
-
+ android:layout_height="match_parent">
+
+
+
+
+
+