diff --git a/app/build.gradle b/app/build.gradle
index 77431a5..a639ca8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -39,6 +39,9 @@ dependencies {
implementation 'androidx.car.app:app:1.4.0'
implementation 'androidx.concurrent:concurrent-futures:1.2.0'
+ // Color Picker Preference
+ implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0'
+
//Google Maps SDK
implementation 'com.google.android.gms:play-services-maps:19.1.0'
implementation 'com.google.android.gms:play-services-location:21.3.0'
diff --git a/app/src/main/java/com/aldo/apps/familyhelpers/FlashlightActivity.java b/app/src/main/java/com/aldo/apps/familyhelpers/FlashlightActivity.java
index 6b10fef..fdc92c3 100644
--- a/app/src/main/java/com/aldo/apps/familyhelpers/FlashlightActivity.java
+++ b/app/src/main/java/com/aldo/apps/familyhelpers/FlashlightActivity.java
@@ -5,15 +5,19 @@ import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.graphics.ColorUtils;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
+import androidx.preference.PreferenceManager;
+import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
+import android.widget.Button;
import android.widget.ImageView;
import com.aldo.apps.familyhelpers.ui.FlashLightLevelShifter;
@@ -32,6 +36,17 @@ public class FlashlightActivity extends AppCompatActivity {
*/
private static final String TAG = "FlashlightActivity";
+ /**
+ * Value to determine whether a color is light or dark. A luminance bigger than 0.5 will be considered
+ * light.
+ */
+ private static double COLOR_LUMINANCE_VALUE = 0.5;
+
+ /**
+ * SharedPreferences instance for accessing user preferences.
+ */
+ private SharedPreferences mPreferences;
+
/**
* {@link ImageView} indicating the current status of the flashlight.
*/
@@ -64,6 +79,7 @@ public class FlashlightActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flashlight);
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mFullscreenController = WindowCompat.getInsetsController(getWindow(),
getWindow().getDecorView());
mBrightnessController = new DisplayBrightnessController(findViewById(R.id.tv_current_brightness), this);
@@ -116,6 +132,7 @@ public class FlashlightActivity extends AppCompatActivity {
initializeColorButton(R.id.btn_onscreen_flashlight_gray, R.color.flashlight_onscreen_gray, false);
initializeColorButton(R.id.btn_onscreen_flashlight_white, R.color.flashlight_onscreen_white, true);
initializeColorButton(R.id.btn_onscreen_flashlight_yellow, R.color.flashlight_onscreen_yellow, true);
+ initCustomColorButton();
}
@Override
@@ -160,6 +177,22 @@ public class FlashlightActivity extends AppCompatActivity {
});
}
+ private void initCustomColorButton() {
+ final Button customBtn = findViewById(R.id.btn_onscreen_flashlight_custom);
+ final int backgroundColor = mPreferences.getInt(
+ getString(R.string.pref_key_on_screen_flashlight_custom_color),
+ getColor(R.color.md_theme_secondary));
+ final boolean isLightColor = ColorUtils.calculateLuminance(backgroundColor) > COLOR_LUMINANCE_VALUE;
+ customBtn.setBackgroundColor(backgroundColor);
+ customBtn.setTextColor(isLightColor ? getColor(R.color.black) : getColor(R.color.white));
+ customBtn.setOnClickListener(v -> {
+ mOnScreenFlashlight.setBackgroundColor(backgroundColor);
+ mOnScreenFlashlight.setVisibility(View.VISIBLE);
+ mFullscreenController.hide(WindowInsetsCompat.Type.systemBars());
+ mBrightnessController.setLightModeColor(isLightColor);
+ });
+ }
+
/**
* Helper method to print any potential errors while subscribing to the current status observable.
*
diff --git a/app/src/main/java/com/aldo/apps/familyhelpers/SettingsActivity.java b/app/src/main/java/com/aldo/apps/familyhelpers/SettingsActivity.java
index 17e2726..e21e549 100644
--- a/app/src/main/java/com/aldo/apps/familyhelpers/SettingsActivity.java
+++ b/app/src/main/java/com/aldo/apps/familyhelpers/SettingsActivity.java
@@ -3,12 +3,15 @@ package com.aldo.apps.familyhelpers;
import android.os.Build;
import android.os.Bundle;
+import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import com.aldo.apps.familyhelpers.utils.FlashlightHelper;
+import com.rarepebble.colorpicker.ColorPreference;
/**
* Simple Settings Activity for some app specific settings.
@@ -40,5 +43,14 @@ public class SettingsActivity extends AppCompatActivity {
public void onCreatePreferences(final Bundle savedInstanceState, final String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
+
+ @Override
+ public void onDisplayPreferenceDialog(@NonNull final Preference preference) {
+ if (preference instanceof ColorPreference) {
+ ((ColorPreference) preference).showDialog(this, 0);
+ } else {
+ super.onDisplayPreferenceDialog(preference);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_flashlight.xml b/app/src/main/res/layout/activity_flashlight.xml
index 0591abf..43bd5c1 100644
--- a/app/src/main/res/layout/activity_flashlight.xml
+++ b/app/src/main/res/layout/activity_flashlight.xml
@@ -18,102 +18,125 @@
android:layout_marginTop="@dimen/flashlight_category_header_margin_top"
android:layout_marginBottom="@dimen/flashlight_category_header_margin_bottom"/>
-
+ app:layout_constraintTop_toBottomOf="@id/tv_onscreen_flashlight"
+ app:layout_constraintBottom_toTopOf="@id/tv_camera_flashlight_title">
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
Aktiviere die Taschenlampe auf minimaler Helligkeit
Aktiviere die Taschenlampe auf mittlerer HelligkeitAktiviere die Taschenlampe auf maximaler Helligkeit
+ Bildschirm TaschenlampeRoter BildschirmBlauer BildschirmGrüner Bildschirm
@@ -56,6 +57,7 @@
Die Empfindlichkeit mit der auf Swipe Gesten reagiert wirdSchrittgrößeDie Größe der Schritte mit der die Helligkeit verändert werden soll
+ Eigene FarbeDu teilst bereits deinen Standort mit der Familie, willst du aufhören?Android Auto wurde gestartet, willst du deinen Standort teilen?Ja, fang an zu teilen
@@ -64,4 +66,6 @@
Anfangen den Standort zu teilenStopAufhören den Standort zu teilen
+ Wähle eine eigene Farbe für deine Bildschirm-Taschenlampe
+ Eigene Farbe
\ No newline at end of file
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index c1240c2..de2b369 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -29,6 +29,7 @@
Activate flashlight on minimum brightnessActivate flashlight on medium brightnessActivate flashlight on maximum brightness
+ On-Screen FlashlightRed On-ScreenBlue On-ScreenGreen On-Screen
@@ -56,6 +57,7 @@
The sensitivity of the swipe gesture on the on-screen flashlightSwipe Step SizeThe change step size of the on-screen swipe gesture
+ Custom colorYou are already sharing your location with your family, do you wanna stop?Android Auto start has been detected, do you wanna share your location?Yes, start to share
@@ -64,4 +66,6 @@
Start to share locationStopStop to share the location
+ Choose an own color to be displayed in the on-screen flashlight.
+ Custom Color
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 529c309..15bf45c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -49,6 +49,7 @@
White On-ScreenGray On-ScreenBrightness: %d
+ Custom ColorSettings
@@ -74,6 +75,8 @@
The sensitivity of the swipe gesture on the on-screen flashlightSwipe Step SizeThe change step size of the on-screen swipe gesture
+ Custom color
+ Choose an own color to be displayed in the on-screen flashlight.location_update_freq
@@ -81,8 +84,9 @@
manual_accuracystore_last_brightnessflashlight_default_brightness
- on_screen_flash_sensititvity
+ on_screen_flash_sensitivityon_screen_flash_step_size
+ on_screen_flash_custom_colorYou are already sharing your location with your family, do you wanna stop?
diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml
index b2b961d..7f4b2e4 100644
--- a/app/src/main/res/xml/root_preferences.xml
+++ b/app/src/main/res/xml/root_preferences.xml
@@ -73,6 +73,13 @@
app:defaultValue="@integer/pref_on_screen_flashlight_step_size_def"
app:summary="@string/pref_on_screen_flashlight_step_size_summary"/>
+
+
diff --git a/build.gradle b/build.gradle
index 7ca59c7..2ed6ba7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,5 +8,6 @@ allprojects {
repositories {
google()
mavenCentral()
+ maven { url "https://jitpack.io" }
}
}
\ No newline at end of file