mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Refactor: Change class name to KiwixWifiP2pBroadcastReceiver
This commit is contained in:
parent
0841d57045
commit
a00481bb5b
@ -17,13 +17,13 @@ import androidx.annotation.Nullable;
|
||||
* Handles the broadcasts pertaining to the wifi p2p group formed in WiFi Direct. Works along with
|
||||
* the wifi p2p manager in {@link LocalFileTransferActivity}.
|
||||
*/
|
||||
public class WifiDirectBroadcastReceiver extends BroadcastReceiver {
|
||||
public class KiwixWifiP2pBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
private WifiP2pManager manager;
|
||||
private WifiP2pManager.Channel channel;
|
||||
private WifiDirectManager wifiDirectManager;
|
||||
|
||||
public WifiDirectBroadcastReceiver(@NonNull WifiP2pManager manager, @NonNull WifiP2pManager.Channel channel,
|
||||
public KiwixWifiP2pBroadcastReceiver(@NonNull WifiP2pManager manager, @NonNull WifiP2pManager.Channel channel,
|
||||
@NonNull WifiDirectManager wifiDirectManager) {
|
||||
super();
|
||||
this.manager = manager;
|
||||
@ -40,9 +40,9 @@ public class WifiDirectBroadcastReceiver extends BroadcastReceiver {
|
||||
int wifiP2pState = intent.getIntExtra(WifiP2pManager.EXTRA_WIFI_STATE, -1);
|
||||
|
||||
if (wifiP2pState == WifiP2pManager.WIFI_P2P_STATE_ENABLED) {
|
||||
((BroadcastListener) wifiDirectManager).setWifiP2pEnabled(true);
|
||||
((P2pEventListener) wifiDirectManager).setWifiP2pEnabled(true);
|
||||
} else {
|
||||
((BroadcastListener) wifiDirectManager).setWifiP2pEnabled(false);
|
||||
((P2pEventListener) wifiDirectManager).setWifiP2pEnabled(false);
|
||||
}
|
||||
Log.d(LocalFileTransferActivity.TAG, "WiFi P2P state changed - " + wifiP2pState);
|
||||
|
||||
@ -67,16 +67,16 @@ public class WifiDirectBroadcastReceiver extends BroadcastReceiver {
|
||||
manager.requestConnectionInfo(channel, wifiDirectManager);
|
||||
} else {
|
||||
// Not connected after connection change -> Disconnected
|
||||
((BroadcastListener) wifiDirectManager).onDisconnected();
|
||||
((P2pEventListener) wifiDirectManager).onDisconnected();
|
||||
}
|
||||
|
||||
|
||||
} else if (WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION.equals(action)) {
|
||||
((BroadcastListener) wifiDirectManager).onDeviceChanged(intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));
|
||||
((P2pEventListener) wifiDirectManager).onDeviceChanged(intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));
|
||||
}
|
||||
}
|
||||
|
||||
public interface BroadcastListener {
|
||||
public interface P2pEventListener {
|
||||
void setWifiP2pEnabled(boolean wifiP2pEnabled);
|
||||
|
||||
void onDisconnected();
|
@ -29,7 +29,7 @@ import static org.kiwix.kiwixmobile.zim_manager.local_file_transfer.LocalFileTra
|
||||
* Manager for the Wifi-P2p API, used in the local file transfer module
|
||||
* */
|
||||
public class WifiDirectManager implements WifiP2pManager.ChannelListener, WifiP2pManager.PeerListListener, WifiP2pManager.ConnectionInfoListener,
|
||||
WifiDirectBroadcastReceiver.BroadcastListener {
|
||||
KiwixWifiP2pBroadcastReceiver.P2pEventListener {
|
||||
|
||||
private static final String TAG = "WifiDirectManager";
|
||||
public static int FILE_TRANSFER_PORT = 8008;
|
||||
@ -65,7 +65,7 @@ public class WifiDirectManager implements WifiP2pManager.ChannelListener, WifiP2
|
||||
}
|
||||
|
||||
public void registerWifiDirectBroadcastRecevier() {
|
||||
receiver = new WifiDirectBroadcastReceiver(manager, channel, this);
|
||||
receiver = new KiwixWifiP2pBroadcastReceiver(manager, channel, this);
|
||||
|
||||
// For specifying broadcasts (of the P2P API) that the module needs to respond to
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user