1
1
package dev.lbeernaert.youhavemail.app
2
2
3
- import android.content.BroadcastReceiver
4
3
import android.content.Context
5
- import android.content.Intent
6
- import android.content.IntentFilter
7
4
import android.content.SharedPreferences
8
5
import android.util.Log
9
- import androidx.localbroadcastmanager.content.LocalBroadcastManager
10
6
import androidx.security.crypto.EncryptedSharedPreferences
11
7
import androidx.security.crypto.MasterKey
12
8
import dev.lbeernaert.youhavemail.Account
13
- import dev.lbeernaert.youhavemail.AccountsUpdated
9
+ import dev.lbeernaert.youhavemail.AccountWatcher
14
10
import dev.lbeernaert.youhavemail.Backend
15
11
import dev.lbeernaert.youhavemail.Event
16
12
import dev.lbeernaert.youhavemail.Proxy
@@ -45,7 +41,7 @@ const val STATE_LOG_TAG = "state"
45
41
// changes.
46
42
var NOTIFICATION_STATE = NotificationState ()
47
43
48
- class State (context : Context ) : AccountsUpdated {
44
+ class State (context : Context ) : AccountWatcher {
49
45
private var mPollInterval = MutableStateFlow (15UL )
50
46
private var mYhm: Yhm
51
47
private var mAccounts: MutableStateFlow <List <Account >>
@@ -57,7 +53,7 @@ class State(context: Context) : AccountsUpdated {
57
53
val key = getOrCreateEncryptionKey(context)
58
54
val dbPath = getDatabasePath(context)
59
55
mYhm = Yhm (dbPath, encryptionKey = key)
60
- mWatchHandle = mYhm.addAccountObserver (this )
56
+ mWatchHandle = mYhm.watchAccounts (this )
61
57
mAccounts = MutableStateFlow (mYhm.accounts())
62
58
val pollInterval = mYhm.pollInterval()
63
59
mPollInterval.value = pollInterval
@@ -161,7 +157,7 @@ class State(context: Context) : AccountsUpdated {
161
157
/* *
162
158
* Unregister receiver and release resource.
163
159
*/
164
- fun close (context : Context ) {
160
+ fun close () {
165
161
Log .i(STATE_LOG_TAG , " Closing" )
166
162
mAccounts.value = ArrayList ()
167
163
mLoginSequence = null
0 commit comments