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
10 changes: 5 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ android {
val properties = Properties().apply {
load(FileInputStream("${rootDir}/local.properties"))
}
val apiRoot = properties["api_root"] ?: ""
val apiMigrated = properties["api_migrated"] ?: ""

defaultConfig {
applicationId = "com.doyoonkim.knutice"
minSdk = 31
targetSdk = 34
versionCode = 11
versionName = "1.3.2"
versionCode = 13
versionName = "1.3.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

buildConfigField("String", "API_ROOT", "\"$apiRoot\"")
buildConfigField("String", "API_MIGRATED", "\"$apiMigrated\"")

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -131,7 +131,7 @@ dependencies {
implementation(libs.androidx.room.ktx)

// Translation
// implementation(libs.translate)
implementation(libs.translate)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import javax.inject.Singleton
class KnuticeRemoteSource @Inject constructor() {

private val knuticeService = Retrofit.Builder()
.baseUrl(BuildConfig.API_ROOT)
.baseUrl(BuildConfig.API_MIGRATED)
.addConverterFactory(GsonConverterFactory.create())
.build()

Expand Down Expand Up @@ -93,13 +93,13 @@ class KnuticeRemoteSource @Inject constructor() {
Log.d("KnuticeRemoteSource", "ValidatedToken: $validatedToken")
try {
knuticeService.create(KnuticeService::class.java).submitUserReport(
ApiReportRequest(body = report.copy(token = validatedToken))
ApiReportRequest(body = report.copy(fcmToken = validatedToken))
).run {
if (this.result?.resultCode == 200) {
Log.d("KnuticeServer", "User report has been submitted successfully.\n${this.body?.message}")
Log.d("KnuticeServer", "User report has been submitted successfully.\n${this.body}")
return Result.success(true)
} else {
Log.d("KnuticeServer", "Failed to submit user report\n${this.body?.message}")
Log.d("KnuticeServer", "Failed to submit user report\n${this.body ?: false}")
return Result.success(false)
}
}
Expand All @@ -121,7 +121,7 @@ class KnuticeRemoteSource @Inject constructor() {
Log.d("KnuticeServer", "Topic preference has been updated.\n${this.body}")
return Result.success(true)
} else {
Log.d("KnuticeServer", "Failed to update topic preference.\n${this.body?.message}")
Log.d("KnuticeServer", "Failed to update topic preference.\n${this.body ?: false}")
return Result.success(false)
}
}
Expand All @@ -135,9 +135,6 @@ class KnuticeRemoteSource @Inject constructor() {

interface KnuticeService {

@GET("/open-api/notice")
suspend fun getTopThreeNotice(): TopThreeNotices

@GET("/open-api/notice/list")
suspend fun getTopThreeNotice(
@Query("noticeName") category: NoticeCategory,
Expand All @@ -161,7 +158,7 @@ interface KnuticeService {
): NoticesPerPage

@Headers("Content-Type: application/json")
@POST("/open-api/token")
@POST("/open-api/fcm")
suspend fun validateToken(
@Body requestBody: ApiDeviceTokenRequest
): ApiPostResult
Expand All @@ -173,7 +170,7 @@ interface KnuticeService {
): ApiPostResult

@Headers("Content-Type: application/json")
@POST("/open-api/token/topic")
@POST("/open-api/topic")
suspend fun submitTopicSubscriptionPreference(
@Body requestBody: ApiTopicSubscriptionRequest
): ApiPostResult
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.doyoonkim.knutice.domain

import android.util.Log
import com.doyoonkim.knutice.data.NoticeLocalRepository
import com.doyoonkim.knutice.model.Notice
import com.doyoonkim.knutice.model.NoticeCategory
import com.doyoonkim.knutice.model.RawNoticeData
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import java.util.Locale
import javax.inject.Inject


Expand Down Expand Up @@ -35,15 +37,17 @@ class FetchTopThreeNoticeByCategory @Inject constructor (
}

fun getTopThreeNotices(category: NoticeCategory): Flow<TopThreeInCategory> {
val translateNeeded: Boolean = Locale.getDefault() != Locale.KOREAN
return repository.getTopThreeNotice(category).map {
if (it.body.isNotEmpty()) {
val result = it.body.toNotice()

TopThreeInCategory(
isSuccessful = true,
notice1 = result[0],
notice2 = result[1],
notice3 = result[2]
)
).also { Log.d("TEST", it.toString()) }
} else {
TopThreeInCategory(
isSuccessful = false
Expand Down
20 changes: 8 additions & 12 deletions app/src/main/java/com/doyoonkim/knutice/model/DataWrappers.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.doyoonkim.knutice.model

import androidx.room.Entity
import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable

Expand All @@ -16,8 +15,9 @@ data class RawNoticeData(
@SerializedName("title") var title: String? = null,
@SerializedName("contentUrl") var contentUrl: String? = null,
@SerializedName("contentImage") var contentImage: String? = null,
@SerializedName("departName") var departName: String? = null,
@SerializedName("registeredAt") var registeredAt: String? = null
@SerializedName("departmentName") var departName: String? = null,
@SerializedName("registeredAt") var registeredAt: String? = null,
@SerializedName("noticeName") var noticeCategory: String? = null
)

// POJO for receiving raw data from the server.
Expand All @@ -40,20 +40,16 @@ data class NoticesPerPage(

data class ApiPostResult(
@SerializedName("result") var result: Result? = Result(),
@SerializedName("body") var body: Body? = Body()
) {
data class Body(
val message: String = ""
)
}
@SerializedName("body") var body: Boolean? = null
)

data class ApiDeviceTokenRequest(
val result: Result = Result(),
val body: DeviceTokenRequest
)

data class DeviceTokenRequest(
val deviceToken: String
val fcmToken: String
)

data class ApiReportRequest(
Expand All @@ -62,7 +58,7 @@ data class ApiReportRequest(
)

data class ReportRequest(
val token: String = "",
val fcmToken: String = "",
val content: String = "",
val clientType: String = "APP",
val deviceName: String = "",
Expand All @@ -75,7 +71,7 @@ data class ApiTopicSubscriptionRequest(
)

data class ManageTopicRequest(
val deviceToken: String = "",
val fcmToken: String = "",
val noticeName: String = "",
val isSubscribed: Boolean = false
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.doyoonkim.knutice.presentation

import android.content.res.Configuration
import android.util.Log
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -9,10 +10,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
Expand All @@ -38,7 +37,6 @@ import com.doyoonkim.knutice.ui.theme.notificationType4
import com.doyoonkim.knutice.ui.theme.subTitle
import com.doyoonkim.knutice.viewModel.CategorizedNotificationViewModel
import com.doyoonkim.knutice.R
import com.doyoonkim.knutice.model.FullContent

@Composable
fun CategorizedNotification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.doyoonkim.knutice.alarm.NotificationAlarmScheduler
import com.doyoonkim.knutice.presentation.component.PermissionRationaleComposable
import com.doyoonkim.knutice.ui.theme.KNUTICETheme
import dagger.hilt.android.AndroidEntryPoint
import java.util.Locale

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ fun MainServiceScreen(
val mainAppState by viewModel.uiState.collectAsState()
val navController = rememberNavController()

// //TODO Live translation feature (TBD)
// var showLanguageDownloadRationale by remember { mutableStateOf(false) }
// LaunchedEffect(Unit) {
// if (Locale.getDefault() != Locale.KOREAN) {
// showLanguageDownloadRationale = true
// }
// }

LaunchedEffect(mainAppState.scheduleTriggered) {
Log.d("MainServiceScreen", "Triggered")
Expand Down Expand Up @@ -277,5 +284,27 @@ fun MainServiceScreen(
)
.background(MaterialTheme.colorScheme.displayBackground)
)

//TODO Live Translation Feature (TBD)
// AnimatedVisibility(
// visible = showLanguageDownloadRationale,
// enter = scaleIn(),
// exit = scaleOut()
// ) {
// Box(
// modifier = Modifier.fillMaxSize()
// .clickable { showLanguageDownloadRationale = false }
// ) {
// PermissionRationaleComposable(
// modifier = Modifier.align(Alignment.Center).padding(start = 20.dp, end = 20.dp),
// permissionName = stringResource(R.string.text_language),
// rationaleTitle = stringResource(R.string.title_langauge_model_download),
// description = stringResource(R.string.description_language_model_download)
// ) {
// viewModel.requestModelDownload()
// showLanguageDownloadRationale = true
// }
// }
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.doyoonkim.knutice.model.Notice
import com.doyoonkim.knutice.model.NoticeCategory
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand Down Expand Up @@ -62,9 +63,12 @@ class CategorizedNotificationViewModel @Inject constructor(
onSuccess = {
val notices = listOf(it.notice1!!, it.notice2!!, it.notice3!!)
when(category) {
NoticeCategory.GENERAL_NEWS -> updateState(
updatedNotificationGeneral = notices
)
NoticeCategory.GENERAL_NEWS -> {

updateState(
updatedNotificationGeneral = notices
)
}
NoticeCategory.ACADEMIC_NEWS -> updateState(
updatedNotificationAcademic = notices
)
Expand All @@ -83,6 +87,7 @@ class CategorizedNotificationViewModel @Inject constructor(
)
}
}

}

data class CategorizedNotificationState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ class MainServiceViewModel @Inject constructor() : ViewModel() {
)
}
}

fun updateLanguageModelDownloadStatus(newStatus: String) {
_uiState.update {
it.copy(
languageModelDownloadResult = newStatus
)
}
}
}

data class MainServiceState(
Expand All @@ -42,5 +50,6 @@ data class MainServiceState(
val isBottomNavBarVisible: Boolean = false,
val tempReserveNoticeForBookmark: Notice = Notice(), // ?
val currentTargetBookmark: Bookmark = Bookmark(-1),
val scheduleTriggered: Boolean = false
val scheduleTriggered: Boolean = false,
val languageModelDownloadResult: String = "YET_STARTED"
)
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="about_title">About</string>
<string name="about_version">Version</string>
<string name="about_oss">Open Source License</string>
<string name="version_code" translatable="false">1.3.2</string>
<string name="version_code" translatable="false">1.3.3</string>
<string name="pref_notification_title">Notification</string>
<string name="title_preference">Preference</string>
<string name="new_notice">New Notice has been delivered!</string>
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ firebaseMessaging = "24.0.2"
kotlinSerialization = "1.6.0"
junitKtx = "1.2.1"
protoliteWellKnownTypes = "18.0.0"
translate = "17.0.3"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand Down Expand Up @@ -72,6 +73,7 @@ firebase-messaging = { group = "com.google.firebase", name = "firebase-messaging
kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref="kotlinSerialization" }
androidx-junit-ktx = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "junitKtx" }
protolite-well-known-types = { group = "com.google.firebase", name = "protolite-well-known-types", version.ref = "protoliteWellKnownTypes" }
translate = { module = "com.google.mlkit:translate", version.ref = "translate" }


[plugins]
Expand Down
Loading