Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 821efb57 authored by Moez Bhatti's avatar Moez Bhatti Committed by GitHub
Browse files

Merge pull request #555 from moezbhatti/delete-old-messages

Delete old messages
parents 2822f1eb f1788610
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -486,6 +486,7 @@
        </receiver>

        <service android:name="com.mariussoft.endlessjabber.sdk.EndlessJabberWakefulService" />
        <service android:name=".service.DeleteOldMessagesService" />

        <service
            android:name=".receiver.UnreadBadgeService"
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.volley.toolbox.Volley;
import com.moez.QKSMS.common.AnalyticsManager;
import com.moez.QKSMS.common.LifecycleHandler;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.QKPreferences;
import com.moez.QKSMS.common.google.DraftCache;
import com.moez.QKSMS.common.google.PduLoaderManager;
import com.moez.QKSMS.common.google.ThumbnailManager;
@@ -103,6 +104,7 @@ public class QKSMSAppBase extends MultiDexApplication {
        LayoutManager.init(this);
        NotificationManager.init(this);
        LiveViewManager.init(this);
        QKPreferences.init(this);

        activePendingMessages();
    }
+47 −0
Original line number Diff line number Diff line
package com.moez.QKSMS.common;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.moez.QKSMS.enums.QKPreference;

public abstract class QKPreferences {

    private static SharedPreferences sPrefs;

    public static void init(Context context) {
        sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    }

    public static boolean getBoolean(QKPreference preference) {
        return sPrefs.getBoolean(preference.getKey(), (boolean) preference.getDefaultValue());
    }

    public static void setBoolean(QKPreference preference, boolean newValue) {
        sPrefs.edit().putBoolean(preference.getKey(), newValue).apply();
    }

    public static int getInt(QKPreference preference) {
        return sPrefs.getInt(preference.getKey(), (int) preference.getDefaultValue());
    }

    public static void setInt(QKPreference preference, int newValue) {
        sPrefs.edit().putInt(preference.getKey(), newValue).apply();
    }

    public static long getLong(QKPreference preference) {
        return sPrefs.getLong(preference.getKey(), (int) preference.getDefaultValue());
    }

    public static void setLong(QKPreference preference, long newValue) {
        sPrefs.edit().putLong(preference.getKey(), newValue).apply();
    }

    public static String getString(QKPreference preference) {
        return sPrefs.getString(preference.getKey(), (String) preference.getDefaultValue());
    }

    public static void setString(QKPreference preference, String newValue) {
        sPrefs.edit().putString(preference.getKey(), newValue).apply();
    }
}
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ public enum QKPreference {
    DELIVERY_TOAST("pref_key_delivery_toast", true),
    DELIVERY_VIBRATE("pref_key_delivery_vibrate", true),

    AUTO_DELETE("pref_key_delete_old_messages", false),
    AUTO_DELETE_UNREAD("pref_key_delete_old_unread_messages", "7"), // This type of preference only accepts strings
    AUTO_DELETE_READ("pref_key_delete_old_read_messages", "7"),

    AUTO_EMOJI("pref_key_auto_emoji", false),
    TEXT_FORMATTING("pref_key_markdown_enabled", false),
    STRIP_UNICODE("pref_key_strip_unicode", false),
@@ -96,6 +100,7 @@ public enum QKPreference {

    // Storage
    COMPOSE_DRAFT("compose_draft", ""),
    LAST_AUTO_DELETE_CHECK("last_auto_delete_check", 0),
    MIGRATED_ICON("migrated_icon", false);

    private String mKey;
+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.preference.PreferenceManager;
import com.moez.QKSMS.service.DeleteOldMessagesService;
import com.moez.QKSMS.transaction.NotificationManager;
import com.moez.QKSMS.ui.settings.SettingsFragment;

@@ -15,5 +16,7 @@ public class BootReceiver extends BroadcastReceiver {
        NotificationManager.create(context);

        SettingsFragment.updateAlarmManager(context, PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.NIGHT_AUTO, false));

        DeleteOldMessagesService.setupAutoDeleteAlarm(context);
    }
}
Loading