mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-30 18:22:45 +02:00
Merge pull request #1026 from davotoula/chage-twitter-to-x
Change twitter proof to use x.com
This commit is contained in:
@@ -26,11 +26,9 @@ import com.vitorpamplona.amethyst.commons.richtext.RichTextViewerState
|
|||||||
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
import com.vitorpamplona.quartz.events.ImmutableListOfLists
|
||||||
|
|
||||||
object CachedRichTextParser {
|
object CachedRichTextParser {
|
||||||
val richTextCache = LruCache<Int, RichTextViewerState>(50)
|
private val richTextCache = LruCache<Int, RichTextViewerState>(50)
|
||||||
|
|
||||||
// fun getCached(content: String): RichTextViewerState? = richTextCache[content]
|
private fun hashCodeCache(
|
||||||
|
|
||||||
fun hashCodeCache(
|
|
||||||
content: String,
|
content: String,
|
||||||
tags: ImmutableListOfLists<String>,
|
tags: ImmutableListOfLists<String>,
|
||||||
callbackUri: String?,
|
callbackUri: String?,
|
||||||
|
@@ -954,7 +954,7 @@ fun WatchIsHiddenUser(
|
|||||||
|
|
||||||
fun getIdentityClaimIcon(identity: IdentityClaim): Int =
|
fun getIdentityClaimIcon(identity: IdentityClaim): Int =
|
||||||
when (identity) {
|
when (identity) {
|
||||||
is TwitterIdentity -> R.drawable.twitter
|
is TwitterIdentity -> R.drawable.x
|
||||||
is TelegramIdentity -> R.drawable.telegram
|
is TelegramIdentity -> R.drawable.telegram
|
||||||
is MastodonIdentity -> R.drawable.mastodon
|
is MastodonIdentity -> R.drawable.mastodon
|
||||||
is GitHubIdentity -> R.drawable.github
|
is GitHubIdentity -> R.drawable.github
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:height="128dp" android:viewportHeight="512"
|
|
||||||
android:viewportWidth="512" android:width="128dp">
|
|
||||||
<path
|
|
||||||
android:pathData="M437,152a72,72 0,0 1,-40 12a72,72 0,0 0,32 -40a72,72 0,0 1,-45 17a72,72 0,0 0,-122 65a200,200 0,0 1,-145 -74a72,72 0,0 0,22 94a72,72 0,0 1,-32 -7a72,72 0,0 0,56 69a72,72 0,0 1,-32 1a72,72 0,0 0,67 50a200,200 0,0 1,-105 29a200,200 0,0 0,309 -179a200,200 0,0 0,35 -37"
|
|
||||||
android:fillColor="#1da1f2"/>
|
|
||||||
</vector>
|
|
9
amethyst/src/main/res/drawable/x.xml
Normal file
9
amethyst/src/main/res/drawable/x.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:width="128dp"
|
||||||
|
android:height="128dp">
|
||||||
|
<path
|
||||||
|
android:fillColor="#1da1f2"
|
||||||
|
android:pathData="M10.053 7.988l5.631 8.024h-1.497L8.566 7.988H10.053zM21 6v12c0 1.657 -1.343 3 -3 3H6c-1.657 0 -3 -1.343 -3 -3V6c0 -1.657 1.343 -3 3 -3h12C19.657 3 21 4.343 21 6zM17.538 17l-4.186 -5.99L16.774 7h-1.311l-2.704 3.16L10.552 7H6.702l3.941 5.633L6.906 17h1.333l3.001 -3.516L13.698 17H17.538z" />
|
||||||
|
</vector>
|
@@ -255,11 +255,11 @@
|
|||||||
<string name="github" translatable="false">Github Gist w/ Proof</string>
|
<string name="github" translatable="false">Github Gist w/ Proof</string>
|
||||||
<string name="telegram" translatable="false">Telegram</string>
|
<string name="telegram" translatable="false">Telegram</string>
|
||||||
<string name="mastodon" translatable="false">Mastodon Post ID w/ Proof</string>
|
<string name="mastodon" translatable="false">Mastodon Post ID w/ Proof</string>
|
||||||
<string name="twitter" translatable="false">Twitter Status w/ Proof</string>
|
<string name="twitter" translatable="false">X Status w/ Proof</string>
|
||||||
<string name="github_proof_url_template" translatable="false">https://gist.github.com/<user>/<gist></string>
|
<string name="github_proof_url_template" translatable="false">https://gist.github.com/<user>/<gist></string>
|
||||||
<string name="telegram_proof_url_template" translatable="false">https://t.me/<proof post></string>
|
<string name="telegram_proof_url_template" translatable="false">https://t.me/<proof post></string>
|
||||||
<string name="mastodon_proof_url_template" translatable="false">https://<server>/<user>/<proof post></string>
|
<string name="mastodon_proof_url_template" translatable="false">https://<server>/<user>/<proof post></string>
|
||||||
<string name="twitter_proof_url_template" translatable="false">https://twitter.com/<user>/status/<proof post></string>
|
<string name="twitter_proof_url_template" translatable="false">https://x.com/<user>/status/<proof post></string>
|
||||||
<string name="private_conversation_notification">"<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."</string>
|
<string name="private_conversation_notification">"<Unable to decrypt private message>\n\nYou were cited in a private/encrypted conversation between %1$s and %2$s."</string>
|
||||||
<string name="account_switch_add_account_dialog_title">Add New Account</string>
|
<string name="account_switch_add_account_dialog_title">Add New Account</string>
|
||||||
<string name="drawer_accounts">Accounts</string>
|
<string name="drawer_accounts">Accounts</string>
|
||||||
|
@@ -45,7 +45,7 @@ abstract class IdentityClaim(
|
|||||||
fun create(
|
fun create(
|
||||||
platformIdentity: String,
|
platformIdentity: String,
|
||||||
proof: String,
|
proof: String,
|
||||||
): IdentityClaim? {
|
): IdentityClaim {
|
||||||
val (platform, identity) = platformIdentity.split(':')
|
val (platform, identity) = platformIdentity.split(':')
|
||||||
|
|
||||||
return when (platform.lowercase()) {
|
return when (platform.lowercase()) {
|
||||||
@@ -87,7 +87,7 @@ class TwitterIdentity(
|
|||||||
identity: String,
|
identity: String,
|
||||||
proof: String,
|
proof: String,
|
||||||
) : IdentityClaim(identity, proof) {
|
) : IdentityClaim(identity, proof) {
|
||||||
override fun toProofUrl() = "https://twitter.com/$identity/status/$proof"
|
override fun toProofUrl() = "https://x.com/$identity/status/$proof"
|
||||||
|
|
||||||
override fun platform() = platform
|
override fun platform() = platform
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ class TwitterIdentity(
|
|||||||
fun parseProofUrl(proofUrl: String): TwitterIdentity? {
|
fun parseProofUrl(proofUrl: String): TwitterIdentity? {
|
||||||
return try {
|
return try {
|
||||||
if (proofUrl.isBlank()) return null
|
if (proofUrl.isBlank()) return null
|
||||||
val path = proofUrl.removePrefix("https://twitter.com/").split("?")[0].split("/")
|
val path = proofUrl.removePrefix("https://x.com/").split("?")[0].split("/")
|
||||||
|
|
||||||
TwitterIdentity(path[0], path[2])
|
TwitterIdentity(path[0], path[2])
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -166,7 +166,7 @@ class MetadataEvent(
|
|||||||
.filter { it.firstOrNull() == "i" }
|
.filter { it.firstOrNull() == "i" }
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
try {
|
try {
|
||||||
IdentityClaim.create(it.get(1), it.get(2))
|
IdentityClaim.create(it[1], it[2])
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("MetadataEvent", "Can't parse identity [${it.joinToString { "," }}]", e)
|
Log.e("MetadataEvent", "Can't parse identity [${it.joinToString { "," }}]", e)
|
||||||
null
|
null
|
||||||
@@ -265,26 +265,5 @@ class MetadataEvent(
|
|||||||
currentJson.put(key, value.trim())
|
currentJson.put(key, value.trim())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createFromScratch(
|
|
||||||
newName: String,
|
|
||||||
signer: NostrSigner,
|
|
||||||
createdAt: Long = TimeUtils.now(),
|
|
||||||
onReady: (MetadataEvent) -> Unit,
|
|
||||||
) {
|
|
||||||
val prop = ObjectMapper().createObjectNode()
|
|
||||||
prop.put("name", newName.trim())
|
|
||||||
|
|
||||||
val writer = StringWriter()
|
|
||||||
ObjectMapper().writeValue(writer, prop)
|
|
||||||
|
|
||||||
val tags = mutableListOf<Array<String>>()
|
|
||||||
|
|
||||||
tags.add(
|
|
||||||
arrayOf("alt", "User profile for $newName"),
|
|
||||||
)
|
|
||||||
|
|
||||||
signer.sign(createdAt, KIND, tags.toTypedArray(), writer.buffer.toString(), onReady)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user