diff --git a/you-have-mail-android/app/build.gradle b/you-have-mail-android/app/build.gradle index a7f7245..b42d18a 100644 --- a/you-have-mail-android/app/build.gradle +++ b/you-have-mail-android/app/build.gradle @@ -20,8 +20,8 @@ android { applicationId "dev.lbeernaert.youhavemail" minSdk 29 targetSdk 33 - versionCode 33 - versionName "0.16.1" + versionCode 34 + versionName "0.16.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/StartReceiver.kt b/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/StartReceiver.kt index 78e23ca..468523c 100644 --- a/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/StartReceiver.kt +++ b/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/StartReceiver.kt @@ -4,9 +4,8 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.util.Log -import androidx.localbroadcastmanager.content.LocalBroadcastManager - -const val START_INTENT= "APP_STARTED" +import dev.lbeernaert.youhavemail.Yhm +import dev.lbeernaert.youhavemail.YhmException class StartReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { @@ -14,10 +13,17 @@ class StartReceiver : BroadcastReceiver() { Log.i("BOOT", "Received boot notification") try { - val localIntent = Intent(START_INTENT) - LocalBroadcastManager.getInstance(context).sendBroadcast(localIntent) - } catch (e: Exception) { - Log.e("BOOT", "Failed to send intent: $e") + val key = getOrCreateEncryptionKey(context) + val dbPath = getDatabasePath(context) + val yhm = Yhm.withoutDbInit(dbPath, encryptionKey = key) + registerWorker(context, yhm.pollInterval().toLong() / 60, false) + } catch (e: YhmException) { + createServiceErrorNotification( + context, + "Failed to Create Yhm on boot and register work", + e + ) + return; } } } diff --git a/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/State.kt b/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/State.kt index d2d6526..138c5f9 100644 --- a/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/State.kt +++ b/you-have-mail-android/app/src/main/java/dev/lbeernaert/youhavemail/app/State.kt @@ -57,7 +57,6 @@ class State(context: Context) : BroadcastReceiver() { val filter = IntentFilter() filter.addAction(POLL_INTENT) - filter.addAction(START_INTENT) LocalBroadcastManager.getInstance(context) .registerReceiver(this, filter) } @@ -208,11 +207,6 @@ class State(context: Context) : BroadcastReceiver() { Log.d(STATE_LOG_TAG, "Received poll intent") onPolled(context, intent.getStringExtra(POLL_INTENT)) } - - START_INTENT -> { - Log.d(STATE_LOG_TAG, "Received start intent") - registerWorker(context, mPollInterval.value.toLong(), true) - } } }