mirror of
https://github.com/Steffo99/twom.git
synced 2024-11-21 23:54:26 +00:00
Refactor again and cleanup avatar stuff
This commit is contained in:
parent
d660c52b91
commit
c56c0124e8
76 changed files with 376 additions and 337 deletions
|
@ -31,7 +31,7 @@
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.MainActivity"
|
android:name=".main.activities.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:theme="@style/Theme.TwoM">
|
android:theme="@style/Theme.TwoM">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -41,15 +41,15 @@
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.LoginActivity"
|
android:name=".login.activities.LoginActivity"
|
||||||
android:theme="@style/Theme.TwoM" />
|
android:theme="@style/Theme.TwoM" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ViewRoomActivity"
|
android:name=".viewroom.activities.ViewRoomActivity"
|
||||||
android:theme="@style/Theme.TwoM" />
|
android:theme="@style/Theme.TwoM" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.ConfigureRoomActivity"
|
android:name=".configureroom.activities.ConfigureRoomActivity"
|
||||||
android:theme="@style/Theme.TwoM" />
|
android:theme="@style/Theme.TwoM" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.components
|
package eu.steffo.twom.avatar.components
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.components
|
package eu.steffo.twom.avatar.components
|
||||||
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.steffo.twom.composables.avatar.components
|
package eu.steffo.twom.avatar.components
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.composables.avatar.effects.bitmapFromMatrixFile
|
import eu.steffo.twom.avatar.effects.bitmapFromMatrixUrl
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview(name = "Regular", widthDp = 40, heightDp = 40)
|
@Preview(name = "Regular", widthDp = 40, heightDp = 40)
|
||||||
|
@ -19,7 +19,7 @@ fun AvatarURL(
|
||||||
) {
|
) {
|
||||||
AvatarImage(
|
AvatarImage(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
bitmap = bitmapFromMatrixFile(url)?.asImageBitmap(),
|
bitmap = bitmapFromMatrixUrl(url)?.asImageBitmap(),
|
||||||
fallbackText = fallbackText,
|
fallbackText = fallbackText,
|
||||||
contentDescription = contentDescription,
|
contentDescription = contentDescription,
|
||||||
alpha = alpha,
|
alpha = alpha,
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.components
|
package eu.steffo.twom.avatar.components
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.steffo.twom.composables.avatar.components
|
package eu.steffo.twom.avatar.components
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.composables.avatar.effects.avatarUrlFromUserId
|
import eu.steffo.twom.avatar.effects.avatarUrlFromUserId
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview(name = "Regular", widthDp = 40, heightDp = 40)
|
@Preview(name = "Regular", widthDp = 40, heightDp = 40)
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.effects
|
package eu.steffo.twom.avatar.effects
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -7,7 +7,7 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
|
|
||||||
private const val TAG = "avatarUrlFromUserId"
|
private const val TAG = "avatarUrlFromUserId"
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.effects
|
package eu.steffo.twom.avatar.effects
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -8,10 +8,8 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import eu.steffo.twom.avatar.utils.getSqOrBitmapFromUri
|
||||||
import androidx.core.net.toUri
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
|
||||||
import eu.steffo.twom.utils.BitmapUtilities
|
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import org.matrix.android.sdk.api.util.md5
|
import org.matrix.android.sdk.api.util.md5
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -19,9 +17,8 @@ import java.io.File
|
||||||
private const val TAG = "bitmapFromMatrixFile"
|
private const val TAG = "bitmapFromMatrixFile"
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun bitmapFromMatrixFile(url: String? = null): Bitmap? {
|
fun bitmapFromMatrixUrl(url: String? = null): Bitmap? {
|
||||||
val session = LocalSession.current
|
val session = LocalSession.current
|
||||||
val resolver = LocalContext.current.contentResolver
|
|
||||||
|
|
||||||
var bitmap by remember { mutableStateOf<Bitmap?>(null) }
|
var bitmap by remember { mutableStateOf<Bitmap?>(null) }
|
||||||
|
|
||||||
|
@ -68,8 +65,7 @@ fun bitmapFromMatrixFile(url: String? = null): Bitmap? {
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "File for $url is: $file")
|
Log.d(TAG, "File for $url is: $file")
|
||||||
|
bitmap = getSqOrBitmapFromUri(file)
|
||||||
bitmap = BitmapUtilities.getCorrectedBitmap(resolver, file.toUri())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bitmap
|
return bitmap
|
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
fun getSqOrBitmapFromUri(file: File): Bitmap {
|
||||||
|
file.inputStream().use { is1 ->
|
||||||
|
file.inputStream().use { is2 ->
|
||||||
|
return getSqOrBitmapFromStreams(
|
||||||
|
inputStream1 = is1,
|
||||||
|
inputStream2 = is2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import readExifOrientation
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
fun getSqOrBitmapFromStreams(inputStream1: InputStream, inputStream2: InputStream): Bitmap {
|
||||||
|
var orientation: Int
|
||||||
|
inputStream1.use {
|
||||||
|
orientation = it.readExifOrientation()
|
||||||
|
}
|
||||||
|
|
||||||
|
lateinit var bitmap: Bitmap
|
||||||
|
inputStream2.use {
|
||||||
|
bitmap = it.readRawBitmap()
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap.squareAndOrient(orientation)
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.content.ContentResolver
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
|
fun getSqOrBitmapFromUri(contentResolver: ContentResolver, uri: Uri): Bitmap? {
|
||||||
|
contentResolver.openInputStream(uri).use { is1 ->
|
||||||
|
is1 ?: return null
|
||||||
|
contentResolver.openInputStream(uri).use { is2 ->
|
||||||
|
is2 ?: return null
|
||||||
|
return getSqOrBitmapFromStreams(
|
||||||
|
inputStream1 = is1,
|
||||||
|
inputStream2 = is2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
fun InputStream.readExifOrientation(): Int {
|
||||||
|
return ExifInterface(this).getAttributeInt(ExifInterface.TAG_ORIENTATION, 1)
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.BitmapFactory
|
||||||
|
import java.io.InputStream
|
||||||
|
|
||||||
|
fun InputStream.readRawBitmap(): Bitmap {
|
||||||
|
return BitmapFactory.decodeStream(this)
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Matrix
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
|
|
||||||
|
fun Bitmap.squareAndOrient(
|
||||||
|
orientation: Int = ExifInterface.ORIENTATION_NORMAL
|
||||||
|
): Bitmap {
|
||||||
|
// Determine the starting points and the size to crop the image to a 1:1 square
|
||||||
|
val xStart: Int
|
||||||
|
val yStart: Int
|
||||||
|
val size: Int
|
||||||
|
if (this.width > this.height) {
|
||||||
|
yStart = 0
|
||||||
|
xStart = (this.width - this.height) / 2
|
||||||
|
size = this.height
|
||||||
|
} else {
|
||||||
|
xStart = 0
|
||||||
|
yStart = (this.height - this.width) / 2
|
||||||
|
size = this.width
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a transformation matrix to rotate the bitmap based on the orientation
|
||||||
|
val transformationMatrix = Matrix()
|
||||||
|
|
||||||
|
when (orientation) {
|
||||||
|
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> {
|
||||||
|
transformationMatrix.postScale(-1f, 1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_180 -> {
|
||||||
|
transformationMatrix.postRotate(180f)
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_FLIP_VERTICAL -> {
|
||||||
|
transformationMatrix.postScale(1f, -1f)
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
||||||
|
// Untested.
|
||||||
|
transformationMatrix.setValues(FloatArray(16) {
|
||||||
|
if (it == 0 || it == 6 || it == 9 || it == 15) {
|
||||||
|
1f
|
||||||
|
} else {
|
||||||
|
0f
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_90 -> {
|
||||||
|
transformationMatrix.postRotate(90f)
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
||||||
|
// Untested.
|
||||||
|
transformationMatrix.setValues(FloatArray(16) {
|
||||||
|
if (it == 3 || it == 5 || it == 10 || it == 12) {
|
||||||
|
1f
|
||||||
|
} else {
|
||||||
|
0f
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_270 -> {
|
||||||
|
transformationMatrix.postRotate(270f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Bitmap.createBitmap(
|
||||||
|
this,
|
||||||
|
xStart,
|
||||||
|
yStart,
|
||||||
|
size,
|
||||||
|
size,
|
||||||
|
transformationMatrix,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.steffo.twom.avatar.utils
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
fun Bitmap.toCachedFile(id: String): File {
|
||||||
|
val file = File.createTempFile("bitmap_$id", ".jpg")
|
||||||
|
file.outputStream().use {
|
||||||
|
this.compress(Bitmap.CompressFormat.JPEG, 85, it)
|
||||||
|
it.flush()
|
||||||
|
}
|
||||||
|
return file
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.avatar.picker
|
package eu.steffo.twom.avatarpicker.components
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
|
@ -11,7 +11,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.utils.BitmapUtilities
|
import eu.steffo.twom.avatar.utils.getSqOrBitmapFromUri
|
||||||
|
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -29,8 +29,8 @@ fun AvatarPickerWrapbox(
|
||||||
val launcher =
|
val launcher =
|
||||||
rememberLauncherForActivityResult(ActivityResultContracts.PickVisualMedia()) ImageSelect@{
|
rememberLauncherForActivityResult(ActivityResultContracts.PickVisualMedia()) ImageSelect@{
|
||||||
it ?: return@ImageSelect
|
it ?: return@ImageSelect
|
||||||
val correctedBitmap = BitmapUtilities.getCorrectedBitmap(resolver, it)
|
val bitmap = getSqOrBitmapFromUri(resolver, it)
|
||||||
onPick(correctedBitmap)
|
onPick(bitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.activities
|
package eu.steffo.twom.configureroom.activities
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -7,7 +7,7 @@ import android.os.Bundle
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
import eu.steffo.twom.composables.configureroom.ConfigureRoomScaffold
|
import eu.steffo.twom.configureroom.components.ConfigureRoomScaffold
|
||||||
|
|
||||||
|
|
||||||
class ConfigureRoomActivity : ComponentActivity() {
|
class ConfigureRoomActivity : ComponentActivity() {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.configureroom
|
package eu.steffo.twom.configureroom.components
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
@ -30,19 +30,18 @@ import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.activities.ConfigureRoomActivity
|
import eu.steffo.twom.avatar.components.AvatarImage
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarImage
|
import eu.steffo.twom.avatar.components.AvatarURL
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarURL
|
import eu.steffo.twom.avatar.utils.toCachedFile
|
||||||
import eu.steffo.twom.composables.avatar.picker.AvatarPickerWrapbox
|
import eu.steffo.twom.avatarpicker.components.AvatarPickerWrapbox
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||||
import eu.steffo.twom.utils.BitmapUtilities
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
fun ConfigureRoomForm(
|
fun ConfigureRoomForm(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
initialConfiguration: ConfigureRoomActivity.Configuration? = null,
|
initialConfiguration: ConfigureRoomActivity.Configuration? = null,
|
||||||
onSubmit: (ConfigureRoomActivity.Configuration) -> Unit = {},
|
|
||||||
) {
|
) {
|
||||||
var name by rememberSaveable { mutableStateOf(initialConfiguration?.name ?: "") }
|
var name by rememberSaveable { mutableStateOf(initialConfiguration?.name ?: "") }
|
||||||
var description by rememberSaveable { mutableStateOf(initialConfiguration?.description ?: "") }
|
var description by rememberSaveable { mutableStateOf(initialConfiguration?.description ?: "") }
|
||||||
|
@ -118,7 +117,7 @@ fun ConfigureRoomForm(
|
||||||
description = description,
|
description = description,
|
||||||
avatarUri = if (avatarBitmap != null) {
|
avatarUri = if (avatarBitmap != null) {
|
||||||
Uri.fromFile(
|
Uri.fromFile(
|
||||||
BitmapUtilities.bitmapToCache("createAvatar", avatarBitmap!!)
|
avatarBitmap!!.toCachedFile("avatar")
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
|
@ -1,20 +1,20 @@
|
||||||
package eu.steffo.twom.composables.configureroom
|
package eu.steffo.twom.configureroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import eu.steffo.twom.activities.ConfigureRoomActivity
|
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.theme.TwoMTheme
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.theme.components.TwoMTheme
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ConfigureRoomScaffold(
|
fun ConfigureRoomScaffold(
|
||||||
initialConfiguration: ConfigureRoomActivity.Configuration? = null,
|
initialConfiguration: ConfigureRoomActivity.Configuration? = null,
|
||||||
) {
|
) {
|
||||||
val session = TwoMGlobals.matrix.authenticationService().getLastAuthenticatedSession()!!
|
val session = TwoMMatrix.matrix.authenticationService().getLastAuthenticatedSession()!!
|
||||||
|
|
||||||
TwoMTheme {
|
TwoMTheme {
|
||||||
CompositionLocalProvider(LocalSession provides session) {
|
CompositionLocalProvider(LocalSession provides session) {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.configureroom
|
package eu.steffo.twom.configureroom.components
|
||||||
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.navigation.BackIconButton
|
import eu.steffo.twom.navigation.components.BackIconButton
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.errorhandling
|
package eu.steffo.twom.errorhandling.components
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Warning
|
import androidx.compose.material.icons.filled.Warning
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.errorhandling
|
package eu.steffo.twom.errorhandling.components
|
||||||
|
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.errorhandling
|
package eu.steffo.twom.errorhandling.components
|
||||||
|
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.errorhandling
|
package eu.steffo.twom.errorhandling.utils
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
@ -6,6 +6,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
|
|
||||||
private const val TAG = "LocalizableError"
|
private const val TAG = "LocalizableError"
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.steffo.twom.activities
|
package eu.steffo.twom.login.activities
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
import eu.steffo.twom.composables.login.components.LoginScaffold
|
import eu.steffo.twom.login.components.LoginScaffold
|
||||||
|
|
||||||
|
|
||||||
class LoginActivity : ComponentActivity() {
|
class LoginActivity : ComponentActivity() {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.login.components
|
package eu.steffo.twom.login.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
@ -19,12 +19,11 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.Display
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.utils.Display
|
||||||
import eu.steffo.twom.composables.fields.PasswordField
|
import eu.steffo.twom.login.effects.LoginStep
|
||||||
import eu.steffo.twom.composables.login.effects.LoginStep
|
import eu.steffo.twom.login.effects.manageLogin
|
||||||
import eu.steffo.twom.composables.login.effects.manageLogin
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.login.components
|
package eu.steffo.twom.login.components
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -9,7 +9,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.composables.theme.TwoMTheme
|
import eu.steffo.twom.theme.components.TwoMTheme
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.login.components
|
package eu.steffo.twom.login.components
|
||||||
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.navigation.BackIconButton
|
import eu.steffo.twom.navigation.components.BackIconButton
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.fields
|
package eu.steffo.twom.login.components
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.RemoveRedEye
|
import androidx.compose.material.icons.filled.RemoveRedEye
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.login.effects
|
package eu.steffo.twom.login.effects
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -7,9 +7,9 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.LocalizableError
|
import eu.steffo.twom.errorhandling.utils.LocalizableError
|
||||||
import eu.steffo.twom.composables.errorhandling.capture
|
import eu.steffo.twom.errorhandling.utils.capture
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||||
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
|
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
@ -43,7 +43,7 @@ fun manageLogin(): LoginManager {
|
||||||
|
|
||||||
Log.d(TAG, "Resetting authentication service...")
|
Log.d(TAG, "Resetting authentication service...")
|
||||||
step = LoginStep.RESET
|
step = LoginStep.RESET
|
||||||
val auth = TwoMGlobals.matrix.authenticationService()
|
val auth = TwoMMatrix.matrix.authenticationService()
|
||||||
error.capture(R.string.login_error_wellknown_generic) {
|
error.capture(R.string.login_error_wellknown_generic) {
|
||||||
auth.reset()
|
auth.reset()
|
||||||
} ?: return null
|
} ?: return null
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.activities
|
package eu.steffo.twom.main.activities
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -6,8 +6,8 @@ import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.core.net.toFile
|
import androidx.core.net.toFile
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import eu.steffo.twom.composables.main.MainScaffold
|
import eu.steffo.twom.main.components.MainScaffold
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
|
@ -21,7 +21,7 @@ class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
TwoMGlobals.ensureMatrix(applicationContext)
|
TwoMMatrix.ensureMatrix(applicationContext)
|
||||||
|
|
||||||
fetchLastSession()
|
fetchLastSession()
|
||||||
openSession()
|
openSession()
|
||||||
|
@ -36,7 +36,7 @@ class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
private fun fetchLastSession() {
|
private fun fetchLastSession() {
|
||||||
Log.d("Main", "Fetching the last successfully authenticated session...")
|
Log.d("Main", "Fetching the last successfully authenticated session...")
|
||||||
session = TwoMGlobals.matrix.authenticationService().getLastAuthenticatedSession()
|
session = TwoMMatrix.matrix.authenticationService().getLastAuthenticatedSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openSession() {
|
private fun openSession() {
|
||||||
|
@ -113,7 +113,7 @@ class MainActivity : ComponentActivity() {
|
||||||
createRoomParams.name = name
|
createRoomParams.name = name
|
||||||
createRoomParams.topic = description
|
createRoomParams.topic = description
|
||||||
createRoomParams.preset = CreateRoomPreset.PRESET_PRIVATE_CHAT
|
createRoomParams.preset = CreateRoomPreset.PRESET_PRIVATE_CHAT
|
||||||
createRoomParams.roomType = TwoMGlobals.ROOM_TYPE
|
createRoomParams.roomType = TwoMMatrix.ROOM_TYPE
|
||||||
createRoomParams.initialStates = mutableListOf(
|
createRoomParams.initialStates = mutableListOf(
|
||||||
CreateRoomStateEvent(
|
CreateRoomStateEvent(
|
||||||
type = "m.room.power_levels",
|
type = "m.room.power_levels",
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.launch
|
import androidx.activity.result.launch
|
||||||
|
@ -20,9 +20,9 @@ import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.activities.LoginActivity
|
import eu.steffo.twom.avatar.components.AvatarUserId
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarUserId
|
import eu.steffo.twom.login.activities.LoginActivity
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.launch
|
import androidx.activity.result.launch
|
||||||
|
@ -12,7 +12,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.activities.ConfigureRoomActivity
|
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
@ -8,10 +8,10 @@ import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ fun MainContentLoggedIn(
|
||||||
val roomSummaries by session.roomService().getRoomSummariesLive(
|
val roomSummaries by session.roomService().getRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = listOf(Membership.JOIN, Membership.INVITE)
|
this.memberships = listOf(Membership.JOIN, Membership.INVITE)
|
||||||
this.includeType = listOf(TwoMGlobals.ROOM_TYPE)
|
this.includeType = listOf(TwoMMatrix.ROOM_TYPE)
|
||||||
}
|
}
|
||||||
).observeAsState()
|
).observeAsState()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
@ -8,13 +8,12 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview(showBackground = true)
|
@Preview(showBackground = true)
|
||||||
fun MainContentNotLoggedIn(
|
fun MainContentNotLoggedIn(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClickLogin: () -> Unit = {},
|
|
||||||
) {
|
) {
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
Row(Modifier.basePadding()) {
|
Row(Modifier.basePadding()) {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
|
@ -6,9 +6,9 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.activities.ConfigureRoomActivity
|
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.theme.TwoMTheme
|
import eu.steffo.twom.theme.components.TwoMTheme
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
|
||||||
@Composable
|
@Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import androidx.compose.material3.CenterAlignedTopAppBar
|
import androidx.compose.material3.CenterAlignedTopAppBar
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.main
|
package eu.steffo.twom.main.components
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
|
@ -24,11 +24,11 @@ import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.activities.ViewRoomActivity
|
import eu.steffo.twom.avatar.components.AvatarURL
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarURL
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.utils.LocalizableError
|
||||||
import eu.steffo.twom.composables.errorhandling.LocalizableError
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.viewroom.activities.ViewRoomActivity
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.matrix
|
package eu.steffo.twom.matrix.complocals
|
||||||
|
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
|
@ -1,15 +1,14 @@
|
||||||
package eu.steffo.twom.utils
|
package eu.steffo.twom.matrix.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import org.matrix.android.sdk.api.Matrix
|
import org.matrix.android.sdk.api.Matrix
|
||||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object containing the global state of the application.
|
* Object containing the global state of the application.
|
||||||
*/
|
*/
|
||||||
object TwoMGlobals {
|
object TwoMMatrix {
|
||||||
/**
|
/**
|
||||||
* The global [Matrix] object of the application.
|
* The global [Matrix] object of the application.
|
||||||
*
|
*
|
||||||
|
@ -44,4 +43,4 @@ object TwoMGlobals {
|
||||||
const val RSVP_STATE_ANSWER_FIELD = "answer"
|
const val RSVP_STATE_ANSWER_FIELD = "answer"
|
||||||
|
|
||||||
const val RSVP_STATE_COMMENT_FIELD = "comment"
|
const val RSVP_STATE_COMMENT_FIELD = "comment"
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.utils
|
package eu.steffo.twom.matrix.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.navigation
|
package eu.steffo.twom.navigation.components
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.components
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
10
app/src/main/java/eu/steffo/twom/theme/utils/basePadding.kt
Normal file
10
app/src/main/java/eu/steffo/twom/theme/utils/basePadding.kt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
|
||||||
|
fun Modifier.basePadding(): Modifier {
|
||||||
|
return this.padding(all = 10.dp)
|
||||||
|
}
|
|
@ -1,14 +1,9 @@
|
||||||
package eu.steffo.twom.composables.theme
|
package eu.steffo.twom.theme.utils
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
|
||||||
fun Modifier.basePadding(): Modifier {
|
|
||||||
return this.padding(all = 10.dp)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Modifier.chipPadding(): Modifier {
|
fun Modifier.chipPadding(): Modifier {
|
||||||
return this.padding(start = 2.5.dp, end = 2.5.dp)
|
return this.padding(start = 2.5.dp, end = 2.5.dp)
|
||||||
}
|
}
|
|
@ -1,130 +0,0 @@
|
||||||
package eu.steffo.twom.utils
|
|
||||||
|
|
||||||
import android.content.ContentResolver
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.graphics.Matrix
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.exifinterface.media.ExifInterface
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class BitmapUtilities {
|
|
||||||
companion object {
|
|
||||||
fun getOrientation(contentResolver: ContentResolver, uri: Uri): Int? {
|
|
||||||
contentResolver.openInputStream(uri).use {
|
|
||||||
if (it == null) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
return ExifInterface(it).getAttributeInt(ExifInterface.TAG_ORIENTATION, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getRawBitmap(contentResolver: ContentResolver, uri: Uri): Bitmap? {
|
|
||||||
contentResolver.openInputStream(uri).use {
|
|
||||||
if (it == null) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
return BitmapFactory.decodeStream(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun squareAndOrient(
|
|
||||||
bitmap: Bitmap,
|
|
||||||
orientation: Int = ExifInterface.ORIENTATION_NORMAL
|
|
||||||
): Bitmap {
|
|
||||||
// Determine the starting points and the size to crop the image to a 1:1 square
|
|
||||||
val xStart: Int
|
|
||||||
val yStart: Int
|
|
||||||
val size: Int
|
|
||||||
if (bitmap.width > bitmap.height) {
|
|
||||||
yStart = 0
|
|
||||||
xStart = (bitmap.width - bitmap.height) / 2
|
|
||||||
size = bitmap.height
|
|
||||||
} else {
|
|
||||||
xStart = 0
|
|
||||||
yStart = (bitmap.height - bitmap.width) / 2
|
|
||||||
size = bitmap.width
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a transformation matrix to rotate the bitmap based on the orientation
|
|
||||||
val transformationMatrix = Matrix()
|
|
||||||
|
|
||||||
when (orientation) {
|
|
||||||
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> {
|
|
||||||
transformationMatrix.postScale(-1f, 1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_ROTATE_180 -> {
|
|
||||||
transformationMatrix.postRotate(180f)
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_FLIP_VERTICAL -> {
|
|
||||||
transformationMatrix.postScale(1f, -1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_TRANSPOSE -> {
|
|
||||||
// Untested.
|
|
||||||
transformationMatrix.setValues(FloatArray(16) {
|
|
||||||
if (it == 0 || it == 6 || it == 9 || it == 15) {
|
|
||||||
1f
|
|
||||||
} else {
|
|
||||||
0f
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_ROTATE_90 -> {
|
|
||||||
transformationMatrix.postRotate(90f)
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_TRANSVERSE -> {
|
|
||||||
// Untested.
|
|
||||||
transformationMatrix.setValues(FloatArray(16) {
|
|
||||||
if (it == 3 || it == 5 || it == 10 || it == 12) {
|
|
||||||
1f
|
|
||||||
} else {
|
|
||||||
0f
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
ExifInterface.ORIENTATION_ROTATE_270 -> {
|
|
||||||
transformationMatrix.postRotate(270f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Bitmap.createBitmap(
|
|
||||||
bitmap,
|
|
||||||
xStart,
|
|
||||||
yStart,
|
|
||||||
size,
|
|
||||||
size,
|
|
||||||
transformationMatrix,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCorrectedBitmap(resolver: ContentResolver, uri: Uri): Bitmap? {
|
|
||||||
val rawBitmap = getRawBitmap(resolver, uri) ?: return null
|
|
||||||
val orientation = getOrientation(resolver, uri) ?: return null
|
|
||||||
return squareAndOrient(rawBitmap, orientation)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bitmapToCache(id: String, bitmap: Bitmap): File {
|
|
||||||
val file = File.createTempFile("bitmap_$id", ".jpg")
|
|
||||||
file.outputStream().use {
|
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 85, it)
|
|
||||||
it.flush()
|
|
||||||
}
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bitmapFromCache(file: File): Bitmap {
|
|
||||||
file.inputStream().use {
|
|
||||||
return BitmapFactory.decodeStream(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.activities
|
package eu.steffo.twom.viewroom.activities
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -7,8 +7,8 @@ import android.util.Log
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.contract.ActivityResultContract
|
import androidx.activity.result.contract.ActivityResultContract
|
||||||
import eu.steffo.twom.composables.viewroom.ViewRoomScaffold
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.viewroom.components.ViewRoomScaffold
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
|
||||||
class ViewRoomActivity : ComponentActivity() {
|
class ViewRoomActivity : ComponentActivity() {
|
||||||
|
@ -31,7 +31,7 @@ class ViewRoomActivity : ComponentActivity() {
|
||||||
private fun fetchLastSession() {
|
private fun fetchLastSession() {
|
||||||
Log.d("Main", "Fetching the last successfully authenticated session...")
|
Log.d("Main", "Fetching the last successfully authenticated session...")
|
||||||
// FIXME: If this is null, it means that something launched this while no session was authenticated...
|
// FIXME: If this is null, it means that something launched this while no session was authenticated...
|
||||||
session = TwoMGlobals.matrix.authenticationService().getLastAuthenticatedSession()!!
|
session = TwoMMatrix.matrix.authenticationService().getLastAuthenticatedSession()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.complocals
|
||||||
|
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.complocals
|
||||||
|
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Email
|
import androidx.compose.material.icons.filled.Email
|
||||||
|
@ -16,7 +16,6 @@ import eu.steffo.twom.R
|
||||||
fun InviteFAB(
|
fun InviteFAB(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClick: () -> Unit = {},
|
onClick: () -> Unit = {},
|
||||||
onUserSelected: (userId: String) -> Unit = {},
|
|
||||||
) {
|
) {
|
||||||
// TODO: Hide if unprivileged
|
// TODO: Hide if unprivileged
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -15,7 +15,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -15,11 +15,12 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.Display
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.utils.Display
|
||||||
import eu.steffo.twom.composables.errorhandling.LocalizableError
|
import eu.steffo.twom.errorhandling.utils.LocalizableError
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
|
@ -23,11 +23,13 @@ import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarUser
|
import eu.steffo.twom.avatar.components.AvatarUser
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.viewroom.effects.resolveUser
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.effects.observeRSVP
|
||||||
|
import eu.steffo.twom.viewroom.effects.resolveUser
|
||||||
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
|
@ -10,7 +10,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
|
@ -9,8 +9,8 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.composables.theme.chipPadding
|
import eu.steffo.twom.theme.utils.chipPadding
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
|
@ -7,7 +7,7 @@ import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
@ -10,10 +10,10 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
import eu.steffo.twom.utils.RSVP
|
import eu.steffo.twom.viewroom.utils.RSVP
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun RSVPForm(
|
fun RSVPForm(
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
@ -9,7 +9,7 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
@ -23,10 +23,12 @@ import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.net.toFile
|
import androidx.core.net.toFile
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.activities.ConfigureRoomActivity
|
import eu.steffo.twom.avatar.components.AvatarURL
|
||||||
import eu.steffo.twom.composables.avatar.components.AvatarURL
|
import eu.steffo.twom.configureroom.activities.ConfigureRoomActivity
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorIconButton
|
import eu.steffo.twom.errorhandling.components.ErrorIconButton
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoomSummary
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
@ -9,8 +9,8 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
@ -14,12 +14,14 @@ import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.Display
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.utils.Display
|
||||||
import eu.steffo.twom.composables.errorhandling.LocalizableError
|
import eu.steffo.twom.errorhandling.utils.LocalizableError
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
|
import eu.steffo.twom.viewroom.effects.observeRSVP
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
@ -9,9 +9,10 @@ import androidx.compose.runtime.livedata.observeAsState
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams
|
import org.matrix.android.sdk.api.session.room.members.RoomMemberQueryParams
|
||||||
import kotlin.jvm.optionals.getOrNull
|
import kotlin.jvm.optionals.getOrNull
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
@ -13,8 +13,10 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import eu.steffo.twom.composables.theme.TwoMTheme
|
import eu.steffo.twom.theme.components.TwoMTheme
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoom
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoomSummary
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
@ -7,9 +7,10 @@ import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.navigation.BackIconButton
|
import eu.steffo.twom.navigation.components.BackIconButton
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoomSummary
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.components
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
@ -8,9 +8,10 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.errorhandling.ErrorText
|
import eu.steffo.twom.errorhandling.components.ErrorText
|
||||||
import eu.steffo.twom.composables.errorhandling.LoadingText
|
import eu.steffo.twom.errorhandling.components.LoadingText
|
||||||
import eu.steffo.twom.composables.theme.basePadding
|
import eu.steffo.twom.theme.utils.basePadding
|
||||||
|
import eu.steffo.twom.viewroom.complocals.LocalRoomSummary
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@Preview
|
@Preview
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.steffo.twom.composables.viewroom
|
package eu.steffo.twom.viewroom.effects
|
||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.livedata.observeAsState
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
import eu.steffo.twom.utils.RSVP
|
import eu.steffo.twom.matrix.utils.TwoMMatrix
|
||||||
import eu.steffo.twom.utils.RSVPAnswer
|
import eu.steffo.twom.viewroom.utils.RSVP
|
||||||
import eu.steffo.twom.utils.TwoMGlobals
|
import eu.steffo.twom.viewroom.utils.RSVPAnswer
|
||||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
|
@ -26,7 +26,7 @@ fun observeRSVP(room: Room, member: RoomMemberSummary): RSVP? {
|
||||||
}
|
}
|
||||||
|
|
||||||
val request by room.stateService().getStateEventLive(
|
val request by room.stateService().getStateEventLive(
|
||||||
eventType = TwoMGlobals.RSVP_STATE_TYPE,
|
eventType = TwoMMatrix.RSVP_STATE_TYPE,
|
||||||
stateKey = QueryStringValue.Equals(member.userId),
|
stateKey = QueryStringValue.Equals(member.userId),
|
||||||
).observeAsState()
|
).observeAsState()
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ fun observeRSVP(room: Room, member: RoomMemberSummary): RSVP? {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val commentField = content[TwoMGlobals.RSVP_STATE_COMMENT_FIELD]
|
val commentField = content[TwoMMatrix.RSVP_STATE_COMMENT_FIELD]
|
||||||
?: return RSVP(
|
?: return RSVP(
|
||||||
event = event,
|
event = event,
|
||||||
answer = RSVPAnswer.UNKNOWN,
|
answer = RSVPAnswer.UNKNOWN,
|
||||||
|
@ -75,7 +75,7 @@ fun observeRSVP(room: Room, member: RoomMemberSummary): RSVP? {
|
||||||
comment = "",
|
comment = "",
|
||||||
)
|
)
|
||||||
|
|
||||||
val answerField = content[TwoMGlobals.RSVP_STATE_ANSWER_FIELD]
|
val answerField = content[TwoMMatrix.RSVP_STATE_ANSWER_FIELD]
|
||||||
?: return RSVP(
|
?: return RSVP(
|
||||||
event = event,
|
event = event,
|
||||||
answer = RSVPAnswer.NONE,
|
answer = RSVPAnswer.NONE,
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.composables.viewroom.effects
|
package eu.steffo.twom.viewroom.effects
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -7,7 +7,7 @@ import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import eu.steffo.twom.composables.matrix.LocalSession
|
import eu.steffo.twom.matrix.complocals.LocalSession
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import org.matrix.android.sdk.api.session.user.model.User
|
import org.matrix.android.sdk.api.session.user.model.User
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.utils
|
package eu.steffo.twom.viewroom.utils
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
|
|
||||||
|
@ -6,4 +6,4 @@ data class RSVP(
|
||||||
val event: Event?,
|
val event: Event?,
|
||||||
val answer: RSVPAnswer,
|
val answer: RSVPAnswer,
|
||||||
val comment: String,
|
val comment: String,
|
||||||
)
|
)
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.steffo.twom.utils
|
package eu.steffo.twom.viewroom.utils
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.BuildCircle
|
import androidx.compose.material.icons.outlined.BuildCircle
|
||||||
|
@ -13,12 +13,12 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.steffo.twom.R
|
import eu.steffo.twom.R
|
||||||
import eu.steffo.twom.composables.theme.LaterColorRole
|
import eu.steffo.twom.theme.utils.LaterColorRole
|
||||||
import eu.steffo.twom.composables.theme.MaybeColorRole
|
import eu.steffo.twom.theme.utils.MaybeColorRole
|
||||||
import eu.steffo.twom.composables.theme.NowayColorRole
|
import eu.steffo.twom.theme.utils.NowayColorRole
|
||||||
import eu.steffo.twom.composables.theme.NullishColorRole
|
import eu.steffo.twom.theme.utils.NullishColorRole
|
||||||
import eu.steffo.twom.composables.theme.StaticColorRole
|
import eu.steffo.twom.theme.utils.StaticColorRole
|
||||||
import eu.steffo.twom.composables.theme.SureColorRole
|
import eu.steffo.twom.theme.utils.SureColorRole
|
||||||
|
|
||||||
enum class RSVPAnswer {
|
enum class RSVPAnswer {
|
||||||
// Will be there!
|
// Will be there!
|
||||||
|
@ -224,4 +224,4 @@ enum class RSVPAnswer {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
abstract fun toCommentPlaceholder(): String
|
abstract fun toCommentPlaceholder(): String
|
||||||
}
|
}
|
Loading…
Reference in a new issue