mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-23 06:07:16 +00:00
fix markdown display
This commit is contained in:
parent
35659fd414
commit
750729c87d
6 changed files with 23 additions and 26 deletions
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="1909"
|
||||
android:versionName="1.1.1"
|
||||
android:versionCode="1911"
|
||||
android:versionName="1.1.2"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.habitrpg.android.habitica.R;
|
|||
import com.habitrpg.android.habitica.models.social.ChatMessage;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
|
||||
|
||||
import net.pherth.android.emoji_library.EmojiTextView;
|
||||
|
||||
|
|
@ -30,15 +31,14 @@ import butterknife.OnClick;
|
|||
import io.realm.OrderedRealmCollection;
|
||||
import io.realm.RealmRecyclerViewAdapter;
|
||||
import rx.Observable;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import rx.subjects.PublishSubject;
|
||||
|
||||
public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessage, ChatRecyclerViewAdapter.ChatRecyclerViewHolder> {
|
||||
|
||||
private User user;
|
||||
private String uuid;
|
||||
private String groupId;
|
||||
private boolean isInboxChat = false;
|
||||
private String replyToUserUUID;
|
||||
private User sendingUser;
|
||||
|
||||
private PublishSubject<ChatMessage> likeMessageEvents = PublishSubject.create();
|
||||
|
|
@ -49,17 +49,10 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
private PublishSubject<ChatMessage> copyMessageAsTodoEvents = PublishSubject.create();
|
||||
private PublishSubject<ChatMessage> copyMessageEvents = PublishSubject.create();
|
||||
|
||||
public ChatRecyclerViewAdapter(@Nullable OrderedRealmCollection<ChatMessage> data, boolean autoUpdate, User user, String groupId) {
|
||||
public ChatRecyclerViewAdapter(@Nullable OrderedRealmCollection<ChatMessage> data, boolean autoUpdate, User user) {
|
||||
super(data, autoUpdate);
|
||||
this.user = user;
|
||||
if (user != null) this.uuid = user.getId();
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
|
||||
public void setToInboxChat(String replyToUserUUID) {
|
||||
this.replyToUserUUID = replyToUserUUID;
|
||||
this.isInboxChat = true;
|
||||
}
|
||||
|
||||
public void setSendingUser(@Nullable User user) {
|
||||
|
|
@ -70,7 +63,7 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
public ChatRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.tavern_chat_item, parent, false);
|
||||
return new ChatRecyclerViewHolder(view, uuid, groupId);
|
||||
return new ChatRecyclerViewHolder(view, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -108,6 +101,7 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
return copyMessageEvents.asObservable();
|
||||
}
|
||||
|
||||
|
||||
class ChatRecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, PopupMenu.OnMenuItemClickListener {
|
||||
|
||||
@BindView(R.id.btn_options)
|
||||
|
|
@ -130,7 +124,7 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
private String userId;
|
||||
private ChatMessage chatMessage;
|
||||
|
||||
ChatRecyclerViewHolder(View itemView, String currentUserId, String groupId) {
|
||||
ChatRecyclerViewHolder(View itemView, String currentUserId) {
|
||||
super(itemView);
|
||||
this.userId = currentUserId;
|
||||
|
||||
|
|
@ -176,9 +170,17 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
DataBindingUtils.setForegroundTintColor(userLabel, msg.getContributorForegroundColor());
|
||||
|
||||
if (messageText != null) {
|
||||
messageText.setText(msg.parsedText);
|
||||
messageText.setText(chatMessage.parsedText);
|
||||
if (msg.parsedText == null) {
|
||||
messageText.setText(msg.text);
|
||||
messageText.setText(chatMessage.text);
|
||||
Observable.just(chatMessage.text)
|
||||
.map(MarkdownParser::parseMarkdown)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(parsedText -> {
|
||||
chatMessage.parsedText = parsedText;
|
||||
messageText.setText(chatMessage.parsedText);
|
||||
}, Throwable::printStackTrace);
|
||||
}
|
||||
this.messageText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
|
@ -260,8 +262,6 @@ public class ChatRecyclerViewAdapter extends RealmRecyclerViewAdapter<ChatMessag
|
|||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ public class ChatListFragment extends BaseFragment implements SwipeRefreshLayout
|
|||
recyclerView.setLayoutManager(layoutManager);
|
||||
}
|
||||
|
||||
chatAdapter = new ChatRecyclerViewAdapter(null, true, user, groupId);
|
||||
chatAdapter = new ChatRecyclerViewAdapter(null, true, user);
|
||||
compositeSubscription.add(chatAdapter.getUserLabelClickEvents().subscribe(userId -> FullProfileActivity.open(getContext(), userId), RxErrorHandler.handleEmptyError()));
|
||||
compositeSubscription.add(chatAdapter.getDeleteMessageEvents().subscribe(this::showDeleteConfirmationDialog, RxErrorHandler.handleEmptyError()));
|
||||
compositeSubscription.add(chatAdapter.getFlatMessageEvents().subscribe(this::showFlagConfirmationDialog, RxErrorHandler.handleEmptyError()));
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ public class InboxMessageListFragment extends BaseMainFragment
|
|||
//layoutManager.setStackFromEnd(false);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
chatAdapter = new ChatRecyclerViewAdapter(null, true, user, null);
|
||||
chatAdapter.setToInboxChat(this.replyToUserUUID);
|
||||
chatAdapter = new ChatRecyclerViewAdapter(null, true, user);
|
||||
chatAdapter.setSendingUser(this.user);
|
||||
recyclerView.setAdapter(chatAdapter);
|
||||
compositeSubscription.add(chatAdapter.getUserLabelClickEvents().subscribe(userId -> FullProfileActivity.open(getContext(), userId), RxErrorHandler.handleEmptyError()));
|
||||
|
|
@ -156,7 +155,6 @@ public class InboxMessageListFragment extends BaseMainFragment
|
|||
UiUtils.dismissKeyboard(getActivity());
|
||||
}
|
||||
|
||||
|
||||
public void setReceivingUser(String chatRoomUser, String replyToUserUUID) {
|
||||
this.chatRoomUser = chatRoomUser;
|
||||
this.replyToUserUUID = replyToUserUUID;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.habitrpg.android.habitica.models.user.User;
|
|||
import com.habitrpg.android.habitica.modules.AppModule;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment;
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
|
||||
import com.habitrpg.android.habitica.ui.views.social.QuestProgressView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -138,7 +139,7 @@ public class PartyDetailFragment extends BaseFragment {
|
|||
return;
|
||||
}
|
||||
titleView.setText(party.name);
|
||||
descriptionView.setText(party.description);
|
||||
descriptionView.setText(MarkdownParser.parseMarkdown(party.description));
|
||||
|
||||
if (quest.key != null) {
|
||||
newQuestButton.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import com.google.gson.JsonDeserializer;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.habitrpg.android.habitica.models.social.Backer;
|
||||
import com.habitrpg.android.habitica.models.social.ChatMessage;
|
||||
import com.habitrpg.android.habitica.models.social.ChatMessageLike;
|
||||
import com.habitrpg.android.habitica.models.user.ContributorInfo;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.realm.RealmList;
|
||||
|
|
|
|||
Loading…
Reference in a new issue