fix #36, allow changing the Bright Display color
This commit is contained in:
parent
14e6b54867
commit
37e704612d
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/display_holder"
|
||||
android:id="@+id/bright_display_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"/>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/bright_display"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/white"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bright_display_change_color"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:alpha="0.5"
|
||||
android:background="@drawable/button_background"
|
||||
android:padding="@dimen/activity_margin"
|
||||
android:text="@string/change_color"
|
||||
android:textSize="@dimen/big_text_size"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue