Rebrand from Casera/MyCrib to honeyDue
Total rebrand across KMM project: - Kotlin package: com.example.casera -> com.tt.honeyDue (dirs + declarations) - Gradle: rootProject.name, namespace, applicationId - Android: manifest, strings.xml (all languages), widget resources - iOS: pbxproj bundle IDs, Info.plist, entitlements, xcconfig - iOS directories: Casera/ -> HoneyDue/, CaseraTests/ -> HoneyDueTests/, etc. - Swift source: all class/struct/enum renames - Deep links: casera:// -> honeydue://, .casera -> .honeydue - App icons replaced with honeyDue honeycomb icon - Domains: casera.treytartt.com -> honeyDue.treytartt.com - Bundle IDs: com.tt.casera -> com.tt.honeyDue - Database table names preserved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package com.tt.honeyDue.storage
|
||||
|
||||
/**
|
||||
* Platform-specific task cache manager interface for persistent storage.
|
||||
* Each platform implements this using their native storage mechanisms.
|
||||
*/
|
||||
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
expect class TaskCacheManager {
|
||||
fun saveTasks(tasksJson: String)
|
||||
fun getTasks(): String?
|
||||
fun clearTasks()
|
||||
|
||||
/**
|
||||
* Check if tasks need refresh due to widget interactions.
|
||||
* Returns true if data was modified externally (e.g., by a widget).
|
||||
*/
|
||||
fun areTasksDirty(): Boolean
|
||||
|
||||
/**
|
||||
* Mark tasks as dirty (needs refresh).
|
||||
* Called when widget modifies task data.
|
||||
*/
|
||||
fun markTasksDirty()
|
||||
|
||||
/**
|
||||
* Clear the dirty flag after tasks have been refreshed.
|
||||
*/
|
||||
fun clearDirtyFlag()
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.tt.honeyDue.storage
|
||||
|
||||
import com.tt.honeyDue.models.CustomTask
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.decodeFromString
|
||||
|
||||
/**
|
||||
* Task cache storage that provides a unified interface for accessing platform-specific
|
||||
* persistent storage. This allows tasks to persist across app restarts for offline access.
|
||||
*/
|
||||
object TaskCacheStorage {
|
||||
private var cacheManager: TaskCacheManager? = null
|
||||
private val json = Json { ignoreUnknownKeys = true }
|
||||
|
||||
/**
|
||||
* Initialize TaskCacheStorage with a platform-specific TaskCacheManager.
|
||||
* This should be called once during app initialization.
|
||||
*/
|
||||
fun initialize(manager: TaskCacheManager) {
|
||||
cacheManager = manager
|
||||
}
|
||||
|
||||
private fun ensureInitialized() {
|
||||
if (cacheManager == null) {
|
||||
cacheManager = getPlatformTaskCacheManager()
|
||||
}
|
||||
}
|
||||
|
||||
fun saveTasks(tasks: List<CustomTask>) {
|
||||
ensureInitialized()
|
||||
try {
|
||||
val tasksJson = json.encodeToString(tasks)
|
||||
cacheManager?.saveTasks(tasksJson)
|
||||
} catch (e: Exception) {
|
||||
println("Error saving tasks to cache: ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
fun getTasks(): List<CustomTask>? {
|
||||
ensureInitialized()
|
||||
return try {
|
||||
val tasksJson = cacheManager?.getTasks()
|
||||
if (tasksJson != null) {
|
||||
json.decodeFromString<List<CustomTask>>(tasksJson)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Error loading tasks from cache: ${e.message}")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun clearTasks() {
|
||||
ensureInitialized()
|
||||
cacheManager?.clearTasks()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if tasks need refresh due to widget interactions.
|
||||
*/
|
||||
fun areTasksDirty(): Boolean {
|
||||
ensureInitialized()
|
||||
return cacheManager?.areTasksDirty() ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark tasks as dirty (needs refresh).
|
||||
* Called when widget modifies task data.
|
||||
*/
|
||||
fun markTasksDirty() {
|
||||
ensureInitialized()
|
||||
cacheManager?.markTasksDirty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the dirty flag after tasks have been refreshed.
|
||||
*/
|
||||
fun clearDirtyFlag() {
|
||||
ensureInitialized()
|
||||
cacheManager?.clearDirtyFlag()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-specific function to get the default TaskCacheManager instance.
|
||||
* For platforms that don't require context (web, iOS, JVM), returns singleton.
|
||||
* For Android, must be initialized via initialize() method before use.
|
||||
*/
|
||||
internal expect fun getPlatformTaskCacheManager(): TaskCacheManager?
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.tt.honeyDue.storage
|
||||
|
||||
/**
|
||||
* Cross-platform theme storage for persisting theme selection.
|
||||
* Uses platform-specific implementations (SharedPreferences on Android, UserDefaults on iOS).
|
||||
*/
|
||||
object ThemeStorage {
|
||||
private var manager: ThemeStorageManager? = null
|
||||
|
||||
fun initialize(themeManager: ThemeStorageManager) {
|
||||
manager = themeManager
|
||||
}
|
||||
|
||||
fun saveThemeId(themeId: String) {
|
||||
manager?.saveThemeId(themeId)
|
||||
}
|
||||
|
||||
fun getThemeId(): String? {
|
||||
return manager?.getThemeId()
|
||||
}
|
||||
|
||||
fun clearThemeId() {
|
||||
manager?.clearThemeId()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-specific theme storage interface.
|
||||
* Each platform implements this using their native storage mechanisms.
|
||||
*/
|
||||
expect class ThemeStorageManager {
|
||||
fun saveThemeId(themeId: String)
|
||||
fun getThemeId(): String?
|
||||
fun clearThemeId()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.tt.honeyDue.storage
|
||||
|
||||
/**
|
||||
* Platform-specific token manager interface for persistent storage.
|
||||
* Each platform implements this using their native storage mechanisms.
|
||||
*/
|
||||
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
expect class TokenManager {
|
||||
fun saveToken(token: String)
|
||||
fun getToken(): String?
|
||||
fun clearToken()
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.tt.honeyDue.storage
|
||||
|
||||
/**
|
||||
* Token storage that provides a unified interface for accessing platform-specific
|
||||
* persistent storage. This allows tokens to persist across app restarts.
|
||||
*/
|
||||
object TokenStorage {
|
||||
private var tokenManager: TokenManager? = null
|
||||
private var cachedToken: String? = null
|
||||
|
||||
/**
|
||||
* Initialize TokenStorage with a platform-specific TokenManager.
|
||||
* This should be called once during app initialization.
|
||||
*/
|
||||
fun initialize(manager: TokenManager) {
|
||||
tokenManager = manager
|
||||
// Load cached token from persistent storage
|
||||
cachedToken = manager.getToken()
|
||||
}
|
||||
|
||||
private fun ensureInitialized() {
|
||||
if (tokenManager == null) {
|
||||
tokenManager = getPlatformTokenManager()
|
||||
cachedToken = tokenManager?.getToken()
|
||||
}
|
||||
}
|
||||
|
||||
fun saveToken(token: String) {
|
||||
ensureInitialized()
|
||||
cachedToken = token
|
||||
tokenManager?.saveToken(token)
|
||||
}
|
||||
|
||||
fun getToken(): String? {
|
||||
ensureInitialized()
|
||||
// Always read from storage to avoid stale cache issues
|
||||
// (DataManager.setAuthToken updates tokenManager directly, bypassing our cachedToken)
|
||||
cachedToken = tokenManager?.getToken()
|
||||
return cachedToken
|
||||
}
|
||||
|
||||
fun clearToken() {
|
||||
ensureInitialized()
|
||||
cachedToken = null
|
||||
tokenManager?.clearToken()
|
||||
}
|
||||
|
||||
fun hasToken(): Boolean = getToken() != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-specific function to get the default TokenManager instance.
|
||||
* For platforms that don't require context (web, iOS, JVM), returns singleton.
|
||||
* For Android, must be initialized via initialize() method before use.
|
||||
*/
|
||||
internal expect fun getPlatformTokenManager(): TokenManager?
|
||||
Reference in New Issue
Block a user