Skip to content

Commit fd7b149

Browse files
Taewan-PEunhoKangootr47Muungisickbirdd
committed
v0.3.0
๐Ÿš€ Feature Updates - ๊ทธ๋ž˜ํ”„ ๋ฐ์ดํ„ฐ ๋ณ€ํ™˜ ๋ฒ„๊ทธ ์ˆ˜์ • - ๋‹ค์ด๋‚˜๋ฏน ํ…Œ๋งˆ ์ง€์› - ์ƒํ’ˆ ์ •๋ณด๋กœ๊นŒ์ง€ ๋”ฅ๋งํฌ ์ง€์› - ์ ‘๊ทผ์„ฑ ๊ฐœ์„  (Talkback ์ „๋ถ€ ์ง€์›) - ํ‘ธ์‹œ ์•Œ๋ฆผ ์ง€์› ๐ŸšงNotice ํ˜„์žฌ ์•Œ๋ฆผ ์„ค์ • ํ† ๊ธ€์— ๋ฒ„๊ทธ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋น ๋ฅธ ์‹œ์ผ ๋‚ด์— ์ˆ˜์ •ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. Co-Authored-By: EunhoKang <[email protected]> Co-Authored-By: ootr47 <[email protected]> Co-Authored-By: ์†๋ฌธ๊ธฐ <[email protected]> Co-Authored-By: ByeongIk Choi <[email protected]>
1 parent fda3a6d commit fd7b149

File tree

172 files changed

+5097
-1605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+5097
-1605
lines changed

โ€Ž.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

โ€Žandroid/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/.idea/workspace.xml
88
/.idea/navEditor.xml
99
/.idea/assetWizardSettings.xml
10+
/.idea/deploymentTargetDropDown.xml
1011
.DS_Store
1112
/build
1213
/captures

โ€Žandroid/.idea/gradle.xml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

โ€Žandroid/.idea/migrations.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

โ€Žandroid/app/build.gradle.kts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ android {
1919
applicationId = "app.priceguard"
2020
minSdk = 29
2121
targetSdk = 34
22-
versionCode = 2
23-
versionName = "0.1.1"
24-
versionCode = 3
25-
versionName = "0.2.0"
22+
versionCode = 4
23+
versionName = "0.3.0"
2624

2725
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2826
}
@@ -64,6 +62,7 @@ dependencies {
6462
implementation("com.google.firebase:firebase-analytics")
6563
implementation("com.google.firebase:firebase-crashlytics")
6664
implementation("com.google.firebase:firebase-perf")
65+
implementation("com.google.firebase:firebase-messaging")
6766

6867
// Android
6968
implementation("androidx.core:core-ktx:1.12.0")
@@ -106,8 +105,13 @@ dependencies {
106105
// Pull to Refresh
107106
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
108107

108+
// Worker
109+
implementation("androidx.work:work-runtime-ktx:2.9.0")
110+
implementation("androidx.hilt:hilt-work:1.1.0")
111+
kapt("androidx.hilt:hilt-compiler:1.1.0")
112+
109113
// Material chart
110-
implementation(project(":materialchart"))
114+
implementation("app.priceguard:materialchart:0.1.2")
111115
}
112116

113117
kapt {

โ€Žandroid/app/src/main/AndroidManifest.xml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
android:supportsRtl="true"
1515
android:theme="@style/Theme.PriceGuard"
1616
tools:targetApi="34">
17+
18+
<meta-data
19+
android:name="com.google.firebase.messaging.price_notification"
20+
android:value="@string/price_notification" />
21+
<meta-data
22+
android:name="com.google.firebase.messaging.default_notification_icon"
23+
android:resource="@drawable/ic_priceguard_notification" />
24+
25+
<activity
26+
android:name=".ui.additem.link.LinkHelperWebViewActivity"
27+
android:exported="false" />
1728
<activity
1829
android:name=".ui.splash.SplashScreenActivity"
1930
android:exported="true">
@@ -37,16 +48,50 @@
3748
android:exported="false" />
3849
<activity
3950
android:name=".ui.additem.AddItemActivity"
40-
android:exported="false" />
51+
android:exported="true">
52+
<intent-filter>
53+
<action android:name="android.intent.action.SEND" />
54+
55+
<category android:name="android.intent.category.DEFAULT" />
56+
57+
<data android:mimeType="text/plain" />
58+
</intent-filter>
59+
</activity>
4160
<activity
4261
android:name=".ui.detail.DetailActivity"
43-
android:exported="false" />
62+
android:exported="true"
63+
android:launchMode="singleTask">
64+
<intent-filter>
65+
<action android:name="android.intent.action.VIEW" />
66+
67+
<category android:name="android.intent.category.DEFAULT" />
68+
<category android:name="android.intent.category.BROWSABLE" />
69+
70+
<data
71+
android:host="product"
72+
android:scheme="priceguard" />
73+
</intent-filter>
74+
</activity>
4475
<activity
4576
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
4677
android:theme="@style/Theme.PriceGuard.WithActionBar" />
4778
<activity
4879
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
4980
android:theme="@style/Theme.PriceGuard.WithActionBar" />
81+
82+
<service
83+
android:name=".service.PriceGuardFirebaseMessagingService"
84+
android:exported="false">
85+
<intent-filter>
86+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
87+
</intent-filter>
88+
</service>
89+
90+
<provider
91+
android:name="androidx.startup.InitializationProvider"
92+
android:authorities="${applicationId}.androidx-startup"
93+
tools:node="remove" />
94+
5095
</application>
5196

5297
</manifest>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package app.priceguard.data
2+
3+
import app.priceguard.data.dto.PriceDataDTO
4+
import app.priceguard.data.graph.ProductChartData
5+
import app.priceguard.materialchart.data.GraphMode
6+
7+
class GraphDataConverter {
8+
9+
fun toDataset(priceData: List<PriceDataDTO>?): List<ProductChartData> {
10+
priceData ?: return listOf()
11+
if (priceData.isEmpty()) {
12+
return listOf()
13+
}
14+
15+
val dataList = mutableListOf<ProductChartData>()
16+
priceData.forEach { dto ->
17+
dto.time ?: return@forEach
18+
dto.price ?: return@forEach
19+
dto.isSoldOut ?: return@forEach
20+
dataList.add(
21+
ProductChartData(
22+
x = dto.time / 1000,
23+
y = dto.price.toFloat(),
24+
valid = dto.isSoldOut.not()
25+
)
26+
)
27+
}
28+
29+
return dataList.toList()
30+
}
31+
32+
fun packWithEdgeData(
33+
list: List<ProductChartData>,
34+
period: GraphMode = GraphMode.DAY
35+
): List<ProductChartData> {
36+
val currentTime = getCurrentTime()
37+
val startTime = getStartTime(period, currentTime)
38+
val sortedList = list.sortedBy { it.x }
39+
val filteredList = sortedList.filter { it.x in startTime..currentTime }
40+
val sievedList = sortedList.filter { it.x !in startTime..currentTime }
41+
val startData = if (sievedList.none()) {
42+
list.first()
43+
} else {
44+
sievedList.last()
45+
}
46+
47+
return if (filteredList.isEmpty()) {
48+
listOf(
49+
ProductChartData(startTime, startData.y, startData.valid),
50+
ProductChartData(currentTime, list.last().y, list.last().valid)
51+
)
52+
} else {
53+
listOf(
54+
ProductChartData(
55+
startTime,
56+
startData.y,
57+
startData.valid
58+
)
59+
) + filteredList + ProductChartData(
60+
currentTime,
61+
filteredList.last().y,
62+
filteredList.last().valid
63+
)
64+
}
65+
}
66+
67+
private fun getStartTime(period: GraphMode, currentTime: Float = getCurrentTime()): Float {
68+
return when (period) {
69+
GraphMode.DAY -> {
70+
currentTime - DAY
71+
}
72+
73+
GraphMode.WEEK -> {
74+
currentTime - WEEK
75+
}
76+
77+
GraphMode.MONTH -> {
78+
currentTime - MONTH
79+
}
80+
81+
GraphMode.QUARTER -> {
82+
currentTime - QUARTER
83+
}
84+
}
85+
}
86+
87+
private fun getCurrentTime(): Float {
88+
return (System.currentTimeMillis() / 1000).toFloat()
89+
}
90+
91+
companion object {
92+
const val DAY = 86400
93+
const val WEEK = DAY * 7
94+
const val MONTH = DAY * 31
95+
const val QUARTER = MONTH * 3
96+
}
97+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package app.priceguard.data.datastore
2+
3+
interface ConfigDataSource {
4+
suspend fun saveDynamicMode(mode: Int)
5+
suspend fun saveDarkMode(mode: Int)
6+
suspend fun getDynamicMode(): Int?
7+
suspend fun getDarkMode(): Int?
8+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package app.priceguard.data.datastore
2+
3+
import androidx.datastore.core.DataStore
4+
import androidx.datastore.preferences.core.Preferences
5+
import androidx.datastore.preferences.core.edit
6+
import androidx.datastore.preferences.core.intPreferencesKey
7+
import app.priceguard.di.ConfigQualifier
8+
import javax.inject.Inject
9+
import kotlinx.coroutines.flow.first
10+
import kotlinx.coroutines.flow.map
11+
12+
class ConfigDataSourceImpl @Inject constructor(
13+
@ConfigQualifier private val dataStore: DataStore<Preferences>
14+
) : ConfigDataSource {
15+
16+
private val dynamicMode = intPreferencesKey("dynamic_mode")
17+
private val darkMode = intPreferencesKey("dark_mode")
18+
19+
override suspend fun saveDynamicMode(mode: Int) {
20+
dataStore.edit { preferences ->
21+
preferences[dynamicMode] = mode
22+
}
23+
}
24+
25+
override suspend fun saveDarkMode(mode: Int) {
26+
dataStore.edit { preferences ->
27+
preferences[darkMode] = mode
28+
}
29+
}
30+
31+
override suspend fun getDynamicMode(): Int? {
32+
return dataStore.data.map { preferences ->
33+
preferences[dynamicMode]
34+
}.first()
35+
}
36+
37+
override suspend fun getDarkMode(): Int? {
38+
return dataStore.data.map { preferences ->
39+
preferences[darkMode]
40+
}.first()
41+
}
42+
}

โ€Žandroid/app/src/main/java/app/priceguard/data/datastore/TokenDataSourceImpl.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ import androidx.datastore.core.DataStore
44
import androidx.datastore.preferences.core.Preferences
55
import androidx.datastore.preferences.core.edit
66
import androidx.datastore.preferences.core.stringPreferencesKey
7+
import app.priceguard.di.TokensQualifier
78
import javax.inject.Inject
89
import kotlinx.coroutines.flow.first
910
import kotlinx.coroutines.flow.map
1011

11-
class TokenDataSourceImpl @Inject constructor(private val dataStore: DataStore<Preferences>) : TokenDataSource {
12+
class TokenDataSourceImpl @Inject constructor(
13+
@TokensQualifier private val dataStore: DataStore<Preferences>
14+
) : TokenDataSource {
1215

1316
private val accessTokenKey = stringPreferencesKey("access_token")
1417
private val refreshTokenKey = stringPreferencesKey("refresh_token")

0 commit comments

Comments
ย (0)