Skip to content

Commit

Permalink
Merge pull request #81 from kw-notice/develop
Browse files Browse the repository at this point in the history
2.2.1
  • Loading branch information
yjyoon-dev committed Feb 7, 2023
2 parents fa54197 + 915f96d commit 19eea0c
Show file tree
Hide file tree
Showing 52 changed files with 937 additions and 344 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
.externalNativeBuild
.cxx
local.properties

release
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ https://play.google.com/store/apps/details?id=dev.yjyoon.kwnotice
# Screenshots

<p>
<img width="22%" src="https://user-images.githubusercontent.com/72238126/180598029-2c5e78df-5fc9-4645-8ddf-c8702b7f0c7b.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/180598032-71850a73-6a92-4512-88e6-a90ab4a3cffa.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/180598038-c3263ad0-e227-4e03-9981-291d1d440e25.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/180598039-8c7ae538-4140-407c-94a7-c91b71eb0ad5.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/216070956-fa5cd3c6-4de0-47d8-9909-107b1a378326.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/216070959-5446afb0-6c68-44ae-888f-27219e9e55fb.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/216070964-676b09f6-2833-4bba-848d-f3aad30e2ad4.png">
<img width="22%" src="https://user-images.githubusercontent.com/72238126/216070969-91a6f571-2979-4463-b483-93648718ceec.png">
</p>

<br>
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ plugins {

android {
namespace = "dev.yjyoon.kwnotice"
compileSdk = 32
compileSdk = 33

defaultConfig {
applicationId = "dev.yjyoon.kwnotice"
minSdk = 24
targetSdk = 32
versionCode = 7
versionName = "2.1.0"
targetSdk = 33
versionCode = 10
versionName = "2.2.1"
}

buildTypes {
Expand Down Expand Up @@ -46,9 +46,9 @@ dependencies {
implementation(project(":data"))
implementation(project(":presentation"))

implementation(platform(libs.google.firebase.bom))
implementation(libs.google.firebase.messaging)
implementation(libs.google.firebase.analytics)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.messaging)
implementation(libs.firebase.analytics)

implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.KWNotice"
tools:targetApi="31">
android:theme="@style/Theme.KWNotice">

<activity
android:name=".presentation.ui.splash.SplashActivity"
android:exported="true"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/dev/yjyoon/kwnotice/fcm/FcmService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.media.RingtoneManager
import android.os.Build
import androidx.core.app.NotificationCompat
import com.google.firebase.messaging.FirebaseMessagingService
Expand All @@ -32,13 +31,10 @@ class FcmService : FirebaseMessagingService() {

val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)

val soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)

val notificationBuilder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(notification.title)
.setContentText(notification.body)
.setSound(soundUri)
.setContentIntent(pendingIntent)
.setAutoCancel(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlin.coroutines.suspendCoroutine
internal class FcmSubscriptionImpl @Inject constructor() : FcmSubscription {

override suspend fun subscribeTo(topic: FcmTopic): Result<Unit> = runCatching {
suspendCoroutine<Unit> { continuation ->
suspendCoroutine { continuation ->
FirebaseMessaging.getInstance().subscribeToTopic(topic.value)
.addOnCompleteListener {
Log.d("fcm", "Subscribed to ${topic.value} successfully")
Expand All @@ -26,7 +26,7 @@ internal class FcmSubscriptionImpl @Inject constructor() : FcmSubscription {
}

override suspend fun unsubscribeFrom(topic: FcmTopic): Result<Unit> = runCatching {
suspendCoroutine<Unit> { continuation ->
suspendCoroutine { continuation ->
FirebaseMessaging.getInstance().unsubscribeFromTopic(topic.value)
.addOnCompleteListener {
Log.d("fcm", "Unsubscribed from ${topic.value} successfully")
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {

dependencies {
classpath(libs.android.gradle)
classpath(libs.kotlin.plugin)
classpath(libs.kotlin.gradle)
classpath(libs.google.services)
classpath(libs.hilt.gradle)
}
Expand Down
14 changes: 7 additions & 7 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ properties.load(project.rootProject.file("local.properties").inputStream())

android {
namespace = "dev.yjyoon.kwnotice.data"
compileSdk = 32
compileSdk = 33

defaultConfig {
minSdk = 24
targetSdk = 32

buildConfigField("String", "BASE_URL", properties["base_url"] as String)
buildConfigField("String", "KW_DORM_NOTICE_URL", properties["kw_dorm_notice_url"] as String)
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
Expand All @@ -34,12 +34,12 @@ android {
dependencies {
implementation(project(":domain"))

implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
annotationProcessor(libs.androidx.room.compiler)
kapt(libs.androidx.room.compiler)
implementation(libs.room.runtime)
implementation(libs.room.ktx)
annotationProcessor(libs.room.compiler)
kapt(libs.room.compiler)

implementation(libs.androidx.datastore.preferences)
implementation(libs.datastore.preferences)

implementation(libs.retrofit.core)
implementation(libs.retrofit.converter.gson)
Expand Down
5 changes: 5 additions & 0 deletions data/src/main/java/dev/yjyoon/kwnotice/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ internal object DataModule {
@Named("BaseUrl")
fun provideBaseUrl(): String = BuildConfig.BASE_URL

@Provides
@Singleton
@Named("KwDormNoticeUrl")
fun provideKwDormNoticeUrl(): String = BuildConfig.KW_DORM_NOTICE_URL

@Provides
@Singleton
@Named("Preferences")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ object FavoriteConverter {
fun dateToString(date: LocalDate): String = date.toString()

@TypeConverter
fun stringToDate(string: String) = LocalDate.parse(string)
fun stringToDate(string: String): LocalDate = LocalDate.parse(string)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ interface FavoriteDao {
@Query("SELECT id FROM favorite WHERE type = 'SwCentral'")
suspend fun getSwCentralIds(): List<Long>

@Query("SELECT id FROM favorite WHERE type = 'KwDorm'")
suspend fun getKwDormIds(): List<Long>

@Query("SELECT * FROM favorite")
fun getAll(): Flow<List<FavoriteEntity>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class FavoriteEntity(
val date: LocalDate,
val url: String
) {
enum class Type { KwHome, SwCentral }
enum class Type { KwHome, SwCentral, KwDorm, Unknown }
}

fun Favorite.toData() = FavoriteEntity(
Expand All @@ -24,6 +24,8 @@ fun Favorite.toData() = FavoriteEntity(
type = when (type) {
Favorite.Type.KwHome -> FavoriteEntity.Type.KwHome
Favorite.Type.SwCentral -> FavoriteEntity.Type.SwCentral
Favorite.Type.KwDorm -> FavoriteEntity.Type.KwDorm
else -> FavoriteEntity.Type.Unknown
},
date = date,
url = url
Expand All @@ -35,6 +37,8 @@ fun FavoriteEntity.toDomain() = Favorite(
type = when (type) {
FavoriteEntity.Type.KwHome -> Favorite.Type.KwHome
FavoriteEntity.Type.SwCentral -> Favorite.Type.SwCentral
FavoriteEntity.Type.KwDorm -> Favorite.Type.KwDorm
else -> Favorite.Type.Unknown
},
date = date,
url = url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package dev.yjyoon.kwnotice.data.remote.api

import dev.yjyoon.kwnotice.data.remote.model.KwDormNoticeResponse
import dev.yjyoon.kwnotice.data.remote.model.KwHomeNoticeResponse
import dev.yjyoon.kwnotice.data.remote.model.SwCentralNoticeResponse
import retrofit2.http.GET
import retrofit2.http.Url

internal interface NoticeService {

Expand All @@ -11,4 +13,7 @@ internal interface NoticeService {

@GET("sw-central")
suspend fun getSwCentralNotices(): List<SwCentralNoticeResponse>

@GET
suspend fun getKwDormNotices(@Url url: String): List<KwDormNoticeResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dev.yjyoon.kwnotice.data.remote.model

import com.google.gson.annotations.SerializedName
import dev.yjyoon.kwnotice.domain.model.Notice
import java.time.LocalDate

data class KwDormNoticeResponse(
@SerializedName("id")
val id: Long,
@SerializedName("title")
val title: String,
@SerializedName("url")
val url: String,
@SerializedName("createdAt")
val postedDate: String,
)

fun KwDormNoticeResponse.toDomain() = Notice.KwDorm(
id = id,
title = title,
url = url,
postedDate = LocalDate.parse(postedDate)
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ internal class FavoriteRepositoryImpl @Inject constructor(
favoriteDao.getSwCentralIds()
}

override suspend fun getFavoriteKwDormIds(): Result<List<Long>> = runCatching {
favoriteDao.getKwDormIds()
}

override fun getAllFavoritesStream(): Flow<List<Favorite>> =
favoriteDao.getAll().map { favorites -> favorites.map { it.toDomain() } }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import dev.yjyoon.kwnotice.data.remote.api.NoticeService
import dev.yjyoon.kwnotice.data.remote.model.toDomain
import dev.yjyoon.kwnotice.domain.model.Notice
import dev.yjyoon.kwnotice.domain.repository.NoticeRepository
import java.time.LocalDate
import javax.inject.Inject
import javax.inject.Named

internal class NoticeRepositoryImpl @Inject constructor(
private val noticeService: NoticeService
private val noticeService: NoticeService,
@Named("KwDormNoticeUrl") private val kwDormNoticeUrl: String
) : NoticeRepository {

override suspend fun getKwHomeNotices(): Result<List<Notice.KwHome>> = runCatching {
Expand All @@ -17,4 +20,15 @@ internal class NoticeRepositoryImpl @Inject constructor(
override suspend fun getSwCentralNotices(): Result<List<Notice.SwCentral>> = runCatching {
noticeService.getSwCentralNotices().map { it.toDomain() }
}

override suspend fun getKwDormNotices(): Result<List<Notice.KwDorm>> = runCatching {
noticeService.getKwDormNotices(kwDormNoticeUrl)
.filter {
LocalDate.parse(it.postedDate)
.plusMonths(4)
.isAfter(LocalDate.now())
}
.reversed()
.map { it.toDomain() }
}
}
25 changes: 14 additions & 11 deletions domain/src/main/java/dev/yjyoon/kwnotice/domain/model/Favorite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ data class Favorite(
val text: String
) {
KwHome(text = KW_HOME),
SwCentral(text = SW_CENTRAL)
SwCentral(text = SW_CENTRAL),
KwDorm(text = KW_DORM),
Unknown(text = UNKNOWN)
}
}

companion object {

fun stringToType(string: String) = when (string) {
KW_HOME -> Type.KwHome
else -> Type.SwCentral
}

const val KW_HOME = "광운대학교"
const val SW_CENTRAL = "SW중심대학사업단"
}
fun String.toFavoriteType(): Favorite.Type = when (this) {
KW_HOME -> Favorite.Type.KwHome
SW_CENTRAL -> Favorite.Type.SwCentral
KW_DORM -> Favorite.Type.KwDorm
else -> Favorite.Type.Unknown
}

const val KW_HOME = "광운대학교"
const val SW_CENTRAL = "SW중심대학사업단"
const val KW_DORM = "빛솔재(기숙사)"
const val UNKNOWN = "UNKNOWN"
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package dev.yjyoon.kwnotice.domain.model
enum class FcmTopic(val value: String) {
KwHomeNew(value = TOPIC_KW_HOME_NEW),
KwHomeEdit(value = TOPIC_KW_HOME_EDIT),
SwCentralNew(value = TOPIC_SW_CENTRAL_NEW)
SwCentralNew(value = TOPIC_SW_CENTRAL_NEW),
KwDormCommon(value = TOPIC_KW_DORM_COMMON),
KwDormRecruitment(value = TOPIC_KW_DORM_RECRUITMENT)
}

private const val TOPIC_KW_HOME_NEW = "kw-home-new"
private const val TOPIC_KW_HOME_EDIT = "kw-home-edit"
private const val TOPIC_SW_CENTRAL_NEW = "sw-central-new"
private const val TOPIC_KW_DORM_COMMON = "kw-dorm-common"
private const val TOPIC_KW_DORM_RECRUITMENT = "kw-dorm-recruitment"
14 changes: 14 additions & 0 deletions domain/src/main/java/dev/yjyoon/kwnotice/domain/model/Notice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ sealed class Notice {
override val url: String,
override val postedDate: LocalDate,
) : Notice()

data class KwDorm(
override val id: Long,
override val title: String,
override val url: String,
override val postedDate: LocalDate,
) : Notice()
}

fun Notice.toFavorite() = when (this) {
Expand All @@ -42,4 +49,11 @@ fun Notice.toFavorite() = when (this) {
date = postedDate,
type = Favorite.Type.SwCentral
)
is Notice.KwDorm -> Favorite(
id = id,
title = title,
url = url,
date = postedDate,
type = Favorite.Type.KwDorm
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ interface FavoriteRepository {

suspend fun getFavoriteSwCentralIds(): Result<List<Long>>

suspend fun getFavoriteKwDormIds(): Result<List<Long>>

fun getAllFavoritesStream(): Flow<List<Favorite>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ interface NoticeRepository {
suspend fun getKwHomeNotices(): Result<List<Notice.KwHome>>

suspend fun getSwCentralNotices(): Result<List<Notice.SwCentral>>
suspend fun getKwDormNotices(): Result<List<Notice.KwDorm>>
}
Loading

0 comments on commit 19eea0c

Please sign in to comment.