Skip to content

Commit

Permalink
Add icon for low-ligh mode from Google Fonts, fix LowLightController …
Browse files Browse the repository at this point in the history
…initialization
  • Loading branch information
0xf104a committed Mar 30, 2024
1 parent b8f5208 commit 83aa7e4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/com/polar/mirror/LowLightController.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ private void enableLowLightMode(){
lastBrightness = layout.screenBrightness;
layout.screenBrightness = 1F;
mActivity.getWindow().setAttributes(layout);
//Set image on FAB
mLowLightModeButton.setImageResource(R.drawable.flashlight_off);
}

private void disableLowLightMode(){
WindowManager.LayoutParams layout = mActivity.getWindow().getAttributes();
Log.d(TAG, "Setting brightness " + lastBrightness);
layout.screenBrightness = lastBrightness;
mActivity.getWindow().setAttributes(layout);
//Set image on FAB
mLowLightModeButton.setImageResource(R.drawable.flashlight_on);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/polar/mirror/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ protected void onCreate(Bundle savedInstanceState) {
mFreezeController = new FreezeController(this, freezeButton, mCameraView,
freezeView);

//Get low-light FAB
FloatingActionButton lowLightModeButton = findViewById(R.id.low_light_button);

//Start camera
try {
startCamera();
mLowLightController = new LowLightController(this);
mLowLightController = new LowLightController(this, lowLightModeButton);
} catch (ExecutionException | InterruptedException e) {
final String toastText = getString(R.string.can_not_start_camera);
Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/flashlight_off.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M792,904 L640,752v128L320,880v-448L56,168l56,-56 736,736 -56,56ZM400,800h160v-128L400,512v288ZM640,526 L560,446v-30l80,-120v-16L394,280l-80,-80h326v-40L274,160l-34,-34v-46h480v240l-80,120v86ZM480,592ZM497,383Z"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/flashlight_on.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M320,880v-440l-80,-120v-240h480v240l-80,120v440L320,880ZM480,620q-25,0 -42.5,-17.5T420,560q0,-25 17.5,-42.5T480,500q25,0 42.5,17.5T540,560q0,25 -17.5,42.5T480,620ZM320,200h320v-40L320,160v40ZM640,280L320,280v16l80,120v384h160v-384l80,-120v-16ZM480,480Z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/action_panel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/low_light"
android:src="@android:drawable/ic_menu_view" />
android:src="@drawable/flashlight_on" />

<TextView
android:layout_width="match_parent"
Expand Down

0 comments on commit 83aa7e4

Please sign in to comment.