mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-30 19:56:10 +00:00
Added help button high battery usage
This commit is contained in:
parent
f62e1bce82
commit
4d756593f5
3 changed files with 36 additions and 6 deletions
|
@ -74,6 +74,7 @@ public class FragmentSetup extends FragmentBase {
|
||||||
|
|
||||||
private TextView tvDozeDone;
|
private TextView tvDozeDone;
|
||||||
private Button btnDoze;
|
private Button btnDoze;
|
||||||
|
private Button btnBattery;
|
||||||
|
|
||||||
private Button btnData;
|
private Button btnData;
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ public class FragmentSetup extends FragmentBase {
|
||||||
|
|
||||||
tvDozeDone = view.findViewById(R.id.tvDozeDone);
|
tvDozeDone = view.findViewById(R.id.tvDozeDone);
|
||||||
btnDoze = view.findViewById(R.id.btnDoze);
|
btnDoze = view.findViewById(R.id.btnDoze);
|
||||||
|
btnBattery = view.findViewById(R.id.btnBattery);
|
||||||
|
|
||||||
btnData = view.findViewById(R.id.btnData);
|
btnData = view.findViewById(R.id.btnData);
|
||||||
|
|
||||||
|
@ -126,6 +128,7 @@ public class FragmentSetup extends FragmentBase {
|
||||||
|
|
||||||
grpWelcome = view.findViewById(R.id.grpWelcome);
|
grpWelcome = view.findViewById(R.id.grpWelcome);
|
||||||
|
|
||||||
|
PackageManager pm = getContext().getPackageManager();
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
|
|
||||||
// Wire controls
|
// Wire controls
|
||||||
|
@ -138,6 +141,7 @@ public class FragmentSetup extends FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnHelp.setVisibility(Helper.getIntentSetupHelp().resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
|
||||||
btnHelp.setOnClickListener(new View.OnClickListener() {
|
btnHelp.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -145,9 +149,6 @@ public class FragmentSetup extends FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
PackageManager pm = getContext().getPackageManager();
|
|
||||||
btnHelp.setVisibility(Helper.getIntentSetupHelp().resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
|
|
||||||
|
|
||||||
btnQuick.setOnClickListener(new View.OnClickListener() {
|
btnQuick.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -187,6 +188,15 @@ public class FragmentSetup extends FragmentBase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final Intent faq = new Intent(Intent.ACTION_VIEW, Uri.parse(Helper.FAQ_URI + "#user-content-faq39"));
|
||||||
|
btnBattery.setVisibility(faq.resolveActivity(pm) == null ? View.GONE : View.VISIBLE);
|
||||||
|
btnBattery.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
startActivity(faq);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
btnData.setOnClickListener(new View.OnClickListener() {
|
btnData.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
|
@ -330,22 +340,29 @@ public class FragmentSetup extends FragmentBase {
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
// Doze
|
||||||
boolean ignoring = true;
|
boolean ignoring = true;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
Intent intent = new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
||||||
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
|
||||||
PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
|
||||||
ignoring = pm.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID);
|
ignoring = (pm != null && pm.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btnDoze.setEnabled(!ignoring);
|
btnDoze.setEnabled(!ignoring);
|
||||||
|
|
||||||
|
// https://issuetracker.google.com/issues/37070074
|
||||||
|
ignoring = (ignoring || Build.VERSION.SDK_INT != Build.VERSION_CODES.M);
|
||||||
tvDozeDone.setText(ignoring ? R.string.title_setup_done : R.string.title_setup_to_do);
|
tvDozeDone.setText(ignoring ? R.string.title_setup_done : R.string.title_setup_to_do);
|
||||||
tvDozeDone.setTextColor(ignoring ? textColorPrimary : colorWarning);
|
tvDozeDone.setTextColor(ignoring ? textColorPrimary : colorWarning);
|
||||||
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds(ignoring ? check : null, null, null, null);
|
tvDozeDone.setCompoundDrawablesWithIntrinsicBounds(ignoring ? check : null, null, null, null);
|
||||||
|
|
||||||
|
// Power saving
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
boolean saving = (cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED);
|
boolean saving = (cm != null &&
|
||||||
|
cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED);
|
||||||
btnData.setVisibility(saving || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
btnData.setVisibility(saving || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,6 +411,18 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@id/tvDozeDone" />
|
app:layout_constraintTop_toTopOf="@id/tvDozeDone" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnBattery"
|
||||||
|
style="?android:attr/buttonStyleSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:minWidth="0dp"
|
||||||
|
android:minHeight="0dp"
|
||||||
|
android:text="@string/title_setup_doze_battery"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btnDoze" />
|
||||||
|
|
||||||
<!-- data saver -->
|
<!-- data saver -->
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -422,7 +434,7 @@
|
||||||
android:minWidth="0dp"
|
android:minWidth="0dp"
|
||||||
android:minHeight="0dp"
|
android:minHeight="0dp"
|
||||||
android:text="@string/title_setup_data"
|
android:text="@string/title_setup_data"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btnDoze" />
|
app:layout_constraintTop_toBottomOf="@id/btnDoze" />
|
||||||
|
|
||||||
<!-- inbox -->
|
<!-- inbox -->
|
||||||
|
|
|
@ -129,6 +129,7 @@
|
||||||
<string name="title_setup_doze">Setup battery optimizations</string>
|
<string name="title_setup_doze">Setup battery optimizations</string>
|
||||||
<string name="title_setup_doze_remark">To continuously receive email (optional)</string>
|
<string name="title_setup_doze_remark">To continuously receive email (optional)</string>
|
||||||
<string name="title_setup_doze_instructions">In the next dialog, select \"All apps\" at the top, select this app and select and confirm \"Don\'t optimize\"</string>
|
<string name="title_setup_doze_instructions">In the next dialog, select \"All apps\" at the top, select this app and select and confirm \"Don\'t optimize\"</string>
|
||||||
|
<string name="title_setup_doze_battery">High battery usage?</string>
|
||||||
<string name="title_setup_data">Disable data saving</string>
|
<string name="title_setup_data">Disable data saving</string>
|
||||||
<string name="title_setup_inbox">Go to messages</string>
|
<string name="title_setup_inbox">Go to messages</string>
|
||||||
<string name="title_setup_to_do">To do</string>
|
<string name="title_setup_to_do">To do</string>
|
||||||
|
|
Loading…
Reference in a new issue