mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-05-09 10:54:31 +02:00
feat: fidelius indicator
This commit is contained in:
parent
3b0b44fcd4
commit
b232dbc056
@ -314,6 +314,10 @@
|
|||||||
"enable_friend_feed_menu_bar": {
|
"enable_friend_feed_menu_bar": {
|
||||||
"name": "Friend Feed Menu Bar",
|
"name": "Friend Feed Menu Bar",
|
||||||
"description": "Enables the new Friend Feed Menu Bar"
|
"description": "Enables the new Friend Feed Menu Bar"
|
||||||
|
},
|
||||||
|
"fidelius_indicator": {
|
||||||
|
"name": "Fidelius Indicator",
|
||||||
|
"description": "Adds a green circle next to messages that have been sent only to you"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -47,4 +47,5 @@ class UserInterfaceTweaks : ConfigContainer() {
|
|||||||
val disableSpotlight = boolean("disable_spotlight") { requireRestart() }
|
val disableSpotlight = boolean("disable_spotlight") { requireRestart() }
|
||||||
val hideSettingsGear = boolean("hide_settings_gear") { requireRestart() }
|
val hideSettingsGear = boolean("hide_settings_gear") { requireRestart() }
|
||||||
val verticalStoryViewer = boolean("vertical_story_viewer") { requireRestart() }
|
val verticalStoryViewer = boolean("vertical_story_viewer") { requireRestart() }
|
||||||
|
val fideliusIndicator = boolean("fidelius_indicator") { requireRestart() }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package me.rhunk.snapenhance.core.features.impl.ui
|
||||||
|
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.drawable.ShapeDrawable
|
||||||
|
import android.graphics.drawable.shapes.Shape
|
||||||
|
import me.rhunk.snapenhance.common.data.ContentType
|
||||||
|
import me.rhunk.snapenhance.common.util.protobuf.ProtoReader
|
||||||
|
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||||
|
import me.rhunk.snapenhance.core.features.Feature
|
||||||
|
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||||
|
import me.rhunk.snapenhance.core.ui.addForegroundDrawable
|
||||||
|
import me.rhunk.snapenhance.core.ui.removeForegroundDrawable
|
||||||
|
|
||||||
|
class FideliusIndicator : Feature("Fidelius Indicator", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) {
|
||||||
|
override fun onActivityCreate() {
|
||||||
|
if (!context.config.userInterface.fideliusIndicator.get()) return
|
||||||
|
|
||||||
|
context.event.subscribe(BindViewEvent::class) { event ->
|
||||||
|
event.chatMessage { _, messageId ->
|
||||||
|
event.view.removeForegroundDrawable("fideliusIndicator")
|
||||||
|
|
||||||
|
val message = context.database.getConversationMessageFromId(messageId.toLong()) ?: return@chatMessage
|
||||||
|
if (message.senderId == context.database.myUserId) return@chatMessage
|
||||||
|
if (message.contentType != ContentType.SNAP.id && message.contentType != ContentType.EXTERNAL_MEDIA.id) return@chatMessage
|
||||||
|
|
||||||
|
if (!ProtoReader(message.messageContent ?: return@chatMessage).containsPath(4, 3, 3, 6)) return@chatMessage
|
||||||
|
|
||||||
|
event.view.addForegroundDrawable("fideliusIndicator", ShapeDrawable(object: Shape() {
|
||||||
|
override fun draw(canvas: Canvas, paint: Paint) {
|
||||||
|
val margin = 25f
|
||||||
|
val radius = 15f
|
||||||
|
|
||||||
|
canvas.drawCircle(margin + radius, canvas.height - margin - radius, radius, paint.apply {
|
||||||
|
color = 0xFF00FF00.toInt()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -110,6 +110,7 @@ class FeatureManager(
|
|||||||
DisableConfirmationDialogs::class,
|
DisableConfirmationDialogs::class,
|
||||||
Stories::class,
|
Stories::class,
|
||||||
DisableComposerModules::class,
|
DisableComposerModules::class,
|
||||||
|
FideliusIndicator::class,
|
||||||
)
|
)
|
||||||
|
|
||||||
initializeFeatures()
|
initializeFeatures()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user