From b5ba6a5e121c5868b25061f5de05d6b8b7a5ce08 Mon Sep 17 00:00:00 2001 From: Doyoon Kim Date: Mon, 21 Oct 2024 22:40:52 +0900 Subject: [PATCH 1/4] [CHORE] Replace Static String with Localizable String. - Add translatable string in String resource, and replace static sting value with it. --- .../java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt | 2 +- app/src/main/res/values-ko-rKR/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) 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 372094e..8ef4d89 100644 --- a/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt +++ b/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt @@ -55,7 +55,7 @@ class PushNotificationHandler @Inject constructor() : FirebaseMessagingService() applicationContext, getString(R.string.inapp_notification_channel_id) ) .setSmallIcon(R.mipmap.ic_launcher) - .setContentTitle("New Notice!") + .setContentTitle(getString(R.string.new_notice)) .setContentText(this@toPushNotification.notification?.body ?: "No message body") .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setAutoCancel(true) diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index c4999d7..712f038 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -15,4 +15,5 @@ 1.0.0 알파 (내부테스트용) 알림 설정 + 새로운 알림이 도착했어요! \ 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 79caa34..0dbd9c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,7 @@ 1.0.0 Alpha Notification Preference + New Notice has been delivered! knutice_default_fcm_channel knutice default notification channel for FCM knutice_inapp_notification_channel From 3f076cd618c2d2150b234148de6aee2d6e8c28c6 Mon Sep 17 00:00:00 2001 From: Doyoon Kim Date: Mon, 21 Oct 2024 22:41:49 +0900 Subject: [PATCH 2/4] [REFACT] Make Full Content Scrollable - Enable scroll feature on composable where full content is being displayed. --- .../presentation/DetailedNoticeContent.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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 5a76a8f..a1de5c1 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/DetailedNoticeContent.kt @@ -10,7 +10,9 @@ 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.shape.RoundedCornerShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.ButtonColors import androidx.compose.material3.IconButton @@ -89,13 +91,19 @@ fun DetailedNoticeContent( fontWeight = FontWeight.Normal ) - Text( + Surface( modifier = Modifier.fillMaxWidth() - .weight(8f), - text = requested.fullContent, - fontSize = 18.sp, - fontWeight = FontWeight.Medium, - ) + .weight(8f) + .verticalScroll(rememberScrollState()), + color = MaterialTheme.colorScheme.containerBackground + ) { + Text( + modifier = Modifier.fillMaxWidth(), + text = requested.fullContent, + fontSize = 18.sp, + fontWeight = FontWeight.Medium, + ) + } Button( onClick = { From f52921bb76ad44c4455c70748a0c2c284af40b29 Mon Sep 17 00:00:00 2001 From: Doyoon Kim Date: Wed, 23 Oct 2024 23:41:07 +0900 Subject: [PATCH 3/4] [REFACT] Replace Notification Icon. - Replace notification icon from SmallIcon to LargeIcon for better visibility. - Convert string resource 'notification channel name' into translatable. --- .../java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt | 4 +++- app/src/main/res/values-ko-rKR/strings.xml | 3 ++- app/src/main/res/values/strings.xml | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) 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 8ef4d89..6d52ba0 100644 --- a/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt +++ b/app/src/main/java/com/doyoonkim/knutice/fcm/PushNotificationHandler.kt @@ -5,6 +5,8 @@ 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 @@ -54,7 +56,7 @@ class PushNotificationHandler @Inject constructor() : FirebaseMessagingService() val notificationBuilder = NotificationCompat.Builder( applicationContext, getString(R.string.inapp_notification_channel_id) ) - .setSmallIcon(R.mipmap.ic_launcher) + .setLargeIcon(Icon.createWithResource(applicationContext, R.mipmap.ic_launcher)) .setContentTitle(getString(R.string.new_notice)) .setContentText(this@toPushNotification.notification?.body ?: "No message body") .setPriority(NotificationCompat.PRIORITY_DEFAULT) diff --git a/app/src/main/res/values-ko-rKR/strings.xml b/app/src/main/res/values-ko-rKR/strings.xml index 712f038..b10222c 100644 --- a/app/src/main/res/values-ko-rKR/strings.xml +++ b/app/src/main/res/values-ko-rKR/strings.xml @@ -12,8 +12,9 @@ 더보기 버전정보 오픈소스 라이센스 - 1.0.0 알파 (내부테스트용) + 1.0.1 알파 (내부테스트용) 알림 설정 새로운 알림이 도착했어요! + 신규 공지 알림 \ 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 0dbd9c1..52711f4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,7 +11,7 @@ About Version Open Source License - 1.0.0 Alpha + 1.0.1 Alpha Notification Preference New Notice has been delivered! @@ -19,5 +19,5 @@ knutice default notification channel for FCM knutice_inapp_notification_channel knutice inapp notification channel - knutice inapp notification Channel + KNUTICE In-app Notice \ No newline at end of file From c77b59934f26ed6281977a2fcea2226f6135df5a Mon Sep 17 00:00:00 2001 From: Doyoon Kim Date: Sun, 27 Oct 2024 23:20:06 +0900 Subject: [PATCH 4/4] [FEAT] Add Actions for Back Button/Gesture. - Define an appropriate action for Back Button Pressed and back gesture provided. 1. If a MoreDetailedContent Composable is appeared, back button/gesture would close the currently appeared DetailedContent Composable. 2. Otherwise, it works just as expected. (Back to where user was previously at. --- .../knutice/navigation/MainNavigator.kt | 16 ++++++++++++---- .../presentation/CategorizedNoficiation.kt | 8 ++++++++ .../presentation/MoreCategorizedNoticiation.kt | 9 ++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) 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 e65da38..a805fba 100644 --- a/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt +++ b/app/src/main/java/com/doyoonkim/knutice/navigation/MainNavigator.kt @@ -38,28 +38,36 @@ fun MainNavigator( viewModel.updateState( updatedCurrentLocation = Destination.MORE_GENERAL ) - MoreCategorizedNotification(category = NoticeCategory.GENERAL_NEWS) + MoreCategorizedNotification(category = NoticeCategory.GENERAL_NEWS) { + navController.popBackStack() + } } composable(Destination.MORE_ACADEMIC.name) { viewModel.updateState( updatedCurrentLocation = Destination.MORE_ACADEMIC ) - MoreCategorizedNotification(category = NoticeCategory.ACADEMIC_NEWS) + MoreCategorizedNotification(category = NoticeCategory.ACADEMIC_NEWS) { + navController.popBackStack() + } } composable(Destination.MORE_SCHOLARSHIP.name) { viewModel.updateState( updatedCurrentLocation = Destination.MORE_SCHOLARSHIP ) - MoreCategorizedNotification(category = NoticeCategory.SCHOLARSHIP_NEWS) + MoreCategorizedNotification(category = NoticeCategory.SCHOLARSHIP_NEWS) { + navController.popBackStack() + } } composable(Destination.MORE_EVENT.name) { viewModel.updateState( updatedCurrentLocation = Destination.MORE_EVENT ) - MoreCategorizedNotification(category = NoticeCategory.EVENT_NEWS) + MoreCategorizedNotification(category = NoticeCategory.EVENT_NEWS) { + navController.popBackStack() + } } composable(Destination.SETTINGS.name) { 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 0d83ba6..511b832 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/CategorizedNoficiation.kt @@ -1,6 +1,7 @@ package com.doyoonkim.knutice.presentation import android.content.res.Configuration +import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -14,6 +15,7 @@ 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 @@ -46,6 +48,12 @@ fun CategorizedNotification( ) { val uiState by viewModel.uiState.collectAsState() + // Back button/gesture actions + BackHandler { + if (uiState.isDetailedViewOpened) viewModel.updateState(updatedIsDetailedViewOpened = false) + else navController.popBackStack() + } + Column( modifier = modifier.verticalScroll( rememberScrollState(0) diff --git a/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt b/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt index 4e87fc0..f1de57d 100644 --- a/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt +++ b/app/src/main/java/com/doyoonkim/knutice/presentation/MoreCategorizedNoticiation.kt @@ -1,6 +1,7 @@ package com.doyoonkim.knutice.presentation import android.util.Log +import androidx.activity.compose.BackHandler import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -38,7 +39,8 @@ import com.doyoonkim.knutice.viewModel.MoreCategorizedNotificationViewModel fun MoreCategorizedNotification( modifier: Modifier = Modifier, viewModel: MoreCategorizedNotificationViewModel = hiltViewModel(), - category: NoticeCategory + category: NoticeCategory, + backButtonHandler: () -> Unit = { } ) { val uiState by viewModel.uiState.collectAsStateWithLifecycle() @@ -49,6 +51,11 @@ fun MoreCategorizedNotification( } ) + BackHandler { + if (uiState.isDetailedContentVisible) viewModel.updatedDetailedContentRequest(false) + else backButtonHandler() + } + Box( modifier = modifier.fillMaxWidth() .pullRefresh(pullRefreshState)