mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-02 15:17:03 +02:00
Check for Sony Stamina mode
This commit is contained in:
@@ -97,6 +97,7 @@ public class FragmentSetup extends FragmentBase {
|
||||
private Button btnInexactAlarms;
|
||||
private Button btnBackgroundRestricted;
|
||||
private Button btnDataSaver;
|
||||
private TextView tvStamina;
|
||||
|
||||
private TextView tvBatteryUsage;
|
||||
private TextView tvSyncStopped;
|
||||
@@ -161,6 +162,7 @@ public class FragmentSetup extends FragmentBase {
|
||||
btnInexactAlarms = view.findViewById(R.id.btnInexactAlarms);
|
||||
btnBackgroundRestricted = view.findViewById(R.id.btnBackgroundRestricted);
|
||||
btnDataSaver = view.findViewById(R.id.btnDataSaver);
|
||||
tvStamina = view.findViewById(R.id.tvStamina);
|
||||
|
||||
tvBatteryUsage = view.findViewById(R.id.tvBatteryUsage);
|
||||
tvSyncStopped = view.findViewById(R.id.tvSyncStopped);
|
||||
@@ -444,6 +446,14 @@ public class FragmentSetup extends FragmentBase {
|
||||
}
|
||||
});
|
||||
|
||||
tvStamina.setPaintFlags(tvStamina.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
tvStamina.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Helper.view(v.getContext(), Uri.parse(Helper.DONTKILL_URI + "sony"), true);
|
||||
}
|
||||
});
|
||||
|
||||
tvBatteryUsage.setPaintFlags(tvBatteryUsage.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
tvBatteryUsage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -530,6 +540,7 @@ public class FragmentSetup extends FragmentBase {
|
||||
grpInexactAlarms.setVisibility(View.GONE);
|
||||
grpBackgroundRestricted.setVisibility(View.GONE);
|
||||
grpDataSaver.setVisibility(View.GONE);
|
||||
tvStamina.setVisibility(View.GONE);
|
||||
|
||||
setContactsPermission(hasPermission(Manifest.permission.READ_CONTACTS));
|
||||
|
||||
@@ -663,6 +674,9 @@ public class FragmentSetup extends FragmentBase {
|
||||
|
||||
grpDataSaver.setVisibility(ConnectionHelper.isDataSaving(getContext())
|
||||
? View.VISIBLE : View.GONE);
|
||||
|
||||
tvStamina.setVisibility(Helper.isStaminaEnabled(getContext())
|
||||
? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -985,6 +985,27 @@ public class Helper {
|
||||
return "Blackview".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
static boolean isSony() {
|
||||
return "sony".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
static boolean isStaminaEnabled(Context context) {
|
||||
// https://dontkillmyapp.com/sony
|
||||
if (BuildConfig.DEBUG)
|
||||
return true;
|
||||
|
||||
if (!isSony())
|
||||
return false;
|
||||
|
||||
try {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
return (Settings.Secure.getInt(resolver, "somc.stamina_mode", 0) > 0);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isSurfaceDuo() {
|
||||
return ("Microsoft".equalsIgnoreCase(Build.MANUFACTURER) && "Surface Duo".equals(Build.MODEL));
|
||||
}
|
||||
@@ -1003,6 +1024,7 @@ public class Helper {
|
||||
// Vivo
|
||||
isRealme() ||
|
||||
isBlackview() ||
|
||||
isSony() ||
|
||||
BuildConfig.DEBUG);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user