diff --git a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java index 7eb1c9a62..3696d03ab 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/webserver/WebServerHelper.java @@ -2,6 +2,8 @@ package org.kiwix.kiwixmobile.webserver; import android.content.Context; import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; @@ -25,12 +27,12 @@ public class WebServerHelper { JNIKiwixServer kiwixServer = new JNIKiwixServer(kiwixLibrary); private static final String TAG = "WebServerHelper"; - public WebServerHelper(Context context) { + public WebServerHelper(@NonNull Context context) { this.context = context; } - public boolean startServerHelper(ServerStateListener stateListener, - ArrayList selectedBooksPath) { + public boolean startServerHelper(@NonNull ServerStateListener stateListener, + @NonNull ArrayList selectedBooksPath) { // 1. Get port from settings screen // 2. Ask user to change port in settings if port is in use. @@ -46,7 +48,7 @@ public class WebServerHelper { return isServerStarted; } - public boolean stopAndroidWebServer(ServerStateListener stateListener) { + public boolean stopAndroidWebServer(@NonNull ServerStateListener stateListener) { if (isServerStarted) { kiwixServer.stop(); isServerStarted = false; @@ -111,7 +113,7 @@ public class WebServerHelper { return ip; } - public static String getAddress() { + @Nullable public static String getAddress() { return "http://" + getIpAddress() + ":" + port; } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java index 0c8743e13..fef2348c1 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/HotspotService.java @@ -14,6 +14,7 @@ import android.os.Build; import android.os.IBinder; import android.util.Log; import android.widget.Toast; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; import org.kiwix.kiwixmobile.R; @@ -68,7 +69,7 @@ public class HotspotService extends Service { notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); } - @Override public int onStartCommand(Intent intent, int flags, int startId) { + @Override public int onStartCommand(@Nullable Intent intent, int flags, int startId) { switch (intent.getAction()) { case ACTION_IS_HOTSPOT_ENABLED: @@ -115,7 +116,7 @@ public class HotspotService extends Service { return START_NOT_STICKY; } - @Nullable @Override public IBinder onBind(Intent intent) { + @Nullable @Override public IBinder onBind(@Nullable Intent intent) { return serviceBinder; } @@ -176,12 +177,12 @@ public class HotspotService extends Service { public class HotspotBinder extends Binder { - public HotspotService getService() { + @NonNull public HotspotService getService() { return HotspotService.this; } } - public void registerCallBack(ServerStateListener myCallback) { + public void registerCallBack(@NonNull ServerStateListener myCallback) { serverStateListener = myCallback; } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java index 4120a47a0..345d92bec 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java +++ b/app/src/main/java/org/kiwix/kiwixmobile/wifi_hotspot/WifiHotspotManager.java @@ -6,6 +6,7 @@ import android.net.wifi.WifiManager; import android.os.Build; import android.os.Handler; import android.util.Log; +import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import org.kiwix.kiwixmobile.webserver.ServerStateListener; @@ -23,14 +24,14 @@ public class WifiHotspotManager { WifiConfiguration currentConfig; private static final String TAG = "WifiHotspotManager"; - public WifiHotspotManager(Context context) { + public WifiHotspotManager(@NonNull Context context) { this.context = context; wifiManager = (WifiManager) this.context.getSystemService(Context.WIFI_SERVICE); } //Workaround to turn on hotspot for Oreo versions @RequiresApi(api = Build.VERSION_CODES.O) - public void turnOnHotspot(ServerStateListener serverStateListener) { + public void turnOnHotspot(@NonNull ServerStateListener serverStateListener) { wifiManager.startLocalOnlyHotspot(new WifiManager.LocalOnlyHotspotCallback() { @Override