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