Skip to content

Commit

Permalink
Merge pull request #51 from hegocre/maintenance/updates
Browse files Browse the repository at this point in the history
Maintenance updates
  • Loading branch information
hegocre authored Sep 15, 2023
2 parents f51171f + e12123c commit 8055e25
Show file tree
Hide file tree
Showing 13 changed files with 760 additions and 57 deletions.
26 changes: 12 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins {
id 'com.android.application'
id 'kotlin-android'
//id 'com.google.devtools.ksp' version "$ksp_version"
id 'org.jetbrains.kotlin.kapt'
id 'com.google.devtools.ksp' version "$kotlin_version-$ksp_version"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
}

Expand All @@ -20,8 +19,8 @@ android {
applicationId "com.yara.raco"
minSdk 26
targetSdk 34
versionCode 32
versionName "1.0.6"
versionCode 34
versionName "1.0.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -45,6 +44,9 @@ android {
}
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
buildTypes {
release {
minifyEnabled true
Expand All @@ -67,7 +69,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.8'
kotlinCompilerExtensionVersion '1.5.3'
}
packagingOptions {
resources {
Expand Down Expand Up @@ -96,11 +98,7 @@ dependencies {

//Room dependencies
implementation "androidx.room:room-ktx:$room_version"
//annotationProcessor "androidx.room:room-compiler:$room_version"
//ksp "androidx.room:room-compiler:$room_version"
kapt "androidx.room:room-compiler:$room_version"

implementation 'com.google.accompanist:accompanist-swiperefresh:0.30.1'
ksp "androidx.room:room-compiler:$room_version"

implementation 'androidx.work:work-runtime-ktx:2.8.1'

Expand All @@ -111,10 +109,10 @@ dependencies {
//Debug and test implementations
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation "androidx.compose.ui:ui-tooling"
debugImplementation "androidx.compose.ui:ui-test-manifest"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.5.1'
debugImplementation "androidx.compose.ui:ui-tooling:1.5.1"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.5.1"
}

// Compiler flag to use experimental Compose APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import com.yara.raco.model.grade.Grade
*/
@kotlinx.serialization.Serializable
@Entity(tableName = "evaluation")
data class Evaluation @JvmOverloads constructor(
data class Evaluation(
@PrimaryKey(autoGenerate = true)
var id: Int,
var subjectId: String,
var name: String,
@Ignore
val listOfGrade: ArrayList<Grade> = arrayListOf()
)
) {
// Constructor for ksp to not fail building
constructor(id: Int, subjectId: String, name: String) : this(id, subjectId, name, arrayListOf())
}
27 changes: 25 additions & 2 deletions app/src/main/java/com/yara/raco/model/notices/Notice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlinx.serialization.Transient
*/
@kotlinx.serialization.Serializable
@Entity(tableName = "notices", primaryKeys = ["id"])
data class Notice @JvmOverloads constructor(
data class Notice(
@SerialName("id")
val id: Int,
@SerialName("titol")
Expand All @@ -42,4 +42,27 @@ data class Notice @JvmOverloads constructor(
@Transient
@ColumnInfo(defaultValue = "1")
var llegit: Boolean = false
)
) {
// Constructor for ksp to not fail building
constructor(
id: Int,
titol: String,
codiAssig: String,
text: String,
dataInsercio: String,
dataModificacio: String,
dataCaducitat: String,
llegit: Boolean
) :
this(
id,
titol,
codiAssig,
text,
dataInsercio,
dataModificacio,
dataCaducitat,
arrayListOf(),
llegit
)
}
55 changes: 40 additions & 15 deletions app/src/main/java/com/yara/raco/ui/components/RacoAboutScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,47 @@ package com.yara.raco.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.material.icons.outlined.Campaign
import androidx.compose.material.icons.outlined.Code
import androidx.compose.material.icons.outlined.Description
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Person
import androidx.compose.material.icons.outlined.Policy
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.contentColorFor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
Expand Down Expand Up @@ -312,37 +343,31 @@ val authors = mapOf(
val licenses = listOf(
LicenseNotice(
name = "Kotlin Programming Language",
copyright = "Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.",
copyright = "Copyright © 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.",
licenseName = "Apache License 2.0",
licenseUrl = "https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt"
),
LicenseNotice(
name = "Android Jetpack",
copyright = "Copyright 2020 Google LLC",
copyright = "Copyright © 2023 The Android Open Source Project",
licenseName = "Apache License 2.0",
licenseUrl = "https://github.com/androidx/androidx/blob/androidx-main/LICENSE.txt"
),
LicenseNotice(
name = "Accompanist",
copyright = "Copyright 2020 The Android Open Source Project",
licenseName = "Apache License 2.0",
licenseUrl = "https://github.com/google/accompanist/blob/main/LICENSE"
),
LicenseNotice(
name = "HtmlText",
copyright = "Copyright 2021 Alexander Karkossa",
copyright = "Copyright © 2021 Alexander Karkossa",
licenseName = "Apache License 2.0",
licenseUrl = "https://github.com/ch4rl3x/HtmlText/blob/main/LICENSE"
),
LicenseNotice(
name = "OkHttp",
copyright = "Copyright 2019 Square, Inc.",
copyright = "Copyright © 2019 Square, Inc.",
licenseName = "Apache License 2.0",
licenseUrl = "https://github.com/square/okhttp/blob/master/LICENSE.txt"
),
LicenseNotice(
name = "WeekSchedule",
copyright = "Copyright 2021 Daniel Rampelt",
copyright = "Copyright © 2021 Daniel Rampelt",
licenseName = "MIT License",
licenseUrl = "https://github.com/drampelt/WeekSchedule/blob/main/LICENSE"
)
Expand Down
43 changes: 22 additions & 21 deletions app/src/main/java/com/yara/raco/ui/components/RacoMainNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.yara.raco.ui.components

import android.widget.Toast
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -12,7 +15,6 @@ import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
Expand All @@ -23,23 +25,23 @@ import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
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.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.navArgument
import com.google.accompanist.swiperefresh.SwipeRefresh
import com.google.accompanist.swiperefresh.SwipeRefreshIndicator
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
import com.yara.raco.R
import com.yara.raco.model.evaluation.EvaluationWithGrades
import com.yara.raco.model.notices.NoticeWithFiles
import com.yara.raco.ui.RacoScreen
import com.yara.raco.ui.components.pullrefresh.PullRefreshIndicator
import com.yara.raco.ui.components.pullrefresh.pullRefresh
import com.yara.raco.ui.components.pullrefresh.rememberPullRefreshState
import com.yara.raco.ui.viewmodel.RacoViewModel
import com.yara.raco.utils.Result
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -89,7 +91,9 @@ fun RacoMainNavHost(
NavHost(
navController = navHostController,
startDestination = RacoScreen.Notes.name,
modifier = modifier
modifier = modifier,
enterTransition = { fadeIn(animationSpec = tween(300)) },
exitTransition = { fadeOut(animationSpec = tween(300)) },
) {
composable(RacoScreen.Notes.name) {
Column {
Expand Down Expand Up @@ -333,28 +337,25 @@ fun RacoMainNavHost(
}
}

@Suppress("deprecation")
@Composable
fun RacoSwipeRefresh(
isRefreshing: Boolean,
onRefresh: () -> Unit,
content: @Composable () -> Unit
) {
val refreshState = rememberSwipeRefreshState(isRefreshing = isRefreshing)
val pullRefreshState = rememberPullRefreshState(
refreshing = isRefreshing,
onRefresh = onRefresh
)

SwipeRefresh(
state = refreshState,
onRefresh = onRefresh,
modifier = Modifier.fillMaxSize(),
indicator = { rState, refreshTrigger ->
SwipeRefreshIndicator(
state = rState,
refreshTriggerDistance = refreshTrigger,
contentColor = MaterialTheme.colorScheme.primary,
backgroundColor = MaterialTheme.colorScheme.surfaceColorAtElevation(4.dp)
)
}
) {
Box(modifier = Modifier.pullRefresh(pullRefreshState)) {
content()

PullRefreshIndicator(
refreshing = isRefreshing,
state = pullRefreshState,
contentColor = MaterialTheme.colorScheme.primary,
modifier = Modifier.align(Alignment.TopCenter)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fun RacoMainScreen(
},
bottomBar = {
RacoMainNavigationBar(
allScreens = RacoScreen.values().asList(),
allScreens = RacoScreen.entries,
currentScreen = currentScreen,
onScreenSelected = { racoScreen ->
navController.navigate(racoScreen.name) {
Expand Down
Loading

0 comments on commit 8055e25

Please sign in to comment.