From 21dcb20d0a360241195c24f9849cbdac3c965880 Mon Sep 17 00:00:00 2001 From: Smooth-E Date: Tue, 18 Apr 2023 23:13:55 +0500 Subject: [PATCH] Fix issues with animation and bottom padding for dialogs. --- .gitignore | 1 + .idea/deploymentTargetDropDown.xml | 17 ----------------- .../monetcolors/BottomInsetAwareDialog.java | 4 ++-- .../smoothie/monetcolors/CopyEntryView.java | 2 +- .../com/smoothie/monetcolors/MainActivity.java | 2 +- app/src/main/res/values-v31/styles.xml | 8 ++++++++ app/src/main/res/values/styles.xml | 7 +++++-- app/src/main/res/values/themes.xml | 2 +- readme.md | 18 +++++++++++++++++- 9 files changed, 36 insertions(+), 25 deletions(-) delete mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/res/values-v31/styles.xml diff --git a/.gitignore b/.gitignore index aa724b7..b849eea 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ .externalNativeBuild .cxx local.properties +/.idea/deploymentTargetDropDown.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index 0e75f06..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/smoothie/monetcolors/BottomInsetAwareDialog.java b/app/src/main/java/com/smoothie/monetcolors/BottomInsetAwareDialog.java index e63b2ad..fd4ce8b 100644 --- a/app/src/main/java/com/smoothie/monetcolors/BottomInsetAwareDialog.java +++ b/app/src/main/java/com/smoothie/monetcolors/BottomInsetAwareDialog.java @@ -10,8 +10,8 @@ public class BottomInsetAwareDialog extends Dialog { - public BottomInsetAwareDialog(@NonNull Context context, int themeResId) { - super(context, themeResId); + public BottomInsetAwareDialog(@NonNull Context context) { + super(context, R.style.SimpleDialog); } @Override diff --git a/app/src/main/java/com/smoothie/monetcolors/CopyEntryView.java b/app/src/main/java/com/smoothie/monetcolors/CopyEntryView.java index bf793ab..852dbfd 100644 --- a/app/src/main/java/com/smoothie/monetcolors/CopyEntryView.java +++ b/app/src/main/java/com/smoothie/monetcolors/CopyEntryView.java @@ -107,7 +107,7 @@ private String getStringForEntry(int entryID) { private void onClick() { Log.d(TAG, "OnClick()"); - Dialog dialog = new BottomInsetAwareDialog(getContext(), R.style.SimpleDialog); + Dialog dialog = new BottomInsetAwareDialog(getContext()); dialog.setContentView(R.layout.dialog_copy_preview); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); diff --git a/app/src/main/java/com/smoothie/monetcolors/MainActivity.java b/app/src/main/java/com/smoothie/monetcolors/MainActivity.java index 26aa833..6c47e03 100644 --- a/app/src/main/java/com/smoothie/monetcolors/MainActivity.java +++ b/app/src/main/java/com/smoothie/monetcolors/MainActivity.java @@ -124,7 +124,7 @@ private void copyColor() { } private void openSaveDialog() { - Dialog dialog = new BottomInsetAwareDialog(this, R.style.SimpleDialog); + Dialog dialog = new BottomInsetAwareDialog(this); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.dialog_variants_list); dialog.setCancelable(true); diff --git a/app/src/main/res/values-v31/styles.xml b/app/src/main/res/values-v31/styles.xml new file mode 100644 index 0000000..b3b6c6e --- /dev/null +++ b/app/src/main/res/values-v31/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index eabeab5..e72203f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,12 +1,15 @@ - + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 64bba5f..c39a12f 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/readme.md b/readme.md index bd3c286..d0c3b6b 100644 --- a/readme.md +++ b/readme.md @@ -71,7 +71,23 @@ Moreover, the app now works on devices which run under API lower than 31 (Androi ## Known issues -When changing the UI mode on your device (e.g. switching from light to dark theme) the app will most likely crash. It may crash in some cases when you are changing its activity state (e.g. returning to the app from a home screen or "Recent applications" screen). The cause of these crashes is the [android-maskable-layout library](https://github.com/Smooth-E/android-maskable-layout) which I am using to cut inner UI elements of rounded-cornered dialogs and scrollable views. Since this library is very outdated (last update in 2020, migrated to AndroidX by me in early spring 2023) I am planning to either replace it with Android's new `ShapeableImageView` where possible or patch the existing library further to resolve mentioned crashes. Stay tuned for the next release! +### Sudden crashes + +When changing the UI state on your device (e.g. switching from light to dark theme) the app will most likely crash. It may crash in some cases when you are changing its activity state (e.g. returning to the app from a home screen or "Recent applications" screen). The cause of these crashes is the [android-maskable-layout library](https://github.com/Smooth-E/android-maskable-layout) which I am using to cut inner UI elements of rounded-cornered dialogs and scrollable views. Since this library is very outdated (last update in 2020, migrated to AndroidX by me in early spring 2023) I am planning to either replace it with Android's new `ShapeableImageView` where possible or patch the existing library further to resolve mentioned crashes. + +### Incinistent experience on different Android versions + +Navigation bar looks differently on different API versions: + +- Android 6 - Android 9 - navigation bar has a blue background and light icons +- Android 10 and Android 11 - navigation bar has a dimmed background and light icons +- Android 12 and others (hopefully) - navigation bar background is blue with dark icons (intended behavior) + +It all started when I realized that Android has a very annoying bug in somewhat recent versions of it: when you want a window to slowly slide from below the screen on entrance and are making to interpolate it's Y position between -100% and 0%, it moves slightly higher (as if the top edge of the navigation bar was the bottom edge of the screen) and then immediately jumps back to where it should've stopped. It turned out that is I set the `android:windowIsFloating` flag to `true`, the animation will perform just fine. However. with this flag enabled, another problem appeared. It turns out, that on older API versions if the window is floating, then on API 23 the bottom inset for it is always 0, and on API 24 to 27 the navigation bar is dimmed. Then I made separate themes for different API versions, but didn't come up with a solution on how to remove dimness on Android 10 and Android 11. + +This is why you will get somewhat inconsistent experience on different Android versions. In future releases I am planning to reimplement these bottom dialogs with `ModalBottomSheet`s and overall redesign the app, since for now it is not really built with Material 3 guidelines in mind. + +> Stay tuned for the next release! ## Licensing and resources