Skip to content

Commit f80ea5e

Browse files
Fixing the crash on the locale change because of missing dagger bindings
1 parent 4bf1272 commit f80ea5e

5 files changed

Lines changed: 32 additions & 50 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,10 @@
7777
android:name="android.appwidget.provider"
7878
android:resource="@xml/widget_provider_progress_list" />
7979
</receiver>
80-
<receiver android:name=".utils.BootCompleteReceiver">
81-
<intent-filter>
82-
<action android:name="android.intent.action.BOOT_COMPLETED" />
83-
</intent-filter>
84-
</receiver>
85-
<receiver android:name=".utils.LocaleChangedReceiver">
80+
<receiver android:name=".utils.SysEventsReceiver">
8681
<intent-filter>
8782
<action android:name="android.intent.action.LOCALE_CHANGED" />
83+
<action android:name="android.intent.action.BOOT_COMPLETED" />
8884
</intent-filter>
8985
</receiver>
9086
<receiver android:name=".notifications.ProgressNotificationReceiver" />

app/src/main/java/com/kevalpatel2106/yip/di/BroadcastReceiverBindings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.kevalpatel2106.yip.di
22

33
import com.kevalpatel2106.yip.notifications.ProgressNotificationReceiver
4-
import com.kevalpatel2106.yip.utils.BootCompleteReceiver
4+
import com.kevalpatel2106.yip.utils.SysEventsReceiver
55
import com.kevalpatel2106.yip.widget.ProgressListWidgetProvider
66
import dagger.Module
77
import dagger.android.ContributesAndroidInjector
@@ -13,7 +13,7 @@ internal abstract class BroadcastReceiverBindings {
1313
internal abstract fun contributesProgressListWidgetProvider(): ProgressListWidgetProvider
1414

1515
@ContributesAndroidInjector
16-
internal abstract fun contributesBootCompleteReceiver(): BootCompleteReceiver
16+
internal abstract fun contributesBootCompleteReceiver(): SysEventsReceiver
1717

1818
@ContributesAndroidInjector
1919
internal abstract fun contributesProgressNotificationReciver(): ProgressNotificationReceiver

app/src/main/java/com/kevalpatel2106/yip/utils/BootCompleteReceiver.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/src/main/java/com/kevalpatel2106/yip/utils/LocaleChangedReceiver.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.kevalpatel2106.yip.utils
2+
3+
import android.annotation.SuppressLint
4+
import android.content.BroadcastReceiver
5+
import android.content.Context
6+
import android.content.Intent
7+
import com.kevalpatel2106.yip.notifications.ProgressNotificationReceiver
8+
import com.kevalpatel2106.yip.repo.providers.AlarmProvider
9+
import dagger.android.AndroidInjection
10+
import javax.inject.Inject
11+
12+
internal class SysEventsReceiver : BroadcastReceiver() {
13+
14+
@Inject
15+
internal lateinit var alarmProvider: AlarmProvider
16+
17+
@SuppressLint("UnsafeProtectedBroadcastReceiver")
18+
override fun onReceive(context: Context, intent: Intent) {
19+
if (intent.isValidIntent()) {
20+
AndroidInjection.inject(this, context)
21+
alarmProvider.updateAlarms(ProgressNotificationReceiver::class.java)
22+
}
23+
}
24+
25+
private fun Intent.isValidIntent(): Boolean {
26+
return action == Intent.ACTION_BOOT_COMPLETED && action == Intent.ACTION_LOCALE_CHANGED
27+
}
28+
}

0 commit comments

Comments
 (0)