Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication: Profile picture dialog + usage in other places #204

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a07b44e
added lectureMarkdownPattern to markdown transformer
julian-wls Oct 24, 2024
31d6c5b
fixed links not opening inside the app
julian-wls Oct 27, 2024
4435755
Merge branch 'develop' into bugfix/communication/attachments-rendering
julian-wls Nov 13, 2024
8fddcb2
changed regex to distinguish between images and other files
julian-wls Nov 14, 2024
95120ee
added DefaultImageProvider to create ImageRequests and markdown Image…
julian-wls Nov 15, 2024
92f76c7
changed ImageRequest in DragAndDropWorkArea to use DefaultImageProvider
julian-wls Nov 15, 2024
0fcec6e
resolved merge conflict
julian-wls Nov 15, 2024
b8008a3
Merge branch 'develop' into bugfix/communication/attachments-rendering
julian-wls Nov 16, 2024
a7f37e7
changed parameters to only pass imageLoader down
julian-wls Nov 16, 2024
1732191
changes to add fixed size to images
julian-wls Nov 18, 2024
0f2b510
resolved some of the issues mentioned
julian-wls Nov 19, 2024
9f68876
fixed image sizing
julian-wls Nov 19, 2024
9c6ac81
resolved merge confict
julian-wls Nov 26, 2024
8f83931
minor changes
julian-wls Nov 26, 2024
cbd5289
minor changes
julian-wls Nov 26, 2024
ae42d96
Added authorImageUrl to posts
FelberMartin Nov 16, 2024
8801742
Started with compose impl
FelberMartin Nov 16, 2024
d6aa2fe
Add author_image_url to database queries
FelberMartin Nov 17, 2024
6a489ae
Showing profile pictures in chatlist
FelberMartin Nov 17, 2024
9ee564e
Added profile pictures to thread ui
FelberMartin Nov 17, 2024
f907a70
Add test for displaying profile picture
FelberMartin Nov 18, 2024
cf92ff0
Added role icon
FelberMartin Nov 18, 2024
63a5c44
Renaming
FelberMartin Nov 18, 2024
9159639
Created string resources for create_reply
FelberMartin Nov 19, 2024
f9935f9
Fixed merge issues
FelberMartin Nov 20, 2024
c0473c4
Addressing small change requests
FelberMartin Nov 26, 2024
715d199
Merge remote-tracking branch 'origin/bugfix/communication/attachments…
FelberMartin Nov 26, 2024
29389c4
Started using CompositionLocal; introduced ArtemisImageProvider
FelberMartin Nov 26, 2024
b3e3668
Merge branch 'develop' into bugfix/communication/attachments-rendering
FelberMartin Nov 28, 2024
944415e
Providing compositionLocals in MainActivity
FelberMartin Nov 28, 2024
1c0a4b7
remember imagerequest
FelberMartin Nov 28, 2024
5c17f3f
Introduced ProfilePictureData.Unknown
FelberMartin Nov 28, 2024
c8723c4
Remove authorImageUrl from posts
FelberMartin Nov 28, 2024
157cb1a
Updated tests + addressed remaining comments
FelberMartin Nov 29, 2024
62842d0
Merge branch 'develop' into bugfix/communication/attachments-rendering
FelberMartin Nov 29, 2024
75e2513
Merge branch 'develop' into bugfix/communication/attachments-rendering
FelberMartin Nov 29, 2024
edc6183
Merge remote-tracking branch 'origin/develop' into feature/communicat…
FelberMartin Nov 29, 2024
5e4d39b
Migrated most files to use coil3
FelberMartin Nov 29, 2024
01c83fd
Remaining files using coil3 (except for markwon)
FelberMartin Nov 29, 2024
5ed6040
Merge branch 'develop' into bugfix/communication/attachments-rendering
FelberMartin Nov 29, 2024
5f8717a
Merge branch 'bugfix/communication/attachments-rendering' into featur…
FelberMartin Nov 30, 2024
4c9eb09
Fix empty username crash
FelberMartin Nov 30, 2024
131b6e0
Merge branch 'feature/communication/show-profile-picture' into chore/…
FelberMartin Nov 30, 2024
fe7b816
Fix merge bug
FelberMartin Nov 30, 2024
e81c658
Merge branch 'feature/communication/show-profile-picture' into chore/…
FelberMartin Nov 30, 2024
7ad3da1
Fix tests
FelberMartin Nov 30, 2024
e3e3651
Trying to create ui-test sub-module
FelberMartin Nov 30, 2024
de2e670
Remove duplicate dependency
FelberMartin Nov 30, 2024
9c34d23
added :core:ui to :core:ui-test
julian-wls Dec 2, 2024
37d2d02
Merge remote-tracking branch 'origin/develop' into feature/communicat…
FelberMartin Dec 5, 2024
75395d3
Update database schema version to 12
FelberMartin Dec 5, 2024
2e4f53b
Fix tests
FelberMartin Dec 5, 2024
02479e1
Merge branch 'develop' into feature/communication/show-profile-picture
FelberMartin Dec 5, 2024
5da05f9
Create ArtemisImageProviderStub
FelberMartin Dec 5, 2024
5b51f31
Using ArtemisImageProvider for Courses
FelberMartin Dec 5, 2024
8544bf4
Remove CourseImageProvider.kt and use new provider in playstore scree…
FelberMartin Dec 5, 2024
446d80a
Fix tests
FelberMartin Dec 6, 2024
d61ad8b
Use ArtemisImageProvider for Markwon images
FelberMartin Dec 6, 2024
d907d97
WIP
FelberMartin Dec 6, 2024
61d6519
Use ArtemisImageProvider for Drag n Drop exercises
FelberMartin Dec 6, 2024
7d7135d
BaseImageProvider now takes the full imageUrl
FelberMartin Dec 6, 2024
d956b45
Merge branch 'feature/communication/show-profile-picture' into chore/…
FelberMartin Dec 6, 2024
4d5043c
Fix tests
FelberMartin Dec 6, 2024
ae814c9
restructure
FelberMartin Dec 6, 2024
5e0829b
Added UserProfileDialog; navigation is not working yet
FelberMartin Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import android.app.Application
import android.app.NotificationChannel
import android.os.Bundle
import androidx.core.app.NotificationManagerCompat
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.memory.MemoryCache
import coil3.ImageLoader
import coil3.PlatformContext
import coil3.SingletonImageLoader
import coil3.memory.MemoryCache
import de.tum.informatics.www1.artemis.native_app.android.db.dbModule
import de.tum.informatics.www1.artemis.native_app.core.common.ArtemisNotificationChannel
import de.tum.informatics.www1.artemis.native_app.core.common.CurrentActivityListener
import de.tum.informatics.www1.artemis.native_app.core.data.dataModule
import de.tum.informatics.www1.artemis.native_app.core.datastore.datastoreModule
Expand All @@ -22,7 +24,6 @@ import de.tum.informatics.www1.artemis.native_app.feature.exerciseview.exerciseM
import de.tum.informatics.www1.artemis.native_app.feature.lectureview.lectureModule
import de.tum.informatics.www1.artemis.native_app.feature.login.loginModule
import de.tum.informatics.www1.artemis.native_app.feature.metis.communicationModule
import de.tum.informatics.www1.artemis.native_app.core.common.ArtemisNotificationChannel
import de.tum.informatics.www1.artemis.native_app.feature.push.pushModule
import de.tum.informatics.www1.artemis.native_app.feature.quiz.quizParticipationModule
import de.tum.informatics.www1.artemis.native_app.feature.settings.settingsModule
Expand All @@ -32,7 +33,7 @@ import org.koin.android.ext.koin.androidContext
import org.koin.androidx.workmanager.koin.workManagerFactory
import org.koin.core.context.startKoin

class ArtemisApplication : Application(), ImageLoaderFactory, CurrentActivityListener {
class ArtemisApplication : Application(), SingletonImageLoader.Factory, CurrentActivityListener {

override val currentActivity = MutableStateFlow<Activity?>(null)

Expand Down Expand Up @@ -84,11 +85,11 @@ class ArtemisApplication : Application(), ImageLoaderFactory, CurrentActivityLis
registerActivityLifecycleCallbacks(this)
}

override fun newImageLoader(): ImageLoader =
override fun newImageLoader(context: PlatformContext): ImageLoader =
ImageLoader.Builder(this)
.memoryCache {
MemoryCache.Builder(this)
.maxSizePercent(0.25)
MemoryCache.Builder()
.maxSizePercent(context, 0.25)
.build()
}
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import de.tum.informatics.www1.artemis.native_app.feature.push.communication_not
CommunicationMessageEntity::class
],
exportSchema = true,
version = 11,
version = 12,
)
@TypeConverters(RoomTypeConverters::class)
abstract class AppDatabase : RoomDatabase() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import de.tum.informatics.www1.artemis.native_app.core.ui.LocalLinkOpener
import de.tum.informatics.www1.artemis.native_app.core.ui.LocalWindowSizeClassProvider
import de.tum.informatics.www1.artemis.native_app.core.ui.WindowSizeClassProvider
import de.tum.informatics.www1.artemis.native_app.core.ui.alert.TextAlertDialog
import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.LocalArtemisImageProvider
import de.tum.informatics.www1.artemis.native_app.feature.courseregistration.courseRegistration
import de.tum.informatics.www1.artemis.native_app.feature.courseregistration.navigateToCourseRegistration
import de.tum.informatics.www1.artemis.native_app.feature.courseview.ui.course_overview.course
Expand All @@ -53,7 +54,7 @@ import de.tum.informatics.www1.artemis.native_app.feature.lectureview.navigateTo
import de.tum.informatics.www1.artemis.native_app.feature.login.LoginScreen
import de.tum.informatics.www1.artemis.native_app.feature.login.loginScreen
import de.tum.informatics.www1.artemis.native_app.feature.login.navigateToLogin
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.visiblemetiscontextreporter.ProvideLocalVisibleMetisContextManager
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.visiblemetiscontextreporter.LocalVisibleMetisContextManager
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.visiblemetiscontextreporter.VisibleMetisContext
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.visiblemetiscontextreporter.VisibleMetisContextManager
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.visiblemetiscontextreporter.VisibleMetisContextReporter
Expand All @@ -73,6 +74,7 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.koin.android.ext.android.get
import org.koin.compose.koinInject

/**
* Main and only activity used in the android app.
Expand Down Expand Up @@ -134,8 +136,8 @@ class MainActivity : AppCompatActivity(),

setContent {
AppTheme {
ProvideLocalVisibleMetisContextManager(
visibleMetisContextManager = visibleMetisContextManager
CompositionLocalProvider(
LocalVisibleMetisContextManager provides visibleMetisContextManager,
) {
val navController = rememberNavController()

Expand Down Expand Up @@ -251,7 +253,8 @@ class MainActivity : AppCompatActivity(),

CompositionLocalProvider(
LocalWindowSizeClassProvider provides windowSizeClassProvider,
LocalLinkOpener provides linkOpener
LocalLinkOpener provides linkOpener,
LocalArtemisImageProvider provides koinInject()
) {
// Use jetpack compose navigation for the navigation logic.
NavHost(navController = navController, startDestination = startDestination) {
Expand Down
1 change: 1 addition & 0 deletions core/core-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
implementation(project(":core:common"))
api(project(":core:common-test"))
implementation(project(":core:ui"))
api(project(":core:ui-test"))
implementation(project(":core:datastore"))
implementation(project(":core:device"))
api(project(":core:device-test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import de.tum.informatics.www1.artemis.native_app.core.data.test.testDataModule
import de.tum.informatics.www1.artemis.native_app.core.datastore.ServerConfigurationService
import de.tum.informatics.www1.artemis.native_app.core.datastore.datastoreModule
import de.tum.informatics.www1.artemis.native_app.core.test.test_setup.TestServerConfigurationProvider
import de.tum.informatics.www1.artemis.native_app.core.ui.uiModule
import de.tum.informatics.www1.artemis.native_app.core.ui.test.uiTestModule
import de.tum.informatics.www1.artemis.native_app.core.websocket.websocketModule
import de.tum.informatics.www1.artemis.native_app.device.test.deviceTestModule
import org.koin.dsl.module
Expand All @@ -15,7 +15,7 @@ val coreTestModules = listOf(
testDataModule,
datastoreModule,
deviceTestModule,
uiModule,
uiTestModule,
websocketModule,
module {
single<ServerConfigurationService> { TestServerConfigurationProvider() }
Expand Down
18 changes: 18 additions & 0 deletions core/ui-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("artemis.android.library")
id("artemis.android.library.compose")
id("artemis.android.flavor.library.instanceSelection")
}

android {
namespace = "de.tum.informatics.www1.artemis.native_app.core.ui.test"
}

dependencies {
implementation(project(":core:ui"))

implementation(libs.koin.core)
implementation(libs.kotlinx.coroutines.core)

implementation(libs.coil.test)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.test

import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.annotation.DelicateCoilApi
import coil3.request.ImageRequest
import coil3.test.FakeImage
import coil3.test.FakeImageLoaderEngine
import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.ArtemisImageProvider


@OptIn(DelicateCoilApi::class)
class ArtemisImageProviderStub : ArtemisImageProvider {

companion object {
fun setup(context: Context) {
// For more info on testing coil, see: https://coil-kt.github.io/coil/testing/
val engine = FakeImageLoaderEngine.Builder()
.default(FakeImage(color = 0x00F))
.build()
val imageLoader = ImageLoader.Builder(context)
.components { add(engine) }
.build()
SingletonImageLoader.setUnsafe(imageLoader)
}
}

@Composable
override fun rememberArtemisImageRequest(imagePath: String): ImageRequest {
return ImageRequest.Builder(LocalContext.current)
.data(imagePath)
.build()
}

@Composable
override fun rememberArtemisImageLoader(): coil.ImageLoader {
return coil.ImageLoader(LocalContext.current)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.test

import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.ArtemisImageProvider
import org.koin.dsl.module

val uiTestModule = module {
single<ArtemisImageProvider> { ArtemisImageProviderStub() }
}
4 changes: 4 additions & 0 deletions core/ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ dependencies {
api(libs.androidx.compose.ui.util)
api(libs.androidx.compose.runtime)
api(libs.androidx.navigation.compose)
api(libs.coil2.base)
api(libs.coil.compose)
api(libs.coil.network)
debugApi(libs.coil.compose.core)
debugApi(libs.coil.test)
api(libs.accompanist.webview)

implementation(libs.kotlinx.datetime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.grid.GridCells
Expand Down Expand Up @@ -56,11 +49,11 @@ import androidx.compose.ui.unit.sp
import androidx.core.graphics.toColorInt
import de.tum.informatics.www1.artemis.native_app.core.model.Course
import de.tum.informatics.www1.artemis.native_app.core.model.CourseWithScore
import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.LocalCourseImageProvider
import de.tum.informatics.www1.artemis.native_app.core.ui.R
import de.tum.informatics.www1.artemis.native_app.core.ui.common.AutoResizeText
import de.tum.informatics.www1.artemis.native_app.core.ui.common.FontSizeRange
import de.tum.informatics.www1.artemis.native_app.core.ui.getWindowSizeClass
import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.LocalArtemisImageProvider

private val headerHeight = 80.dp

Expand Down Expand Up @@ -107,13 +100,11 @@ fun Modifier.computeCourseItemModifier(isCompact: Boolean): Modifier {
fun CompactCourseItemHeader(
modifier: Modifier,
course: Course,
serverUrl: String,
authorizationToken: String,
compactCourseHeaderViewMode: CompactCourseHeaderViewMode,
onClick: () -> Unit = {},
content: @Composable ColumnScope.() -> Unit
) {
val painter = getCourseIconPainter(course, serverUrl, authorizationToken)
val painter = getCourseIconPainter(course)

Card(modifier = modifier, onClick = onClick) {
Column(
Expand Down Expand Up @@ -180,14 +171,10 @@ fun CompactCourseItemHeader(
@Composable
private fun getCourseIconPainter(
course: Course,
serverUrl: String,
authorizationToken: String
): Painter {
return if (course.courseIconPath != null) {
LocalCourseImageProvider.current.rememberCourseImagePainter(
courseIconPath = course.courseIconPath.orEmpty(),
serverUrl = serverUrl,
authorizationToken = authorizationToken
LocalArtemisImageProvider.current.rememberArtemisAsyncImagePainter(
imagePath = course.courseIconPath.orEmpty()
)
} else rememberVectorPainter(image = Icons.Default.QuestionMark)
}
Expand All @@ -196,13 +183,11 @@ private fun getCourseIconPainter(
fun ExpandedCourseItemHeader(
modifier: Modifier,
course: Course,
serverUrl: String,
authorizationToken: String,
onClick: () -> Unit = {},
content: @Composable ColumnScope.() -> Unit,
rightHeaderContent: @Composable BoxScope.() -> Unit
) {
val courseIconPainter = getCourseIconPainter(course, serverUrl, authorizationToken)
val courseIconPainter = getCourseIconPainter(course)

val courseColor: Color? = remember {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.common.image

import android.graphics.drawable.Drawable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
Expand All @@ -9,16 +8,17 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import coil.imageLoader
import coil.request.ErrorResult
import coil.request.ImageRequest
import coil.request.SuccessResult
import coil3.Image
import coil3.imageLoader
import coil3.request.ErrorResult
import coil3.request.ImageRequest
import coil3.request.SuccessResult
import de.tum.informatics.www1.artemis.native_app.core.data.DataState

@Composable
fun loadAsyncImageDrawable(request: ImageRequest): AsyncImageDrawableResult {
val context = LocalContext.current
var dataState: DataState<Drawable> by remember(request) { mutableStateOf(DataState.Loading()) }
var dataState: DataState<Image> by remember(request) { mutableStateOf(DataState.Loading()) }

// We simply increase this counter to trigger a reload
var reloadCounter by remember(request) { mutableStateOf(0) }
Expand All @@ -31,7 +31,7 @@ fun loadAsyncImageDrawable(request: ImageRequest): AsyncImageDrawableResult {
}

is SuccessResult -> {
DataState.Success(result.drawable)
DataState.Success(result.image)
}
}
}
Expand All @@ -48,6 +48,6 @@ fun loadAsyncImageDrawable(request: ImageRequest): AsyncImageDrawableResult {
}

data class AsyncImageDrawableResult(
val dataState: DataState<Drawable>,
val dataState: DataState<Image>,
val requestRetry: () -> Unit
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.common

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp

val TextUnit.nonScaledSp
@Composable
get() = (this.value / LocalDensity.current.fontScale).sp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import coil.ImageLoader
import de.tum.informatics.www1.artemis.native_app.core.ui.remote_images.LocalArtemisImageProvider
import io.noties.markwon.Markwon

val LocalMarkwon: ProvidableCompositionLocal<Markwon?> =
compositionLocalOf { null }

@Composable
fun ProvideMarkwon(imageLoader: ImageLoader? = null, content: @Composable () -> Unit) {
fun ProvideMarkwon(content: @Composable () -> Unit) {
val imageLoader = LocalArtemisImageProvider.current.rememberArtemisImageLoader()
val context = LocalContext.current

val imageWith = context.resources.displayMetrics.widthPixels
Expand Down
Loading