diff --git a/frontend/app/build.gradle.kts b/frontend/app/build.gradle.kts index 947a608..575ce8c 100644 --- a/frontend/app/build.gradle.kts +++ b/frontend/app/build.gradle.kts @@ -40,7 +40,6 @@ android { } dependencies { - implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.activity.compose) @@ -52,6 +51,8 @@ dependencies { implementation(libs.androidx.appcompat) implementation(libs.material) implementation(libs.androidx.activity) + implementation(libs.ktor.client.core) + implementation(libs.ktor.client.cio) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) diff --git a/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt b/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt index a9059e1..d8b54c6 100644 --- a/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt +++ b/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt @@ -4,17 +4,37 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Refresh -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material.icons.automirrored.outlined.ArrowBack +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import dev.svitan.antifed.ui.theme.AntiFedTheme +import kotlinx.coroutines.delay @OptIn(ExperimentalMaterial3Api::class) class AuthActivity : ComponentActivity() { @@ -24,6 +44,8 @@ class AuthActivity : ComponentActivity() { setContent { AntiFedTheme { var serverUrl by remember { mutableStateOf("") } + var checkingUrl by remember { mutableStateOf(false) } + fun isServerUrlOkay(): Boolean { var re = Regex( "(?:http[s]?:\\/\\/.)?(?:www\\.)?[-a-zA-Z0-9@%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b(?:[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]*)", @@ -32,7 +54,38 @@ class AuthActivity : ComponentActivity() { return re.containsMatchIn(serverUrl) } + LaunchedEffect(serverUrl) { + if (serverUrl.isBlank()) return@LaunchedEffect + if (!isServerUrlOkay()) return@LaunchedEffect + + checkingUrl = true + delay(1000) +// val client = HttpClient(CIO) +// val response = client.get(serverUrl) +// println(response.status) + checkingUrl = false + } + Scaffold( + topBar = { + TopAppBar( + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.primaryContainer, + titleContentColor = MaterialTheme.colorScheme.primary + ), + title = { + Text(stringResource(R.string.auth)) + }, + navigationIcon = { + IconButton(onClick = { finish() }) { + Icon( + imageVector = Icons.AutoMirrored.Outlined.ArrowBack, + contentDescription = stringResource(R.string.go_back) + ) + } + } + ) + }, modifier = Modifier.fillMaxSize() ) { innerPadding -> Column( @@ -51,6 +104,14 @@ class AuthActivity : ComponentActivity() { label = { Text(stringResource(R.string.server_url)) }, singleLine = true, isError = !isServerUrlOkay(), + trailingIcon = { + if (checkingUrl) + CircularProgressIndicator( + modifier = Modifier.width(36.dp), + color = MaterialTheme.colorScheme.secondary, + trackColor = MaterialTheme.colorScheme.surfaceVariant + ) + } ) } } diff --git a/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt b/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt index 3c72c34..35920b9 100644 --- a/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt +++ b/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt @@ -5,18 +5,34 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.AccountCircle -import androidx.compose.material.icons.filled.Menu import androidx.compose.material.icons.outlined.AccountCircle import androidx.compose.material.icons.outlined.Menu -import androidx.compose.material.icons.sharp.AccountCircle -import androidx.compose.material.icons.twotone.AccountCircle -import androidx.compose.material3.* -import androidx.compose.runtime.* -import androidx.compose.ui.* +import androidx.compose.material3.DrawerValue +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ModalDrawerSheet +import androidx.compose.material3.ModalNavigationDrawer +import androidx.compose.material3.NavigationDrawerItem +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.rememberDrawerState +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp @@ -78,7 +94,7 @@ class MainActivity : ComponentActivity() { titleContentColor = MaterialTheme.colorScheme.primary ), title = { - Text("AntiFed") + Text(stringResource(R.string.app_name)) }, navigationIcon = { IconButton(onClick = { diff --git a/frontend/app/src/main/res/values-sk/strings.xml b/frontend/app/src/main/res/values-sk/strings.xml index f473c61..24847df 100644 --- a/frontend/app/src/main/res/values-sk/strings.xml +++ b/frontend/app/src/main/res/values-sk/strings.xml @@ -4,4 +4,5 @@ AntiFed autentikácia Ukázať menu Ísť do nastavení autentikácie + Ísť späť \ No newline at end of file diff --git a/frontend/app/src/main/res/values/strings.xml b/frontend/app/src/main/res/values/strings.xml index 763065f..4028c5d 100644 --- a/frontend/app/src/main/res/values/strings.xml +++ b/frontend/app/src/main/res/values/strings.xml @@ -4,6 +4,7 @@ AntiFed auth Show menu Go to auth settings + Go back \ No newline at end of file diff --git a/frontend/gradle/libs.versions.toml b/frontend/gradle/libs.versions.toml index 4d17131..b6deff7 100644 --- a/frontend/gradle/libs.versions.toml +++ b/frontend/gradle/libs.versions.toml @@ -6,20 +6,22 @@ junit = "4.13.2" junitVersion = "1.1.5" espressoCore = "3.5.1" lifecycleRuntimeKtx = "2.6.1" -activityCompose = "1.8.0" +activityCompose = "1.10.1" composeBom = "2024.09.00" -appcompat = "1.6.1" +appcompat = "1.7.0" material = "1.10.0" activity = "1.10.1" +ktorClientCore = "3.1.3" +ktorClientCio = "3.1.3" [libraries] -androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version = "1.16.0" } junit = { group = "junit", name = "junit", version.ref = "junit" } -androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } -androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } -androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version = "1.2.1" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version = "3.6.1" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version = "2.9.0" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } -androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version = "2025.05.00" } androidx-ui = { group = "androidx.compose.ui", name = "ui" } androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } @@ -28,8 +30,10 @@ androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-man androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-material3 = { group = "androidx.compose.material3", name = "material3" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } -material = { group = "com.google.android.material", name = "material", version.ref = "material" } +material = { group = "com.google.android.material", name = "material", version = "1.12.0" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } +ktor-client-core = { group = "io.ktor", name = "ktor-client-core", version.ref = "ktorClientCore" } +ktor-client-cio = { group = "io.ktor", name = "ktor-client-cio", version.ref = "ktorClientCio" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" }