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

View File

@ -9,7 +9,6 @@ data class Telemetry(
val buildType: String, val buildType: String,
val debug: Boolean, val debug: Boolean,
val isUnstableBuild: Boolean, val isUnstableBuild: Boolean,
val time: Long,
val brand: String, val brand: String,
val manufacturer: String, val manufacturer: String,
val model: 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)) }, thumbnail = imageBundle?.selectBestImage(dp_25 * dp_25)?.let { img -> img.toURLInfoSystemLinkUrl(ev.system.toProto(), img.process, listOf(PolycentricCache.SERVER)) },
subscribers = null subscribers = null
), ),
msg = post.content, msg = post.content.substring(0, PolycentricPlatformComment.MAX_COMMENT_SIZE),
rating = RatingLikeDislikes(likes, dislikes), rating = RatingLikeDislikes(likes, dislikes),
date = if (unixMilliseconds != null) Instant.ofEpochMilli(unixMilliseconds).atOffset(ZoneOffset.UTC) else OffsetDateTime.MIN, date = if (unixMilliseconds != null) Instant.ofEpochMilli(unixMilliseconds).atOffset(ZoneOffset.UTC) else OffsetDateTime.MIN,
replyCount = replies.toInt(), replyCount = replies.toInt(),

View File

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