Skip to content

Commit

Permalink
Fix-up disabling low-light mode
Browse files Browse the repository at this point in the history
  • Loading branch information
0xf104a committed Mar 29, 2024
1 parent 3aa104f commit 4c93a3c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/com/polar/mirror/LowLightController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.WindowManager;

import androidx.camera.core.Preview;
Expand All @@ -14,6 +15,7 @@ public class LowLightController {
private final Activity mActivity;
private float lastBrightness = 1;
public boolean isLowLightModeEnabled = false;
private static final String TAG = "LowLightController";


LowLightController(Activity activity, Preview cameraPreview){
Expand All @@ -30,6 +32,7 @@ private void enableLowLightMode(){

private void disableLowLightMode(){
WindowManager.LayoutParams layout = mActivity.getWindow().getAttributes();
Log.d(TAG, "Setting brightness " + lastBrightness);
layout.screenBrightness = lastBrightness;
mActivity.getWindow().setAttributes(layout);
}
Expand All @@ -40,9 +43,9 @@ private void disableLowLightMode(){
*/
public boolean toggleLowLightMode(){
if(isLowLightModeEnabled){
enableLowLightMode();
}else{
disableLowLightMode();
}else{
enableLowLightMode();
}
isLowLightModeEnabled = !isLowLightModeEnabled;
return isLowLightModeEnabled;
Expand Down

0 comments on commit 4c93a3c

Please sign in to comment.