Browse Source

Remove GradientDrawable to make corner radius

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 year ago
parent
commit
199150660e

+ 4 - 17
app/src/main/java/com/nextcloud/ui/fileactions/FileActionsBottomSheet.kt

@@ -45,6 +45,7 @@ import androidx.lifecycle.ViewModelProvider
 import com.google.android.material.bottomsheet.BottomSheetBehavior
 import com.google.android.material.bottomsheet.BottomSheetBehavior
 import com.google.android.material.bottomsheet.BottomSheetDialog
 import com.google.android.material.bottomsheet.BottomSheetDialog
 import com.google.android.material.bottomsheet.BottomSheetDialogFragment
 import com.google.android.material.bottomsheet.BottomSheetDialogFragment
+import com.google.android.material.shape.CornerFamily
 import com.nextcloud.android.common.ui.theme.utils.ColorRole
 import com.nextcloud.android.common.ui.theme.utils.ColorRole
 import com.nextcloud.client.account.CurrentAccountProvider
 import com.nextcloud.client.account.CurrentAccountProvider
 import com.nextcloud.client.di.Injectable
 import com.nextcloud.client.di.Injectable
@@ -111,25 +112,11 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
         bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
         bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
         bottomSheetDialog.behavior.skipCollapsed = true
         bottomSheetDialog.behavior.skipCollapsed = true
 
 
-        applyTintedRoundedBackground()
+        viewThemeUtils.platform.colorViewBackground(binding.bottomSheet, ColorRole.SURFACE_VARIANT)
 
 
         return binding.root
         return binding.root
     }
     }
 
 
-    // TODO It will be moved android-common library
-    private fun applyTintedRoundedBackground() {
-        val shape = GradientDrawable()
-
-        val cornerRadius = convertDpToPixel(32f, requireContext()).toFloat()
-        shape.cornerRadii = floatArrayOf(
-            cornerRadius, cornerRadius, cornerRadius, cornerRadius,
-            0f, 0f, 0f, 0f)
-
-        viewThemeUtils.platform.tintDrawable(requireContext(), shape, ColorRole.SURFACE_VARIANT)
-
-        binding.root.background = shape
-    }
-
     private fun handleState(
     private fun handleState(
         state: FileActionsViewModel.UiState
         state: FileActionsViewModel.UiState
     ) {
     ) {
@@ -215,11 +202,11 @@ class FileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
     private fun toggleLoadingOrContent(state: FileActionsViewModel.UiState) {
     private fun toggleLoadingOrContent(state: FileActionsViewModel.UiState) {
         if (state is FileActionsViewModel.UiState.Loading) {
         if (state is FileActionsViewModel.UiState.Loading) {
             binding.bottomSheetLoading.isVisible = true
             binding.bottomSheetLoading.isVisible = true
-            binding.bottomSheetContent.isVisible = false
+            binding.bottomSheetHeader.isVisible = false
             viewThemeUtils.platform.colorCircularProgressBar(binding.bottomSheetLoading, ColorRole.PRIMARY)
             viewThemeUtils.platform.colorCircularProgressBar(binding.bottomSheetLoading, ColorRole.PRIMARY)
         } else {
         } else {
             binding.bottomSheetLoading.isVisible = false
             binding.bottomSheetLoading.isVisible = false
-            binding.bottomSheetContent.isVisible = true
+            binding.bottomSheetHeader.isVisible = true
         }
         }
     }
     }
 
 

+ 57 - 49
app/src/main/res/layout/file_actions_bottom_sheet.xml

@@ -19,67 +19,75 @@
   ~ License along with this program.  If not, see <http://www.gnu.org/licenses/>.
   ~ License along with this program.  If not, see <http://www.gnu.org/licenses/>.
   ~
   ~
   -->
   -->
-<LinearLayout
-    android:id="@+id/bottom_sheet"
+<androidx.coordinatorlayout.widget.CoordinatorLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
+    android:background="@android:color/transparent"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
+    android:layout_height="match_parent">
 
 
-    <com.google.android.material.bottomsheet.BottomSheetDragHandleView
+    <FrameLayout
+        style="@style/Widget.Material3.BottomSheet"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
+        android:layout_height="match_parent"
+        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
 
 
-    <com.google.android.material.progressindicator.CircularProgressIndicator
-        android:id="@+id/bottom_sheet_loading"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"
-        android:indeterminate="true"
-        android:layout_marginBottom="@dimen/standard_margin"
-        tools:visibility="gone" />
+        <LinearLayout
+            android:id="@+id/bottom_sheet"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical">
 
 
-    <LinearLayout
-        android:id="@+id/bottom_sheet_content"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        android:layout_marginBottom="@dimen/standard_margin"
-        android:gravity="center"
-        android:visibility="visible">
+            <com.google.android.material.bottomsheet.BottomSheetDragHandleView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
 
 
-        <include
-            android:id="@+id/thumbnail_layout"
-            layout="@layout/file_thumbnail"
-            android:layout_width="wrap_content"
-            android:layout_marginStart="12dp"
-            android:layout_height="wrap_content" />
+            <com.google.android.material.progressindicator.CircularProgressIndicator
+                android:id="@+id/bottom_sheet_loading"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:indeterminate="true"
+                android:layout_marginBottom="@dimen/standard_margin"
+                tools:visibility="gone" />
 
 
-        <TextView
-            android:id="@+id/title"
-            android:layout_marginStart="24dp"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:ellipsize="middle"
-            android:lines="1"
-            android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall"
-            tools:text="Test file name which is very very very very very long.pdf" />
+            <LinearLayout
+                android:id="@+id/bottom_sheet_header"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:layout_marginBottom="@dimen/standard_margin"
+                android:gravity="center"
+                android:visibility="visible">
 
 
-    </LinearLayout>
+                <include
+                    android:id="@+id/thumbnail_layout"
+                    layout="@layout/file_thumbnail"
+                    android:layout_width="wrap_content"
+                    android:layout_marginStart="12dp"
+                    android:layout_height="wrap_content" />
 
 
-    <androidx.core.widget.NestedScrollView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+                <TextView
+                    android:id="@+id/title"
+                    android:layout_marginStart="24dp"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:ellipsize="middle"
+                    android:lines="1"
+                    android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall"
+                    tools:text="Test file name which is very very very very very long.pdf" />
 
 
-        <LinearLayout
-            android:id="@+id/file_actions_list"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical" />
+            </LinearLayout>
+
+            <LinearLayout
+                android:id="@+id/file_actions_list"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical" />
+
+        </LinearLayout>
 
 
-    </androidx.core.widget.NestedScrollView>
+    </FrameLayout>
 
 
-</LinearLayout>
+</androidx.coordinatorlayout.widget.CoordinatorLayout>