Snackbar when data saver is enabled

This commit is contained in:
M66B
2019-07-28 16:50:43 +02:00
parent c55cafa5d0
commit 9be0e5c788
4 changed files with 33 additions and 44 deletions

View File

@@ -20,7 +20,6 @@ package eu.faircode.email;
*/
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
@@ -29,7 +28,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -76,8 +74,6 @@ public class FragmentSetup extends FragmentBase {
private Button btnDoze;
private Button btnBattery;
private Button btnData;
private Button btnInbox;
private Group grpWelcome;
@@ -122,8 +118,6 @@ public class FragmentSetup extends FragmentBase {
btnDoze = view.findViewById(R.id.btnDoze);
btnBattery = view.findViewById(R.id.btnBattery);
btnData = view.findViewById(R.id.btnData);
btnInbox = view.findViewById(R.id.btnInbox);
grpWelcome = view.findViewById(R.id.grpWelcome);
@@ -200,19 +194,6 @@ public class FragmentSetup extends FragmentBase {
}
});
btnData.setOnClickListener(new View.OnClickListener() {
@Override
@TargetApi(Build.VERSION_CODES.N)
public void onClick(View v) {
try {
startActivity(new Intent(Settings.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS,
Uri.parse("package:" + BuildConfig.APPLICATION_ID)));
} catch (Throwable ex) {
Log.e(ex);
}
}
});
btnInbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -237,8 +218,6 @@ public class FragmentSetup extends FragmentBase {
tvDozeDone.setCompoundDrawables(null, null, null, null);
btnDoze.setEnabled(false);
btnData.setVisibility(View.GONE);
btnInbox.setEnabled(false);
boolean welcome = prefs.getBoolean("welcome", true);
@@ -361,14 +340,6 @@ public class FragmentSetup extends FragmentBase {
tvDozeDone.setText(ignoring ? R.string.title_setup_done : R.string.title_setup_to_do);
tvDozeDone.setTextColor(ignoring ? textColorPrimary : colorWarning);
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds(ignoring ? check : null, null, null, null);
// Power saving
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
boolean saving = (cm != null &&
cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED);
btnData.setVisibility(saving || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
}
}
@Override