mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Improve participants list
This commit is contained in:
parent
9cdce626e9
commit
4ddc68b774
@ -100,7 +100,11 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutRes() {
|
public int getLayoutRes() {
|
||||||
|
if (header != null) {
|
||||||
return R.layout.rv_item_contact;
|
return R.layout.rv_item_contact;
|
||||||
|
} else {
|
||||||
|
return R.layout.rv_item_participant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,10 @@ import android.text.TextUtils;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.bumptech.glide.load.model.GlideUrl;
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
@ -32,14 +36,6 @@ import com.bumptech.glide.load.model.LazyHeaders;
|
|||||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.nextcloud.talk.adapters.items.AdvancedUserItem;
|
|
||||||
import com.nextcloud.talk.adapters.items.GenericTextHeaderItem;
|
|
||||||
import com.nextcloud.talk.adapters.items.UserItem;
|
import com.nextcloud.talk.adapters.items.UserItem;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
@ -48,29 +44,26 @@ import com.nextcloud.talk.models.database.UserEntity;
|
|||||||
import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter;
|
import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter;
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
|
import com.nextcloud.talk.models.json.participants.ParticipantsOverall;
|
||||||
import com.nextcloud.talk.models.json.rooms.Conversation;
|
import com.nextcloud.talk.models.json.rooms.Conversation;
|
||||||
import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
import com.nextcloud.talk.models.json.rooms.RoomOverall;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.glide.GlideApp;
|
import com.nextcloud.talk.utils.glide.GlideApp;
|
||||||
import com.nextcloud.talk.utils.preferencestorage.DatabaseStorageModule;
|
import com.nextcloud.talk.utils.preferencestorage.DatabaseStorageModule;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
|
||||||
import com.yarolegovich.mp.MaterialChoicePreference;
|
import com.yarolegovich.mp.MaterialChoicePreference;
|
||||||
import com.yarolegovich.mp.MaterialPreferenceCategory;
|
import com.yarolegovich.mp.MaterialPreferenceCategory;
|
||||||
import com.yarolegovich.mp.MaterialPreferenceScreen;
|
import com.yarolegovich.mp.MaterialPreferenceScreen;
|
||||||
|
|
||||||
|
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -119,6 +112,8 @@ public class ConversationInfoController extends BaseController {
|
|||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
private Disposable roomDisposable;
|
private Disposable roomDisposable;
|
||||||
|
private Disposable participantsDisposable;
|
||||||
|
|
||||||
private Conversation conversation;
|
private Conversation conversation;
|
||||||
|
|
||||||
private FlexibleAdapter<AbstractFlexibleItem> adapter;
|
private FlexibleAdapter<AbstractFlexibleItem> adapter;
|
||||||
@ -163,6 +158,9 @@ public class ConversationInfoController extends BaseController {
|
|||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
adapter = new FlexibleAdapter<>(recyclerViewItems, getActivity(), true);
|
adapter = new FlexibleAdapter<>(recyclerViewItems, getActivity(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SmoothScrollLinearLayoutManager layoutManager =
|
SmoothScrollLinearLayoutManager layoutManager =
|
||||||
new SmoothScrollLinearLayoutManager(getActivity());
|
new SmoothScrollLinearLayoutManager(getActivity());
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
@ -171,34 +169,42 @@ public class ConversationInfoController extends BaseController {
|
|||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleParticipants() {
|
private void handleParticipants(List<Participant> participants) {
|
||||||
UserItem userItem;
|
UserItem userItem;
|
||||||
Participant participant;
|
Participant participant;
|
||||||
|
EnumParticipantTypeConverter enumParticipantTypeConverter = new EnumParticipantTypeConverter();
|
||||||
|
|
||||||
recyclerViewItems = new ArrayList<>();
|
recyclerViewItems = new ArrayList<>();
|
||||||
|
HashMap<String, HashMap<String, Object>> conversationParticipants = conversation.getParticipants();
|
||||||
GenericTextHeaderItem genericTextHeaderItem = new GenericTextHeaderItem("bla");
|
|
||||||
EnumParticipantTypeConverter enumParticipantTypeConverter = new EnumParticipantTypeConverter();
|
|
||||||
Iterator it = conversation.getParticipants().entrySet().iterator();
|
|
||||||
HashMap<String, Object> internalHashMap;
|
HashMap<String, Object> internalHashMap;
|
||||||
while (it.hasNext()) {
|
UserItem ownUserItem = null;
|
||||||
participant = new Participant();
|
for (int i = 0; i < participants.size(); i++) {
|
||||||
Map.Entry pair = (Map.Entry)it.next();
|
participant = participants.get(i);
|
||||||
participant.setUserId((String) pair.getKey());
|
internalHashMap = conversationParticipants.get(participant.getUserId());
|
||||||
internalHashMap = (HashMap<String, Object>) pair.getValue();
|
participant.setInCall((long)internalHashMap.get("call") != 0);
|
||||||
|
if (!participant.getUserId().equals(conversationUser.getUserId())) {
|
||||||
participant.setName((String) internalHashMap.get("name"));
|
participant.setName((String) internalHashMap.get("name"));
|
||||||
participant.setParticipantFlags((long) internalHashMap.get("call"));
|
} else {
|
||||||
|
participant.setName(getResources().getString(R.string.nc_chat_you) + " (" + internalHashMap.get("name") + ")");
|
||||||
|
}
|
||||||
participant.setType(enumParticipantTypeConverter.getFromInt((int)(long) internalHashMap.get("type")));
|
participant.setType(enumParticipantTypeConverter.getFromInt((int)(long) internalHashMap.get("type")));
|
||||||
|
|
||||||
userItem = new UserItem(participant, conversationUser, genericTextHeaderItem);
|
userItem = new UserItem(participant, conversationUser, null);
|
||||||
|
userItem.setEnabled(!participant.getSessionId().equals("0"));
|
||||||
userItem.setEnabled(participant.getParticipantFlags() != 0);
|
if (!participant.getUserId().equals(conversationUser.getUserId())) {
|
||||||
|
ownUserItem = userItem;
|
||||||
|
} else {
|
||||||
recyclerViewItems.add(userItem);
|
recyclerViewItems.add(userItem);
|
||||||
it.remove();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ownUserItem != null) {
|
||||||
|
recyclerViewItems.add(ownUserItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAdapter();
|
setupAdapter();
|
||||||
|
|
||||||
|
participantsListCategory.setVisibility(View.VISIBLE);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +221,33 @@ public class ConversationInfoController extends BaseController {
|
|||||||
return getResources().getString(R.string.nc_conversation_menu_conversation_info);
|
return getResources().getString(R.string.nc_conversation_menu_conversation_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getListOfParticipants() {
|
||||||
|
ncApi.getPeersForCall(credentials, ApiUtils.getUrlForParticipants(conversationUser.getBaseUrl(), conversationToken))
|
||||||
|
.subscribeOn(Schedulers.newThread())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<ParticipantsOverall>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
participantsDisposable = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(ParticipantsOverall participantsOverall) {
|
||||||
|
handleParticipants(participantsOverall.getOcs().getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
participantsDisposable.dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
private void fetchRoomInfo() {
|
private void fetchRoomInfo() {
|
||||||
ncApi.getRoom(credentials, ApiUtils.getRoom(conversationUser.getBaseUrl(), conversationToken))
|
ncApi.getRoom(credentials, ApiUtils.getRoom(conversationUser.getBaseUrl(), conversationToken))
|
||||||
.subscribeOn(Schedulers.newThread())
|
.subscribeOn(Schedulers.newThread())
|
||||||
@ -228,14 +261,13 @@ public class ConversationInfoController extends BaseController {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(RoomOverall roomOverall) {
|
public void onNext(RoomOverall roomOverall) {
|
||||||
conversation = roomOverall.getOcs().getData();
|
conversation = roomOverall.getOcs().getData();
|
||||||
|
getListOfParticipants();
|
||||||
|
|
||||||
if (progressBar != null) {
|
if (progressBar != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadConversationAvatar();
|
loadConversationAvatar();
|
||||||
handleParticipants();
|
|
||||||
|
|
||||||
|
|
||||||
if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
||||||
messageNotificationLevel.setEnabled(true);
|
messageNotificationLevel.setEnabled(true);
|
||||||
@ -269,7 +301,6 @@ public class ConversationInfoController extends BaseController {
|
|||||||
|
|
||||||
materialPreferenceScreen.setVisibility(View.VISIBLE);
|
materialPreferenceScreen.setVisibility(View.VISIBLE);
|
||||||
nameCategoryView.setVisibility(View.VISIBLE);
|
nameCategoryView.setVisibility(View.VISIBLE);
|
||||||
participantsListCategory.setVisibility(View.VISIBLE);
|
|
||||||
conversationDisplayName.setText(conversation.getDisplayName());
|
conversationDisplayName.setText(conversation.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
app/src/main/res/layout/rv_item_participant.xml
Normal file
52
app/src/main/res/layout/rv_item_participant.xml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Nextcloud Talk application
|
||||||
|
~
|
||||||
|
~ @author Mario Danic
|
||||||
|
~ Copyright (C) 2017-2018 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/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/item_height"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<com.nextcloud.talk.utils.MagicFlipView
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/avatar_flip_view"
|
||||||
|
android:layout_width="@dimen/avatar_size"
|
||||||
|
android:layout_height="@dimen/avatar_size"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
app:animationDuration="170"
|
||||||
|
app:enableInitialAnimation="true"
|
||||||
|
app:rearBackgroundColor="@color/colorPrimary"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_toEndOf="@id/avatar_flip_view"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
|
tools:text="Contact item text"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user