feat: add notification prompting logic; implement methods to track and set notification prompts in PreferencesManager
This commit is contained in:
+7
@@ -179,6 +179,12 @@ class PreferencesManager(
|
|||||||
_notifyListContentUpdated.value = enabled
|
_notifyListContentUpdated.value = enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasPromptedNotifications(): Boolean = prefs.getBoolean(KEY_HAS_PROMPTED_NOTIFICATIONS, false)
|
||||||
|
|
||||||
|
fun setHasPromptedNotifications(prompted: Boolean) {
|
||||||
|
prefs.edit().putBoolean(KEY_HAS_PROMPTED_NOTIFICATIONS, prompted).apply()
|
||||||
|
}
|
||||||
|
|
||||||
// Persist per-list column widths (fieldId -> widthDp)
|
// Persist per-list column widths (fieldId -> widthDp)
|
||||||
// Stored as a JSON object string in SharedPreferences under key: COLUMN_WIDTHS_PREFIX + listId
|
// Stored as a JSON object string in SharedPreferences under key: COLUMN_WIDTHS_PREFIX + listId
|
||||||
fun getColumnWidths(listId: String): Map<String, Float> {
|
fun getColumnWidths(listId: String): Map<String, Float> {
|
||||||
@@ -283,6 +289,7 @@ class PreferencesManager(
|
|||||||
private const val KEY_NOTIFY_LIST_REMOVED = "notify_list_removed"
|
private const val KEY_NOTIFY_LIST_REMOVED = "notify_list_removed"
|
||||||
private const val KEY_NOTIFY_LIST_CONTENT_UPDATED = "notify_list_content_updated"
|
private const val KEY_NOTIFY_LIST_CONTENT_UPDATED = "notify_list_content_updated"
|
||||||
private const val KEY_LAST_LIST_NOTIFY_CHECK_TS = "last_list_notify_check_ts"
|
private const val KEY_LAST_LIST_NOTIFY_CHECK_TS = "last_list_notify_check_ts"
|
||||||
|
private const val KEY_HAS_PROMPTED_NOTIFICATIONS = "has_prompted_notifications"
|
||||||
private const val COLUMN_WIDTHS_PREFIX = "column_widths_" // + listId
|
private const val COLUMN_WIDTHS_PREFIX = "column_widths_" // + listId
|
||||||
private const val COLUMN_ALIGN_PREFIX = "column_align_" // + listId
|
private const val COLUMN_ALIGN_PREFIX = "column_align_" // + listId
|
||||||
private const val DEFAULT_SERVER_URL = "http://10.0.2.2:3000/api/"
|
private const val DEFAULT_SERVER_URL = "http://10.0.2.2:3000/api/"
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ fun ListsScreen(
|
|||||||
var notifPrompted by remember { mutableStateOf(false) }
|
var notifPrompted by remember { mutableStateOf(false) }
|
||||||
val permissionLauncher =
|
val permissionLauncher =
|
||||||
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||||
|
prefsLocal.setHasPromptedNotifications(true)
|
||||||
// Mirror setup behavior: toggle all list notifications to granted state
|
// Mirror setup behavior: toggle all list notifications to granted state
|
||||||
prefsLocal.setNotifyListAddedEnabled(granted)
|
prefsLocal.setNotifyListAddedEnabled(granted)
|
||||||
prefsLocal.setNotifyListEditedEnabled(granted)
|
prefsLocal.setNotifyListEditedEnabled(granted)
|
||||||
@@ -132,7 +133,7 @@ fun ListsScreen(
|
|||||||
ConnectionStatusAction(
|
ConnectionStatusAction(
|
||||||
prefs = prefsLocal,
|
prefs = prefsLocal,
|
||||||
onBecameConnected = {
|
onBecameConnected = {
|
||||||
if (Build.VERSION.SDK_INT >= 33 && !notifPrompted) {
|
if (Build.VERSION.SDK_INT >= 33 && !notifPrompted && !prefsLocal.hasPromptedNotifications()) {
|
||||||
val granted =
|
val granted =
|
||||||
ContextCompat.checkSelfPermission(
|
ContextCompat.checkSelfPermission(
|
||||||
context,
|
context,
|
||||||
|
|||||||
+1
@@ -68,6 +68,7 @@ fun ServerSetupScreen(onSetupComplete: () -> Unit) {
|
|||||||
fun finishOnce() {
|
fun finishOnce() {
|
||||||
if (!completed) {
|
if (!completed) {
|
||||||
completed = true
|
completed = true
|
||||||
|
preferencesManager.setHasPromptedNotifications(true)
|
||||||
onSetupComplete()
|
onSetupComplete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user