Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Access CLIENT_ID
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
Expand All @@ -22,13 +22,13 @@ jobs:
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
run: echo CLIENT_SECRET=\"$CLIENT_SECRET\" >> ./apikey.properties
- name: set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
- name: Build with Gradle
run: ./gradlew clean && ./gradlew assembleDebug
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: app-debug.apk
path: app/build/outputs/apk/debug/app-debug.apk
66 changes: 32 additions & 34 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.devtools.ksp' version "$kotlin_version-$ksp_version"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
id 'org.jetbrains.kotlin.plugin.compose' version "$kotlin_version"
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

def apiKeyPropertiesFile = rootProject.file("apikey.properties")
def apiKeyProperties = new Properties()
apiKeyProperties.load(new FileInputStream(apiKeyPropertiesFile))

android {
namespace 'com.yara.raco'
compileSdk 34
namespace = 'com.yara.raco'
compileSdk = 36

defaultConfig {
applicationId "com.yara.raco"
minSdk 26
targetSdk 34
versionCode 34
versionName "1.0.7"
targetSdk 36
versionCode 36
versionName "1.0.8"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
useSupportLibrary = true
}
resourceConfigurations += ['ca', 'es', 'en']

Expand All @@ -50,26 +57,17 @@ android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
shrinkResources = true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
applicationIdSuffix ".debug"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.3'
compose = true
buildConfig = true
}
packagingOptions {
resources {
Expand All @@ -81,42 +79,42 @@ android {
dependencies {

//Android dependencies
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
implementation 'androidx.core:core-ktx:1.16.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.9.2'
implementation 'androidx.datastore:datastore-preferences:1.1.7'

//Compose dependencies
implementation platform('androidx.compose:compose-bom:2023.09.00')
implementation platform('androidx.compose:compose-bom:2025.07.00')
implementation "androidx.compose.ui:ui"
implementation "androidx.compose.runtime:runtime-livedata"
implementation "androidx.compose.ui:ui-tooling-preview"
implementation 'androidx.compose.material:material-icons-extended'
implementation 'androidx.compose.material3:material3'

implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.navigation:navigation-compose:2.7.2'
implementation 'androidx.activity:activity-compose:1.10.1'
implementation 'androidx.navigation:navigation-compose:2.9.3'

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

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

implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'com.squareup.okhttp3:okhttp:5.1.0'

implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0'

//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.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"
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.8.3'
debugImplementation "androidx.compose.ui:ui-tooling:1.8.3"
debugImplementation "androidx.compose.ui:ui-test-manifest:1.8.3"
}

// Compiler flag to use experimental Compose APIs
tasks.withType(KotlinCompilationTask).configureEach {
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
freeCompilerArgs.addAll("-opt-in=kotlin.RequiresOptIn", "-Xjvm-default=all-compatibility")
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/yara/raco/api/EventsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ class EventsApi private constructor() {

val status = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (status == 200 && body != null) {
if (status == 200) {
val results = Json.decodeFromString<EventsResponse>(body).results
Result.Success(results)
} else {
Result.Error(ResultCode.ERROR_API_BAD_REQUEST)
}

} catch (e: Exception) {
} catch (_: Exception) {
Result.Error(ResultCode.ERROR_API_BAD_REQUEST)
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/yara/raco/api/NoticesApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.yara.raco.api
import android.annotation.SuppressLint
import android.app.DownloadManager
import android.content.*
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.webkit.MimeTypeMap
Expand All @@ -19,6 +18,7 @@ import com.yara.raco.utils.ResultCode
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.Serializable
import androidx.core.net.toUri

class NoticesApi private constructor() {

Expand All @@ -32,14 +32,14 @@ class NoticesApi private constructor() {

val statusCode = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (statusCode == 200 && body != null) {
if (statusCode == 200) {
val aux = Json.decodeFromString<NoticeResponse>(body).results
Result.Success(aux)
} else {
Expand All @@ -53,7 +53,7 @@ class NoticesApi private constructor() {

@SuppressLint("UnspecifiedRegisterReceiverFlag")
fun getAttachment(context: Context, file: File, accessToken: String) {
val request = DownloadManager.Request(Uri.parse(file.url))
val request = DownloadManager.Request(file.url.toUri())
.setTitle(file.nom)
.setMimeType(file.nom.getMime() ?: file.tipusMime)
.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, file.nom)
Expand Down Expand Up @@ -81,7 +81,7 @@ class NoticesApi private constructor() {
if (status == DownloadManager.STATUS_SUCCESSFUL) {
columIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)
if (columIndex < 0) return
val filePath = Uri.parse(cursor.getString(columIndex))
val filePath = cursor.getString(columIndex).toUri()

columIndex = cursor.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE)
if (columIndex < 0) return
Expand All @@ -100,7 +100,7 @@ class NoticesApi private constructor() {

try {
context.startActivity(intent)
} catch (e: ActivityNotFoundException) {
} catch (_: ActivityNotFoundException) {
Toast.makeText(
context,
context.getString(R.string.cannot_open_file),
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/yara/raco/api/ScheduleApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class ScheduleApi private constructor() {

val statusCode = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (statusCode == 200 && body != null) {
if (statusCode == 200) {
val aux = Json.decodeFromString<ScheduleResponse>(body).results
Result.Success(aux)
} else {
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/yara/raco/api/SemesterApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ class SemesterApi private constructor() {

val statusCode = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (statusCode == 200 && body != null) {
if (statusCode == 200) {
val id = Json.decodeFromString<CurrentSemesterResponse>(body).id
Result.Success(id)
} else {
Result.Error(ResultCode.ERROR_API_BAD_RESPONSE)
}

} catch (e: Exception) {
} catch (_: Exception) {
Result.Error(ResultCode.ERROR_API_BAD_REQUEST)
}

Expand All @@ -59,21 +59,21 @@ class SemesterApi private constructor() {

val statusCode = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (statusCode == 200 && body != null) {
if (statusCode == 200) {
val id = Json.decodeFromString<ExamsResponse>(body).results
Result.Success(id)
} else {
Result.Error(ResultCode.ERROR_API_BAD_RESPONSE)
}

} catch (e: Exception) {
} catch (_: Exception) {
Result.Error(ResultCode.ERROR_API_BAD_REQUEST)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/yara/raco/api/SubjectsAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class SubjectsAPI private constructor() {

val statusCode = response.code
val body = withContext(Dispatchers.IO) {
response.body?.string()
response.body.string()
}

withContext(Dispatchers.IO) {
response.close()
}

if (statusCode == 200 && body != null) {
if (statusCode == 200) {
val aux = Json.decodeFromString<SubjectResponse>(body).results
Result.Success(aux)
}
Expand Down
24 changes: 14 additions & 10 deletions app/src/main/java/com/yara/raco/api/TokenApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ class TokenApi private constructor() {

val code = tokenResponse.code
val body = withContext(Dispatchers.IO) {
tokenResponse.body?.string()
tokenResponse.body.string()
}

withContext(Dispatchers.IO) {
tokenResponse.close()
}

if (code == 200 && body != null) {
if (code == 200) {
Result.Success(Json.decodeFromString(body))
} else {
Result.Error(0)
}

} catch (e: Exception) {
} catch (_: Exception) {
Result.Error(1)
}

Expand All @@ -60,19 +60,23 @@ class TokenApi private constructor() {

val code = tokenResponse.code
val body = withContext(Dispatchers.IO) {
tokenResponse.body?.string()
tokenResponse.body.string()
}

withContext(Dispatchers.IO) {
tokenResponse.close()
}

if (code == 200 && body != null) {
Result.Success(Json.decodeFromString(body))
} else if (code == 400) {
Result.Error(400)
} else {
Result.Error(0)
when (code) {
200 -> {
Result.Success(Json.decodeFromString(body))
}
400 -> {
Result.Error(400)
}
else -> {
Result.Error(0)
}
}

} catch (e: Exception) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/yara/raco/database/RacoDatabase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class RacoDatabase : RoomDatabase() {
RacoDatabase::class.java,
"raco.db"
)
.fallbackToDestructiveMigration()
.fallbackToDestructiveMigration(false)
.build()

INSTANCE = instance
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/yara/raco/ui/RacoScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import com.yara.raco.R

enum class RacoScreen(
@StringRes val title: Int,
@param:StringRes val title: Int,
val selectedIcon: ImageVector,
val unselectedIcon: ImageVector
) {
Expand Down
Loading