diff --git a/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt b/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt
index 6d52ba0..fe29669 100644
--- a/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt
@@ -1,28 +1,20 @@
package com.doyoonkim.knutice.fcm
import android.Manifest
-import android.app.NotificationChannel
-import android.app.NotificationManager
-import android.content.Context
import android.content.pm.PackageManager
-import android.graphics.Bitmap
import android.graphics.drawable.Icon
-import android.os.Build
import android.util.Log
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.doyoonkim.knutice.data.KnuticeRemoteSource
import com.example.knutice.R
-import com.google.android.datatransport.Priority
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.messaging.FirebaseMessaging
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
-import java.util.UUID
import javax.inject.Inject
import kotlin.random.Random
-import kotlin.random.nextInt
class PushNotificationHandler @Inject constructor() : FirebaseMessagingService() {
@Inject lateinit var remoteSource: KnuticeRemoteSource
diff --git a/app/src/main/java/com/doyoonkim/knutice/model/Types.kt b/app/src/main/java/com/doyoonkim/knutice/model/Types.kt
index a254d24..ad307e4 100644
--- a/app/src/main/java/com/doyoonkim/knutice/model/Types.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/model/Types.kt
@@ -2,4 +2,4 @@ package com.doyoonkim.knutice.model
enum class NoticeCategory { GENERAL_NEWS, ACADEMIC_NEWS, SCHOLARSHIP_NEWS, EVENT_NEWS, Unspecified }
-enum class Destination { MAIN, MORE_GENERAL, MORE_ACADEMIC, MORE_SCHOLARSHIP, MORE_EVENT, SETTINGS, CS }
\ No newline at end of file
+enum class Destination { MAIN, MORE_GENERAL, MORE_ACADEMIC, MORE_SCHOLARSHIP, MORE_EVENT, SETTINGS, CS, OSS }
\ No newline at end of file
diff --git a/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt b/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt
index a805fba..91cb51f 100644
--- a/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt
@@ -12,6 +12,7 @@ import com.doyoonkim.knutice.model.Destination
import com.doyoonkim.knutice.model.NoticeCategory
import com.doyoonkim.knutice.presentation.CategorizedNotification
import com.doyoonkim.knutice.presentation.MoreCategorizedNotification
+import com.doyoonkim.knutice.presentation.OpenSourceLicenseNotice
import com.doyoonkim.knutice.presentation.UserPreference
import com.doyoonkim.knutice.viewModel.MainActivityViewModel
@@ -75,8 +76,16 @@ fun MainNavigator(
updatedCurrentLocation = Destination.SETTINGS
)
UserPreference(
- Modifier.padding(top = 20.dp, start = 10.dp, end = 10.dp)
+ Modifier.padding(top = 20.dp, start = 10.dp, end = 10.dp),
+ navController
)
}
+
+ composable(Destination.OSS.name) {
+ viewModel.updateState(
+ updatedCurrentLocation = Destination.OSS
+ )
+ OpenSourceLicenseNotice()
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt
index 511b832..8a0f465 100644
--- a/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt
@@ -15,7 +15,6 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
-import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt
index a1de5c1..36b4dec 100644
--- a/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt
@@ -3,6 +3,7 @@ package com.doyoonkim.knutice.presentation
import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.Image
+import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -48,7 +49,8 @@ fun DetailedNoticeContent(
val localContext = LocalContext.current
Surface(
- modifier = modifier.fillMaxWidth(),
+ modifier = modifier.fillMaxWidth()
+ .background(MaterialTheme.colorScheme.containerBackground),
shape = RoundedCornerShape(10.dp),
color = MaterialTheme.colorScheme.containerBackground
) {
diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/MainActivity.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/MainActivity.kt
index 4ccb232..e2f1887 100644
--- a/app/src/main/java/com/doyoonkim/knutice/presentation/MainActivity.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/presentation/MainActivity.kt
@@ -54,6 +54,7 @@ class MainActivity : ComponentActivity() {
// Permission is already granted, and Push Notification is available
} else {
// Need to inform user that the app won't display push notification.
+ // TODO: Add small pop-up style composable to be shown to indicate that a push notification won't available.
}
}
@@ -83,6 +84,13 @@ class MainActivity : ComponentActivity() {
}
}
}
+
+ override fun onDestroy() {
+ super.onDestroy()
+
+ viewModelStore.clear()
+ this.externalCacheDir?.delete()
+ }
}
@OptIn(ExperimentalMaterial3Api::class)
@@ -129,6 +137,7 @@ fun MainServiceScreen(
Destination.MORE_SCHOLARSHIP -> R.string.scholarship_news
Destination.MORE_EVENT -> R.string.event_news
Destination.SETTINGS -> R.string.title_preference
+ Destination.OSS -> R.string.oss_notice
else -> R.string.app_name
}),
fontSize = 20.sp,
diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/OssNotice.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/OssNotice.kt
new file mode 100644
index 0000000..c64da1a
--- /dev/null
+++ b/app/src/main/java/com/doyoonkim/knutice/presentation/OssNotice.kt
@@ -0,0 +1,30 @@
+package com.doyoonkim.knutice.presentation
+
+import android.webkit.WebView
+import androidx.compose.foundation.layout.fillMaxWidth
+import androidx.compose.foundation.layout.padding
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.viewinterop.AndroidView
+
+@Composable
+fun OpenSourceLicenseNotice(
+ modifier: Modifier = Modifier
+) {
+ AndroidView(
+ modifier = modifier.fillMaxWidth().padding(5.dp),
+ factory = { context ->
+ WebView(context).apply {
+ loadUrl("https://knutice.github.io/KNUTICE-OpenSourceLicense/Android/opensource.html")
+ }
+ }
+ )
+}
+
+@Composable
+@Preview
+fun OpenSourceLicenseNotice_Preview() {
+ OpenSourceLicenseNotice()
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/UserPreference.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/UserPreference.kt
index 6352631..953ed3d 100644
--- a/app/src/main/java/com/doyoonkim/knutice/presentation/UserPreference.kt
+++ b/app/src/main/java/com/doyoonkim/knutice/presentation/UserPreference.kt
@@ -1,5 +1,9 @@
package com.doyoonkim.knutice.presentation
+import android.Manifest
+import android.content.Intent
+import android.content.pm.PackageManager
+import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -8,18 +12,33 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.HorizontalDivider
+import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+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.graphics.ColorFilter
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.core.content.ContextCompat
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.compose.LifecycleEventEffect
+import androidx.navigation.NavController
+import androidx.navigation.compose.rememberNavController
+import com.doyoonkim.knutice.model.Destination
+import com.doyoonkim.knutice.ui.theme.buttonContainer
import com.doyoonkim.knutice.ui.theme.subTitle
import com.example.knutice.R
@@ -28,7 +47,17 @@ import com.example.knutice.R
@Composable
fun UserPreference(
modifier: Modifier = Modifier,
+ navController: NavController = rememberNavController()
) {
+ var permissionStatus by remember { mutableStateOf(false) }
+ val context = LocalContext.current
+
+ LifecycleEventEffect(Lifecycle.Event.ON_RESUME) {
+ permissionStatus = ContextCompat.checkSelfPermission(
+ context, Manifest.permission.POST_NOTIFICATIONS
+ ) == PackageManager.PERMISSION_GRANTED
+ }
+
Column(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally,
@@ -78,9 +107,17 @@ fun UserPreference(
}
Switch(
- checked = false,
- onCheckedChange = { },
- enabled = false
+ checked = permissionStatus,
+ onCheckedChange = {
+ val settingIntent = Intent(
+ "android.settings.APP_NOTIFICATION_SETTINGS"
+ ).apply {
+ this.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ this.putExtra("android.provider.extra.APP_PACKAGE", context.packageName)
+ }
+ context.startActivity(settingIntent)
+ },
+ enabled = true
)
}
}
@@ -133,8 +170,8 @@ fun UserPreference(
Row(
modifier = Modifier.fillMaxWidth().wrapContentSize()
- .padding(top = 15.dp, bottom = 15.dp),
- verticalAlignment = Alignment.Bottom
+ .padding(top = 5.dp, bottom = 5.dp),
+ verticalAlignment = Alignment.CenterVertically,
) {
Text(
modifier = Modifier.wrapContentHeight().weight(5f),
@@ -144,14 +181,15 @@ fun UserPreference(
textAlign = TextAlign.Start
)
- //TODO: Should be replaced with Actual Icon Button.
- Text(
- modifier = Modifier.wrapContentHeight().weight(2f),
- text = ">",
- fontWeight = FontWeight.Normal,
- fontSize = 14.sp,
- textAlign = TextAlign.End
- )
+ IconButton(
+ onClick = { navController.navigate(Destination.OSS.name) }
+ ) {
+ Image(
+ painter = painterResource(R.drawable.baseline_arrow_forward_ios_24),
+ contentDescription = "Button to OSS Notice",
+ colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.buttonContainer)
+ )
+ }
}
HorizontalDivider(
diff --git a/app/src/main/res/drawable/baseline_arrow_forward_ios_24.xml b/app/src/main/res/drawable/baseline_arrow_forward_ios_24.xml
new file mode 100644
index 0000000..19201cb
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_arrow_forward_ios_24.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml
index b10222c..8bdfc32 100644
--- a/app/src/main/res/values-ko-rKR/strings.xml
+++ b/app/src/main/res/values-ko-rKR/strings.xml
@@ -17,4 +17,5 @@
설정
새로운 알림이 도착했어요!
신규 공지 알림
+ 오픈소스 라이센스
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 52711f4..7050c37 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -20,4 +20,5 @@
knutice_inapp_notification_channel
knutice inapp notification channel
KNUTICE In-app Notice
+ Open Source License
\ No newline at end of file