mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Refactor: Use AlertDialogShower for EnableLocationServices
- Also removed use of startActivityForResult() for EnableWifiP2pServices, since it is checked during the initialisation of WifiDirectManager in onCreate()
This commit is contained in:
parent
0a5d924b5f
commit
4b23a64f86
@ -28,6 +28,10 @@ sealed class KiwixDialog(
|
||||
null, R.string.request_enable_wifi, R.string.yes, android.R.string.no
|
||||
)
|
||||
|
||||
object EnableLocationServices : KiwixDialog(
|
||||
null, R.string.request_enable_location, R.string.yes, android.R.string.no
|
||||
)
|
||||
|
||||
data class FileTransferConfirmation(override val args: Array<out Any>) : KiwixDialog( // For the local file transfer module
|
||||
null, R.string.transfer_to, R.string.yes, android.R.string.cancel
|
||||
), HasBodyFormatArgs {
|
||||
|
@ -484,31 +484,28 @@ public class LocalFileTransferActivity extends AppCompatActivity implements
|
||||
}
|
||||
|
||||
private void requestEnableLocationServices() {
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment prev =
|
||||
getSupportFragmentManager().findFragmentByTag(RequestEnableLocationServicesDialog.TAG);
|
||||
|
||||
if (prev == null) {
|
||||
RequestEnableLocationServicesDialog dialogFragment =
|
||||
new RequestEnableLocationServicesDialog();
|
||||
dialogFragment.show(fragmentTransaction, RequestEnableLocationServicesDialog.TAG);
|
||||
}
|
||||
alertDialogShower.show(KiwixDialog.EnableLocationServices.INSTANCE,
|
||||
new Function0<Unit>() {
|
||||
@Override public Unit invoke() {
|
||||
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),
|
||||
REQUEST_ENABLE_LOCATION_SERVICES);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
},
|
||||
new Function0<Unit>() {
|
||||
@Override public Unit invoke() {
|
||||
showToast(LocalFileTransferActivity.this, R.string.discovery_needs_location,
|
||||
Toast.LENGTH_SHORT);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void requestEnableWifiP2pServices() {
|
||||
/*FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment prev =
|
||||
getSupportFragmentManager().findFragmentByTag(RequestEnableWifiP2pServicesDialog.TAG);
|
||||
|
||||
if (prev == null) {
|
||||
RequestEnableWifiP2pServicesDialog dialogFragment = new RequestEnableWifiP2pServicesDialog();
|
||||
dialogFragment.show(fragmentTransaction, RequestEnableWifiP2pServicesDialog.TAG);
|
||||
}*/
|
||||
alertDialogShower.show(KiwixDialog.EnableWifiP2pServices.INSTANCE,
|
||||
new Function0<Unit>() {
|
||||
@Override public Unit invoke() {
|
||||
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS),
|
||||
REQUEST_ENABLE_WIFI_P2P);
|
||||
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
},
|
||||
@ -537,13 +534,6 @@ public class LocalFileTransferActivity extends AppCompatActivity implements
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*case REQUEST_ENABLE_WIFI_P2P: {
|
||||
if (!wifiDirectManager.isWifiP2pEnabled()) {
|
||||
showToast(this, R.string.discovery_needs_wifi, Toast.LENGTH_LONG);
|
||||
}
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user