Faster access to remove all notifications

This commit is contained in:
Thomas 2023-03-13 17:08:05 +01:00
parent bbcc9244e3
commit 25c372280f
3 changed files with 24 additions and 35 deletions

View File

@ -27,12 +27,10 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.tabs.TabLayout;
@ -93,23 +91,7 @@ public class FragmentNotificationContainer extends Fragment {
dialogBuilder.setView(dialogView.getRoot());
dialogView.clearAllNotif.setOnClickListener(v1 -> {
AlertDialog.Builder db = new MaterialAlertDialogBuilder(requireActivity());
db.setTitle(R.string.delete_notification_ask_all);
db.setMessage(R.string.delete_notification_all_warning);
db.setPositiveButton(R.string.delete_all, (dialog, id) -> {
changes.set(true);
NotificationsVM notificationsVM = new ViewModelProvider(FragmentNotificationContainer.this).get(NotificationsVM.class);
notificationsVM.clearNotification(BaseMainActivity.currentUserID, BaseMainActivity.currentInstance, BaseMainActivity.currentToken)
.observe(getViewLifecycleOwner(), unused -> {
Toasty.info(requireActivity(), R.string.delete_notification_all, Toasty.LENGTH_LONG).show();
});
dialog.dismiss();
});
db.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = db.create();
alertDialog.show();
});
boolean displayAllCategory = sharedpreferences.getBoolean(getString(R.string.SET_DISPLAY_ALL_NOTIFICATIONS_TYPE) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, false);
dialogView.displayAllCategories.setChecked(displayAllCategory);
@ -204,18 +186,27 @@ public class FragmentNotificationContainer extends Fragment {
}
});
dialogView.more.setOnClickListener(v1 -> {
if (dialogView.clearAllNotif.getVisibility() == View.VISIBLE) {
dialogView.clearAllNotif.setVisibility(View.GONE);
((MaterialButton) v1).setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_baseline_expand_more_24, requireContext().getTheme()));
} else {
dialogView.clearAllNotif.setVisibility(View.VISIBLE);
((MaterialButton) v1).setIcon(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_baseline_expand_less_24, requireContext().getTheme()));
}
});
dialogBuilder.setOnDismissListener(dialogInterface -> doAction(changes.get(), excludedCategoriesList));
dialogBuilder.setPositiveButton(R.string.close, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create();
dialogView.clearAllNotif.setOnClickListener(v1 -> {
AlertDialog.Builder db = new MaterialAlertDialogBuilder(requireActivity());
db.setTitle(R.string.delete_notification_ask_all);
db.setMessage(R.string.delete_notification_all_warning);
db.setPositiveButton(R.string.delete_all, (dialog, id) -> {
changes.set(true);
NotificationsVM notificationsVM = new ViewModelProvider(FragmentNotificationContainer.this).get(NotificationsVM.class);
notificationsVM.clearNotification(BaseMainActivity.currentUserID, BaseMainActivity.currentInstance, BaseMainActivity.currentToken)
.observe(getViewLifecycleOwner(), unused -> {
Toasty.info(requireActivity(), R.string.delete_notification_all, Toasty.LENGTH_LONG).show();
});
dialog.dismiss();
alertDialog.dismiss();
});
db.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialogDb = db.create();
alertDialogDb.show();
});
alertDialog.show();
});

View File

@ -128,9 +128,8 @@
</com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.button.MaterialButton
android:id="@+id/more"
style="@style/Widget.Material3.Button.TextButton"
<androidx.appcompat.widget.AppCompatTextView
style="@style/TextAppearance.Material3.TitleMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
@ -138,18 +137,16 @@
android:text="@string/more_actions"
android:textAllCaps="false"
android:textColor="?colorError"
app:icon="@drawable/ic_baseline_expand_more_24"
app:iconTint="?colorError"
app:rippleColor="?colorError" />
android:background="@drawable/red_border" />
<com.google.android.material.button.MaterialButton
android:id="@+id/clear_all_notif"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_marginTop="10dp"
android:layout_height="wrap_content"
android:text="@string/clear_all_notif"
android:textColor="?colorError"
android:visibility="gone"
app:icon="@drawable/ic_baseline_delete_24"
app:iconTint="?colorError"
app:rippleColor="?colorError"

View File

@ -4,6 +4,7 @@ Added:
Changed:
- Maths formula aligned to the left
- Faster access to delete all notifications
Fixed:
- Fix an issue with Nitter and some URLs