mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Add avatar & conversation name to info
This commit is contained in:
parent
353add122a
commit
d492e8040b
@ -970,7 +970,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
|||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
inflater.inflate(R.menu.menu_conversation, menu);
|
inflater.inflate(R.menu.menu_conversation, menu);
|
||||||
|
|
||||||
if (!conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
if (conversationUser.hasSpreedCapabilityWithName("mention-flag")) {
|
||||||
menu.findItem(R.id.nc_conversation_info).setVisible(true);
|
menu.findItem(R.id.nc_conversation_info).setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
menu.findItem(R.id.nc_conversation_info).setVisible(false);
|
menu.findItem(R.id.nc_conversation_info).setVisible(false);
|
||||||
|
@ -21,14 +21,22 @@
|
|||||||
package com.nextcloud.talk.controllers;
|
package com.nextcloud.talk.controllers;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
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 com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
|
import com.bumptech.glide.load.model.LazyHeaders;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
@ -38,9 +46,11 @@ import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter;
|
|||||||
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.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.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.yarolegovich.mp.MaterialChoicePreference;
|
import com.yarolegovich.mp.MaterialChoicePreference;
|
||||||
|
import com.yarolegovich.mp.MaterialPreferenceCategory;
|
||||||
import com.yarolegovich.mp.MaterialPreferenceScreen;
|
import com.yarolegovich.mp.MaterialPreferenceScreen;
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +84,15 @@ public class ConversationInfoController extends BaseController {
|
|||||||
@BindView(R.id.conversation_info_message_notifications)
|
@BindView(R.id.conversation_info_message_notifications)
|
||||||
MaterialChoicePreference messageNotificationLevel;
|
MaterialChoicePreference messageNotificationLevel;
|
||||||
|
|
||||||
|
@BindView(R.id.conversation_info_name)
|
||||||
|
MaterialPreferenceCategory nameCategoryView;
|
||||||
|
|
||||||
|
@BindView(R.id.avatar_image)
|
||||||
|
ImageView conversationAvatarImageView;
|
||||||
|
|
||||||
|
@BindView(R.id.display_name_text)
|
||||||
|
TextView conversationDisplayName;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
|
|
||||||
@ -102,7 +121,7 @@ public class ConversationInfoController extends BaseController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
|
protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
|
||||||
return inflater.inflate(R.layout.conversation_info, container, false);
|
return inflater.inflate(R.layout.controller_conversation_info, container, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -143,6 +162,9 @@ public class ConversationInfoController extends BaseController {
|
|||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
materialPreferenceScreen.setVisibility(View.VISIBLE);
|
materialPreferenceScreen.setVisibility(View.VISIBLE);
|
||||||
|
nameCategoryView.setVisibility(View.VISIBLE);
|
||||||
|
conversationDisplayName.setText(conversation.getDisplayName());
|
||||||
|
loadConversationAvatar();
|
||||||
|
|
||||||
if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) {
|
||||||
messageNotificationLevel.setEnabled(true);
|
messageNotificationLevel.setEnabled(true);
|
||||||
@ -199,4 +221,53 @@ public class ConversationInfoController extends BaseController {
|
|||||||
messageNotificationLevel.setValue("mention");
|
messageNotificationLevel.setValue("mention");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadConversationAvatar() {
|
||||||
|
int avatarSize = getResources().getDimensionPixelSize(R.dimen.avatar_size_big);
|
||||||
|
|
||||||
|
switch (conversation.getType()) {
|
||||||
|
case ROOM_TYPE_ONE_TO_ONE_CALL:
|
||||||
|
if (!TextUtils.isEmpty(conversation.getName())) {
|
||||||
|
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(conversationUser.getBaseUrl(),
|
||||||
|
conversation.getName(), R.dimen.avatar_size), new LazyHeaders.Builder()
|
||||||
|
.setHeader("Accept", "image/*")
|
||||||
|
.setHeader("User-Agent", ApiUtils.getUserAgent())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||||
|
.asBitmap()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.load(glideUrl)
|
||||||
|
.centerInside()
|
||||||
|
.override(avatarSize, avatarSize)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
|
.into(conversationAvatarImageView);
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ROOM_GROUP_CALL:
|
||||||
|
|
||||||
|
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||||
|
.asBitmap()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.load(R.drawable.ic_people_group_white_24px)
|
||||||
|
.centerInside()
|
||||||
|
.override(avatarSize, avatarSize)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
|
.into(conversationAvatarImageView);
|
||||||
|
break;
|
||||||
|
case ROOM_PUBLIC_CALL:
|
||||||
|
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||||
|
.asBitmap()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.load(R.drawable.ic_link_white_24px)
|
||||||
|
.centerInside()
|
||||||
|
.override(avatarSize, avatarSize)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
|
||||||
|
.into(conversationAvatarImageView);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
75
app/src/main/res/layout/controller_conversation_info.xml
Normal file
75
app/src/main/res/layout/controller_conversation_info.xml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?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"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="@dimen/item_height"
|
||||||
|
android:layout_height="@dimen/item_height"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||||
|
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateTint="@color/colorPrimary"
|
||||||
|
android:indeterminateTintMode="src_in" />
|
||||||
|
|
||||||
|
<com.yarolegovich.mp.MaterialPreferenceCategory
|
||||||
|
android:id="@+id/conversation_info_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/avatar_image"
|
||||||
|
android:layout_width="@dimen/avatar_size_big"
|
||||||
|
android:layout_height="@dimen/avatar_size_big"
|
||||||
|
android:layout_centerHorizontal="true" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/display_name_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/avatar_image"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="@dimen/margin_between_elements" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
</com.yarolegovich.mp.MaterialPreferenceCategory>
|
||||||
|
|
||||||
|
<include
|
||||||
|
layout="@layout/notification_settings_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/conversation_info_name"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -1,42 +0,0 @@
|
|||||||
<?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"
|
|
||||||
android:orientation="vertical" android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBar"
|
|
||||||
android:layout_width="@dimen/item_height"
|
|
||||||
android:layout_height="@dimen/item_height"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:indeterminateTint="@color/colorPrimary"
|
|
||||||
android:indeterminateTintMode="src_in"/>
|
|
||||||
|
|
||||||
<include layout="@layout/notification_settings_item"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
Loading…
Reference in New Issue
Block a user