Explorar o código

Use Material Button

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk hai 1 ano
pai
achega
1d87082913

+ 14 - 28
app/src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.kt

@@ -9,11 +9,11 @@ import android.view.View
 import android.view.ViewGroup
 import android.widget.ImageView
 import android.widget.LinearLayout
-import android.widget.TextView
 import androidx.recyclerview.widget.GridLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import com.google.android.material.bottomsheet.BottomSheetBehavior
 import com.google.android.material.bottomsheet.BottomSheetDialogFragment
+import com.google.android.material.button.MaterialButton
 import com.google.android.material.snackbar.Snackbar
 import com.nextcloud.client.di.Injectable
 import com.nextcloud.client.utils.IntentUtil.createSendIntent
@@ -86,19 +86,13 @@ class SendShareDialog : BottomSheetDialogFragment(), Injectable {
         val sendShareButtons = view.findViewById<LinearLayout>(R.id.send_share_buttons)
         val divider = view.findViewById<View>(R.id.divider)
 
-        // Share with people
-        val sharePeopleText = view.findViewById<TextView>(R.id.share_people_button)
-        sharePeopleText.setOnClickListener { shareFile(file) }
-        val sharePeopleImageView = view.findViewById<ImageView>(R.id.share_people_icon)
-        themeShareButtonImage(sharePeopleImageView)
-        sharePeopleImageView.setOnClickListener { shareFile(file) }
+        val btnShare = view.findViewById<MaterialButton>(R.id.btn_share)
+        viewThemeUtils?.material?.colorMaterialButtonPrimaryFilled(btnShare)
+        btnShare.setOnClickListener { shareFile(file) }
 
-        // Share via link button
-        val shareLinkText = view.findViewById<TextView>(R.id.share_link_button)
-        shareLinkText.setOnClickListener { shareByLink() }
-        val shareLinkImageView = view.findViewById<ImageView>(R.id.share_link_icon)
-        themeShareButtonImage(shareLinkImageView)
-        shareLinkImageView.setOnClickListener { shareByLink() }
+        val btnShareViaLink = view.findViewById<MaterialButton>(R.id.btn_link)
+        viewThemeUtils?.material?.colorMaterialButtonPrimaryFilled(btnShareViaLink)
+        btnShareViaLink.setOnClickListener { shareByLink() }
 
         if (hideNcSharingOptions) {
             sendShareButtons.visibility = View.GONE
@@ -106,29 +100,21 @@ class SendShareDialog : BottomSheetDialogFragment(), Injectable {
         } else if (file!!.isSharedWithMe && !file!!.canReshare()) {
             showResharingNotAllowedSnackbar()
             if (file!!.isFolder) {
-                shareLinkText.visibility = View.GONE
-                shareLinkImageView.visibility = View.GONE
-                sharePeopleText.visibility = View.GONE
-                sharePeopleImageView.visibility = View.GONE
+                btnShare.visibility = View.GONE
+                btnShareViaLink.visibility = View.GONE
                 dialog!!.hide()
             } else {
-                shareLinkText.isEnabled = false
-                shareLinkText.alpha = 0.3f
-                shareLinkImageView.isEnabled = false
-                shareLinkImageView.alpha = 0.3f
-                sharePeopleText.isEnabled = false
-                sharePeopleText.alpha = 0.3f
-                sharePeopleImageView.isEnabled = false
-                sharePeopleImageView.alpha = 0.3f
+                btnShareViaLink.isEnabled = false
+                btnShareViaLink.alpha = 0.3f
+
+                btnShare.isEnabled = false
+                btnShare.alpha = 0.3f
             }
         }
 
         // populate send apps
         val sendIntent = createSendIntent(requireContext(), file!!)
         val sendButtonDataList = setupSendButtonData(sendIntent)
-        if ("off".equals(requireContext().getString(R.string.send_files_to_other_apps), ignoreCase = true)) {
-            sharePeopleText.visibility = View.GONE
-        }
         val clickListener = setupSendButtonClickListener(sendIntent)
         val sendButtonsView = view.findViewById<RecyclerView>(R.id.send_button_recycler_view)
         sendButtonsView.layoutManager = GridLayoutManager(activity, 4)

+ 46 - 77
app/src/main/res/layout/send_share_fragment.xml

@@ -23,98 +23,67 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:background="@color/bg_default">
 
-    <RelativeLayout
+    <FrameLayout
+        android:id="@+id/standard_bottom_sheet"
+        style="@style/Widget.Material3.BottomSheet"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
 
         <LinearLayout
-            android:id="@+id/send_share_buttons"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_marginEnd="@dimen/send_share_fragment_layout_margin"
-            android:layout_marginLeft="@dimen/send_share_fragment_layout_margin"
-            android:layout_marginRight="@dimen/send_share_fragment_layout_margin"
-            android:layout_marginStart="@dimen/send_share_fragment_layout_margin"
-            android:orientation="horizontal"
-            android:baselineAligned="false"
-            android:padding="@dimen/send_share_fragment_layout_padding">
+            android:orientation="vertical">
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:orientation="vertical"
-            tools:ignore="UseCompoundDrawables">
+            <LinearLayout
+                android:id="@+id/send_share_buttons"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:gravity="center"
+                android:orientation="horizontal"
+                android:padding="@dimen/send_share_fragment_layout_padding">
 
-            <ImageView
-                android:id="@+id/share_people_icon"
-                android:layout_width="@dimen/share_icon_size"
-                android:layout_height="@dimen/share_icon_size"
-                android:layout_gravity="center_horizontal"
-                android:contentDescription="@string/share"
-                android:src="@drawable/shared_via_users"
-                android:paddingTop="@dimen/share_people_icon_layout_padding"
-                android:paddingEnd="@dimen/share_people_icon_layout_padding"
-                android:paddingBottom="@dimen/share_people_icon_layout_padding"
-                android:paddingStart="@dimen/standard_half_padding"
-                android:background="@drawable/round_bgnd"/>
+                <com.google.android.material.button.MaterialButton
+                    android:id="@+id/btn_share"
+                    style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/share"
+                    app:iconTint="@color/white"
+                    android:textColor="@color/white"
+                    app:icon="@drawable/shared_via_users" />
 
-            <TextView
-                android:id="@+id/share_people_button"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:drawable="@drawable/ic_share"
-                android:text="@string/share"
-                android:paddingTop="@dimen/standard_half_padding"
-                android:textColor="@color/text_color"/>
-        </LinearLayout>
+                <com.google.android.material.button.MaterialButton
+                    android:id="@+id/btn_link"
+                    style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/link"
+                    app:iconTint="@color/white"
+                    android:textColor="@color/white"
+                    app:icon="@drawable/shared_via_link" />
 
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:orientation="vertical"
-            tools:ignore="UseCompoundDrawables">
+            </LinearLayout>
 
-            <ImageView
-                android:id="@+id/share_link_icon"
-                android:layout_width="@dimen/share_icon_size"
-                android:layout_height="@dimen/share_icon_size"
-                android:layout_gravity="center_horizontal"
-                android:contentDescription="@string/link"
-                android:src="@drawable/shared_via_link"
-                android:padding="12dp"
-                android:background="@drawable/round_bgnd"/>
+            <View
+                android:id="@+id/divider"
+                android:layout_width="match_parent"
+                android:layout_height="1dp"
+                android:alpha="0.3"
+                android:background="@color/background_color_inverse"/>
 
-            <TextView
-                android:id="@+id/share_link_button"
-                android:layout_width="wrap_content"
+            <androidx.recyclerview.widget.RecyclerView
+                android:id="@+id/send_button_recycler_view"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_gravity="center_horizontal"
-                android:drawable="@drawable/ic_share"
-                android:text="@string/link"
-                android:paddingTop="@dimen/standard_half_padding"
-                android:textColor="@color/text_color"/>
+                tools:listitem="@layout/send_button" />
+
         </LinearLayout>
 
-    </LinearLayout>
+    </FrameLayout>
 
-    <View
-        android:id="@+id/divider"
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:layout_below="@id/send_share_buttons"
-        android:alpha="0.3"
-        android:background="@color/background_color_inverse"/>
-
-        <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/send_button_recycler_view"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_below="@id/divider"
-        tools:listitem="@layout/send_button" />
-    </RelativeLayout>
 </androidx.coordinatorlayout.widget.CoordinatorLayout>