Commit 66d709c3 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add hostname attribute/parameter

parent d27a602a
...@@ -188,7 +188,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -188,7 +188,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
protected void onSetupView() { protected void onSetupView() {
messageRecyclerView = rootView.findViewById(R.id.messageRecyclerView); messageRecyclerView = rootView.findViewById(R.id.messageRecyclerView);
messageListAdapter = new MessageListAdapter(getContext()); messageListAdapter = new MessageListAdapter(getContext(), hostname);
messageRecyclerView.setAdapter(messageListAdapter); messageRecyclerView.setAdapter(messageListAdapter);
messageListAdapter.setOnItemClickListener(this); messageListAdapter.setOnItemClickListener(this);
messageListAdapter.setOnItemLongClickListener(this); messageListAdapter.setOnItemLongClickListener(this);
...@@ -369,7 +369,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements ...@@ -369,7 +369,7 @@ public class RoomFragment extends AbstractChatRoomFragment implements
new DefaultTempSpotlightUserCaller(methodCallHelper) new DefaultTempSpotlightUserCaller(methodCallHelper)
), ),
pair.first.get(), pair.first.get(),
RocketChatUserStatusProvider.getInstance(), RocketChatUserStatusProvider.INSTANCE,
AndroidSchedulers.from(BackgroundLooper.get()), AndroidSchedulers.from(BackgroundLooper.get()),
AndroidSchedulers.mainThread() AndroidSchedulers.mainThread()
) )
......
...@@ -117,7 +117,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatRoomDialogFragment { ...@@ -117,7 +117,7 @@ public class UsersOfRoomDialogFragment extends AbstractChatRoomDialogFragment {
RecyclerView recyclerView = (RecyclerView) getDialog().findViewById(R.id.recyclerview); RecyclerView recyclerView = (RecyclerView) getDialog().findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2)); recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
recyclerView.setAdapter( recyclerView.setAdapter(
new RoomUserAdapter(getContext(), realmHelper, rocketChatAbsoluteUrlOptional.get())); new RoomUserAdapter(getContext(), realmHelper, rocketChatAbsoluteUrlOptional.get(), hostname));
} }
private void requestGetUsersOfRoom() { private void requestGetUsersOfRoom() {
......
...@@ -224,10 +224,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -224,10 +224,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
private void onRenderCurrentUser(User user, RocketChatAbsoluteUrl absoluteUrl) { private void onRenderCurrentUser(User user, RocketChatAbsoluteUrl absoluteUrl) {
if (user != null && absoluteUrl != null) { if (user != null && absoluteUrl != null) {
new UserRenderer(getContext(), user) UserRenderer userRenderer = new UserRenderer(user);
.avatarInto(rootView.findViewById(R.id.current_user_avatar), absoluteUrl) userRenderer.showAvatar(rootView.findViewById(R.id.current_user_avatar), hostname);
.usernameInto(rootView.findViewById(R.id.current_user_name)) userRenderer.showUsername(rootView.findViewById(R.id.current_user_name));
.statusColorInto(rootView.findViewById(R.id.current_user_status)); userRenderer.showStatusColor(rootView.findViewById(R.id.current_user_status));
} }
} }
......
...@@ -97,7 +97,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen ...@@ -97,7 +97,7 @@ public class AddDirectMessageDialogFragment extends AbstractAddRoomDialogFragmen
(realm, text) -> realm.where(RealmUser.class) (realm, text) -> realm.where(RealmUser.class)
.contains(RealmUser.USERNAME, text, Case.INSENSITIVE) .contains(RealmUser.USERNAME, text, Case.INSENSITIVE)
.findAllSorted(RealmUser.USERNAME), .findAllSorted(RealmUser.USERNAME),
context -> new SuggestUserAdapter(context, rocketChatAbsoluteUrlOptional.get())); context -> new SuggestUserAdapter(context, rocketChatAbsoluteUrlOptional.get(), hostname));
autoCompleteTextView.setAdapter(adapter); autoCompleteTextView.setAdapter(adapter);
} }
......
...@@ -19,13 +19,14 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe ...@@ -19,13 +19,14 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
protected final TextView timestamp; protected final TextView timestamp;
protected final View userAndTimeContainer; protected final View userAndTimeContainer;
protected final AbsoluteUrl absoluteUrl; protected final AbsoluteUrl absoluteUrl;
protected final String hostname;
protected final View newDayContainer; protected final View newDayContainer;
protected final TextView newDayText; protected final TextView newDayText;
/** /**
* constructor WITH hostname. * constructor WITH hostname.
*/ */
public AbstractMessageViewHolder(View itemView, AbsoluteUrl absoluteUrl) { public AbstractMessageViewHolder(View itemView, AbsoluteUrl absoluteUrl, String hostname) {
super(itemView); super(itemView);
avatar = itemView.findViewById(R.id.user_avatar); avatar = itemView.findViewById(R.id.user_avatar);
errorImageView = itemView.findViewById(R.id.errorImageView); errorImageView = itemView.findViewById(R.id.errorImageView);
...@@ -36,6 +37,7 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe ...@@ -36,6 +37,7 @@ public abstract class AbstractMessageViewHolder extends ModelViewHolder<PairedMe
newDayContainer = itemView.findViewById(R.id.newday_container); newDayContainer = itemView.findViewById(R.id.newday_container);
newDayText = itemView.findViewById(R.id.newday_text); newDayText = itemView.findViewById(R.id.newday_text);
this.absoluteUrl = absoluteUrl; this.absoluteUrl = absoluteUrl;
this.hostname = hostname;
} }
/** /**
......
...@@ -22,14 +22,16 @@ public class MessageListAdapter extends ExtModelListAdapter<Message, PairedMessa ...@@ -22,14 +22,16 @@ public class MessageListAdapter extends ExtModelListAdapter<Message, PairedMessa
private static final int VIEW_TYPE_NORMAL_MESSAGE = 1; private static final int VIEW_TYPE_NORMAL_MESSAGE = 1;
private static final int VIEW_TYPE_SYSTEM_MESSAGE = 2; private static final int VIEW_TYPE_SYSTEM_MESSAGE = 2;
private String hostname;
private AbsoluteUrl absoluteUrl; private AbsoluteUrl absoluteUrl;
private boolean autoloadImages = false; private boolean autoloadImages = false;
private boolean hasNext; private boolean hasNext;
private boolean isLoaded; private boolean isLoaded;
public MessageListAdapter(Context context) { public MessageListAdapter(Context context, String hostname) {
super(context); super(context);
this.hostname = hostname;
} }
public void setAbsoluteUrl(AbsoluteUrl absoluteUrl) { public void setAbsoluteUrl(AbsoluteUrl absoluteUrl) {
...@@ -92,11 +94,11 @@ public class MessageListAdapter extends ExtModelListAdapter<Message, PairedMessa ...@@ -92,11 +94,11 @@ public class MessageListAdapter extends ExtModelListAdapter<Message, PairedMessa
protected AbstractMessageViewHolder onCreateRealmModelViewHolder(int viewType, View itemView) { protected AbstractMessageViewHolder onCreateRealmModelViewHolder(int viewType, View itemView) {
switch (viewType) { switch (viewType) {
case VIEW_TYPE_NORMAL_MESSAGE: case VIEW_TYPE_NORMAL_MESSAGE:
return new MessageNormalViewHolder(itemView, absoluteUrl); return new MessageNormalViewHolder(itemView, absoluteUrl, hostname);
case VIEW_TYPE_SYSTEM_MESSAGE: case VIEW_TYPE_SYSTEM_MESSAGE:
return new MessageSystemViewHolder(itemView, absoluteUrl); return new MessageSystemViewHolder(itemView, absoluteUrl, hostname);
default: default:
return new AbstractMessageViewHolder(itemView, absoluteUrl) { return new AbstractMessageViewHolder(itemView, absoluteUrl, hostname) {
@Override @Override
protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {} protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {}
}; };
......
...@@ -19,8 +19,8 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder { ...@@ -19,8 +19,8 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder {
/** /**
* constructor WITH hostname. * constructor WITH hostname.
*/ */
public MessageNormalViewHolder(View itemView, AbsoluteUrl absoluteUrl) { public MessageNormalViewHolder(View itemView, AbsoluteUrl absoluteUrl, String hostname) {
super(itemView, absoluteUrl); super(itemView, absoluteUrl, hostname);
body = itemView.findViewById(R.id.message_body); body = itemView.findViewById(R.id.message_body);
urls = itemView.findViewById(R.id.message_urls); urls = itemView.findViewById(R.id.message_urls);
attachments = itemView.findViewById(R.id.message_attachments); attachments = itemView.findViewById(R.id.message_attachments);
...@@ -28,12 +28,12 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder { ...@@ -28,12 +28,12 @@ public class MessageNormalViewHolder extends AbstractMessageViewHolder {
@Override @Override
protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) { protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {
new MessageRenderer(itemView.getContext(), pairedMessage.target, autoloadImages) MessageRenderer messageRenderer = new MessageRenderer(pairedMessage.target, autoloadImages);
.avatarInto(avatar, absoluteUrl) messageRenderer.showAvatar(avatar, hostname);
.usernameInto(username, subUsername) messageRenderer.showUsername(username, subUsername);
.timestampInto(timestamp) messageRenderer.showTimestampOrMessageState(timestamp);
.bodyInto(body) messageRenderer.showBody(body);
.urlsInto(urls) messageRenderer.showUrl(urls);
.attachmentsInto(attachments, absoluteUrl); messageRenderer.showAttachment(attachments, absoluteUrl);
} }
} }
...@@ -16,18 +16,17 @@ public class MessageSystemViewHolder extends AbstractMessageViewHolder { ...@@ -16,18 +16,17 @@ public class MessageSystemViewHolder extends AbstractMessageViewHolder {
/** /**
* constructor WITH hostname. * constructor WITH hostname.
*/ */
public MessageSystemViewHolder(View itemView, AbsoluteUrl absoluteUrl) { public MessageSystemViewHolder(View itemView, AbsoluteUrl absoluteUrl, String hostname) {
super(itemView, absoluteUrl); super(itemView, absoluteUrl, hostname);
body = itemView.findViewById(R.id.message_body); body = itemView.findViewById(R.id.message_body);
} }
@Override @Override
protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) { protected void bindMessage(PairedMessage pairedMessage, boolean autoloadImages) {
new MessageRenderer(itemView.getContext(), pairedMessage.target, autoloadImages) MessageRenderer messageRenderer = new MessageRenderer(pairedMessage.target, autoloadImages);
.avatarInto(avatar, absoluteUrl) messageRenderer.showAvatar(avatar, hostname);
.usernameInto(username, subUsername) messageRenderer.showUsername(username, subUsername);
.timestampInto(timestamp); messageRenderer.showTimestampOrMessageState(timestamp);
if (pairedMessage.target != null) { if (pairedMessage.target != null) {
body.setText(MessageType.parse(pairedMessage.target.getType()) body.setText(MessageType.parse(pairedMessage.target.getType())
.getString(body.getContext(), pairedMessage.target)); .getString(body.getContext(), pairedMessage.target));
......
...@@ -24,16 +24,18 @@ public class RoomUserAdapter extends RecyclerView.Adapter<RoomUserViewHolder> { ...@@ -24,16 +24,18 @@ public class RoomUserAdapter extends RecyclerView.Adapter<RoomUserViewHolder> {
private final LayoutInflater inflater; private final LayoutInflater inflater;
private final RealmHelper realmHelper; private final RealmHelper realmHelper;
private final AbsoluteUrl absoluteUrl; private final AbsoluteUrl absoluteUrl;
private final String hostname;
private List<String> usernames; private List<String> usernames;
/** /**
* Constructor with required parameters. * Constructor with required parameters.
*/ */
public RoomUserAdapter(Context context, RealmHelper realmHelper, AbsoluteUrl absoluteUrl) { public RoomUserAdapter(Context context, RealmHelper realmHelper, AbsoluteUrl absoluteUrl, String hostname) {
this.context = context; this.context = context;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.realmHelper = realmHelper; this.realmHelper = realmHelper;
this.absoluteUrl = absoluteUrl; this.absoluteUrl = absoluteUrl;
this.hostname = hostname;
} }
@Override @Override
...@@ -57,14 +59,15 @@ public class RoomUserAdapter extends RecyclerView.Adapter<RoomUserViewHolder> { ...@@ -57,14 +59,15 @@ public class RoomUserAdapter extends RecyclerView.Adapter<RoomUserViewHolder> {
.setUsername(username) .setUsername(username)
.setUtcOffset(0) .setUtcOffset(0)
.build(); .build();
new UserRenderer(context, user)
.avatarInto(holder.avatar, absoluteUrl) UserRenderer userRenderer = new UserRenderer(user);
.usernameInto(holder.username); userRenderer.showAvatar(holder.avatar, hostname);
userRenderer.showUsername(holder.username);
} else { } else {
new UserRenderer(context, realmUser.asUser()) UserRenderer userRenderer = new UserRenderer(realmUser.asUser());
.statusColorInto(holder.status) userRenderer.showAvatar(holder.avatar, hostname);
.avatarInto(holder.avatar, absoluteUrl) userRenderer.showUsername(holder.username);
.usernameInto(holder.username); userRenderer.showStatusColor(holder.status);
} }
} }
......
...@@ -16,17 +16,19 @@ import chat.rocket.android.renderer.UserRenderer; ...@@ -16,17 +16,19 @@ import chat.rocket.android.renderer.UserRenderer;
*/ */
public class SuggestUserAdapter extends RealmAutoCompleteAdapter<RealmUser> { public class SuggestUserAdapter extends RealmAutoCompleteAdapter<RealmUser> {
private final AbsoluteUrl absoluteUrl; private final AbsoluteUrl absoluteUrl;
private final String hostname;
public SuggestUserAdapter(Context context, AbsoluteUrl absoluteUrl) { public SuggestUserAdapter(Context context, AbsoluteUrl absoluteUrl, String hostname) {
super(context, R.layout.listitem_room_user, R.id.room_user_name); super(context, R.layout.listitem_room_user, R.id.room_user_name);
this.absoluteUrl = absoluteUrl; this.absoluteUrl = absoluteUrl;
this.hostname = hostname;
} }
@Override @Override
protected void onBindItemView(View itemView, RealmUser user) { protected void onBindItemView(View itemView, RealmUser user) {
new UserRenderer(itemView.getContext(), user.asUser()) UserRenderer userRenderer = new UserRenderer(user.asUser());
.statusColorInto(itemView.findViewById(R.id.room_user_status)) userRenderer.showStatusColor(itemView.findViewById(R.id.room_user_status));
.avatarInto(itemView.findViewById(R.id.room_user_avatar), absoluteUrl); userRenderer.showAvatar(itemView.findViewById(R.id.room_user_avatar), hostname);
} }
@Override @Override
......
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