From 08156c4cd5abc911369dfca6555ec336d82f5bf8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Aug 2019 22:25:29 +0200 Subject: [PATCH] adding an SOS button at the main screen --- .../flashlight/activities/MainActivity.kt | 10 +++- app/src/main/res/layout/activity_main.xml | 33 +++++++++---- app/src/main/res/layout/activity_settings.xml | 46 +++++++++---------- app/src/main/res/values/dimens.xml | 3 +- 4 files changed, 58 insertions(+), 34 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt index b4e80bc..934b276 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt @@ -49,6 +49,8 @@ class MainActivity : SimpleActivity() { mCameraImpl!!.toggleFlashlight() } + sos_btn.setOnClickListener {} + setupStroboscope() checkAppOnSDCard() } @@ -58,9 +60,13 @@ class MainActivity : SimpleActivity() { mCameraImpl!!.handleCameraSetup() checkState(MyCameraImpl.isFlashlightOn) - changeIconColor(config.backgroundColor.getContrastColor(), bright_display_btn) + val contrastColor = config.backgroundColor.getContrastColor() + changeIconColor(contrastColor, bright_display_btn) bright_display_btn.beVisibleIf(config.brightDisplay) + sos_btn.beVisibleIf(config.sos) + sos_btn.setTextColor(contrastColor) stroboscope_btn.beVisibleIf(config.stroboscope) + if (!config.stroboscope) { mCameraImpl!!.stopStroboscope() stroboscope_bar.beInvisible() @@ -68,7 +74,7 @@ class MainActivity : SimpleActivity() { updateTextColors(main_holder) if (stroboscope_bar.isInvisible()) { - changeIconColor(config.backgroundColor.getContrastColor(), stroboscope_btn) + changeIconColor(contrastColor, stroboscope_btn) } requestedOrientation = if (config.forcePortraitMode) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else ActivityInfo.SCREEN_ORIENTATION_SENSOR diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c87dcd2..f37a527 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -16,8 +16,8 @@ android:id="@+id/flashlight_btn" android:layout_width="@dimen/main_button_size" android:layout_height="@dimen/main_button_size" - android:layout_marginBottom="@dimen/activity_margin" - android:layout_marginTop="@dimen/activity_margin" + android:layout_marginTop="@dimen/normal_margin" + android:layout_marginBottom="@dimen/normal_margin" android:background="@drawable/circles_big" app:layout_constraintBottom_toTopOf="@+id/bright_display_btn" app:layout_constraintEnd_toEndOf="parent" @@ -29,36 +29,53 @@ android:id="@+id/bright_display_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/activity_margin" - android:layout_marginTop="@dimen/buttons_margin" + android:layout_marginTop="@dimen/normal_margin" + android:layout_marginBottom="@dimen/normal_margin" android:background="@drawable/ic_bright_display" android:padding="@dimen/activity_margin" - app:layout_constraintBottom_toTopOf="@+id/stroboscope_btn" + app:layout_constraintBottom_toTopOf="@+id/sos_btn" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/flashlight_btn"/> + + + app:layout_constraintTop_toBottomOf="@+id/sos_btn"/> - - - - - - + + + + + + - 30dp 250dp 150dp + + 26sp