diff --git a/app/src/main/java/rocks/poopjournal/flashy/activities/MainActivity.java b/app/src/main/java/rocks/poopjournal/flashy/activities/MainActivity.java
index d790ec0..a6ba669 100644
--- a/app/src/main/java/rocks/poopjournal/flashy/activities/MainActivity.java
+++ b/app/src/main/java/rocks/poopjournal/flashy/activities/MainActivity.java
@@ -1,21 +1,18 @@
package rocks.poopjournal.flashy.activities;
import android.animation.LayoutTransition;
-import android.content.BroadcastReceiver;
import android.content.Intent;
-import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
-import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
@@ -23,11 +20,13 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager;
+import com.google.android.material.color.MaterialColors;
import com.google.android.material.slider.Slider;
import com.skydoves.colorpickerview.ColorPickerView;
import com.skydoves.colorpickerview.listeners.ColorListener;
import me.tankery.lib.circularseekbar.CircularSeekBar;
+
import rocks.poopjournal.flashy.NoFlashlightDialog;
import rocks.poopjournal.flashy.R;
import rocks.poopjournal.flashy.databinding.MainActivityBinding;
@@ -38,7 +37,7 @@
public class MainActivity extends AppCompatActivity {
//Fields
- RelativeLayout root_layout ;
+ private int invertedBackgroundColor = 0;
private int brightness = -999;
private Window window;
private SharedPreferences legacyPreferences; //kept for legacy reasons
@@ -100,7 +99,7 @@ protected void onCreate(Bundle savedInstanceState) {
legacyPreferences = getSharedPreferences("my_prefs", MODE_PRIVATE);
applyListeners();
init();
- if (savedInstanceState != null && legacyPreferences.getInt("default_option", 1) == 2) {
+ if (savedInstanceState != null && !isFlashOption()) {
brightness = savedInstanceState.getInt("brightness");
WindowManager.LayoutParams layoutpars = window.getAttributes();
layoutpars.screenBrightness = (float) brightness / 100;
@@ -109,10 +108,6 @@ protected void onCreate(Bundle savedInstanceState) {
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) {
getSupportFragmentManager().setFragmentResultListener(NoFlashlightDialog.NO_FLASH_DIALOG_DISMISSED, this, ((requestKey, result) -> binding.bgOptions.callOnClick()));
- binding.sosButton.setVisibility(View.GONE);
- binding.sosIcon.setVisibility(View.GONE);
- binding.stroboscopeButton.setVisibility(View.GONE);
- binding.stroboscopeIcon.setVisibility(View.GONE);
binding.stroboscopeInterval.setVisibility(View.GONE);
binding.stroboscopeIntervalSlider.setVisibility(View.GONE);
} else {
@@ -123,8 +118,8 @@ protected void onCreate(Bundle savedInstanceState) {
binding.stroboscopeInterval.setVisibility(isOn ? View.VISIBLE : View.GONE);
binding.stroboscopeIntervalSlider.setVisibility(isOn ? View.VISIBLE : View.GONE);
}));
- binding.sosButton.setOnClickListener(v -> helper.toggleSos(this));
- binding.stroboscopeButton.setOnClickListener(v -> helper.toggleStroboscope(this));
+ binding.sosIcon.setOnClickListener(v -> helper.toggleSos(this));
+ binding.stroboscopeIcon.setOnClickListener(v -> helper.toggleStroboscope(this));
float stroboscopeIntervalInPreferences = defaultPreferences.getFloat("stroboscope_interval", -1);
helper.setStroboscopeInterval(stroboscopeIntervalInPreferences != -1 ? (int) (stroboscopeIntervalInPreferences * 1000) : 500);
binding.stroboscopeIntervalSlider.setValue(stroboscopeIntervalInPreferences != -1 ? stroboscopeIntervalInPreferences : 0.5F);
@@ -139,13 +134,12 @@ public void onStopTrackingTouch(@NonNull Slider slider) {
}
});
}
- root_layout = findViewById(R.id.root_layout);
ColorPickerView colorPickerView = findViewById(R.id.colorPickerView);
colorPickerView.setColorListener(new ColorListener() {
@Override
public void onColorSelected(int color, boolean fromUser) {
- root_layout.setBackgroundColor(color);
+ updateUIColors(color);
}
});
}
@@ -162,36 +156,19 @@ protected void onDestroy() {
turnOffFlashlightOnScreenOffReceiver.unregisterWith(this);
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(@NonNull MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.settings_menu_item) {
- startActivity(new Intent(this, SettingsActivity.class));
- return true;
- } else if (id == R.id.about_menu_item) {
- startActivity(new Intent(this, AboutActivity.class));
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
void applyListeners() {
binding.bgOptions.setOnClickListener(view -> {
SharedPreferences.Editor editor = legacyPreferences.edit();
- editor.putInt("default_option", legacyPreferences.getInt("default_option", 1) == 1 ? 2 : 1);
+ editor.putInt("default_option", isFlashOption() ? 2 : 1);
editor.apply();
init();
});
+ binding.aboutIcon.setOnClickListener(view -> startActivity(new Intent(this, AboutActivity.class)));
+ binding.settingsIcon.setOnClickListener(view -> startActivity(new Intent(this, SettingsActivity.class)));
}
void init() {
- if (legacyPreferences.getInt("default_option", 1) == 1) {
+ if (isFlashOption()) {
updateOptionsUI(true);
refreshActivityForFlashLight();
} else {
@@ -235,21 +212,21 @@ public void onStartTrackingTouch(@Nullable CircularSeekBar circularSeekBar) {
binding.progressCircular.setPointerColor(Color.parseColor("#AAAABB"));
binding.powerCenter.setOnClickListener(v -> helper.toggleNormalFlash(this));
}
- binding.rootLayout.setBackgroundColor(Color.parseColor("#00000000")); //transparent
+ binding.colorPickerView.setEnabled(false);
+ binding.colorPickerView.setVisibility(View.GONE);
+ updateUIColors(Color.parseColor("#00000000")); //transparent
}
private void changeButtonColors(FlashlightMode mode, boolean isTurnedOn) {
switch (mode) {
case NORMAL:
- binding.powerCenter.setColorFilter(isTurnedOn ? Color.parseColor("#28FFB137") : Color.parseColor("#F3F3F7"));
+ binding.powerCenter.setColorFilter(isTurnedOn ? Color.parseColor("#28FFB137") : invertedBackgroundColor);
binding.powerIcon.setColorFilter(isTurnedOn ? Color.parseColor("#FFB137") : Color.parseColor("#AAAABB"));
break;
case SOS:
- binding.sosButton.setColorFilter(isTurnedOn ? Color.parseColor("#28FFB137") : Color.parseColor("#F3F3F7"));
binding.sosIcon.setColorFilter(isTurnedOn ? Color.parseColor("#FFB137") : Color.parseColor("#AAAABB"));
break;
case STROBOSCOPE:
- binding.stroboscopeButton.setColorFilter(isTurnedOn ? Color.parseColor("#28FFB137") : Color.parseColor("#F3F3F7"));
binding.stroboscopeIcon.setColorFilter(isTurnedOn ? Color.parseColor("#FFB137") : Color.parseColor("#AAAABB"));
break;
default:
@@ -281,7 +258,8 @@ void refreshActivityForScreenLight() {
binding.progressCircular.setEnabled(true);
if (defaultPreferences.getBoolean("no_flash_when_screen", true) && getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH))
helper.turnOffAll(this);
- binding.rootLayout.setBackgroundColor(Color.parseColor("#FFFFFF")); //force set white, because it does not make sense for the app to be dark when using screen light
+ binding.colorPickerView.setEnabled(true);
+ binding.colorPickerView.setVisibility(View.VISIBLE);
if (binding.progressCircular.getProgress() > 0) {
binding.progressCircular.setOnSeekBarChangeListener(null);
binding.progressCircular.setProgress(0f);
@@ -306,12 +284,34 @@ public void onStartTrackingTouch(CircularSeekBar seekBar) {
}
});
binding.powerCenter.setOnClickListener(view -> binding.progressCircular.setProgress(brightness != 100 ? 100 : 0));
+ updateUIColors(Color.parseColor("#FFFFFF")); //force set white, because it does not make sense for the app to be dark when using screen light
+ }
+
+ void updateUIColors(int backgroundColor) {
+ invertedBackgroundColor = Utils.invertColor(isFlashOption() ? MaterialColors.getColor(this, android.R.attr.colorBackground, 0) : backgroundColor);
+ PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(invertedBackgroundColor, PorterDuff.Mode.SRC_ATOP);
+ binding.toolbar.setTitleTextColor(invertedBackgroundColor);
+ binding.powerCenter.setColorFilter(colorFilter);
+ binding.bgOptions.getBackground().setColorFilter(colorFilter);
+ binding.bgFlashlightMode.getBackground().setColorFilter(colorFilter);
+ binding.aboutIcon.setColorFilter(colorFilter);
+ binding.settingsIcon.setColorFilter(colorFilter);
+
+ binding.rootLayout.setBackgroundColor(backgroundColor);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ window.setStatusBarColor(backgroundColor);
+ window.setNavigationBarColor(backgroundColor);
+ }
+ }
+
+ boolean isFlashOption() {
+ return legacyPreferences.getInt("default_option", 1) == 1;
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
- if (legacyPreferences.getInt("default_option", 1) == 2) {
+ if (!isFlashOption()) {
outState.putInt("brightness", brightness);
}
}
diff --git a/app/src/main/java/rocks/poopjournal/flashy/utils/Utils.java b/app/src/main/java/rocks/poopjournal/flashy/utils/Utils.java
index 66ce6eb..87c733a 100644
--- a/app/src/main/java/rocks/poopjournal/flashy/utils/Utils.java
+++ b/app/src/main/java/rocks/poopjournal/flashy/utils/Utils.java
@@ -1,5 +1,6 @@
package rocks.poopjournal.flashy.utils;
+import android.graphics.Color;
import static android.hardware.Camera.Parameters.FLASH_MODE_AUTO;
import static android.hardware.Camera.Parameters.FLASH_MODE_ON;
import static android.hardware.Camera.Parameters.FLASH_MODE_TORCH;
@@ -12,6 +13,7 @@
import android.hardware.Camera;
import androidx.appcompat.app.AppCompatDelegate;
+import androidx.core.graphics.ColorUtils;
import androidx.preference.PreferenceManager;
import java.util.List;
@@ -77,4 +79,10 @@ public static void applyThemeFromSettings(Context context) {
context.setTheme(preferences.getBoolean("md3", false) ? R.style.AppTheme_Material3 : R.style.AppTheme);
}
+ public static int invertColor(int color) {
+ int red = 255 - Color.red(color);
+ int green = 255 - Color.green(color);
+ int blue = 255 - Color.blue(color);
+ return Color.rgb(red, green, blue);
+ }
}
diff --git a/app/src/main/res/drawable/ic_info.xml b/app/src/main/res/drawable/ic_info.xml
new file mode 100644
index 0000000..919dc2c
--- /dev/null
+++ b/app/src/main/res/drawable/ic_info.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_rectangle_bg_options.xml b/app/src/main/res/drawable/ic_rectangle_bg_options.xml
index 0a470fa..f8e0731 100644
--- a/app/src/main/res/drawable/ic_rectangle_bg_options.xml
+++ b/app/src/main/res/drawable/ic_rectangle_bg_options.xml
@@ -5,5 +5,6 @@
android:viewportHeight="40">
+ android:fillColor="#FFFFFF"
+ android:fillAlpha="0.16"/>
diff --git a/app/src/main/res/drawable/ic_settings.xml b/app/src/main/res/drawable/ic_settings.xml
new file mode 100644
index 0000000..80e4787
--- /dev/null
+++ b/app/src/main/res/drawable/ic_settings.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/font/lexenddeca_variablefont_wght.ttf b/app/src/main/res/font/lexenddeca_variablefont_wght.ttf
new file mode 100644
index 0000000..e895baf
Binary files /dev/null and b/app/src/main/res/font/lexenddeca_variablefont_wght.ttf differ
diff --git a/app/src/main/res/layout-land/main_activity.xml b/app/src/main/res/layout-land/main_activity.xml
index 257e8b4..745ca68 100644
--- a/app/src/main/res/layout-land/main_activity.xml
+++ b/app/src/main/res/layout-land/main_activity.xml
@@ -9,26 +9,28 @@
+ android:background="@android:color/transparent"
+ app:elevation="0dp">
-
+ android:background="@android:color/transparent"
+ app:titleTextAppearance="@style/TextAppearance.ToolbarTitle"
+ app:title="@string/app_name"
+ app:titleCentered="true" />
-
+ android:orientation="horizontal">
-
-
-
-
-
-
-
-
-
-
-
+ android:id="@+id/bg_options"
+ android:layout_width="88dp"
+ android:layout_height="40dp"
+ android:background="@drawable/ic_rectangle_bg_options">
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+ android:src="@drawable/ic_settings" />
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml
index 3775d7b..e21d92f 100644
--- a/app/src/main/res/layout/main_activity.xml
+++ b/app/src/main/res/layout/main_activity.xml
@@ -9,22 +9,24 @@
+ android:background="@android:color/transparent"
+ app:elevation="0dp">
-
+ android:background="@android:color/transparent"
+ app:titleTextAppearance="@style/TextAppearance.ToolbarTitle"
+ app:title="@string/app_name"
+ app:titleCentered="true" />
-
+ android:orientation="horizontal">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:id="@+id/bg_options"
+ android:layout_width="88dp"
+ android:layout_height="40dp"
+ android:background="@drawable/ic_rectangle_bg_options">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_alignParentBottom="true"
+ android:src="@drawable/ic_settings" />
\ No newline at end of file
diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml
index ed63411..7675837 100644
--- a/app/src/main/res/values-night/styles.xml
+++ b/app/src/main/res/values-night/styles.xml
@@ -8,11 +8,15 @@
- @color/colorAccent
- @android:color/white
- ?attr/colorPrimary
+ - false
+ - false
- @style/RoundedCornersBottomSheetTheme
+
+
@@ -26,6 +35,8 @@