Add post editing capability (#2828)

* Add post editing capability

* Don't try to reprocess already uploaded attachments.
Fixes editing posts with existing media

* Don't mark post edits as modified until editing occurs

* Disable UI for things that can't be edited when editing a post

* Finally convert SFragment to kotlin

* Use api endpoint for fetching status source for editing

* Apply review feedback
This commit is contained in:
Levi Bard 2022-12-08 10:18:12 +01:00 committed by GitHub
commit a6b6a40ba6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 676 additions and 527 deletions

View file

@ -137,7 +137,7 @@ data class Status(
)
}
private fun getEditableText(): String {
fun getEditableText(): String {
val contentSpanned = content.parseAsMastodonHtml()
val builder = SpannableStringBuilder(content.parseAsMastodonHtml())
for (span in contentSpanned.getSpans(0, content.length, URLSpan::class.java)) {
@ -146,7 +146,9 @@ data class Status(
if (url == url1) {
val start = builder.getSpanStart(span)
val end = builder.getSpanEnd(span)
builder.replace(start, end, "@$username")
if (start >= 0 && end >= 0) {
builder.replace(start, end, "@$username")
}
break
}
}

View file

@ -0,0 +1,24 @@
/* Copyright 2022 Tusky Contributors
*
* This file is a part of Tusky.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tusky; if not,
* see <http://www.gnu.org/licenses>. */
package com.keylesspalace.tusky.entity
import com.google.gson.annotations.SerializedName
data class StatusSource(
val id: String,
val text: String,
@SerializedName("spoiler_text") val spoilerText: String,
)