Skip to content

Commit

Permalink
Merge pull request #167 from TimerTiTi/Release-1.2.1
Browse files Browse the repository at this point in the history
Release 1.2.1
  • Loading branch information
koreatlwls authored Jul 17, 2024
2 parents bf79345 + 5ded4fe commit d7af3f3
Show file tree
Hide file tree
Showing 50 changed files with 842 additions and 653 deletions.
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@

</application>

<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="*" />
</intent>
</queries>
</manifest>
4 changes: 2 additions & 2 deletions build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object BuildType {

object AppConfig {
const val APP_ID = "com.titi.app"
const val APP_VERSION_NAME = "1.2.0"
const val APP_VERSION_CODE = 34
const val APP_VERSION_NAME = "1.2.1"
const val APP_VERSION_CODE = 36
const val APP_NAME = "TiTi"
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ private fun TdsWeekLineBar(
text = time,
style = textStyle,
topLeft = Offset(
x = center.x - dateTextLayoutResult.size.width / 2,
y = startY - dateTextLayoutResult.size.height - spacing,
x = center.x - timeTextLayoutResult.size.width / 2,
y = startY - timeTextLayoutResult.size.height - spacing,
),
)

Expand Down Expand Up @@ -190,7 +190,7 @@ private fun TdsWeekLineChartPreview() {
.background(Color.White),
weekLineChartData = listOf(
TdsWeekLineChartData(
time = 6200,
time = 36000,
date = "1/12",
),
TdsWeekLineChartData(
Expand Down
13 changes: 13 additions & 0 deletions core/designsystem/src/main/res/drawable/email_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>
<path
android:pathData="M22,6C22,4.9 21.1,4 20,4H4C2.9,4 2,4.9 2,6V18C2,19.1 2.9,20 4,20H20C21.1,20 22,19.1 22,18V6ZM20,6L12,11L4,6H20ZM20,18H4V8L12,13L20,8V18Z"
android:fillColor="#000000"/>
</group>
</vector>
20 changes: 20 additions & 0 deletions core/designsystem/src/main/res/drawable/github_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="800dp"
android:height="800dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M9.292,21V18.441L9.325,16.622C9.366,16.056 9.586,15.523 9.949,15.11C9.954,15.104 9.96,15.098 9.965,15.092C9.979,15.076 9.97,15.051 9.949,15.049V15.049C7.526,14.746 5.001,13.723 5.001,9.267C4.985,8.17 5.343,7.106 6.004,6.272C6.028,6.243 6.051,6.214 6.075,6.185V6.185C6.106,6.148 6.116,6.098 6.102,6.051C6.101,6.049 6.1,6.046 6.099,6.043C6.083,5.99 6.068,5.937 6.054,5.883C5.811,4.965 5.863,3.984 6.205,3.098C6.208,3.092 6.21,3.085 6.213,3.079C6.226,3.046 6.253,3.021 6.287,3.015V3.015C6.502,2.977 7.37,2.925 9.033,4.073C9.085,4.109 9.137,4.146 9.191,4.184V4.184C9.229,4.212 9.278,4.22 9.323,4.207C9.325,4.207 9.326,4.206 9.328,4.206C9.417,4.181 9.506,4.156 9.596,4.134C11.177,3.732 12.823,3.732 14.404,4.134C14.489,4.155 14.574,4.178 14.658,4.202C14.66,4.203 14.662,4.203 14.664,4.204C14.717,4.219 14.775,4.209 14.82,4.177V4.177C14.87,4.141 14.919,4.107 14.967,4.073C16.626,2.928 17.489,2.976 17.705,3.015V3.015C17.74,3.021 17.768,3.046 17.781,3.079C17.783,3.084 17.784,3.088 17.786,3.092C18.134,3.978 18.189,4.962 17.946,5.883C17.931,5.938 17.916,5.993 17.899,6.047V6.047C17.884,6.096 17.895,6.149 17.928,6.189C17.929,6.19 17.93,6.191 17.931,6.192C17.953,6.219 17.974,6.245 17.996,6.272C18.657,7.106 19.015,8.17 19,9.267C19,13.747 16.456,14.743 14.021,15.015V15.015C14.007,15.017 14.001,15.033 14.01,15.044C14.014,15.048 14.018,15.052 14.021,15.056C14.267,15.33 14.458,15.654 14.581,16.01C14.71,16.382 14.763,16.78 14.735,17.175V21"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#323232"
android:strokeLineCap="round"/>
<path
android:pathData="M4,17C4.369,17.052 4.722,17.188 5.031,17.397C5.34,17.607 5.597,17.884 5.784,18.208C5.942,18.496 6.156,18.75 6.413,18.956C6.669,19.161 6.964,19.313 7.279,19.404C7.595,19.495 7.925,19.523 8.251,19.485C8.577,19.448 8.893,19.346 9.179,19.185"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#323232"
android:strokeLineCap="round"/>
</vector>
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/instagram_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M8,3C5.243,3 3,5.243 3,8V16C3,18.757 5.243,21 8,21H16C18.757,21 21,18.757 21,16V8C21,5.243 18.757,3 16,3H8ZM8,5H16C17.654,5 19,6.346 19,8V16C19,17.654 17.654,19 16,19H8C6.346,19 5,17.654 5,16V8C5,6.346 6.346,5 8,5ZM17,6C16.735,6 16.48,6.105 16.293,6.293C16.105,6.48 16,6.735 16,7C16,7.265 16.105,7.52 16.293,7.707C16.48,7.895 16.735,8 17,8C17.265,8 17.52,7.895 17.707,7.707C17.895,7.52 18,7.265 18,7C18,6.735 17.895,6.48 17.707,6.293C17.52,6.105 17.265,6 17,6ZM12,7C9.243,7 7,9.243 7,12C7,14.757 9.243,17 12,17C14.757,17 17,14.757 17,12C17,9.243 14.757,7 12,7ZM12,9C13.654,9 15,10.346 15,12C15,13.654 13.654,15 12,15C10.346,15 9,13.654 9,12C9,10.346 10.346,9 12,9Z"
android:fillColor="#000000"/>
</vector>
10 changes: 10 additions & 0 deletions core/ui/src/main/kotlin/com/titi/app/core/ui/ContextExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.titi.app.core.ui

import android.app.Activity
import android.app.NotificationManager
import android.content.Context
import android.view.WindowManager

Expand All @@ -11,3 +12,12 @@ fun Context.setBrightness(isDark: Boolean) {
if (isDark) 5f / 255 else WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
activity.window.attributes = layoutParams
}

fun Context.removeNotification() {
val notificationManager = this.getSystemService(
Context.NOTIFICATION_SERVICE,
) as NotificationManager

notificationManager.cancel(0)
notificationManager.cancel(1)
}
78 changes: 45 additions & 33 deletions core/util/src/main/kotlin/com/titi/app/core/util/JavaTimeUtil.kt
Original file line number Diff line number Diff line change
@@ -1,46 +1,14 @@
package com.titi.app.core.util

import java.time.DayOfWeek
import java.time.Duration
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter

fun isCurrentWeek(checkDate: ZonedDateTime, currentDate: LocalDate): Boolean {
val diffMonday = currentDate.dayOfWeek.value - DayOfWeek.MONDAY.value
val diffSunday = DayOfWeek.SUNDAY.value - currentDate.dayOfWeek.value

val monday = currentDate
.minusDays(diffMonday.toLong())
.atStartOfDay()
.atZone(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

val sunday = currentDate
.plusDays(diffSunday.toLong())
.atTime(23, 59, 59)
.atZone(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

return checkDate.isAfter(monday) && checkDate.isBefore(sunday)
}

fun isCurrentDaily(checkDate: ZonedDateTime, currentDate: LocalDate): Boolean {
val startCurrentDay = currentDate
.atStartOfDay()
.atZone(ZoneId.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

val endCurrentDay = currentDate
.atTime(23, 59, 59)
.atZone(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

return checkDate.isAfter(startCurrentDay) && checkDate.isBefore(endCurrentDay)
}

fun LocalDateTime.toOnlyTime(): String {
val formatter = DateTimeFormatter.ofPattern("HH:mm:ss")
return this.format(formatter)
Expand Down Expand Up @@ -91,3 +59,47 @@ fun getDailyDayWithHour(hour: Int): Pair<String, String> {
startDateTime to endDateTime
}
}

fun areDatesInSameMonth(localDate: LocalDate, zonedDateTime: ZonedDateTime): Boolean {
val zonedDateTimeToLocalDate = zonedDateTime.toLocalDate()

return localDate.year == zonedDateTimeToLocalDate.year &&
localDate.month == zonedDateTimeToLocalDate.month
}

fun areDatesInSameWeek(localDate: LocalDate, zonedDateTime: ZonedDateTime): Boolean {
val (monday, sunday) = getMondaySunday(localDate)

return zonedDateTime.isAfter(monday) && zonedDateTime.isBefore(sunday)
}

fun areDatesInSameDay(localDate: LocalDate, zonedDateTime: ZonedDateTime): Boolean {
val zonedDateTimeToLocalDate = zonedDateTime.toLocalDate()

return localDate == zonedDateTimeToLocalDate
}

fun getMondaySunday(currentDate: LocalDate): Pair<ZonedDateTime, ZonedDateTime> {
val diffMonday = currentDate.dayOfWeek.value - DayOfWeek.MONDAY.value
val diffSunday = DayOfWeek.SUNDAY.value - currentDate.dayOfWeek.value

val monday = currentDate
.minusDays(diffMonday.toLong())
.atStartOfDay(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

val sunday = currentDate
.plusDays(diffSunday.toLong())
.atTime(23, 59, 59)
.atZone(ZoneOffset.systemDefault())
.withZoneSameInstant(ZoneOffset.UTC)

return Pair(monday, sunday)
}

fun getMeasureTime(dateTime: String): Long {
val inputDateTime = ZonedDateTime.parse(dateTime)
val currentDateTime = ZonedDateTime.now(ZoneOffset.UTC)

return Duration.between(inputDateTime, currentDateTime).seconds
}
8 changes: 0 additions & 8 deletions core/util/src/main/kotlin/com/titi/app/core/util/TimeUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.titi.app.core.util

import org.threeten.bp.Duration
import org.threeten.bp.ZoneId
import org.threeten.bp.ZoneOffset
import org.threeten.bp.ZonedDateTime
import org.threeten.bp.format.DateTimeFormatter

Expand All @@ -26,13 +25,6 @@ fun getTimeToLong(hour: String, minutes: String, seconds: String): Long {
return hourLong * 3600 + minutesLong * 60 + secondsLong
}

fun getMeasureTime(dateTime: String): Long {
val inputDateTime = ZonedDateTime.parse(dateTime)
val currentDateTime = ZonedDateTime.now(ZoneOffset.UTC)

return Duration.between(inputDateTime, currentDateTime).seconds
}

fun addTimeLine(
startTime: ZonedDateTime,
endTime: ZonedDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.PendingIntent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP
import android.net.Uri
import androidx.core.app.NotificationCompat
import com.titi.app.core.util.goAsync
Expand Down Expand Up @@ -37,7 +38,7 @@ internal class AlarmReceiver : BroadcastReceiver() {

val deepLink = "titi://"
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(deepLink)).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
flags = FLAG_ACTIVITY_SINGLE_TOP
}
val pendingIntent: PendingIntent = PendingIntent.getActivity(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ interface DailyRepository {

suspend fun getDailies(startDateTime: String, endDateTime: String): List<DailyRepositoryModel>?

suspend fun getAllDailies(): List<DailyRepositoryModel>?
fun getDailiesFlow(
startDateTime: String,
endDateTime: String,
): Flow<List<DailyRepositoryModel>?>

fun getAllDailiesFlow(): Flow<List<DailyRepositoryModel>?>

suspend fun upsert(dailyRepositoryModel: DailyRepositoryModel)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ internal interface DailyDao {
)
suspend fun getDailies(startDateTime: String, endDateTime: String): List<DailyEntity>?

@Query(
"SELECT * FROM dailies " +
" WHERE datetime(day) " +
"BETWEEN datetime(:startDateTime) AND datetime(:endDateTime)",
)
fun getDailiesFlow(startDateTime: String, endDateTime: String): Flow<List<DailyEntity>?>

@Query("SELECT * FROM dailies")
suspend fun getAllDailies(): List<DailyEntity>?
fun getAllDailiesFlow(): Flow<List<DailyEntity>?>

@Upsert
suspend fun upsert(dailyEntity: DailyEntity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,22 @@ internal class DailyRepositoryImpl @Inject constructor(
)?.map { it.toRepositoryModel() }
}

override suspend fun getAllDailies(): List<DailyRepositoryModel>? {
return dailyDao.getAllDailies()?.map { it.toRepositoryModel() }
override fun getDailiesFlow(
startDateTime: String,
endDateTime: String,
): Flow<List<DailyRepositoryModel>?> {
return dailyDao.getDailiesFlow(
startDateTime = startDateTime,
endDateTime = endDateTime,
).map { dailies ->
dailies?.map { it.toRepositoryModel() }
}
}

override fun getAllDailiesFlow(): Flow<List<DailyRepositoryModel>?> {
return dailyDao.getAllDailiesFlow().map { dailies ->
dailies?.map { it.toRepositoryModel() }
}
}

override suspend fun upsert(dailyRepositoryModel: DailyRepositoryModel) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.titi.app.doamin.daily.usecase

import com.titi.app.data.daily.api.DailyRepository
import com.titi.app.doamin.daily.mapper.toDomainModel
import com.titi.app.doamin.daily.model.Daily
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class GetAllDailiesFlowUseCase @Inject constructor(
private val dailyRepository: DailyRepository,
) {
operator fun invoke(): Flow<List<Daily>?> = dailyRepository.getAllDailiesFlow()
.map { dailies ->
dailies?.map { it.toDomainModel() }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.titi.app.doamin.daily.usecase

import com.titi.app.core.util.getMondaySunday
import com.titi.app.data.daily.api.DailyRepository
import com.titi.app.doamin.daily.mapper.toDomainModel
import com.titi.app.doamin.daily.model.Daily
import java.time.LocalDate
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class GetCurrentWeekDailiesFlowUseCase @Inject constructor(
private val dailyRepository: DailyRepository,
) {
operator fun invoke(currentDate: LocalDate): Flow<List<Daily>?> {
val (monday, sunday) = getMondaySunday(currentDate)

return dailyRepository.getDailiesFlow(
startDateTime = monday.toString(),
endDateTime = sunday.toString(),
).map { dailies ->
dailies?.map { it.toDomainModel() }
}
}
}

This file was deleted.

Loading

0 comments on commit d7af3f3

Please sign in to comment.