mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-22 12:03:09 -04:00
Refactor createHotspotIntent()
This commit is contained in:
parent
51167a9886
commit
6cafde5061
@ -165,7 +165,7 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
// mobileDataDialog();
|
// mobileDataDialog();
|
||||||
//} else {
|
//} else {
|
||||||
if (ServerUtils.isServerStarted) {
|
if (ServerUtils.isServerStarted) {
|
||||||
createHotspotIntent(ACTION_STOP_SERVER);
|
startService(createHotspotIntent(ACTION_STOP_SERVER));
|
||||||
} else {
|
} else {
|
||||||
startHotspotManuallyDialog();
|
startHotspotManuallyDialog();
|
||||||
}
|
}
|
||||||
@ -220,7 +220,8 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
|
||||||
== PackageManager.PERMISSION_GRANTED) {
|
== PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
createHotspotIntent(ACTION_IS_HOTSPOT_ENABLED); //If hotspot is already enabled, turn it off
|
startService(createHotspotIntent(
|
||||||
|
ACTION_IS_HOTSPOT_ENABLED)); //If hotspot is already enabled, turn it off
|
||||||
} else {
|
} else {
|
||||||
//Ask location permission if not granted
|
//Ask location permission if not granted
|
||||||
ActivityCompat.requestPermissions(this,
|
ActivityCompat.requestPermissions(this,
|
||||||
@ -298,7 +299,7 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
case Activity.RESULT_OK:
|
case Activity.RESULT_OK:
|
||||||
// All required changes were successfully made
|
// All required changes were successfully made
|
||||||
Log.v(TAG, states.isLocationPresent() + "");
|
Log.v(TAG, states.isLocationPresent() + "");
|
||||||
createHotspotIntent(ACTION_TURN_ON_AFTER_O);
|
startService(createHotspotIntent(ACTION_TURN_ON_AFTER_O));
|
||||||
break;
|
break;
|
||||||
case Activity.RESULT_CANCELED:
|
case Activity.RESULT_CANCELED:
|
||||||
// The user was asked to change settings, but chose not to
|
// The user was asked to change settings, but chose not to
|
||||||
@ -347,7 +348,7 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
// All location settings are satisfied. The client can initialize location
|
// All location settings are satisfied. The client can initialize location
|
||||||
// requests here.
|
// requests here.
|
||||||
|
|
||||||
createHotspotIntent(ACTION_TURN_ON_AFTER_O);
|
startService(createHotspotIntent(ACTION_TURN_ON_AFTER_O));
|
||||||
|
|
||||||
//}
|
//}
|
||||||
} catch (ApiException exception) {
|
} catch (ApiException exception) {
|
||||||
@ -435,9 +436,9 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void createHotspotIntent(String ACTION) {
|
Intent createHotspotIntent(String ACTION) {
|
||||||
serviceIntent.setAction(ACTION);
|
serviceIntent.setAction(ACTION);
|
||||||
startService(serviceIntent);
|
return serviceIntent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mobileDataDialog() {
|
void mobileDataDialog() {
|
||||||
@ -528,7 +529,7 @@ public class ZimHostActivity extends BaseActivity implements
|
|||||||
@Override public void onHotspotStateReceived(@NonNull Boolean isHotspotEnabled) {
|
@Override public void onHotspotStateReceived(@NonNull Boolean isHotspotEnabled) {
|
||||||
if (isHotspotEnabled) //if hotspot is already enabled, turn it off.
|
if (isHotspotEnabled) //if hotspot is already enabled, turn it off.
|
||||||
{
|
{
|
||||||
createHotspotIntent(ACTION_TURN_OFF_AFTER_O);
|
startService(createHotspotIntent(ACTION_TURN_OFF_AFTER_O));
|
||||||
} else //If hotspot is not already enabled, then turn it on.
|
} else //If hotspot is not already enabled, then turn it on.
|
||||||
{
|
{
|
||||||
setupLocationServices();
|
setupLocationServices();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user