Commit 6c59e5f3 authored by Thomas's avatar Thomas
Browse files

Replace with id but allow to quickly clear the cache

parent a10b4046
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -596,7 +596,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
                    for (Notification notificationsAlreadyPresent : notificationList) {
                        //We compare the date of each status and we only add status having a date greater than the another, it is inserted at this position
                        //Pinned messages are ignored because their date can be older
                        if (notificationReceived.created_at.after(notificationsAlreadyPresent.created_at)) {
                        if (notificationReceived.id.compareTo(notificationsAlreadyPresent.id) > 0) {
                            if (!notificationList.contains(notificationReceived)) {
                                notificationList.add(position, notificationReceived);
                                notificationAdapter.notifyItemInserted(position);
+18 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.service.notification.StatusBarNotification;
import android.view.LayoutInflater;
import android.view.View;
@@ -42,8 +44,11 @@ import java.util.concurrent.atomic.AtomicBoolean;

import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
import app.fedilab.android.client.entities.app.StatusCache;
import app.fedilab.android.databinding.FragmentNotificationContainerBinding;
import app.fedilab.android.databinding.PopupNotificationSettingsBinding;
import app.fedilab.android.exception.DBException;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.ui.pageadapter.FedilabNotificationPageAdapter;
@@ -90,8 +95,21 @@ public class FragmentNotificationContainer extends Fragment {
            ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayPollResults);
            ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayUpdatesFromPeople);
            ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayFollows);

            DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(requireActivity()));
            DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getTrackDrawable()), ThemeHelper.getSwitchCompatTrackDrawable(requireActivity()));
            //Clear notifications from cache
            dialogView.clearNotificationCache.setOnClickListener(v2 -> new Thread(() -> {
                try {
                    new StatusCache(requireActivity()).deleteNotifications(MainActivity.currentUserID, MainActivity.currentInstance);
                    Handler mainHandler = new Handler(Looper.getMainLooper());
                    changes.set(true);
                    Runnable myRunnable = () -> Toasty.info(requireActivity(), getString(R.string.notification_remove_from_cache), Toasty.LENGTH_SHORT).show();
                    mainHandler.post(myRunnable);
                } catch (DBException e) {
                    e.printStackTrace();
                }
            }).start());
            dialogView.clearAllNotif.setOnClickListener(v1 -> {
                AlertDialog.Builder db = new AlertDialog.Builder(requireActivity(), Helper.dialogStyle());
                db.setTitle(R.string.delete_notification_ask_all);
+18 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <androidx.appcompat.widget.SwitchCompat
            android:id="@+id/display_all_categories"
            android:layout_width="match_parent"
@@ -103,6 +104,23 @@

        </com.google.android.material.button.MaterialButtonToggleGroup>


        <com.google.android.material.button.MaterialButton
            android:id="@+id/clear_notification_cache"
            style="@style/MyOutlinedButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:paddingTop="3dp"
            android:paddingBottom="3dp"
            android:text="@string/clear_cache"
            android:textAlignment="textStart"
            app:icon="@drawable/ic_baseline_cached_24"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <com.google.android.material.button.MaterialButton
            android:id="@+id/more"
            style="@style/Widget.MaterialComponents.Button.TextButton"
+1 −0
Original line number Diff line number Diff line
@@ -1567,4 +1567,5 @@
    <string name="max_indentation_thread">Max indentation in threads</string>
    <string name="set_unlisted_replies">Unlisted replies</string>
    <string name="set_unlisted_replies_indication">It only concerns \"public\" replies. When enabled, your replies will automatically have the visibility \"unlisted\" instead of \"public\"</string>
    <string name="notification_remove_from_cache">Notifications have been removed from cache.</string>
</resources>