Эх сурвалжийг харах

make adding users easier to discover

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 жил өмнө
parent
commit
5b214ccfec

+ 30 - 28
app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt

@@ -30,7 +30,6 @@ import android.view.MenuItem
 import android.view.View
 import android.view.ViewGroup
 import android.widget.ProgressBar
-import android.widget.TextView
 import androidx.appcompat.widget.SwitchCompat
 import androidx.emoji.widget.EmojiTextView
 import androidx.recyclerview.widget.RecyclerView
@@ -70,10 +69,13 @@ import com.nextcloud.talk.utils.DateUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.bundle.BundleKeys
 import com.nextcloud.talk.utils.preferences.preferencestorage.DatabaseStorageModule
-import com.nextcloud.talk.utils.ui.MaterialPreferenceCategoryWithRightLink
 import com.yarolegovich.lovelydialog.LovelySaveStateHandler
 import com.yarolegovich.lovelydialog.LovelyStandardDialog
-import com.yarolegovich.mp.*
+import com.yarolegovich.mp.MaterialChoicePreference
+import com.yarolegovich.mp.MaterialPreferenceCategory
+import com.yarolegovich.mp.MaterialPreferenceScreen
+import com.yarolegovich.mp.MaterialStandardPreference
+import com.yarolegovich.mp.MaterialSwitchPreference
 import eu.davidea.flexibleadapter.FlexibleAdapter
 import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
 import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
@@ -110,7 +112,9 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
     @BindView(R.id.display_name_text)
     lateinit var conversationDisplayName: EmojiTextView
     @BindView(R.id.participants_list_category)
-    lateinit var participantsListCategory: MaterialPreferenceCategoryWithRightLink
+    lateinit var participantsListCategory: MaterialPreferenceCategory
+    @BindView(R.id.addParticipantsAction)
+    lateinit var addParticipantsAction: MaterialStandardPreference;
     @BindView(R.id.recycler_view)
     lateinit var recyclerView: RecyclerView
     @BindView(R.id.deleteConversationAction)
@@ -121,9 +125,6 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
     lateinit var ownOptionsCategory: MaterialPreferenceCategory
     @BindView(R.id.muteCalls)
     lateinit var muteCalls: MaterialSwitchPreference
-    @BindView(R.id.mpc_action)
-    lateinit var actionTextView: TextView;
-
     @set:Inject
     lateinit var ncApi: NcApi
     @set:Inject
@@ -200,7 +201,7 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
             saveStateHandler = LovelySaveStateHandler()
         }
 
-        actionTextView.visibility = View.GONE
+        addParticipantsAction.visibility = View.GONE
     }
 
     private fun setupWebinaryView() {
@@ -350,24 +351,6 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
             recyclerView.adapter = adapter
 
             adapter!!.addListener(this)
-            actionTextView.setOnClickListener {
-                val bundle = Bundle()
-                val existingParticipantsId = arrayListOf<String>()
-
-                recyclerViewItems.forEach {
-                    val userItem = it as UserItem
-                    existingParticipantsId.add(userItem.model.userId)
-                }
-
-                bundle.putBoolean(BundleKeys.KEY_ADD_PARTICIPANTS, true);
-                bundle.putStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS, existingParticipantsId)
-                bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
-
-                getRouter().pushController((RouterTransaction.with(ContactsController(bundle))
-                        .pushChangeHandler(HorizontalChangeHandler())
-                        .popChangeHandler(HorizontalChangeHandler())));
-
-            }
         }
     }
 
@@ -430,6 +413,25 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
 
     }
 
+    @OnClick(R.id.addParticipantsAction)
+    internal fun addParticipants() {
+        val bundle = Bundle()
+        val existingParticipantsId = arrayListOf<String>()
+
+        recyclerViewItems.forEach {
+            val userItem = it as UserItem
+            existingParticipantsId.add(userItem.model.userId)
+        }
+
+        bundle.putBoolean(BundleKeys.KEY_ADD_PARTICIPANTS, true);
+        bundle.putStringArrayList(BundleKeys.KEY_EXISTING_PARTICIPANTS, existingParticipantsId)
+        bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token)
+
+        getRouter().pushController((RouterTransaction.with(ContactsController(bundle))
+                .pushChangeHandler(HorizontalChangeHandler())
+                .popChangeHandler(HorizontalChangeHandler())))
+    }
+
     @OnClick(R.id.leaveConversationAction)
     internal fun leaveConversation() {
         workerData?.let {
@@ -475,9 +477,9 @@ class ConversationInfoController(args: Bundle) : BaseController(args), FlexibleA
                         val conversationCopy = conversation
 
                         if (conversationCopy!!.canModerate(conversationUser)) {
-                            actionTextView.visibility = View.VISIBLE
+                            addParticipantsAction.visibility = View.VISIBLE
                         } else {
-                            actionTextView.visibility = View.GONE
+                            addParticipantsAction.visibility = View.GONE
                         }
 
                         if (isAttached && (!isBeingDestroyed || !isDestroyed)) {

+ 0 - 165
app/src/main/java/com/nextcloud/talk/utils/ui/MaterialPreferenceCategoryWithRightLink.java

@@ -1,165 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.nextcloud.talk.utils.ui;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.text.TextUtils;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.nextcloud.talk.R;
-import com.yarolegovich.mp.util.Utils;
-
-import androidx.annotation.ColorInt;
-import androidx.annotation.ColorRes;
-import androidx.cardview.widget.CardView;
-import androidx.core.content.ContextCompat;
-
-public class MaterialPreferenceCategoryWithRightLink extends CardView {
-
-    private ViewGroup container;
-    private TextView title;
-    private TextView action;
-
-    public MaterialPreferenceCategoryWithRightLink(Context context) {
-        super(context);
-        init(null);
-    }
-
-    public MaterialPreferenceCategoryWithRightLink(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        init(attrs);
-    }
-
-    public MaterialPreferenceCategoryWithRightLink(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-        init(attrs);
-    }
-
-    private void init(AttributeSet attrs) {
-        int titleColor = -1;
-        String titleText = "";
-        String actionText = "";
-        if (attrs != null) {
-            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.MaterialPreferenceCategory);
-            try {
-                if (ta.hasValue(R.styleable.MaterialPreferenceCategory_mpc_title)) {
-                    titleText = ta.getString(R.styleable.MaterialPreferenceCategory_mpc_title);
-                }
-
-                if (ta.hasValue(R.styleable.MaterialPreferenceCategory_mpc_action)) {
-                    actionText = ta.getString(R.styleable.MaterialPreferenceCategory_mpc_action);
-                }
-
-                titleColor = ta.getColor(R.styleable.MaterialPreferenceCategory_mpc_title_color, -1);
-            } finally {
-                ta.recycle();
-            }
-        }
-
-        inflate(getContext(), R.layout.category_with_right_action, this);
-
-        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
-                ViewGroup.LayoutParams.MATCH_PARENT,
-                ViewGroup.LayoutParams.WRAP_CONTENT);
-        params.setMargins(0, 0, 0, Utils.dpToPixels(getContext(), 4));
-
-        setUseCompatPadding(true);
-
-        setRadius(0);
-
-        container = (ViewGroup) findViewById(R.id.mpc_container);
-        title = (TextView) findViewById(R.id.mpc_title);
-        action = findViewById(R.id.mpc_action);
-
-        if (!TextUtils.isEmpty(titleText)) {
-            title.setVisibility(View.VISIBLE);
-            title.setText(titleText);
-        }
-
-        if (!TextUtils.isEmpty(actionText)) {
-            action.setVisibility(View.VISIBLE);
-            action.setText(actionText);
-        }
-
-        if (titleColor != -1) {
-            title.setTextColor(titleColor);
-        }
-    }
-
-    public void setAction(String actionText) {
-        action.setText(actionText);
-    }
-
-    public void setTitle(String titleText) {
-        title.setVisibility(View.VISIBLE);
-        title.setText(titleText);
-    }
-
-    public void setTitleColor(@ColorInt int color) {
-        title.setTextColor(color);
-    }
-
-    public void setTitleColorRes(@ColorRes int colorRes) {
-        title.setTextColor(ContextCompat.getColor(getContext(), colorRes));
-    }
-
-    @Override
-    public void addView(View child) {
-        if (container != null) {
-            container.addView(child);
-        } else {
-            super.addView(child);
-        }
-    }
-
-    @Override
-    public void addView(View child, int index) {
-        if (container != null) {
-            container.addView(child, index);
-        } else {
-            super.addView(child, index);
-        }
-    }
-
-    @Override
-    public void addView(View child, ViewGroup.LayoutParams params) {
-        if (container != null) {
-            container.addView(child, params);
-        } else {
-            super.addView(child, params);
-        }
-    }
-
-    @Override
-    public void addView(View child, int index, ViewGroup.LayoutParams params) {
-        if (container != null) {
-            container.addView(child, index, params);
-        } else {
-            super.addView(child, index, params);
-        }
-    }
-
-}

+ 30 - 0
app/src/main/res/drawable/ic_account_plus.xml

@@ -0,0 +1,30 @@
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2020 Nextcloud.
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+  License as published by the Free Software Foundation; either
+  version 3 of the License, or any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+
+  You should have received a copy of the GNU Affero General Public
+  License along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+  Icon provided by Android Material Library in Apache License 2.0
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:tint="#666666"
+    android:viewportWidth="24.0"
+    android:viewportHeight="24.0">
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z" />
+</vector>

+ 0 - 56
app/src/main/res/layout/category_with_right_action.xml

@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-  ~ Nextcloud Talk application
-  ~
-  ~ @author Mario Danic
-  ~ Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
-  ~
-  ~ This program is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ at your option) any later version.
-  ~
-  ~ This program is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
-  -->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools">
-
-    <LinearLayout
-        android:id="@+id/mpc_container"
-        style="@style/PreferenceContainer"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical">
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <TextView
-                android:id="@+id/mpc_title"
-                style="@style/PreferenceHeader"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:visibility="gone"
-                tools:text="Title"/>
-
-            <TextView
-                android:id="@+id/mpc_action"
-                style="@style/PreferenceHeader"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:visibility="gone"
-                tools:text="Add" />
-
-        </RelativeLayout>
-
-    </LinearLayout>
-
-</merge>

+ 13 - 5
app/src/main/res/layout/controller_conversation_info.xml

@@ -103,7 +103,7 @@
 
             </com.yarolegovich.mp.MaterialPreferenceCategory>
 
-            <com.nextcloud.talk.utils.ui.MaterialPreferenceCategoryWithRightLink
+            <com.yarolegovich.mp.MaterialPreferenceCategory
                 android:id="@+id/participants_list_category"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
@@ -111,9 +111,17 @@
                 android:visibility="gone"
                 apc:cardBackgroundColor="@color/bg_default"
                 apc:cardElevation="0dp"
-                apc:mpc_action="@string/nc_add"
                 apc:mpc_title="@string/nc_participants"
-                tools:ignore="UnknownIdInLayout">
+                tools:ignore="UnknownIdInLayout"
+                tools:visibility="visible">
+
+                <com.yarolegovich.mp.MaterialStandardPreference
+                    android:id="@+id/addParticipantsAction"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    apc:mp_icon="@drawable/ic_account_plus"
+                    apc:mp_icon_tint="@color/grey_600"
+                    apc:mp_title="@string/nc_participants_add" />
 
                 <androidx.recyclerview.widget.RecyclerView
                     android:id="@+id/recycler_view"
@@ -121,7 +129,7 @@
                     android:layout_height="wrap_content"
                     tools:listitem="@layout/rv_item_contact" />
 
-            </com.nextcloud.talk.utils.ui.MaterialPreferenceCategoryWithRightLink>
+            </com.yarolegovich.mp.MaterialPreferenceCategory>
 
             <com.yarolegovich.mp.MaterialPreferenceCategory
                 android:id="@+id/ownOptions"
@@ -157,7 +165,7 @@
                 android:layout_height="wrap_content"
                 android:layout_below="@id/otherRoomOptions"
                 android:visibility="gone"
-                tools:visibility="visible" />
+                tools:visibility="gone" />
 
             <include
                 layout="@layout/webinar_info_item"

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

@@ -289,6 +289,7 @@
     <string name="nc_limit_hit">%s characters limit has been hit</string>
     <string name="nc_groups">Groups</string>
     <string name="nc_participants">Participants</string>
+    <string name="nc_participants_add">Add participants</string>
 
     <string name="nc_owner">Owner</string>
     <string name="nc_moderator">Moderator</string>