diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-10-29 22:51:29 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-10-29 22:51:29 +0300 |
commit | 3c7d4f6cbfacc1399a39fad8611e1c4eb819987f (patch) | |
tree | 8835a664676481a1bc2a3d326411505b7825dbe3 /app/src | |
parent | 1417c6b4ee1e52ee05333d4b783879be11524877 (diff) |
#289 📎 Add more sources to upload attachments
Design fine tuning
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src')
4 files changed, 82 insertions, 14 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 f8ff805a6..cb7660130 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,15 +1,23 @@ 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 androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; import androidx.fragment.app.DialogFragment; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; @@ -18,9 +26,11 @@ import java.util.stream.Stream; import it.niedermann.nextcloud.deck.databinding.DialogAttachmentPickerBinding; import it.niedermann.nextcloud.deck.ui.branding.Branded; +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; @@ -44,25 +54,31 @@ public class CardAttachmentPicker extends BottomSheetDialogFragment implements B } } + @NonNull @Override - public void onStart() { - super.onStart(); + public Dialog onCreateDialog(Bundle savedInstanceState) { + final Dialog dialog = super.onCreateDialog(savedInstanceState); - @Nullable Context context = getContext(); - if (context != null && isBrandingEnabled(context)) { - applyBrand(readBrandMainColor(context)); + if (SDK_INT >= Build.VERSION_CODES.O_MR1) { + if (!isDarkTheme(requireContext())) { + setWhiteNavigationBar(dialog); + } } - } - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + return dialog; } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = DialogAttachmentPickerBinding.inflate(inflater, container, false); + + @Nullable Context context = getContext(); + if (context != null && isBrandingEnabled(context)) { + applyBrand(readBrandMainColor(context)); + } + return binding.getRoot(); } @@ -99,7 +115,38 @@ public class CardAttachmentPicker extends BottomSheetDialogFragment implements B binding.pickCameraIamge, binding.pickContactIamge, binding.pickFileIamge - ).forEach(image -> image.setBackgroundTintList(ColorStateList.valueOf(mainColor))); + ).forEach(image -> { + image.setBackgroundTintList(ColorStateList.valueOf(mainColor)); + image.setImageTintList(ColorStateList.valueOf( + DeckColorUtil.contrastRatioIsSufficient(mainColor, Color.WHITE) + ? Color.WHITE + : Color.BLACK + )); + }); } } + + @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/bottom_sheet_rounded.xml b/app/src/main/res/drawable/bottom_sheet_rounded.xml new file mode 100644 index 000000000..ba266ed32 --- /dev/null +++ b/app/src/main/res/drawable/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/layout/dialog_attachment_picker.xml b/app/src/main/res/layout/dialog_attachment_picker.xml index 120fd5b9e..150a5a3a5 100644 --- a/app/src/main/res/layout/dialog_attachment_picker.xml +++ b/app/src/main/res/layout/dialog_attachment_picker.xml @@ -5,7 +5,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:padding="@dimen/spacer_2x" + android:paddingStart="@dimen/spacer_2x" + android:paddingEnd="@dimen/spacer_2x" + android:paddingTop="@dimen/spacer_3x" + android:paddingBottom="@dimen/spacer_3x" app:behavior_hideable="false" app:behavior_peekHeight="90dp" app:justifyContent="space_around" @@ -27,7 +30,7 @@ android:background="@drawable/circle_grey600_36dp" android:contentDescription="@null" android:padding="12dp" - app:backgroundTint="@color/grey600" + app:backgroundTint="@color/defaultBrand" app:srcCompat="@drawable/ic_baseline_photo_camera_24" app:tint="@color/primary" /> @@ -55,7 +58,7 @@ android:background="@drawable/circle_grey600_36dp" android:contentDescription="@null" android:padding="12dp" - app:backgroundTint="@color/grey600" + app:backgroundTint="@color/defaultBrand" app:srcCompat="@drawable/ic_person_grey600_24dp" app:tint="@color/primary" /> @@ -83,7 +86,7 @@ android:background="@drawable/circle_grey600_36dp" android:contentDescription="@null" android:padding="12dp" - app:backgroundTint="@color/grey600" + app:backgroundTint="@color/defaultBrand" app:layout_flexGrow="1" app:srcCompat="@drawable/ic_attach_file_grey600_24dp" app:tint="@color/primary" /> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index c253ae461..874d2e751 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -7,6 +7,15 @@ <item name="toolbarStyle">@style/toolbarStyle</item> <item name="android:windowBackground">?attr/colorPrimary</item> <item name="textAppearanceHeadline1">@style/Deck.TextAppearance.Headline1</item> + <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item> + </style> + + <style name="AppBottomSheetDialogTheme" parent="Theme.MaterialComponents.DayNight.BottomSheetDialog"> + <item name="bottomSheetStyle">@style/AppModalStyle</item> + </style> + + <style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal"> + <item name="android:background">@drawable/bottom_sheet_rounded</item> </style> <style name="toolbarStyle" parent="@style/Widget.AppCompat.Toolbar"> |