Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37e70461 authored by tibbi's avatar tibbi
Browse files

fix #36, allow changing the Bright Display color

parent 14e6b548
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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'
}
+24 −2
Original line number Diff line number Diff line
@@ -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()
+5 −3
Original line number Diff line number Diff line
@@ -65,11 +65,13 @@ class WidgetConfigureActivity : SimpleActivity() {
    }

    private fun pickBackgroundColor() {
        ColorPickerDialog(this, mWidgetColorWithoutTransparency) {
            mWidgetColorWithoutTransparency = it
        ColorPickerDialog(this, mWidgetColorWithoutTransparency) { wasPositivePressed, color ->
            if (wasPositivePressed) {
                mWidgetColorWithoutTransparency = color
                updateColors()
            }
        }
    }

    private fun requestWidgetUpdate() {
        Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE, null, this, MyWidgetProvider::class.java).apply {
+22 −4
Original line number Diff line number Diff line
<?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">

    <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>