Remove mobile data enabled check

This commit is contained in:
Adeel 2019-08-27 17:02:57 +05:00
parent 8a8c9f91ff
commit 33233b6ca5
2 changed files with 0 additions and 53 deletions

View File

@ -7,7 +7,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
@ -17,7 +16,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
@ -31,7 +29,6 @@ import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import java.io.File; import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -49,7 +46,6 @@ import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BookOnDiskDeleg
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter; import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskAdapter;
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem; import org.kiwix.kiwixmobile.zim_manager.fileselect_view.adapter.BooksOnDiskListItem;
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle;
import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_IS_HOTSPOT_ENABLED; import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_IS_HOTSPOT_ENABLED;
import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_START_SERVER; import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_START_SERVER;
import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_STOP_SERVER; import static org.kiwix.kiwixmobile.wifi_hotspot.HotspotService.ACTION_STOP_SERVER;
@ -74,7 +70,6 @@ public class ZimHostActivity extends BaseActivity implements
private static final String TAG = "ZimHostActivity"; private static final String TAG = "ZimHostActivity";
private static final int MY_PERMISSIONS_ACCESS_FINE_LOCATION = 102; private static final int MY_PERMISSIONS_ACCESS_FINE_LOCATION = 102;
private static final int LOCATION_SETTINGS_PERMISSION_RESULT = 101;
public static final String SELECTED_ZIM_PATHS_KEY = "selected_zim_paths"; public static final String SELECTED_ZIM_PATHS_KEY = "selected_zim_paths";
private static final String IP_STATE_KEY = "ip_state_key"; private static final String IP_STATE_KEY = "ip_state_key";
private Task<LocationSettingsResponse> task; private Task<LocationSettingsResponse> task;
@ -152,15 +147,11 @@ public class ZimHostActivity extends BaseActivity implements
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
toggleHotspot(); toggleHotspot();
} else { } else {
//if (isMobileDataEnabled(context)) {
// mobileDataDialog();
//} else {
if (ServerUtils.isServerStarted) { if (ServerUtils.isServerStarted) {
startService(createHotspotIntent(ACTION_STOP_SERVER)); startService(createHotspotIntent(ACTION_STOP_SERVER));
} else { } else {
startHotspotManuallyDialog(); startHotspotManuallyDialog();
} }
//}
} }
} }
@ -250,26 +241,6 @@ public class ZimHostActivity extends BaseActivity implements
booksAdapter.notifyDataSetChanged(); booksAdapter.notifyDataSetChanged();
} }
// This method checks if mobile data is enabled in user's device.
static boolean isMobileDataEnabled(Context context) {
ConnectivityManager cm =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
try {
Class cmClass = Class.forName(cm.getClass().getName());
Method method = cmClass.getDeclaredMethod("getMobileDataEnabled");
method.setAccessible(true);
return (Boolean) method.invoke(cm);
} catch (Exception e) {
Log.e(TAG, e.toString());
}
return false;
}
//This method sends the user to data usage summary settings activity
private void openMobileDataActivity() {
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
}
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) { @NonNull int[] grantResults) {
if (requestCode == MY_PERMISSIONS_ACCESS_FINE_LOCATION) { if (requestCode == MY_PERMISSIONS_ACCESS_FINE_LOCATION) {
@ -346,7 +317,6 @@ public class ZimHostActivity extends BaseActivity implements
} }
@Override public void onError(Throwable e) { @Override public void onError(Throwable e) {
// display the ip and don't forget to dismiss the dialog
progressDialog.dismiss(); progressDialog.dismiss();
Toast.makeText(ZimHostActivity.this, R.string.server_failed_message, Toast.LENGTH_SHORT) Toast.makeText(ZimHostActivity.this, R.string.server_failed_message, Toast.LENGTH_SHORT)
.show(); .show();
@ -359,25 +329,6 @@ public class ZimHostActivity extends BaseActivity implements
return new Intent(this, HotspotService.class).setAction(action); return new Intent(this, HotspotService.class).setAction(action);
} }
void mobileDataDialog() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
AlertDialog.Builder builder = new AlertDialog.Builder(this, dialogStyle());
builder.setPositiveButton(this.getString(R.string.yes),
(dialog, id) -> openMobileDataActivity());
builder.setNegativeButton((android.R.string.no),
(dialog, id) -> startHotspotManuallyDialog());
builder.setTitle(this.getString(R.string.mobile_data_enabled));
builder.setMessage(
this.getString(R.string.mobile_data_message) + "\n" + this.getString(
R.string.mobile_data_message_confirmation)
);
builder.setCancelable(false);
AlertDialog dialog = builder.create();
dialog.show();
}
}
@Override public void onServerStarted(@NonNull String ipAddress) { @Override public void onServerStarted(@NonNull String ipAddress) {
this.ip = ipAddress; this.ip = ipAddress;
layoutServerStarted(); layoutServerStarted();
@ -423,7 +374,6 @@ public class ZimHostActivity extends BaseActivity implements
@Override public void onHotspotFailedToStart() { @Override public void onHotspotFailedToStart() {
//Show a dialog to turn off default hotspot //Show a dialog to turn off default hotspot
alertDialogShower.show(KiwixDialog.TurnOffHotspotManually.INSTANCE, alertDialogShower.show(KiwixDialog.TurnOffHotspotManually.INSTANCE,
new Function0<Unit>() { new Function0<Unit>() {
@Override public Unit invoke() { @Override public Unit invoke() {

View File

@ -42,9 +42,6 @@
<string name="progress_dialog_starting_server">Starting server</string> <string name="progress_dialog_starting_server">Starting server</string>
<string name="start_server_dialog_title">Start server</string> <string name="start_server_dialog_title">Start server</string>
<string name="start_server_dialog_message">You can now start the server using this ip address and port no.</string> <string name="start_server_dialog_message">You can now start the server using this ip address and port no.</string>
<string name="mobile_data_enabled">Warning: Mobile data enabled</string>
<string name="mobile_data_message">You\'re about to turn on your wifi hotspot. This feature can work without data usage.</string>
<string name="mobile_data_message_confirmation">Do you want to disable your data?</string>
<string name="hotspot_dialog_title">Turn on your WIFI hotspot</string> <string name="hotspot_dialog_title">Turn on your WIFI hotspot</string>
<string name="hotspot_dialog_message">In order for this feature to work you need to first turn on your WIFI hotspot manually.</string> <string name="hotspot_dialog_message">In order for this feature to work you need to first turn on your WIFI hotspot manually.</string>
<string name="hotspot_dialog_neutral_button">YES, IVE TURNED IT ON</string> <string name="hotspot_dialog_neutral_button">YES, IVE TURNED IT ON</string>