Comment truncation

This commit is contained in:
Koen 2023-10-19 14:51:12 +02:00
parent 51d0f18168
commit 8254bcc647
5 changed files with 8 additions and 6 deletions

View file

@ -39,4 +39,8 @@ class PolycentricPlatformComment : IPlatformComment {
fun cloneWithUpdatedReplyCount(replyCount: Int?): PolycentricPlatformComment {
return PolycentricPlatformComment(contextUrl, author, message, rating, date, reference, replyCount);
}
companion object {
val MAX_COMMENT_SIZE = 2000
}
}

View file

@ -57,7 +57,7 @@ class CommentDialog(context: Context?, val contextUrl: String, val ref: Protocol
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
_textCharacterCount.text = count.toString();
if (count > MAX_COMMENT_SIZE) {
if (count > PolycentricPlatformComment.MAX_COMMENT_SIZE) {
_textCharacterCount.setTextColor(Color.RED);
_textCharacterCountMax.setTextColor(Color.RED);
_buttonCreate.alpha = 0.4f;
@ -79,7 +79,7 @@ class CommentDialog(context: Context?, val contextUrl: String, val ref: Protocol
_buttonCreate.setOnClickListener {
clearFocus();
if (_editComment.text.count() > MAX_COMMENT_SIZE) {
if (_editComment.text.count() > PolycentricPlatformComment.MAX_COMMENT_SIZE) {
UIDialogs.toast(context, "Comment should be less than 5000 characters");
return@setOnClickListener;
}
@ -131,6 +131,5 @@ class CommentDialog(context: Context?, val contextUrl: String, val ref: Protocol
companion object {
private val TAG = "CommentDialog";
private val MAX_COMMENT_SIZE = 5000;
}
}

View file

@ -9,7 +9,6 @@ data class Telemetry(
val buildType: String,
val debug: Boolean,
val isUnstableBuild: Boolean,
val time: Long,
val brand: String,
val manufacturer: String,
val model: String

View file

@ -302,7 +302,7 @@ class StatePolycentric {
thumbnail = imageBundle?.selectBestImage(dp_25 * dp_25)?.let { img -> img.toURLInfoSystemLinkUrl(ev.system.toProto(), img.process, listOf(PolycentricCache.SERVER)) },
subscribers = null
),
msg = post.content,
msg = post.content.substring(0, PolycentricPlatformComment.MAX_COMMENT_SIZE),
rating = RatingLikeDislikes(likes, dislikes),
date = if (unixMilliseconds != null) Instant.ofEpochMilli(unixMilliseconds).atOffset(ZoneOffset.UTC) else OffsetDateTime.MIN,
replyCount = replies.toInt(),

View file

@ -49,7 +49,7 @@
android:id="@+id/character_count_max"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/5000"
android:text="/2000"
android:textSize="14dp"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular" />