Commit 625dbcaf authored by Leonardo Aramaki's avatar Leonardo Aramaki Committed by GitHub

Merge pull request #334 from filipedelimabrito/develop

Fix #268
parents cac8330a db07be9b
......@@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
......
......@@ -10,7 +10,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -25,14 +25,10 @@ import android.view.ViewGroup;
import com.fernandocejas.arrow.optional.Optional;
import com.jakewharton.rxbinding2.support.v4.widget.RxDrawerLayout;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import chat.rocket.android.BackgroundLooper;
import chat.rocket.android.R;
import chat.rocket.android.api.MethodCallHelper;
......@@ -50,6 +46,7 @@ import chat.rocket.android.helper.TextUtils;
import chat.rocket.android.layouthelper.chatroom.AbstractNewMessageIndicatorManager;
import chat.rocket.android.layouthelper.chatroom.MessageFormManager;
import chat.rocket.android.layouthelper.chatroom.MessageListAdapter;
import chat.rocket.android.layouthelper.chatroom.ModelListAdapter;
import chat.rocket.android.layouthelper.chatroom.PairedMessage;
import chat.rocket.android.layouthelper.extra_action.AbstractExtraActionItem;
import chat.rocket.android.layouthelper.extra_action.MessageExtraActionBehavior;
......@@ -59,8 +56,11 @@ import chat.rocket.android.layouthelper.extra_action.upload.ImageUploadActionIte
import chat.rocket.android.layouthelper.extra_action.upload.VideoUploadActionItem;
import chat.rocket.android.log.RCLog;
import chat.rocket.android.renderer.RocketChatUserStatusProvider;
import chat.rocket.android.service.ConnectivityManager;
import chat.rocket.android.service.temp.DeafultTempSpotlightRoomCaller;
import chat.rocket.android.service.temp.DefaultTempSpotlightUserCaller;
import chat.rocket.android.widget.internal.ExtraActionPickerDialogFragment;
import chat.rocket.android.widget.message.MessageFormLayout;
import chat.rocket.android.widget.message.autocomplete.AutocompleteManager;
import chat.rocket.android.widget.message.autocomplete.channel.ChannelSource;
import chat.rocket.android.widget.message.autocomplete.user.UserSource;
......@@ -70,6 +70,7 @@ import chat.rocket.core.interactors.MessageInteractor;
import chat.rocket.core.interactors.SessionInteractor;
import chat.rocket.core.models.Message;
import chat.rocket.core.models.Room;
import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.persistence.realm.repositories.RealmMessageRepository;
import chat.rocket.persistence.realm.repositories.RealmRoomRepository;
import chat.rocket.persistence.realm.repositories.RealmServerInfoRepository;
......@@ -77,11 +78,10 @@ import chat.rocket.persistence.realm.repositories.RealmSessionRepository;
import chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository;
import chat.rocket.persistence.realm.repositories.RealmSpotlightUserRepository;
import chat.rocket.persistence.realm.repositories.RealmUserRepository;
import chat.rocket.android.layouthelper.chatroom.ModelListAdapter;
import chat.rocket.persistence.realm.RealmStore;
import chat.rocket.android.service.ConnectivityManager;
import chat.rocket.android.widget.internal.ExtraActionPickerDialogFragment;
import chat.rocket.android.widget.message.MessageFormLayout;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.RuntimePermissions;
......@@ -89,10 +89,12 @@ import permissions.dispatcher.RuntimePermissions;
* Chat room screen.
*/
@RuntimePermissions
public class RoomFragment extends AbstractChatRoomFragment
implements OnBackPressListener, ExtraActionPickerDialogFragment.Callback,
ModelListAdapter.OnItemClickListener<PairedMessage>,
ModelListAdapter.OnItemLongClickListener<PairedMessage>, RoomContract.View {
public class RoomFragment extends AbstractChatRoomFragment implements
OnBackPressListener,
ExtraActionPickerDialogFragment.Callback,
ModelListAdapter.OnItemClickListener<PairedMessage>,
ModelListAdapter.OnItemLongClickListener<PairedMessage>,
RoomContract.View {
private static final int DIALOG_ID = 1;
private static final String HOSTNAME = "hostname";
......@@ -102,11 +104,11 @@ public class RoomFragment extends AbstractChatRoomFragment
private String roomId;
private LoadMoreScrollListener scrollListener;
private MessageFormManager messageFormManager;
private RecyclerViewAutoScrollManager autoScrollManager;
private RecyclerViewAutoScrollManager recyclerViewAutoScrollManager;
protected AbstractNewMessageIndicatorManager newMessageIndicatorManager;
protected Snackbar unreadIndicator;
private boolean previousUnreadMessageExists;
private MessageListAdapter adapter;
private MessageListAdapter messageListAdapter;
private AutocompleteManager autocompleteManager;
private List<AbstractExtraActionItem> extraActionItems;
......@@ -122,8 +124,7 @@ public class RoomFragment extends AbstractChatRoomFragment
private Message edittingMessage = null;
public RoomFragment() {
}
public RoomFragment() {}
/**
* create fragment with roomId.
......@@ -187,16 +188,17 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
protected void onSetupView() {
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
adapter = new MessageListAdapter(getContext());
listView.setAdapter(adapter);
adapter.setOnItemClickListener(this);
adapter.setOnItemLongClickListener(this);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL, true);
listView.setLayoutManager(layoutManager);
autoScrollManager = new RecyclerViewAutoScrollManager(layoutManager) {
RecyclerView messageRecyclerView = (RecyclerView) rootView.findViewById(R.id.messageRecyclerView);
messageListAdapter = new MessageListAdapter(getContext());
messageRecyclerView.setAdapter(messageListAdapter);
messageListAdapter.setOnItemClickListener(this);
messageListAdapter.setOnItemLongClickListener(this);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, true);
messageRecyclerView.setLayoutManager(linearLayoutManager);
recyclerViewAutoScrollManager = new RecyclerViewAutoScrollManager(linearLayoutManager) {
@Override
protected void onAutoScrollMissed() {
if (newMessageIndicatorManager != null) {
......@@ -204,17 +206,17 @@ public class RoomFragment extends AbstractChatRoomFragment
}
}
};
adapter.registerAdapterDataObserver(autoScrollManager);
messageListAdapter.registerAdapterDataObserver(recyclerViewAutoScrollManager);
scrollListener = new LoadMoreScrollListener(layoutManager, 40) {
scrollListener = new LoadMoreScrollListener(linearLayoutManager, 40) {
@Override
public void requestMoreItem() {
presenter.loadMoreMessages();
}
};
listView.addOnScrollListener(scrollListener);
listView.addOnScrollListener(
new RecyclerViewScrolledToBottomListener(layoutManager, 1, this::markAsReadIfNeeded));
messageRecyclerView.addOnScrollListener(scrollListener);
messageRecyclerView.addOnScrollListener(
new RecyclerViewScrolledToBottomListener(linearLayoutManager, 1, this::markAsReadIfNeeded));
newMessageIndicatorManager = new AbstractNewMessageIndicatorManager() {
@Override
......@@ -247,7 +249,7 @@ public class RoomFragment extends AbstractChatRoomFragment
}
private void scrollToLatestMessage() {
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.messageRecyclerView);
if (listView != null) {
listView.scrollToPosition(0);
}
......@@ -264,11 +266,11 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void onDestroyView() {
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.messageRecyclerView);
if (listView != null) {
RecyclerView.Adapter adapter = listView.getAdapter();
if (adapter != null) {
adapter.unregisterAdapterDataObserver(autoScrollManager);
adapter.unregisterAdapterDataObserver(recyclerViewAutoScrollManager);
}
}
......@@ -340,15 +342,12 @@ public class RoomFragment extends AbstractChatRoomFragment
}
private void setupMessageComposer() {
final MessageFormLayout messageFormLayout =
(MessageFormLayout) rootView.findViewById(R.id.message_composer);
messageFormManager =
new MessageFormManager(messageFormLayout, this::showExtraActionSelectionDialog);
final MessageFormLayout messageFormLayout = (MessageFormLayout) rootView.findViewById(R.id.messageComposer);
messageFormManager = new MessageFormManager(messageFormLayout, this::showExtraActionSelectionDialog);
messageFormManager.setSendMessageCallback(this::sendMessage);
messageFormLayout.setEditTextCommitContentListener(this::onCommitContent);
autocompleteManager =
new AutocompleteManager((ViewGroup) rootView.findViewById(R.id.message_list_root));
autocompleteManager = new AutocompleteManager((ViewGroup) rootView.findViewById(R.id.messageListRelativeLayout));
autocompleteManager.registerSource(
new ChannelSource(
......@@ -452,8 +451,7 @@ public class RoomFragment extends AbstractChatRoomFragment
public void onItemSelected(int itemId) {
for (AbstractExtraActionItem extraActionItem : extraActionItems) {
if (extraActionItem.getItemId() == itemId) {
RoomFragmentPermissionsDispatcher
.onExtraActionSelectedWithCheck(RoomFragment.this, extraActionItem);
RoomFragmentPermissionsDispatcher.onExtraActionSelectedWithCheck(RoomFragment.this, extraActionItem);
return;
}
}
......@@ -529,7 +527,7 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void setupWith(RocketChatAbsoluteUrl rocketChatAbsoluteUrl) {
adapter.setAbsoluteUrl(rocketChatAbsoluteUrl);
messageListAdapter.setAbsoluteUrl(rocketChatAbsoluteUrl);
}
@Override
......@@ -555,7 +553,7 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void updateHistoryState(boolean hasNext, boolean isLoaded) {
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.messageRecyclerView);
if (listView == null || !(listView.getAdapter() instanceof MessageListAdapter)) {
return;
}
......@@ -581,10 +579,10 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void showMessages(List<Message> messages) {
if (adapter == null) {
if (messageListAdapter == null) {
return;
}
adapter.updateData(messages);
messageListAdapter.updateData(messages);
}
@Override
......@@ -600,12 +598,12 @@ public class RoomFragment extends AbstractChatRoomFragment
@Override
public void autoloadImages() {
adapter.setAutoloadImages(true);
messageListAdapter.setAutoloadImages(true);
}
@Override
public void manualLoadImages() {
adapter.setAutoloadImages(false);
messageListAdapter.setAutoloadImages(false);
}
private void onEditMessage(Message message) {
......
......@@ -10,4 +10,4 @@ public interface OnBackPressListener {
* @return whether back is handled or not.
*/
boolean onBackPressed();
}
}
\ No newline at end of file
......@@ -40,8 +40,7 @@ public class MessageRenderer extends AbstractRenderer<Message> {
*/
public MessageRenderer avatarInto(RocketChatAvatar rocketChatAvatar, AbsoluteUrl absoluteUrl) {
if (object.getSyncState() == SyncState.FAILED) {
rocketChatAvatar.loadImage(VectorDrawableCompat
.create(context.getResources(), R.drawable.ic_error_outline_black_24dp, null));
rocketChatAvatar.loadImage(VectorDrawableCompat.create(context.getResources(), R.drawable.ic_error_outline_black_24dp, null));
} else if (TextUtils.isEmpty(object.getAvatar())) {
userRenderer.avatarInto(rocketChatAvatar, absoluteUrl);
} else {
......@@ -76,10 +75,12 @@ public class MessageRenderer extends AbstractRenderer<Message> {
}
switch (object.getSyncState()) {
case SyncState.NOT_SYNCED:
case SyncState.SYNCING:
textView.setText(R.string.sending);
break;
case SyncState.FAILED:
textView.setText(R.string.failed_to_sync);
break;
default:
textView.setText(DateTime.fromEpocMs(object.getTimestamp(), DateTime.Format.TIME));
break;
......
......@@ -21,8 +21,7 @@ public class NewMessageObserver extends AbstractModelObserver<RealmMessage> {
private final MethodCallHelper methodCall;
public NewMessageObserver(Context context, String hostname,
RealmHelper realmHelper, DDPClientRef ddpClientRef) {
public NewMessageObserver(Context context, String hostname, RealmHelper realmHelper, DDPClientRef ddpClientRef) {
super(context, hostname, realmHelper, ddpClientRef);
methodCall = new MethodCallHelper(realmHelper, ddpClientRef);
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/message_list_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/messageListRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="chat.rocket.android.fragment.chatroom.RoomFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:id="@+id/messageRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/message_composer" />
android:layout_above="@+id/messageComposer" />
<chat.rocket.android.widget.message.MessageFormLayout
android:id="@+id/message_composer"
android:id="@+id/messageComposer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.AppCompat.Light"
android:layout_alignParentBottom="true" />
android:layout_alignParentBottom="true"
android:theme="@style/Theme.AppCompat.Light" />
</RelativeLayout>
\ No newline at end of file
......@@ -16,6 +16,7 @@
<string name="users_of_room_title">Members List</string>
<string name="fmt_room_user_count">Total: %,d users</string>
<string name="sending">Sending…</string>
<string name="failed_to_sync">Failed to send!</string>
<string name="resend">Resend</string>
<string name="discard">Discard</string>
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
......
......@@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'io.realm:realm-gradle-plugin:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.5.0'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
......
......@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment