diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-11-01 17:31:57 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-11-01 17:31:57 +0300 |
commit | ad41b1df555d085edaaf5f00963ff9007536f88c (patch) | |
tree | 5633c6f58842e3ce1d84622ca98e0bf7da801f38 /app | |
parent | f05402c7b67f8ea234f6e9ce749dfe8ba95b22af (diff) |
Fix crash on Android 4.4
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java | 62 | ||||
-rw-r--r-- | app/src/main/res/drawable-v21/bottom_sheet_rounded.xml | 9 | ||||
-rw-r--r-- | app/src/main/res/drawable-xxxhdpi/background.png | bin | 44461 -> 0 bytes | |||
-rw-r--r-- | app/src/main/res/drawable/bottom_sheet_rounded.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values-v21/styles.xml | 9 |
5 files changed, 27 insertions, 56 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java index 02c13a8c8..1d89ee0ce 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/picker/CardAttachmentPicker.java @@ -1,25 +1,17 @@ package it.niedermann.nextcloud.deck.ui.card.attachments.picker; -import android.app.Dialog; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.LayerDrawable; -import android.os.Build; import android.os.Bundle; -import android.util.DisplayMetrics; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.Window; import android.widget.ImageView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.RequiresApi; import androidx.fragment.app.DialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; @@ -31,7 +23,6 @@ import it.niedermann.nextcloud.deck.util.DeckColorUtil; import static android.os.Build.VERSION.SDK_INT; import static android.os.Build.VERSION_CODES.LOLLIPOP; -import static it.niedermann.nextcloud.deck.DeckApplication.isDarkTheme; import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.isBrandingEnabled; import static it.niedermann.nextcloud.deck.ui.branding.BrandingUtil.readBrandMainColor; @@ -57,21 +48,6 @@ public class CardAttachmentPicker extends BottomSheetDialogFragment implements B } } - @NonNull - @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { - final Dialog dialog = super.onCreateDialog(savedInstanceState); - - if (SDK_INT >= Build.VERSION_CODES.O_MR1) { - if (!isDarkTheme(requireContext())) { - setWhiteNavigationBar(dialog); - } - } - - return dialog; - } - - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -107,38 +83,16 @@ public class CardAttachmentPicker extends BottomSheetDialogFragment implements B @Override public void applyBrand(int mainColor) { if (SDK_INT >= LOLLIPOP) { + final ColorStateList backgroundColorStateList = ColorStateList.valueOf(mainColor); + final ColorStateList foregroundColorStateList = ColorStateList.valueOf( + DeckColorUtil.contrastRatioIsSufficient(mainColor, Color.WHITE) + ? Color.WHITE + : Color.BLACK + ); for (ImageView v : brandedViews) { - v.setBackgroundTintList(ColorStateList.valueOf(mainColor)); - v.setImageTintList(ColorStateList.valueOf( - DeckColorUtil.contrastRatioIsSufficient(mainColor, Color.WHITE) - ? Color.WHITE - : Color.BLACK - )); + v.setBackgroundTintList(backgroundColorStateList); + v.setImageTintList(foregroundColorStateList); } } } - - @RequiresApi(api = Build.VERSION_CODES.M) - private void setWhiteNavigationBar(@NonNull Dialog dialog) { - Window window = dialog.getWindow(); - if (window != null) { - DisplayMetrics metrics = new DisplayMetrics(); - window.getWindowManager().getDefaultDisplay().getMetrics(metrics); - - GradientDrawable dimDrawable = new GradientDrawable(); - // ...customize your dim effect here - - GradientDrawable navigationBarDrawable = new GradientDrawable(); - navigationBarDrawable.setShape(GradientDrawable.RECTANGLE); - navigationBarDrawable.setColor(Color.WHITE); - - Drawable[] layers = {dimDrawable, navigationBarDrawable}; - - LayerDrawable windowBackground = new LayerDrawable(layers); - windowBackground.setLayerInsetTop(1, metrics.heightPixels); - - window.setBackgroundDrawable(windowBackground); - } - } - } diff --git a/app/src/main/res/drawable-v21/bottom_sheet_rounded.xml b/app/src/main/res/drawable-v21/bottom_sheet_rounded.xml new file mode 100644 index 000000000..ba266ed32 --- /dev/null +++ b/app/src/main/res/drawable-v21/bottom_sheet_rounded.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" + android:shape="rectangle"> + <solid android:color="?attr/colorSurface" /> + <corners + android:topLeftRadius="16dp" + android:topRightRadius="16dp" /> + +</shape>
\ No newline at end of file diff --git a/app/src/main/res/drawable-xxxhdpi/background.png b/app/src/main/res/drawable-xxxhdpi/background.png Binary files differdeleted file mode 100644 index 90856f4c8..000000000 --- a/app/src/main/res/drawable-xxxhdpi/background.png +++ /dev/null diff --git a/app/src/main/res/drawable/bottom_sheet_rounded.xml b/app/src/main/res/drawable/bottom_sheet_rounded.xml index ba266ed32..cef4c2314 100644 --- a/app/src/main/res/drawable/bottom_sheet_rounded.xml +++ b/app/src/main/res/drawable/bottom_sheet_rounded.xml @@ -1,9 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> - <solid android:color="?attr/colorSurface" /> + <solid android:color="@color/primary" /> <corners android:topLeftRadius="16dp" android:topRightRadius="16dp" /> - </shape>
\ No newline at end of file diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml new file mode 100644 index 000000000..61e9c4157 --- /dev/null +++ b/app/src/main/res/values-v21/styles.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="AppBottomSheetDialogTheme" parent="Theme.MaterialComponents.DayNight.BottomSheetDialog"> + <item name="bottomSheetStyle">@style/AppModalStyle</item> + <item name="android:windowIsFloating">false</item> + <item name="android:navigationBarColor">@color/primary</item> + <item name="android:statusBarColor">@android:color/transparent</item> + </style> +</resources>
\ No newline at end of file |