Battery optimizations still enabled

pull/212/head
M66B 1 year ago
parent 4484a0cece
commit c4df249c30

@ -250,6 +250,7 @@ public class FragmentMessages extends FragmentBase
private SwipeRefreshLayoutEx swipeRefresh;
private TextView tvAirplane;
private TextView tvNotifications;
private TextView tvBatteryOptimizations;
private TextView tvSupport;
private ImageButton ibHintSupport;
private ImageButton ibHintSwipe;
@ -273,6 +274,7 @@ public class FragmentMessages extends FragmentBase
private ContentLoadingProgressBar pbWait;
private Group grpAirplane;
private Group grpNotifications;
private Group grpBatteryOptimizations;
private Group grpSupport;
private Group grpHintSupport;
private Group grpHintSwipe;
@ -554,6 +556,7 @@ public class FragmentMessages extends FragmentBase
swipeRefresh = view.findViewById(R.id.swipeRefresh);
tvAirplane = view.findViewById(R.id.tvAirplane);
tvNotifications = view.findViewById(R.id.tvNotifications);
tvBatteryOptimizations = view.findViewById(R.id.tvBatteryOptimizations);
tvSupport = view.findViewById(R.id.tvSupport);
ibHintSupport = view.findViewById(R.id.ibHintSupport);
ibHintSwipe = view.findViewById(R.id.ibHintSwipe);
@ -578,6 +581,7 @@ public class FragmentMessages extends FragmentBase
pbWait = view.findViewById(R.id.pbWait);
grpAirplane = view.findViewById(R.id.grpAirplane);
grpNotifications = view.findViewById(R.id.grpNotifications);
grpBatteryOptimizations = view.findViewById(R.id.grpBatteryOptimizations);
grpSupport = view.findViewById(R.id.grpSupport);
grpHintSupport = view.findViewById(R.id.grpHintSupport);
grpHintSwipe = view.findViewById(R.id.grpHintSwipe);
@ -644,6 +648,15 @@ public class FragmentMessages extends FragmentBase
}
});
tvBatteryOptimizations.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(v.getContext(), ActivitySetup.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
v.getContext().startActivity(intent);
}
});
grpSupport.setVisibility(View.GONE);
tvSupport.setOnClickListener(new View.OnClickListener() {
@Override
@ -1847,6 +1860,7 @@ public class FragmentMessages extends FragmentBase
FragmentDialogTheme.setBackground(getContext(), view, false);
grpAirplane.setVisibility(View.GONE);
grpNotifications.setVisibility(View.GONE);
grpBatteryOptimizations.setVisibility(View.GONE);
tvNoEmail.setVisibility(View.GONE);
tvNoEmailHint.setVisibility(View.GONE);
etSearch.setVisibility(View.GONE);
@ -5039,6 +5053,8 @@ public class FragmentMessages extends FragmentBase
lbm.registerReceiver(receiver, iff);
final Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
ConnectivityManager cm = Helper.getSystemService(context, ConnectivityManager.class);
NetworkRequest.Builder builder = new NetworkRequest.Builder();
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
@ -5052,7 +5068,12 @@ public class FragmentMessages extends FragmentBase
hasPermission(Manifest.permission.POST_NOTIFICATIONS));
grpNotifications.setVisibility(canNotify ? View.GONE : View.VISIBLE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean isIgnoring = (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE ||
Boolean.TRUE.equals(Helper.isIgnoringOptimizations(context)));
boolean enabled = prefs.getBoolean("enabled", true);
boolean reminder = prefs.getBoolean("setup_reminder", true);
grpBatteryOptimizations.setVisibility(!isIgnoring && enabled && reminder ? View.VISIBLE : View.GONE);
boolean compact = prefs.getBoolean("compact", false);
int zoom = prefs.getInt("view_zoom", compact ? 0 : 1);
adapter.setCompact(compact);

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15.67,4L14,4L14,2h-4v2L8.33,4C7.6,4 7,4.6 7,5.33v15.33C7,21.4 7.6,22 8.33,22h7.33c0.74,0 1.34,-0.6 1.34,-1.33L17,5.33C17,4.6 16.4,4 15.67,4zM13,18h-2v-2h2v2zM13,14h-2L11,9h2v5z"/>
</vector>

@ -66,6 +66,31 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifications" />
<TextView
android:id="@+id/tvBatteryOptimizations"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/baseline_battery_alert_24"
android:drawablePadding="6dp"
android:paddingHorizontal="12dp"
android:paddingVertical="6dp"
android:text="@string/title_hint_battery_optimizations"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:drawableTint="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorNotifications" />
<View
android:id="@+id/vSeparatorBatteryOptimizations"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvBatteryOptimizations" />
<TextView
android:id="@+id/tvSupport"
android:layout_width="wrap_content"
@ -76,7 +101,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorNotifications" />
app:layout_constraintTop_toBottomOf="@+id/vSeparatorBatteryOptimizations" />
<View
android:id="@+id/vSeparatorSupport"
@ -465,6 +490,12 @@
android:layout_height="0dp"
app:constraint_referenced_ids="tvNotifications,vSeparatorNotifications" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpBatteryOptimizations"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="tvBatteryOptimizations,vSeparatorBatteryOptimizations" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpSupport"
android:layout_width="0dp"

@ -2090,6 +2090,7 @@
<string name="title_hint_folder_sync">To limit battery and network usage not all folders and not all messages will be synchronized by default</string>
<string name="title_hint_airplane">Airplane mode is on</string>
<string name="title_hint_notifications">No notification permissions</string>
<string name="title_hint_battery_optimizations">Battery optimizations still enabled</string>
<string name="title_hint_support">If you have a question or a problem, please use the support menu to get help</string>
<string name="title_hint_message_actions">Swipe left to trash; Swipe right to archive (if available); The swipe actions can be configured in the account settings</string>
<string name="title_hint_message_selection">Long press a message to start selecting multiple messages; Hold and swipe up or down to select more messages</string>

Loading…
Cancel
Save