Add support to `/devtools` command
This commit is contained in:
parent
f67cf0d591
commit
8623b85ac8
|
@ -215,7 +215,7 @@ Rageshake can be very useful to get logs from a release version of the applicati
|
|||
|
||||
- Element Android has a `developer mode` in the `Settings/Advanced settings`. Other useful options are available here;
|
||||
- Show hidden Events can also help to debug feature. When devepor mode is enabled, it is possible to view the source (= the Json content) of any Events;
|
||||
- Type `/devtools` in Element Web to access a developer menu. On Element Android, available in the Menu of a Room timeline, after enabling developer mode;
|
||||
- Type `/devtools` in a Room composer to access a developer menu. There are some other entry points. Developer mode has to be enabled;
|
||||
- Hidden debug menu: when developer mode is enabled and on debug build, there are some extra screens that can be accessible using the green wheel. In those screens, it will be possible to toggle some feature flags;
|
||||
- Using logcat, filtering with `onResume` can help you to understand what screen are currently displayed on your device. Searching for string displayed on the screen can also help to find the running code in the codebase.
|
||||
- When this is possible, prefer using `sealed interface` instead of `sealed class`;
|
||||
|
|
|
@ -1402,6 +1402,7 @@
|
|||
<string name="command_description_avatar_for_room">Changes your avatar in this current room only</string>
|
||||
<string name="command_description_markdown">On/Off markdown</string>
|
||||
<string name="command_description_clear_scalar_token">To fix Matrix Apps management</string>
|
||||
<string name="command_description_devtools">Open the developer tools screen</string>
|
||||
<string name="command_description_whois">Displays information about a user</string>
|
||||
|
||||
<string name="markdown_has_been_enabled">Markdown has been enabled.</string>
|
||||
|
|
|
@ -52,6 +52,7 @@ enum class Command(
|
|||
MARKDOWN("/markdown", null, "<on|off>", R.string.command_description_markdown, false, false),
|
||||
RAINBOW("/rainbow", null, "<message>", R.string.command_description_rainbow, false, true),
|
||||
RAINBOW_EMOTE("/rainbowme", null, "<message>", R.string.command_description_rainbow_emote, false, true),
|
||||
DEVTOOLS("/devtools", null, "", R.string.command_description_devtools, true, false),
|
||||
CLEAR_SCALAR_TOKEN("/clear_scalar_token", null, "", R.string.command_description_clear_scalar_token, false, false),
|
||||
SPOILER("/spoiler", null, "<message>", R.string.command_description_spoiler, false, true),
|
||||
SHRUG("/shrug", null, "<message>", R.string.command_description_shrug, false, true),
|
||||
|
|
|
@ -317,6 +317,13 @@ class CommandParser @Inject constructor() {
|
|||
ParsedCommand.ErrorSyntax(Command.MARKDOWN)
|
||||
}
|
||||
}
|
||||
Command.DEVTOOLS.matches(slashCommand) -> {
|
||||
if (messageParts.size == 1) {
|
||||
ParsedCommand.DevTools
|
||||
} else {
|
||||
ParsedCommand.ErrorSyntax(Command.DEVTOOLS)
|
||||
}
|
||||
}
|
||||
Command.CLEAR_SCALAR_TOKEN.matches(slashCommand) -> {
|
||||
if (messageParts.size == 1) {
|
||||
ParsedCommand.ClearScalarToken
|
||||
|
|
|
@ -60,6 +60,7 @@ sealed interface ParsedCommand {
|
|||
data class ChangeAvatarForRoom(val url: String) : ParsedCommand
|
||||
data class SetMarkdown(val enable: Boolean) : ParsedCommand
|
||||
object ClearScalarToken : ParsedCommand
|
||||
object DevTools : ParsedCommand
|
||||
data class SendSpoiler(val message: String) : ParsedCommand
|
||||
data class SendShrug(val message: CharSequence) : ParsedCommand
|
||||
data class SendLenny(val message: CharSequence) : ParsedCommand
|
||||
|
|
|
@ -1810,6 +1810,9 @@ class TimelineFragment :
|
|||
dismissLoadingDialog()
|
||||
views.composerLayout.setTextIfDifferent("")
|
||||
when (parsedCommand) {
|
||||
is ParsedCommand.DevTools -> {
|
||||
navigator.openDevTools(requireContext(), timelineArgs.roomId)
|
||||
}
|
||||
is ParsedCommand.SetMarkdown -> {
|
||||
showSnackWithMessage(getString(if (parsedCommand.enable) R.string.markdown_has_been_enabled else R.string.markdown_has_been_disabled))
|
||||
}
|
||||
|
|
|
@ -255,6 +255,10 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||
is ParsedCommand.SetUserPowerLevel -> {
|
||||
handleSetUserPowerLevel(parsedCommand)
|
||||
}
|
||||
is ParsedCommand.DevTools -> {
|
||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand))
|
||||
popDraft()
|
||||
}
|
||||
is ParsedCommand.ClearScalarToken -> {
|
||||
// TODO
|
||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandNotImplemented)
|
||||
|
|
Loading…
Reference in New Issue