Fix keyword alarm and add visual indicators
- Fix: Only keyword-matched deals send notifications - Add: Visual indicator for keyword-matched deals (badge + border) - Add: Polling interval setting with persistence - Add: Version check in settings - Add: Update dialog on app start
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.hotdeal.alarm.data.local.preferences
|
||||
|
||||
import android.content.Context
|
||||
import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.intPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
/**
|
||||
* 앱 설정 저장 (DataStore)
|
||||
*/
|
||||
class AppSettings(private val context: Context) {
|
||||
|
||||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "app_settings")
|
||||
|
||||
companion object {
|
||||
private val POLLING_INTERVAL_KEY = intPreferencesKey("polling_interval_minutes")
|
||||
private const val DEFAULT_INTERVAL = 2
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴� 주기 (분)
|
||||
*/
|
||||
val pollingInterval: Flow<Int> = context.dataStore.data
|
||||
.map { preferences ->
|
||||
preferences[POLLING_INTERVAL_KEY] ?: DEFAULT_INTERVAL
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴� 주기 설정 저장
|
||||
*/
|
||||
suspend fun setPollingInterval(minutes: Int) {
|
||||
context.dataStore.edit { preferences ->
|
||||
preferences[POLLING_INTERVAL_KEY] = minutes
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user