From da44c936be6550dbb866ccb7fc180b789473d3e3 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 10 Jun 2022 11:34:23 +0200 Subject: [PATCH] Added notifications disabled warning --- .../eu/faircode/email/FragmentMessages.java | 20 +++++++++++ .../drawable/twotone_notifications_off_24.xml | 15 ++++++++ app/src/main/res/layout/fragment_messages.xml | 34 ++++++++++++++++++- app/src/main/res/values/strings.xml | 1 + 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/twotone_notifications_off_24.xml diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 2c6119658f..7ec532cbc0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -34,6 +34,7 @@ import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecorato import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_TOUCH_DRAG_MOVE_RATIO_BCK; import static me.everything.android.ui.overscroll.OverScrollBounceEffectDecoratorBase.DEFAULT_TOUCH_DRAG_MOVE_RATIO_FWD; +import android.Manifest; import android.animation.ObjectAnimator; import android.app.Activity; import android.app.Dialog; @@ -258,6 +259,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private ViewGroup view; private SwipeRefreshLayoutEx swipeRefresh; private TextView tvAirplane; + private TextView tvNotifications; private TextView tvSupport; private ImageButton ibHintSupport; private ImageButton ibHintSwipe; @@ -280,6 +282,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. private BottomNavigationView bottom_navigation; private ContentLoadingProgressBar pbWait; private Group grpAirplane; + private Group grpNotifications; private Group grpSupport; private Group grpHintSupport; private Group grpHintSwipe; @@ -537,6 +540,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. // Get controls swipeRefresh = view.findViewById(R.id.swipeRefresh); tvAirplane = view.findViewById(R.id.tvAirplane); + tvNotifications = view.findViewById(R.id.tvNotifications); tvSupport = view.findViewById(R.id.tvSupport); ibHintSupport = view.findViewById(R.id.ibHintSupport); ibHintSwipe = view.findViewById(R.id.ibHintSwipe); @@ -560,6 +564,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. pbWait = view.findViewById(R.id.pbWait); grpAirplane = view.findViewById(R.id.grpAirplane); + grpNotifications = view.findViewById(R.id.grpNotifications); grpSupport = view.findViewById(R.id.grpSupport); grpHintSupport = view.findViewById(R.id.grpHintSupport); grpHintSwipe = view.findViewById(R.id.grpHintSwipe); @@ -615,6 +620,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } }); + tvNotifications.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + v.getContext().startActivity( + new Intent(v.getContext(), ActivitySetup.class) + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)); + } + }); + grpSupport.setVisibility(View.GONE); tvSupport.setOnClickListener(new View.OnClickListener() { @Override @@ -1617,6 +1631,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. // Initialize FragmentDialogTheme.setBackground(getContext(), view, false); grpAirplane.setVisibility(View.GONE); + grpNotifications.setVisibility(View.GONE); tvNoEmail.setVisibility(View.GONE); tvNoEmailHint.setVisibility(View.GONE); etSearch.setVisibility(View.GONE); @@ -4469,6 +4484,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. updateAirplaneMode(ConnectionHelper.airplaneMode(getContext())); getContext().registerReceiver(airplanemode, new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED)); + boolean canNotify = + (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU || + hasPermission(Manifest.permission.POST_NOTIFICATIONS)); + grpNotifications.setVisibility(canNotify ? View.GONE : View.VISIBLE); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); boolean compact = prefs.getBoolean("compact", false); int zoom = prefs.getInt("view_zoom", compact ? 0 : 1); diff --git a/app/src/main/res/drawable/twotone_notifications_off_24.xml b/app/src/main/res/drawable/twotone_notifications_off_24.xml new file mode 100644 index 0000000000..7551633813 --- /dev/null +++ b/app/src/main/res/drawable/twotone_notifications_off_24.xml @@ -0,0 +1,15 @@ + + + + diff --git a/app/src/main/res/layout/fragment_messages.xml b/app/src/main/res/layout/fragment_messages.xml index 1773c3bfb5..bdbaa5f7ce 100644 --- a/app/src/main/res/layout/fragment_messages.xml +++ b/app/src/main/res/layout/fragment_messages.xml @@ -21,6 +21,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" + android:background="?android:attr/selectableItemBackground" android:drawableStart="@drawable/twotone_flight_24" android:drawablePadding="6dp" android:drawableTint="?android:attr/textColorPrimary" @@ -40,6 +41,31 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvAirplane" /> + + + + + app:layout_constraintTop_toBottomOf="@+id/vSeparatorNotifications" /> + + Long press a folder for options, like adding a folder to the navigation menu for quick access To limit battery and network usage not all folders and not all messages will be synchronized by default Airplane mode is on + Notifications are disabled If you have a question or a problem, please use the support menu to get help Swipe left to trash; Swipe right to archive (if available); The swipe actions can be configured in the account settings Long press a message to start selecting multiple messages; Hold and swipe up or down to select more messages