mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 07:16:04 -04:00
Inject HotspotStateListener
This commit is contained in:
parent
d1572c142d
commit
d9b191bc78
@ -2,6 +2,7 @@ package org.kiwix.kiwixmobile.di.modules
|
||||
|
||||
import android.app.Application
|
||||
import android.app.NotificationManager
|
||||
import android.app.Service
|
||||
import android.content.Context
|
||||
import android.net.wifi.WifiManager
|
||||
import dagger.Module
|
||||
@ -11,6 +12,7 @@ import org.kiwix.kiwixlib.JNIKiwixServer
|
||||
import org.kiwix.kiwixmobile.di.ServiceScope
|
||||
import org.kiwix.kiwixmobile.webserver.WebServerHelper
|
||||
import org.kiwix.kiwixmobile.wifi_hotspot.HotspotNotificationManager
|
||||
import org.kiwix.kiwixmobile.wifi_hotspot.HotspotStateListener
|
||||
import org.kiwix.kiwixmobile.wifi_hotspot.WifiHotspotManager
|
||||
|
||||
@Module
|
||||
@ -25,8 +27,16 @@ class ServiceModule {
|
||||
|
||||
@Provides
|
||||
@ServiceScope
|
||||
fun providesWifiHotspotManager(wifiManager: WifiManager): WifiHotspotManager =
|
||||
WifiHotspotManager(wifiManager)
|
||||
fun providesWifiHotspotManager(
|
||||
wifiManager: WifiManager,
|
||||
hotspotStateListener: HotspotStateListener
|
||||
): WifiHotspotManager =
|
||||
WifiHotspotManager(wifiManager, hotspotStateListener)
|
||||
|
||||
@Provides
|
||||
@ServiceScope
|
||||
fun providesHotspotStateListener(service: Service): HotspotStateListener =
|
||||
service as HotspotStateListener
|
||||
|
||||
@Provides
|
||||
@ServiceScope
|
||||
|
@ -57,8 +57,6 @@ public class HotspotService extends Service implements HotspotStateListener {
|
||||
.inject(this);
|
||||
super.onCreate();
|
||||
|
||||
hotspotManager.registerListener(this);
|
||||
|
||||
stopReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
@ -24,8 +24,10 @@ public class WifiHotspotManager {
|
||||
WifiManager wifiManager;
|
||||
|
||||
@Inject
|
||||
public WifiHotspotManager(@NonNull WifiManager wifiManager) {
|
||||
public WifiHotspotManager(@NonNull WifiManager wifiManager,
|
||||
HotspotStateListener hotspotStateListener) {
|
||||
this.wifiManager = wifiManager;
|
||||
this.hotspotStateListener = hotspotStateListener;
|
||||
}
|
||||
|
||||
//Workaround to turn on hotspot for Oreo versions
|
||||
@ -83,8 +85,4 @@ public class WifiHotspotManager {
|
||||
+ " \n SSID is : "
|
||||
+ wifiConfiguration.SSID);
|
||||
}
|
||||
|
||||
public void registerListener(@NonNull HotspotStateListener hotspotStateListener) {
|
||||
this.hotspotStateListener = hotspotStateListener;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user