-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: support user mentions (#10)
* Support displaying user mentions in posts and push notifications. * Use simple ext plugin instead. * Support user autocomplete on smartphones. * Automatic popup position and height restriction. Ondismiss request. * Only show non-empty user autocompletion popups. * Fix merge problems.
- Loading branch information
Showing
33 changed files
with
643 additions
and
104 deletions.
There are no files selected for viewing
30 changes: 25 additions & 5 deletions
30
...um/informatics/www1/artemis/native_app/core/common/markdown/ArtemisMarkdownTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.common.markdown | ||
|
||
object ArtemisMarkdownTransformer { | ||
abstract class ArtemisMarkdownTransformer { | ||
|
||
private val customMarkdownPattern = "\\[(text|quiz|lecture|modeling|file-upload|programing)](.*)\\(((?:/|\\w|\\d)+)\\)\\[/\\1]".toRegex() | ||
private val exerciseMarkdownPattern = | ||
"\\[(text|quiz|lecture|modeling|file-upload|programing)](.*)\\(((?:/|\\w|\\d)+)\\)\\[/\\1]".toRegex() | ||
private val userMarkdownPattern = "\\[user](.*?)\\((.*?)\\)\\[/user]".toRegex() | ||
|
||
fun transformMarkdown(markdown: String, serverUrl: String): String { | ||
return customMarkdownPattern.replace(markdown) { matchResult -> | ||
fun transformMarkdown(markdown: String): String { | ||
return exerciseMarkdownPattern.replace(markdown) { matchResult -> | ||
val title = matchResult.groups[2]?.value.orEmpty() | ||
val url = matchResult.groups[3]?.value.orEmpty() | ||
"[$title]($serverUrl$url)" | ||
transformExerciseMarkdown(title, url) | ||
}.let { | ||
userMarkdownPattern.replace(it) { matchResult -> | ||
val fullName = matchResult.groups[1]?.value.orEmpty() | ||
val userName = matchResult.groups[2]?.value.orEmpty() | ||
transformUserMentionMarkdown( | ||
text = matchResult.groups[0]?.value.orEmpty(), | ||
fullName = fullName, | ||
userName = userName | ||
) | ||
} | ||
} | ||
} | ||
|
||
protected abstract fun transformExerciseMarkdown(title: String, url: String): String | ||
|
||
protected abstract fun transformUserMentionMarkdown( | ||
text: String, | ||
fullName: String, | ||
userName: String | ||
): String | ||
} |
9 changes: 9 additions & 0 deletions
9
...nformatics/www1/artemis/native_app/core/common/markdown/PostArtemisMarkdownTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.common.markdown | ||
|
||
class PostArtemisMarkdownTransformer(val serverUrl: String) : ArtemisMarkdownTransformer() { | ||
override fun transformExerciseMarkdown(title: String, url: String): String { | ||
return "[$title]($serverUrl$url)" | ||
} | ||
|
||
override fun transformUserMentionMarkdown(text: String, fullName: String, userName: String): String = "|||@$fullName|||" | ||
} |
8 changes: 8 additions & 0 deletions
8
...ww1/artemis/native_app/core/common/markdown/PushNotificationArtemisMarkdownTransformer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.common.markdown | ||
|
||
object PushNotificationArtemisMarkdownTransformer : ArtemisMarkdownTransformer() { | ||
|
||
override fun transformExerciseMarkdown(title: String, url: String): String = title | ||
|
||
override fun transformUserMentionMarkdown(text: String, fullName: String, userName: String): String = "@$fullName" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...atics/www1/artemis/native_app/feature/metis/conversation/ui/reply/AutoCompleteCategory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.reply | ||
|
||
import androidx.annotation.StringRes | ||
|
||
class AutoCompleteCategory(@StringRes val name: Int, val items: List<AutoCompleteHint>) |
3 changes: 3 additions & 0 deletions
3
...formatics/www1/artemis/native_app/feature/metis/conversation/ui/reply/AutoCompleteHint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.reply | ||
|
||
data class AutoCompleteHint(val hint: String, val replacementText: String, val id: String) |
5 changes: 3 additions & 2 deletions
5
...s/www1/artemis/native_app/feature/metis/conversation/ui/reply/InitialReplyTextProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.reply | ||
|
||
import androidx.compose.ui.text.input.TextFieldValue | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface InitialReplyTextProvider { | ||
|
||
val newMessageText: Flow<String> | ||
val newMessageText: Flow<TextFieldValue> | ||
|
||
fun updateInitialReplyText(text: String) | ||
fun updateInitialReplyText(text: TextFieldValue) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...1/artemis/native_app/feature/metis/conversation/ui/reply/ReplyAutoCompleteHintProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.reply | ||
|
||
import androidx.compose.runtime.ProvidableCompositionLocal | ||
import androidx.compose.runtime.compositionLocalOf | ||
import de.tum.informatics.www1.artemis.native_app.core.data.DataState | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flowOf | ||
|
||
internal val LocalReplyAutoCompleteHintProvider: ProvidableCompositionLocal<ReplyAutoCompleteHintProvider> = compositionLocalOf { | ||
object : ReplyAutoCompleteHintProvider { | ||
override val legalTagChars: List<Char> = emptyList() | ||
|
||
override fun produceAutoCompleteHints( | ||
tagChar: Char, | ||
query: String | ||
): Flow<DataState<List<AutoCompleteCategory>>> = flowOf(DataState.Success(emptyList())) | ||
} | ||
} | ||
|
||
internal interface ReplyAutoCompleteHintProvider { | ||
|
||
val legalTagChars: List<Char> | ||
|
||
fun produceAutoCompleteHints( | ||
tagChar: Char, | ||
query: String | ||
): Flow<DataState<List<AutoCompleteCategory>>> | ||
} |
Oops, something went wrong.