Browse Source

optimize status dialog layout, add status active visual

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 years ago
parent
commit
8369e4c413

+ 44 - 19
src/main/java/com/nextcloud/ui/SetStatusDialogFragment.kt

@@ -24,18 +24,18 @@ import android.accounts.Account
 import android.annotation.SuppressLint
 import android.app.Dialog
 import android.content.Context
+import android.graphics.Color
 import android.os.Bundle
-import android.util.Log
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.view.inputmethod.InputMethodManager
 import androidx.annotation.VisibleForTesting
+import androidx.appcompat.app.AlertDialog
 import androidx.emoji.bundled.BundledEmojiCompatConfig
 import androidx.emoji.text.EmojiCompat
 import androidx.fragment.app.DialogFragment
 import androidx.recyclerview.widget.LinearLayoutManager
-import com.google.android.material.dialog.MaterialAlertDialogBuilder
 import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
 import com.nextcloud.client.account.User
@@ -57,6 +57,7 @@ import com.owncloud.android.lib.resources.users.StatusType
 import com.owncloud.android.ui.activity.BaseActivity
 import com.owncloud.android.ui.adapter.PredefinedStatusClickListener
 import com.owncloud.android.ui.adapter.PredefinedStatusListAdapter
+import com.owncloud.android.utils.ThemeUtils
 import com.vanniktech.emoji.EmojiManager
 import com.vanniktech.emoji.EmojiPopup
 import com.vanniktech.emoji.googlecompat.GoogleCompatEmojiProvider
@@ -115,15 +116,7 @@ class SetStatusDialogFragment : DialogFragment(),
     override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
         binding = DialogSetStatusBinding.inflate(LayoutInflater.from(context))
 
-        binding.clearStatus.setOnClickListener { /* ... */ }
-        binding.setStatus.setOnClickListener { /* ... */ }
-
-        binding.onlineStatus.setOnClickListener { /* ... */ }
-        binding.awayStatus.setOnClickListener { /* ... */ }
-        binding.dndStatus.setOnClickListener { /* ... */ }
-        binding.invisibleStatus.setOnClickListener { /* ... */ }
-
-        return MaterialAlertDialogBuilder(requireContext())
+        return AlertDialog.Builder(requireContext())
             .setView(binding.root)
             .create()
     }
@@ -182,10 +175,40 @@ class SetStatusDialogFragment : DialogFragment(),
             SetStatusTask(
                 statusType,
                 accountManager.currentOwnCloudAccount?.savedAccount,
-                context)
+                context),
+            onResult = { visualizeStatus(statusType) }
         )
     }
 
+    private fun visualizeStatus(statusType: StatusType) {
+        when (statusType) {
+            StatusType.ONLINE -> {
+                clearTopStatus()
+                onlineStatus.strokeColor = ThemeUtils.primaryColor(context)
+            }
+            StatusType.AWAY -> {
+                clearTopStatus()
+                awayStatus.strokeColor = ThemeUtils.primaryColor(context)
+            }
+            StatusType.DND -> {
+                clearTopStatus()
+                dndStatus.strokeColor = ThemeUtils.primaryColor(context)
+            }
+            StatusType.INVISIBLE -> {
+                clearTopStatus()
+                invisibleStatus.strokeColor = ThemeUtils.primaryColor(context)
+            }
+            else -> clearTopStatus()
+        }
+    }
+
+    private fun clearTopStatus() {
+        onlineStatus.strokeColor = Color.TRANSPARENT
+        awayStatus.strokeColor = Color.TRANSPARENT
+        dndStatus.strokeColor = Color.TRANSPARENT
+        invisibleStatus.strokeColor = Color.TRANSPARENT
+    }
+
     private fun setStatusMessage() {
         if (selectedPredefinedMessageId != null) {
             asyncRunner.postQuickTask(
@@ -261,13 +284,15 @@ class SetStatusDialogFragment : DialogFragment(),
      */
     companion object {
         @JvmStatic
-        fun newInstance(user: User, status: Status?) =
-            SetStatusDialogFragment().apply {
-                arguments = Bundle().apply {
-                    putParcelable(ARG_CURRENT_USER_PARAM, user)
-                    putParcelable(ARG_CURRENT_STATUS_PARAM, status)
-                }
-            }
+        fun newInstance(user: User, status: Status?): SetStatusDialogFragment {
+            val args = Bundle()
+            args.putParcelable(ARG_CURRENT_USER_PARAM, user)
+            args.putParcelable(ARG_CURRENT_STATUS_PARAM, status)
+            val dialogFragment = SetStatusDialogFragment()
+            dialogFragment.arguments = args
+            dialogFragment.setStyle(STYLE_NORMAL, R.style.Theme_ownCloud_Dialog)
+            return dialogFragment
+        }
     }
 
     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

+ 91 - 81
src/main/res/layout/dialog_set_status.xml

@@ -22,8 +22,8 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:layout_margin="@dimen/standard_margin"
-    android:orientation="vertical">
+    android:orientation="vertical"
+    android:padding="@dimen/standard_padding">
 
     <TextView
         android:id="@+id/onlineStatusView"
@@ -56,17 +56,21 @@
             <com.google.android.material.card.MaterialCardView
                 android:id="@+id/onlineStatus"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/account_item_layout_height"
+                android:layout_height="@dimen/online_status_item_height"
+                android:layout_gravity="center_vertical"
                 android:layout_marginEnd="@dimen/standard_half_margin"
                 android:layout_weight="1"
                 android:orientation="horizontal"
                 app:cardBackgroundColor="@color/grey_200"
+                app:strokeWidth="2dp"
                 app:cardElevation="0dp">
 
                 <RelativeLayout
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:layout_margin="@dimen/standard_margin"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_vertical"
+                    android:layout_marginStart="@dimen/standard_margin"
+                    android:layout_marginEnd="@dimen/standard_margin"
                     android:orientation="horizontal"
                     tools:ignore="UnusedAttribute">
 
@@ -86,7 +90,6 @@
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_centerInParent="true"
-                        android:layout_marginEnd="@dimen/standard_margin"
                         android:layout_toEndOf="@id/online_icon"
                         android:orientation="vertical">
 
@@ -121,17 +124,21 @@
             <com.google.android.material.card.MaterialCardView
                 android:id="@+id/awayStatus"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/account_item_layout_height"
+                android:layout_height="@dimen/online_status_item_height"
+                android:layout_gravity="center_vertical"
                 android:layout_marginStart="@dimen/standard_half_margin"
                 android:layout_weight="1"
+                app:strokeWidth="2dp"
                 android:orientation="horizontal"
                 app:cardBackgroundColor="@color/grey_200"
                 app:cardElevation="0dp">
 
                 <RelativeLayout
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:layout_margin="@dimen/standard_margin"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_vertical"
+                    android:layout_marginStart="@dimen/standard_margin"
+                    android:layout_marginEnd="@dimen/standard_margin"
                     android:orientation="horizontal"
                     tools:ignore="UnusedAttribute">
 
@@ -151,7 +158,6 @@
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_centerInParent="true"
-                        android:layout_marginEnd="@dimen/standard_margin"
                         android:layout_toEndOf="@id/away_icon"
                         android:orientation="vertical">
 
@@ -195,17 +201,21 @@
             <com.google.android.material.card.MaterialCardView
                 android:id="@+id/dndStatus"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/account_item_layout_height"
+                android:layout_height="@dimen/online_status_item_height"
+                android:layout_gravity="center_vertical"
                 android:layout_marginEnd="@dimen/standard_half_margin"
                 android:layout_weight="1"
+                app:strokeWidth="2dp"
                 android:orientation="horizontal"
                 app:cardBackgroundColor="@color/grey_200"
                 app:cardElevation="0dp">
 
                 <RelativeLayout
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:layout_margin="@dimen/standard_margin"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_vertical"
+                    android:layout_marginStart="@dimen/standard_margin"
+                    android:layout_marginEnd="@dimen/standard_margin"
                     android:orientation="horizontal"
                     tools:ignore="UnusedAttribute">
 
@@ -237,16 +247,6 @@
                             android:text="@string/dnd"
                             android:textAppearance="?android:attr/textAppearanceListItem" />
 
-                        <TextView
-                            android:id="@+id/dnd_text"
-                            android:layout_width="match_parent"
-                            android:layout_height="wrap_content"
-                            android:ellipsize="end"
-                            android:gravity="top"
-                            android:maxLines="1"
-                            android:text="Mute notifications"
-                            android:textColor="?android:attr/textColorSecondary" />
-
                     </LinearLayout>
 
                 </RelativeLayout>
@@ -256,8 +256,10 @@
             <com.google.android.material.card.MaterialCardView
                 android:id="@+id/invisibleStatus"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/account_item_layout_height"
+                android:layout_height="@dimen/online_status_item_height"
+                android:layout_gravity="center_vertical"
                 android:layout_marginStart="@dimen/standard_half_margin"
+
                 android:layout_weight="1"
                 android:orientation="horizontal"
                 app:cardBackgroundColor="@color/grey_200"
@@ -265,8 +267,10 @@
 
                 <RelativeLayout
                     android:layout_width="match_parent"
-                    android:layout_height="match_parent"
-                    android:layout_margin="@dimen/standard_margin"
+                    android:layout_height="wrap_content"
+                    android:layout_gravity="center_vertical"
+                    android:layout_marginStart="@dimen/standard_margin"
+                    android:layout_marginEnd="@dimen/standard_margin"
                     android:orientation="horizontal"
                     tools:ignore="UnusedAttribute">
 
@@ -285,7 +289,6 @@
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
                         android:layout_centerInParent="true"
-                        android:layout_marginEnd="@dimen/standard_margin"
                         android:layout_toEndOf="@id/invisible_icon"
                         android:orientation="vertical">
 
@@ -299,16 +302,6 @@
                             android:text="@string/invisible"
                             android:textAppearance="?android:attr/textAppearanceListItem" />
 
-                        <TextView
-                            android:id="@+id/invisible_text"
-                            android:layout_width="match_parent"
-                            android:layout_height="wrap_content"
-                            android:ellipsize="end"
-                            android:gravity="top"
-                            android:maxLines="1"
-                            android:text="Appear offline"
-                            android:textColor="?android:attr/textColorSecondary" />
-
                     </LinearLayout>
 
                 </RelativeLayout>
@@ -329,57 +322,74 @@
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toBottomOf="@id/statusView" />
 
-    <TextView
-        android:id="@+id/statusMessage"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="@dimen/standard_half_margin"
-        android:text="@string/status_message"
-        android:textColor="@color/text_color"
-        android:textSize="@dimen/activity_list_item_title_header_text_size"
-        app:layout_constraintTop_toBottomOf="@+id/statusView" />
-
     <LinearLayout
+        android:id="@+id/fragment_container"
         android:layout_width="match_parent"
-        android:layout_height="48dp"
-        android:orientation="horizontal"
-        tools:layout_editor_absoluteX="201dp"
-        tools:layout_editor_absoluteY="141dp">
-
-        <com.vanniktech.emoji.EmojiEditText
-            android:id="@+id/emoji"
-            android:layout_width="48dp"
-            android:layout_height="match_parent"
-            android:textSize="25sp"
-            android:gravity="center"
-            android:cursorVisible="false"
-            app:maxEmojiCount="1"
-            android:background="@color/grey_200"
-            tools:text="☁️" />
-
-        <EditText
-            android:id="@+id/customStatusInput"
-            android:layout_width="0dp"
-            android:layout_height="match_parent"
-            android:layout_weight="1"
-            android:hint="@string/whats_your_status"
-            android:importantForAutofill="no"
-            android:inputType="textAutoCorrect" />
-    </LinearLayout>
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:orientation="vertical">
 
-    <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/predefinedStatusList"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        tools:itemCount="5"
-        tools:listitem="@layout/predefined_status">
+        <TextView
+            android:id="@+id/statusMessage"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="@dimen/standard_half_margin"
+            android:text="@string/status_message"
+            android:textColor="@color/text_color"
+            android:textSize="@dimen/activity_list_item_title_header_text_size"
+            app:layout_constraintTop_toBottomOf="@+id/statusView" />
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/activity_row_layout_height"
+            android:orientation="horizontal">
+
+            <com.google.android.material.card.MaterialCardView
+                android:id="@+id/emojiCard"
+                android:layout_width="@dimen/activity_row_layout_height"
+                android:layout_height="@dimen/activity_row_layout_height"
+                android:layout_gravity="center_vertical"
+                android:layout_marginEnd="@dimen/standard_half_margin"
+                android:orientation="horizontal"
+                app:cardBackgroundColor="@color/grey_200"
+                app:cardElevation="0dp">
+
+                <com.vanniktech.emoji.EmojiEditText
+                    android:id="@+id/emoji"
+                    android:layout_width="@dimen/activity_row_layout_height"
+                    android:layout_height="@dimen/activity_row_layout_height"
+                    android:background="@color/grey_200"
+                    android:cursorVisible="false"
+                    android:gravity="center"
+                    android:text="@string/default_emoji"
+                    android:textSize="25sp"
+                    app:maxEmojiCount="1" />
+
+            </com.google.android.material.card.MaterialCardView>
+
+            <EditText
+                android:id="@+id/customStatusInput"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                android:hint="@string/whats_your_status"
+                android:importantForAutofill="no"
+                android:inputType="textAutoCorrect" />
+        </LinearLayout>
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/predefinedStatusList"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            tools:itemCount="5"
+            tools:listitem="@layout/predefined_status" />
 
-    </androidx.recyclerview.widget.RecyclerView>
+    </LinearLayout>
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/standard_margin"
+        android:layout_marginTop="@dimen/standard_half_margin"
         android:orientation="horizontal">
 
         <TextView
@@ -399,7 +409,7 @@
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginTop="@dimen/standard_margin"
+        android:layout_marginTop="@dimen/standard_half_margin"
         android:orientation="horizontal">
 
         <com.google.android.material.button.MaterialButton

+ 1 - 0
src/main/res/values/dims.xml

@@ -138,4 +138,5 @@
     <dimen name="account_action_button_margin">12dp</dimen>
     <dimen name="account_action_button_height">50dp</dimen>
     <dimen name="account_action_button_vertical_margin">10dp</dimen>
+    <dimen name="online_status_item_height">52dp</dimen>
 </resources>

+ 1 - 0
src/main/res/values/strings.xml

@@ -951,6 +951,7 @@
     <string name="away">Away</string>
     <string name="invisible">Invisible</string>
     <string translatable="false" name="divider">—</string>
+    <string translatable="false" name="default_emoji">😃</string>
     <string name="dontClear">Don\'t clear</string>
     <string name="today">Today</string>
 </resources>