From 5b214ccfec07b9e8120119e1ce879187b26db753 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 12 Apr 2021 17:40:36 +0200 Subject: [PATCH] make adding users easier to discover Signed-off-by: Andy Scherzinger --- .../controllers/ConversationInfoController.kt | 58 +++--- ...terialPreferenceCategoryWithRightLink.java | 165 ------------------ app/src/main/res/drawable/ic_account_plus.xml | 30 ++++ .../res/layout/category_with_right_action.xml | 56 ------ .../layout/controller_conversation_info.xml | 18 +- app/src/main/res/values/strings.xml | 1 + 6 files changed, 74 insertions(+), 254 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/utils/ui/MaterialPreferenceCategoryWithRightLink.java create mode 100644 app/src/main/res/drawable/ic_account_plus.xml delete mode 100644 app/src/main/res/layout/category_with_right_action.xml diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index b0033aa46..d2cb185ad 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/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() - - 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() + + 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)) { diff --git a/app/src/main/java/com/nextcloud/talk/utils/ui/MaterialPreferenceCategoryWithRightLink.java b/app/src/main/java/com/nextcloud/talk/utils/ui/MaterialPreferenceCategoryWithRightLink.java deleted file mode 100644 index 4e4f4996b..000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/ui/MaterialPreferenceCategoryWithRightLink.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic - * - * 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 . - */ - -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); - } - } - -} diff --git a/app/src/main/res/drawable/ic_account_plus.xml b/app/src/main/res/drawable/ic_account_plus.xml new file mode 100644 index 000000000..101291a7f --- /dev/null +++ b/app/src/main/res/drawable/ic_account_plus.xml @@ -0,0 +1,30 @@ + + + + diff --git a/app/src/main/res/layout/category_with_right_action.xml b/app/src/main/res/layout/category_with_right_action.xml deleted file mode 100644 index 39072a674..000000000 --- a/app/src/main/res/layout/category_with_right_action.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/controller_conversation_info.xml b/app/src/main/res/layout/controller_conversation_info.xml index 1eef0bdbc..a8a89b44c 100644 --- a/app/src/main/res/layout/controller_conversation_info.xml +++ b/app/src/main/res/layout/controller_conversation_info.xml @@ -103,7 +103,7 @@ - + tools:ignore="UnknownIdInLayout" + tools:visibility="visible"> + + - + + tools:visibility="gone" /> %s characters limit has been hit Groups Participants + Add participants Owner Moderator