Add changelog support, fix #479 and other things

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2019-04-02 14:34:38 +02:00
parent 43db544fc3
commit 1b86d7ff1e
14 changed files with 124 additions and 49 deletions

View file

@ -21,6 +21,8 @@
package com.nextcloud.talk.adapters.items;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
@ -139,7 +141,7 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
holder.dialogDate.setText(DateUtils.getRelativeTimeSpanString(conversation.getLastActivity() * 1000L,
System.currentTimeMillis(), 0, DateUtils.FORMAT_ABBREV_RELATIVE));
if (!TextUtils.isEmpty(conversation.getLastMessage().getSystemMessage())) {
if (!TextUtils.isEmpty(conversation.getLastMessage().getSystemMessage()) || Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) {
holder.dialogLastMessageUserAvatar.setVisibility(View.GONE);
holder.dialogLastMessage.setText(conversation.getLastMessage().getText());
} else {
@ -178,20 +180,27 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
} else if (!conversation.getLastMessage().getActorId().equals(userEntity.getUserId())
&& !conversation.getType().equals(Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL)) {
holder.dialogLastMessageUserAvatar.setVisibility(View.VISIBLE);
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
conversation.getLastMessage().getActorId(), R.dimen.small_item_height), new LazyHeaders.Builder()
.setHeader("Accept", "image/*")
.setHeader("User-Agent", ApiUtils.getUserAgent())
.build());
GlideApp.with(context)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.load(glideUrl)
.centerInside()
.override(smallAvatarSize, smallAvatarSize)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(holder.dialogLastMessageUserAvatar);
if (!"bots".equals(conversation.getLastMessage().getActorType())) {
GlideUrl glideUrl = new GlideUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
conversation.getLastMessage().getActorId(), R.dimen.small_item_height), new LazyHeaders.Builder()
.setHeader("Accept", "image/*")
.setHeader("User-Agent", ApiUtils.getUserAgent())
.build());
GlideApp.with(context)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.load(glideUrl)
.centerInside()
.override(smallAvatarSize, smallAvatarSize)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(holder.dialogLastMessageUserAvatar);
} else {
TextDrawable drawable = TextDrawable.builder().beginConfig().bold().endConfig().buildRound(">", context.getResources().getColor(R.color.nc_grey));
holder.dialogLastMessageUserAvatar.setImageDrawable(drawable);
}
} else {
holder.dialogLastMessageUserAvatar.setVisibility(View.GONE);
}
@ -229,6 +238,24 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
}
}
if (Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) {
Drawable[] layers = new Drawable[2];
layers[0] = context.getDrawable(R.drawable.ic_launcher_background);
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground);
LayerDrawable layerDrawable = new LayerDrawable(layers);
GlideApp.with(context)
.asDrawable()
.diskCacheStrategy(DiskCacheStrategy.NONE)
.load(layerDrawable)
.centerInside()
.override(avatarSize, avatarSize)
.apply(RequestOptions.bitmapTransform(new CircleCrop()))
.into(holder.dialogAvatar);
shouldLoadAvatar = false;
}
if (shouldLoadAvatar) {
switch (conversation.getType()) {
case ROOM_TYPE_ONE_TO_ONE_CALL:

View file

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.text.Spannable;
import android.text.SpannableString;
@ -69,6 +70,9 @@ public class MagicIncomingTextMessageViewHolder
@Inject
UserUtils userUtils;
@Inject
Context context;
private View itemView;
public MagicIncomingTextMessageViewHolder(View itemView) {
@ -91,29 +95,34 @@ public class MagicIncomingTextMessageViewHolder
messageAuthor.setText(R.string.nc_nick_guest);
}
if (message.getActorType().equals("guests") && !message.isGrouped()) {
TextDrawable drawable = TextDrawable.builder().beginConfig().bold()
.endConfig().buildRound(String.valueOf(messageAuthor.getText().charAt(0)), NextcloudTalkApplication
.getSharedApplication().getResources().getColor(R.color.nc_grey));
if (!message.isGrouped) {
messageUserAvatarView.setVisibility(View.VISIBLE);
messageUserAvatarView.setImageDrawable(drawable);
}
if (message.getActorType().equals("guests")) {
TextDrawable drawable = TextDrawable.builder().beginConfig().bold()
.endConfig().buildRound(String.valueOf(messageAuthor.getText().charAt(0)), NextcloudTalkApplication
.getSharedApplication().getResources().getColor(R.color.nc_grey));
messageUserAvatarView.getHierarchy().setPlaceholderImage(drawable);
} else if (message.getActorType().equals("bots") && message.getActorId().equals("changelog")) {
Drawable[] layers = new Drawable[2];
layers[0] = context.getDrawable(R.drawable.ic_launcher_background);
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground);
LayerDrawable layerDrawable = new LayerDrawable(layers);
messageUserAvatarView.getHierarchy().setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable));
} else if (message.getActorType().equals("bots")) {
TextDrawable drawable = TextDrawable.builder().beginConfig().bold().endConfig().buildRound(">", context.getResources().getColor(R.color.nc_grey));
messageUserAvatarView.setVisibility(View.VISIBLE);
messageUserAvatarView.getHierarchy().setPlaceholderImage(drawable);
}
} else {
Resources resources = context.getResources();
Resources resources = NextcloudTalkApplication.getSharedApplication().getResources();
if (message.isGrouped()) {
messageUserAvatarView.setVisibility(View.INVISIBLE);
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.white_two),
resources.getColor(R.color.transparent),
resources.getColor(R.color.white_two), R.drawable.shape_grouped_incoming_message);
ViewCompat.setBackground(bubble, bubbleDrawable);
messageAuthor.setVisibility(View.GONE);
} else {
messageUserAvatarView.setVisibility(View.VISIBLE);
Drawable bubbleDrawable = DisplayUtils.getMessageSelector(resources.getColor(R.color.white_two),
resources.getColor(R.color.transparent),
resources.getColor(R.color.white_two), R.drawable.shape_incoming_message);
ViewCompat.setBackground(bubble, bubbleDrawable);
messageAuthor.setVisibility(View.VISIBLE);
}
HashMap<String, HashMap<String, String>> messageParameters = message.getMessageParameters();

View file

@ -21,9 +21,13 @@
package com.nextcloud.talk.adapters.messages;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.view.View;
import autodagger.AutoInjector;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.nextcloud.talk.R;
@ -33,14 +37,21 @@ import com.nextcloud.talk.utils.DisplayUtils;
import com.stfalcon.chatkit.messages.MessageHolders;
import com.vanniktech.emoji.EmojiTextView;
import javax.inject.Inject;
@AutoInjector(NextcloudTalkApplication.class)
public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageMessageViewHolder<ChatMessage> {
@BindView(R.id.messageText)
EmojiTextView messageText;
@Inject
Context context;
public MagicPreviewMessageViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
}
@SuppressLint("SetTextI18n")
@ -53,6 +64,15 @@ public class MagicPreviewMessageViewHolder extends MessageHolders.IncomingImageM
userAvatar.setVisibility(View.INVISIBLE);
} else {
userAvatar.setVisibility(View.VISIBLE);
if ("bots".equals(message.getActorType()) && "changelog".equals(message.getActorId())) {
Drawable[] layers = new Drawable[2];
layers[0] = context.getDrawable(R.drawable.ic_launcher_background);
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground);
LayerDrawable layerDrawable = new LayerDrawable(layers);
userAvatar.getHierarchy().setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable));
}
}
}

View file

@ -429,8 +429,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
if (currentConversation != null && !readOnlyCheckPerformed) {
readOnlyCheckPerformed = true;
if (currentConversation.getConversationReadOnlyState() != null &&
!currentConversation.getConversationReadOnlyState().equals(Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY)) {
if (currentConversation.getConversationReadOnlyState() != null && currentConversation.getConversationReadOnlyState().equals(Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY)) {
messageInput.setHint(R.string.nc_readonly_hint);
conversationVoiceCallMenuItem.getIcon().setAlpha(99);
@ -1060,7 +1059,9 @@ public class ChatController extends BaseController implements MessagesListAdapte
conversationVideoMenuItem = menu.findItem(R.id.conversation_video_call);
}
checkReadOnlyState();
if (conversationUser.hasSpreedCapabilityWithName("read-only-rooms")) {
checkReadOnlyState();
}
}

View file

@ -22,6 +22,8 @@ package com.nextcloud.talk.controllers;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
@ -62,10 +64,7 @@ import com.nextcloud.talk.utils.preferencestorage.DatabaseStorageModule;
import com.vanniktech.emoji.EmojiTextView;
import com.yarolegovich.lovelydialog.LovelySaveStateHandler;
import com.yarolegovich.lovelydialog.LovelyStandardDialog;
import com.yarolegovich.mp.MaterialChoicePreference;
import com.yarolegovich.mp.MaterialPreferenceCategory;
import com.yarolegovich.mp.MaterialPreferenceScreen;
import com.yarolegovich.mp.MaterialStandardPreference;
import com.yarolegovich.mp.*;
import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
@ -106,6 +105,8 @@ public class ConversationInfoController extends BaseController {
MaterialStandardPreference leaveConversationAction;
@BindView(R.id.ownOptions)
MaterialPreferenceCategory ownOptionsCategory;
@BindView(R.id.muteCalls)
MaterialSwitchPreference muteCalls;
@Inject
NcApi ncApi;
@ -376,6 +377,10 @@ public class ConversationInfoController extends BaseController {
deleteConversationAction.setVisibility(View.VISIBLE);
}
if (Conversation.ConversationType.ROOM_SYSTEM.equals(conversation.getType())) {
muteCalls.setVisibility(View.GONE);
}
getListOfParticipants();
if (progressBar != null) {
@ -483,6 +488,13 @@ public class ConversationInfoController extends BaseController {
.getRoundedBitmapDrawableFromVectorDrawableResource(getResources(),
R.drawable.ic_link_white_24px));
break;
case ROOM_SYSTEM:
Drawable[] layers = new Drawable[2];
layers[0] = context.getDrawable(R.drawable.ic_launcher_background);
layers[1] = context.getDrawable(R.drawable.ic_launcher_foreground);
LayerDrawable layerDrawable = new LayerDrawable(layers);
conversationAvatarImageView.getHierarchy().setPlaceholderImage(DisplayUtils.getRoundedDrawable(layerDrawable));
default:
break;
}

View file

@ -30,7 +30,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.*;
import android.view.inputmethod.EditorInfo;
import android.widget.ProgressBar;

View file

@ -41,7 +41,6 @@ import autodagger.AutoInjector;
import butterknife.BindView;
import com.bluelinelabs.conductor.RouterTransaction;
import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler;
import com.bluelinelabs.logansquare.LoganSquare;
import com.nextcloud.talk.R;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.controllers.base.BaseController;
@ -49,7 +48,6 @@ import com.nextcloud.talk.events.CertificateEvent;
import com.nextcloud.talk.jobs.PushRegistrationWorker;
import com.nextcloud.talk.models.LoginData;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.push.PushConfigurationState;
import com.nextcloud.talk.utils.bundle.BundleKeys;
import com.nextcloud.talk.utils.database.user.UserUtils;
import com.nextcloud.talk.utils.preferences.AppPreferences;
@ -63,7 +61,6 @@ import io.requery.reactivex.ReactiveEntityStore;
import org.greenrobot.eventbus.EventBus;
import javax.inject.Inject;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.CookieManager;
import java.net.URLDecoder;

View file

@ -47,7 +47,6 @@ import com.nextcloud.talk.controllers.ConversationsListController;
import com.nextcloud.talk.controllers.base.BaseController;
import com.nextcloud.talk.events.BottomSheetLockEvent;
import com.nextcloud.talk.interfaces.ConversationMenuInterface;
import com.nextcloud.talk.jobs.DeleteConversationWorker;
import com.nextcloud.talk.jobs.LeaveConversationWorker;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.rooms.Conversation;

View file

@ -33,6 +33,8 @@ public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.Co
return Conversation.ConversationType.ROOM_GROUP_CALL;
case 3:
return Conversation.ConversationType.ROOM_PUBLIC_CALL;
case 4:
return Conversation.ConversationType.ROOM_SYSTEM;
default:
return Conversation.ConversationType.DUMMY;
}
@ -49,6 +51,8 @@ public class EnumRoomTypeConverter extends IntBasedTypeConverter<Conversation.Co
return 2;
case ROOM_PUBLIC_CALL:
return 3;
case ROOM_SYSTEM:
return 4;
default:
return 0;
}

View file

@ -143,7 +143,8 @@ public class Conversation {
DUMMY,
ROOM_TYPE_ONE_TO_ONE_CALL,
ROOM_GROUP_CALL,
ROOM_PUBLIC_CALL
ROOM_PUBLIC_CALL,
ROOM_SYSTEM
}
}

View file

@ -100,6 +100,12 @@ public class DisplayUtils {
}
}
public static Drawable getRoundedDrawable(Drawable drawable) {
Bitmap bitmap = getBitmap(drawable);
new RoundAsCirclePostprocessor(true).process(bitmap);
return new BitmapDrawable(bitmap);
}
public static Bitmap getRoundedBitmapFromVectorDrawableResource(Resources resources, int resource) {
VectorDrawable vectorDrawable = (VectorDrawable) resources.getDrawable(resource);
Bitmap bitmap = getBitmap(vectorDrawable);
@ -116,12 +122,12 @@ public class DisplayUtils {
return fontMetrics.descent - fontMetrics.ascent;
}
private static Bitmap getBitmap(VectorDrawable vectorDrawable) {
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
private static Bitmap getBitmap(Drawable drawable) {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
vectorDrawable.draw(canvas);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}

View file

@ -25,7 +25,6 @@ import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;

View file

@ -47,7 +47,7 @@
app:flexWrap="wrap"
app:justifyContent="flex_end">
<TextView
<com.vanniktech.emoji.EmojiTextView
android:id="@+id/messageAuthor"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -46,6 +46,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
apc:mp_default_value="false"
android:id="@+id/muteCalls"
apc:mp_key="mute_calls"
apc:mp_title="@string/nc_mute_calls" />