mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -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
|
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
|
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
|
null, R.string.transfer_to, R.string.yes, android.R.string.cancel
|
||||||
), HasBodyFormatArgs {
|
), HasBodyFormatArgs {
|
||||||
|
@ -484,31 +484,28 @@ public class LocalFileTransferActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void requestEnableLocationServices() {
|
private void requestEnableLocationServices() {
|
||||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
alertDialogShower.show(KiwixDialog.EnableLocationServices.INSTANCE,
|
||||||
Fragment prev =
|
new Function0<Unit>() {
|
||||||
getSupportFragmentManager().findFragmentByTag(RequestEnableLocationServicesDialog.TAG);
|
@Override public Unit invoke() {
|
||||||
|
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),
|
||||||
if (prev == null) {
|
REQUEST_ENABLE_LOCATION_SERVICES);
|
||||||
RequestEnableLocationServicesDialog dialogFragment =
|
return Unit.INSTANCE;
|
||||||
new RequestEnableLocationServicesDialog();
|
}
|
||||||
dialogFragment.show(fragmentTransaction, RequestEnableLocationServicesDialog.TAG);
|
},
|
||||||
}
|
new Function0<Unit>() {
|
||||||
|
@Override public Unit invoke() {
|
||||||
|
showToast(LocalFileTransferActivity.this, R.string.discovery_needs_location,
|
||||||
|
Toast.LENGTH_SHORT);
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestEnableWifiP2pServices() {
|
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,
|
alertDialogShower.show(KiwixDialog.EnableWifiP2pServices.INSTANCE,
|
||||||
new Function0<Unit>() {
|
new Function0<Unit>() {
|
||||||
@Override public Unit invoke() {
|
@Override public Unit invoke() {
|
||||||
startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS),
|
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
|
||||||
REQUEST_ENABLE_WIFI_P2P);
|
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -537,13 +534,6 @@ public class LocalFileTransferActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
break;
|
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