mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 13:48:52 +01:00
Merge pull request #555 from moezbhatti/delete-old-messages
Delete old messages
This commit is contained in:
@@ -486,6 +486,7 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<service android:name="com.mariussoft.endlessjabber.sdk.EndlessJabberWakefulService" />
|
<service android:name="com.mariussoft.endlessjabber.sdk.EndlessJabberWakefulService" />
|
||||||
|
<service android:name=".service.DeleteOldMessagesService" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".receiver.UnreadBadgeService"
|
android:name=".receiver.UnreadBadgeService"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import com.android.volley.toolbox.Volley;
|
|||||||
import com.moez.QKSMS.common.AnalyticsManager;
|
import com.moez.QKSMS.common.AnalyticsManager;
|
||||||
import com.moez.QKSMS.common.LifecycleHandler;
|
import com.moez.QKSMS.common.LifecycleHandler;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
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.DraftCache;
|
||||||
import com.moez.QKSMS.common.google.PduLoaderManager;
|
import com.moez.QKSMS.common.google.PduLoaderManager;
|
||||||
import com.moez.QKSMS.common.google.ThumbnailManager;
|
import com.moez.QKSMS.common.google.ThumbnailManager;
|
||||||
@@ -103,6 +104,7 @@ public class QKSMSAppBase extends MultiDexApplication {
|
|||||||
LayoutManager.init(this);
|
LayoutManager.init(this);
|
||||||
NotificationManager.init(this);
|
NotificationManager.init(this);
|
||||||
LiveViewManager.init(this);
|
LiveViewManager.init(this);
|
||||||
|
QKPreferences.init(this);
|
||||||
|
|
||||||
activePendingMessages();
|
activePendingMessages();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,10 @@ public enum QKPreference {
|
|||||||
DELIVERY_TOAST("pref_key_delivery_toast", true),
|
DELIVERY_TOAST("pref_key_delivery_toast", true),
|
||||||
DELIVERY_VIBRATE("pref_key_delivery_vibrate", 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),
|
AUTO_EMOJI("pref_key_auto_emoji", false),
|
||||||
TEXT_FORMATTING("pref_key_markdown_enabled", false),
|
TEXT_FORMATTING("pref_key_markdown_enabled", false),
|
||||||
STRIP_UNICODE("pref_key_strip_unicode", false),
|
STRIP_UNICODE("pref_key_strip_unicode", false),
|
||||||
@@ -96,6 +100,7 @@ public enum QKPreference {
|
|||||||
|
|
||||||
// Storage
|
// Storage
|
||||||
COMPOSE_DRAFT("compose_draft", ""),
|
COMPOSE_DRAFT("compose_draft", ""),
|
||||||
|
LAST_AUTO_DELETE_CHECK("last_auto_delete_check", 0),
|
||||||
MIGRATED_ICON("migrated_icon", false);
|
MIGRATED_ICON("migrated_icon", false);
|
||||||
|
|
||||||
private String mKey;
|
private String mKey;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import com.moez.QKSMS.service.DeleteOldMessagesService;
|
||||||
import com.moez.QKSMS.transaction.NotificationManager;
|
import com.moez.QKSMS.transaction.NotificationManager;
|
||||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||||
|
|
||||||
@@ -15,5 +16,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
NotificationManager.create(context);
|
NotificationManager.create(context);
|
||||||
|
|
||||||
SettingsFragment.updateAlarmManager(context, PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.NIGHT_AUTO, false));
|
SettingsFragment.updateAlarmManager(context, PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsFragment.NIGHT_AUTO, false));
|
||||||
|
|
||||||
|
DeleteOldMessagesService.setupAutoDeleteAlarm(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.moez.QKSMS.service;
|
||||||
|
|
||||||
|
import android.app.AlarmManager;
|
||||||
|
import android.app.IntentService;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.moez.QKSMS.common.QKPreferences;
|
||||||
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
|
import com.moez.QKSMS.transaction.SmsHelper;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
public class DeleteOldMessagesService extends IntentService {
|
||||||
|
private static final String TAG = "DeleteOldMessages";
|
||||||
|
|
||||||
|
public DeleteOldMessagesService() {
|
||||||
|
super(TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onHandleIntent(Intent intent) {
|
||||||
|
Calendar last = Calendar.getInstance();
|
||||||
|
last.setTimeInMillis(QKPreferences.getLong(QKPreference.LAST_AUTO_DELETE_CHECK));
|
||||||
|
|
||||||
|
Calendar current = Calendar.getInstance();
|
||||||
|
|
||||||
|
// Continue if the auto delete setting is enabled, and we haven't done a purge today
|
||||||
|
if (QKPreferences.getBoolean(QKPreference.AUTO_DELETE) && (last.getTimeInMillis() == 0 ||
|
||||||
|
current.get(Calendar.DAY_OF_YEAR) != last.get(Calendar.DAY_OF_YEAR) ||
|
||||||
|
current.get(Calendar.YEAR) != last.get(Calendar.YEAR))) {
|
||||||
|
Log.i(TAG, "Ready to delete old messages");
|
||||||
|
QKPreferences.setLong(QKPreference.LAST_AUTO_DELETE_CHECK, System.currentTimeMillis());
|
||||||
|
|
||||||
|
deleteOldUnreadMessages(this);
|
||||||
|
deleteOldReadMessages(this);
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "Not going to delete old messages");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteOldUnreadMessages(Context context) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.DAY_OF_YEAR, -Integer.parseInt(QKPreferences.getString(QKPreference.AUTO_DELETE_UNREAD)));
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY));
|
||||||
|
calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE));
|
||||||
|
calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND));
|
||||||
|
int count = deleteOldMessages(context, SmsHelper.UNREAD_SELECTION, calendar.getTimeInMillis());
|
||||||
|
Log.i(TAG, "Deleted unread messages: " + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteOldReadMessages(Context context) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.add(Calendar.DAY_OF_YEAR, -Integer.parseInt(QKPreferences.getString(QKPreference.AUTO_DELETE_READ)));
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY));
|
||||||
|
calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE));
|
||||||
|
calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND));
|
||||||
|
int count = deleteOldMessages(context, SmsHelper.READ_SELECTION + "=" + SmsHelper.READ, calendar.getTimeInMillis());
|
||||||
|
Log.i(TAG, "Deleted read messages: " + count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int deleteOldMessages(Context context, String selection, long before) {
|
||||||
|
selection += " AND " + SmsHelper.COLUMN_DATE + "<=?";
|
||||||
|
|
||||||
|
try {
|
||||||
|
return context.getContentResolver().delete(SmsHelper.SMS_CONTENT_PROVIDER, selection, new String[]{String.valueOf(before)});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupAutoDeleteAlarm(Context context) {
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 3); // We want this service to run when the phone is not likely being used
|
||||||
|
|
||||||
|
Intent intent = new Intent(context, DeleteOldMessagesService.class);
|
||||||
|
PendingIntent pIntent = PendingIntent.getService(context, 9237, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
|
AlarmManager alarm = (AlarmManager) context.getSystemService(ALARM_SERVICE);
|
||||||
|
alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,6 +86,7 @@ public class SmsHelper {
|
|||||||
public static final String COLUMN_BODY = "body";
|
public static final String COLUMN_BODY = "body";
|
||||||
public static final String COLUMN_SEEN = "seen";
|
public static final String COLUMN_SEEN = "seen";
|
||||||
|
|
||||||
|
public static final String READ_SELECTION = COLUMN_READ + " = " + READ;
|
||||||
public static final String UNREAD_SELECTION = COLUMN_READ + " = " + UNREAD;
|
public static final String UNREAD_SELECTION = COLUMN_READ + " = " + UNREAD;
|
||||||
public static final String UNSEEN_SELECTION = COLUMN_SEEN + " = " + UNREAD;
|
public static final String UNSEEN_SELECTION = COLUMN_SEEN + " = " + UNREAD;
|
||||||
public static final String FAILED_SELECTION = COLUMN_TYPE + " = " + Message.FAILED;
|
public static final String FAILED_SELECTION = COLUMN_TYPE + " = " + Message.FAILED;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.moez.QKSMS.common.utils.MessageUtils;
|
|||||||
import com.moez.QKSMS.data.Conversation;
|
import com.moez.QKSMS.data.Conversation;
|
||||||
import com.moez.QKSMS.enums.QKPreference;
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
import com.moez.QKSMS.receiver.IconColorReceiver;
|
import com.moez.QKSMS.receiver.IconColorReceiver;
|
||||||
|
import com.moez.QKSMS.service.DeleteOldMessagesService;
|
||||||
import com.moez.QKSMS.transaction.NotificationManager;
|
import com.moez.QKSMS.transaction.NotificationManager;
|
||||||
import com.moez.QKSMS.transaction.SmsHelper;
|
import com.moez.QKSMS.transaction.SmsHelper;
|
||||||
import com.moez.QKSMS.ui.base.QKActivity;
|
import com.moez.QKSMS.ui.base.QKActivity;
|
||||||
@@ -100,6 +101,8 @@ public class MainActivity extends QKActivity {
|
|||||||
//Adds a small/non intrusive snackbar that asks the user to rate the app
|
//Adds a small/non intrusive snackbar that asks the user to rate the app
|
||||||
SnackEngage.from(this).withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
|
SnackEngage.from(this).withSnack(new QKRateSnack().withDuration(BaseSnack.DURATION_LONG))
|
||||||
.build().engageWhenAppropriate();
|
.build().engageWhenAppropriate();
|
||||||
|
|
||||||
|
DeleteOldMessagesService.setupAutoDeleteAlarm(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ import com.moez.QKSMS.R;
|
|||||||
import com.moez.QKSMS.common.DialogHelper;
|
import com.moez.QKSMS.common.DialogHelper;
|
||||||
import com.moez.QKSMS.common.DonationManager;
|
import com.moez.QKSMS.common.DonationManager;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
|
import com.moez.QKSMS.common.QKPreferences;
|
||||||
import com.moez.QKSMS.common.utils.ColorUtils;
|
import com.moez.QKSMS.common.utils.ColorUtils;
|
||||||
import com.moez.QKSMS.enums.QKPreference;
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
import com.moez.QKSMS.ui.ThemeManager;
|
import com.moez.QKSMS.ui.ThemeManager;
|
||||||
import com.moez.QKSMS.ui.search.SearchFragment;
|
|
||||||
import com.moez.QKSMS.ui.settings.SettingsActivity;
|
import com.moez.QKSMS.ui.settings.SettingsActivity;
|
||||||
import com.moez.QKSMS.ui.view.QKTextView;
|
import com.moez.QKSMS.ui.view.QKTextView;
|
||||||
|
|
||||||
@@ -62,12 +62,12 @@ public abstract class QKActivity extends AppCompatActivity {
|
|||||||
mProgressDialog.setCancelable(false);
|
mProgressDialog.setCancelable(false);
|
||||||
|
|
||||||
LiveViewManager.registerView(QKPreference.TINTED_STATUS, this, key -> {
|
LiveViewManager.registerView(QKPreference.TINTED_STATUS, this, key -> {
|
||||||
mStatusTintEnabled = getBoolean(QKPreference.TINTED_STATUS) &&
|
mStatusTintEnabled = QKPreferences.getBoolean(QKPreference.TINTED_STATUS) &&
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||||
});
|
});
|
||||||
|
|
||||||
LiveViewManager.registerView(QKPreference.TINTED_NAV, this, key -> {
|
LiveViewManager.registerView(QKPreference.TINTED_NAV, this, key -> {
|
||||||
mNavigationTintEnabled = getBoolean(QKPreference.TINTED_NAV) &&
|
mNavigationTintEnabled = QKPreferences.getBoolean(QKPreference.TINTED_NAV) &&
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -296,28 +296,4 @@ public abstract class QKActivity extends AppCompatActivity {
|
|||||||
public RequestQueue getRequestQueue() {
|
public RequestQueue getRequestQueue() {
|
||||||
return ((QKSMSApp) getApplication()).getRequestQueue();
|
return ((QKSMSApp) getApplication()).getRequestQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBoolean(QKPreference preference) {
|
|
||||||
return getPrefs().getBoolean(preference.getKey(), (boolean) preference.getDefaultValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBoolean(QKPreference preference, boolean newValue) {
|
|
||||||
getPrefs().edit().putBoolean(preference.getKey(), newValue).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getInt(QKPreference preference) {
|
|
||||||
return getPrefs().getInt(preference.getKey(), (int) preference.getDefaultValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInt(QKPreference preference, int newValue) {
|
|
||||||
getPrefs().edit().putInt(preference.getKey(), newValue).apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getString(QKPreference preference) {
|
|
||||||
return getPrefs().getString(preference.getKey(), (String) preference.getDefaultValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setString(QKPreference preference, String newValue) {
|
|
||||||
getPrefs().edit().putString(preference.getKey(), newValue).apply();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.moez.QKSMS.R;
|
|||||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||||
import com.moez.QKSMS.common.FontManager;
|
import com.moez.QKSMS.common.FontManager;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
|
import com.moez.QKSMS.common.QKPreferences;
|
||||||
import com.moez.QKSMS.common.emoji.EmojiRegistry;
|
import com.moez.QKSMS.common.emoji.EmojiRegistry;
|
||||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||||
import com.moez.QKSMS.data.Contact;
|
import com.moez.QKSMS.data.Contact;
|
||||||
@@ -106,7 +107,7 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
|
|||||||
}
|
}
|
||||||
|
|
||||||
LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key -> {
|
LiveViewManager.registerView(QKPreference.HIDE_AVATAR_CONVERSATIONS, this, key -> {
|
||||||
holder.mAvatarView.setVisibility(mContext.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE);
|
holder.mAvatarView.setVisibility(QKPreferences.getBoolean(QKPreference.HIDE_AVATAR_CONVERSATIONS) ? View.GONE : View.VISIBLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import com.moez.QKSMS.common.CIELChEvaluator;
|
|||||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||||
import com.moez.QKSMS.common.DialogHelper;
|
import com.moez.QKSMS.common.DialogHelper;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
|
import com.moez.QKSMS.common.QKPreferences;
|
||||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||||
import com.moez.QKSMS.common.utils.MessageUtils;
|
import com.moez.QKSMS.common.utils.MessageUtils;
|
||||||
import com.moez.QKSMS.common.vcard.ContactOperations;
|
import com.moez.QKSMS.common.vcard.ContactOperations;
|
||||||
@@ -188,7 +189,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE);
|
||||||
mProxSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
mProxSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
|
|
||||||
if (mContext.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
if (QKPreferences.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
||||||
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +248,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
if (mContext.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
if (QKPreferences.getBoolean(QKPreference.PROXIMITY_SENSOR)) {
|
||||||
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
mSensorManager.registerListener(this, mProxSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ import com.moez.QKSMS.common.DialogHelper;
|
|||||||
import com.moez.QKSMS.common.DonationManager;
|
import com.moez.QKSMS.common.DonationManager;
|
||||||
import com.moez.QKSMS.common.ListviewHelper;
|
import com.moez.QKSMS.common.ListviewHelper;
|
||||||
import com.moez.QKSMS.common.LiveViewManager;
|
import com.moez.QKSMS.common.LiveViewManager;
|
||||||
|
import com.moez.QKSMS.common.QKPreferences;
|
||||||
import com.moez.QKSMS.common.utils.DateFormatter;
|
import com.moez.QKSMS.common.utils.DateFormatter;
|
||||||
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
import com.moez.QKSMS.common.utils.KeyboardUtils;
|
||||||
import com.moez.QKSMS.common.utils.PackageUtils;
|
import com.moez.QKSMS.common.utils.PackageUtils;
|
||||||
import com.moez.QKSMS.enums.QKPreference;
|
import com.moez.QKSMS.enums.QKPreference;
|
||||||
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
|
import com.moez.QKSMS.receiver.NightModeAutoReceiver;
|
||||||
|
import com.moez.QKSMS.service.DeleteOldMessagesService;
|
||||||
import com.moez.QKSMS.transaction.EndlessJabber;
|
import com.moez.QKSMS.transaction.EndlessJabber;
|
||||||
import com.moez.QKSMS.transaction.NotificationManager;
|
import com.moez.QKSMS.transaction.NotificationManager;
|
||||||
import com.moez.QKSMS.transaction.SmsHelper;
|
import com.moez.QKSMS.transaction.SmsHelper;
|
||||||
@@ -105,6 +107,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
public static final String DELIVERY_REPORTS = "pref_key_delivery";
|
public static final String DELIVERY_REPORTS = "pref_key_delivery";
|
||||||
public static final String DELIVERY_TOAST = "pref_key_delivery_toast";
|
public static final String DELIVERY_TOAST = "pref_key_delivery_toast";
|
||||||
public static final String DELIVERY_VIBRATE = "pref_key_delivery_vibrate";
|
public static final String DELIVERY_VIBRATE = "pref_key_delivery_vibrate";
|
||||||
|
public static final String DELETE_OLD_MESSAGES = "pref_key_delete_old_messages";
|
||||||
|
public static final String DELETE_UNREAD_MESSAGES = "pref_key_delete_old_unread_messages";
|
||||||
|
public static final String DELETE_READ_MESSAGES = "pref_key_delete_old_read_messages";
|
||||||
public static final String YAPPY = "pref_key_endlessjabber";
|
public static final String YAPPY = "pref_key_endlessjabber";
|
||||||
public static final String BLOCKED_ENABLED = "pref_key_blocked_enabled";
|
public static final String BLOCKED_ENABLED = "pref_key_blocked_enabled";
|
||||||
public static final String BLOCKED_SENDERS = "pref_key_blocked_senders";
|
public static final String BLOCKED_SENDERS = "pref_key_blocked_senders";
|
||||||
@@ -283,6 +288,16 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
font_weight.setSummary(mFontWeights[i == 2 ? 0 : 1]);
|
font_weight.setSummary(mFontWeights[i == 2 ? 0 : 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditTextPreference deleteUnread = (EditTextPreference) findPreference(DELETE_UNREAD_MESSAGES);
|
||||||
|
if (deleteUnread != null) {
|
||||||
|
deleteUnread.setSummary(mContext.getString(R.string.pref_delete_old_messages_unread_summary, QKPreferences.getString(QKPreference.AUTO_DELETE_UNREAD)));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditTextPreference deleteRead = (EditTextPreference) findPreference(DELETE_READ_MESSAGES);
|
||||||
|
if (deleteRead != null) {
|
||||||
|
deleteRead.setSummary(mContext.getString(R.string.pref_delete_old_messages_read_summary, QKPreferences.getString(QKPreference.AUTO_DELETE_READ)));
|
||||||
|
}
|
||||||
|
|
||||||
Preference day_start = findPreference(DAY_START);
|
Preference day_start = findPreference(DAY_START);
|
||||||
if (day_start != null) {
|
if (day_start != null) {
|
||||||
day_start.setSummary(DateFormatter.getSummaryTimestamp(mContext, mPrefs.getString(DAY_START, "6:00")));
|
day_start.setSummary(DateFormatter.getSummaryTimestamp(mContext, mPrefs.getString(DAY_START, "6:00")));
|
||||||
@@ -442,6 +457,33 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
case NIGHT_START:
|
case NIGHT_START:
|
||||||
updateAlarmManager(mContext, true);
|
updateAlarmManager(mContext, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DELETE_OLD_MESSAGES:
|
||||||
|
if ((Boolean) newValue) {
|
||||||
|
new QKDialog()
|
||||||
|
.setContext(mContext)
|
||||||
|
.setTitle(R.string.pref_delete_old_messages)
|
||||||
|
.setMessage(R.string.dialog_delete_old_messages)
|
||||||
|
.setPositiveButton(R.string.yes, v -> {
|
||||||
|
QKPreferences.setBoolean(QKPreference.AUTO_DELETE, true);
|
||||||
|
((CheckBoxPreference) preference).setChecked(true);
|
||||||
|
DeleteOldMessagesService.setupAutoDeleteAlarm(mContext);
|
||||||
|
mContext.makeToast(R.string.toast_deleting_old_messages);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DELETE_UNREAD_MESSAGES:
|
||||||
|
preference.setSummary(mContext.getString(R.string.pref_delete_old_messages_unread_summary, newValue));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DELETE_READ_MESSAGES:
|
||||||
|
preference.setSummary(mContext.getString(R.string.pref_delete_old_messages_read_summary, newValue));
|
||||||
|
break;
|
||||||
|
|
||||||
case YAPPY:
|
case YAPPY:
|
||||||
if ((Boolean) newValue) {
|
if ((Boolean) newValue) {
|
||||||
try {
|
try {
|
||||||
@@ -546,7 +588,7 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
|||||||
case SHOULD_I_ANSWER:
|
case SHOULD_I_ANSWER:
|
||||||
final String packageName = "org.mistergroup.muzutozvednout";
|
final String packageName = "org.mistergroup.muzutozvednout";
|
||||||
if (!PackageUtils.isAppInstalled(mContext, packageName)) {
|
if (!PackageUtils.isAppInstalled(mContext, packageName)) {
|
||||||
String referrer="referrer=utm_source%3Dqksms%26utm_medium%3Dapp%26utm_campaign%3Dqksmssettings";
|
String referrer = "referrer=utm_source%3Dqksms%26utm_medium%3Dapp%26utm_campaign%3Dqksmssettings";
|
||||||
new QKDialog()
|
new QKDialog()
|
||||||
.setContext(mContext)
|
.setContext(mContext)
|
||||||
.setTitle(R.string.dialog_should_i_answer_title)
|
.setTitle(R.string.dialog_should_i_answer_title)
|
||||||
|
|||||||
@@ -170,6 +170,12 @@
|
|||||||
<string name="pref_delivery_toast_summary">Show a short toast to indicate a message being delivered</string>
|
<string name="pref_delivery_toast_summary">Show a short toast to indicate a message being delivered</string>
|
||||||
<string name="pref_delivery_vibrate">Vibrate</string>
|
<string name="pref_delivery_vibrate">Vibrate</string>
|
||||||
<string name="pref_delivery_vibrate_summary">Vibrate on message delivery</string>
|
<string name="pref_delivery_vibrate_summary">Vibrate on message delivery</string>
|
||||||
|
<string name="pref_delete_old_messages">Delete old messages</string>
|
||||||
|
<string name="pref_delete_old_messages_summary">Automatically delete messages once they\'re old enough</string>
|
||||||
|
<string name="pref_delete_old_messages_unread">Unread messages</string>
|
||||||
|
<string name="pref_delete_old_messages_unread_summary">Automatically delete unread messages after %s days</string>
|
||||||
|
<string name="pref_delete_old_messages_read">Read messages</string>
|
||||||
|
<string name="pref_delete_old_messages_read_summary">Automatically delete read messages after %s days</string>
|
||||||
<string name="pref_yappy">Yappy integration</string>
|
<string name="pref_yappy">Yappy integration</string>
|
||||||
<string name="pref_endlessjabber_summary">Enable full support for Yappy</string>
|
<string name="pref_endlessjabber_summary">Enable full support for Yappy</string>
|
||||||
<string name="pref_blocked_conversations">Blocked conversations</string>
|
<string name="pref_blocked_conversations">Blocked conversations</string>
|
||||||
@@ -591,6 +597,7 @@
|
|||||||
<string name="dialog_conversation_details_recipients">Recipients (%s)</string>
|
<string name="dialog_conversation_details_recipients">Recipients (%s)</string>
|
||||||
<string name="dialog_should_i_answer_title">Should I Answer? not installed</string>
|
<string name="dialog_should_i_answer_title">Should I Answer? not installed</string>
|
||||||
<string name="dialog_should_i_answer_message">Would you like to download the app from Google Play now?</string>
|
<string name="dialog_should_i_answer_message">Would you like to download the app from Google Play now?</string>
|
||||||
|
<string name="dialog_delete_old_messages">Are you sure you want to automatically delete old messages?</string>
|
||||||
|
|
||||||
<!-- Title for audio file picker -->
|
<!-- Title for audio file picker -->
|
||||||
<string name="select_audio">Choose audio</string>
|
<string name="select_audio">Choose audio</string>
|
||||||
@@ -636,6 +643,7 @@
|
|||||||
<string name="toast_endlessjabber_not_installed">EndlessJabber is not installed, opening Google Play</string>
|
<string name="toast_endlessjabber_not_installed">EndlessJabber is not installed, opening Google Play</string>
|
||||||
<string name="toast_changelog_error">Couldn\'t load the changelog. Please try again later</string>
|
<string name="toast_changelog_error">Couldn\'t load the changelog. Please try again later</string>
|
||||||
<string name="toast_conversation_error">Couldn\'t open conversation</string>
|
<string name="toast_conversation_error">Couldn\'t open conversation</string>
|
||||||
|
<string name="toast_deleting_old_messages">Your old messages will be deleted shortly</string>
|
||||||
|
|
||||||
<!--Toast shown to thank user for donating-->
|
<!--Toast shown to thank user for donating-->
|
||||||
<string name="thanks_1">Thank you for donating! You\'re my new best friend.</string>
|
<string name="thanks_1">Thank you for donating! You\'re my new best friend.</string>
|
||||||
|
|||||||
@@ -73,6 +73,15 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_key_mobile_only" />
|
android:key="pref_key_mobile_only" />
|
||||||
|
<Preference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="pref_key_delete_old_messages" />
|
||||||
|
<Preference
|
||||||
|
android:defaultValue="7"
|
||||||
|
android:key="pref_key_delete_old_unread_messages" />
|
||||||
|
<Preference
|
||||||
|
android:defaultValue="7"
|
||||||
|
android:key="pref_key_delete_old_read_messages" />
|
||||||
<Preference
|
<Preference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="pref_key_strip_unicode" />
|
android:key="pref_key_strip_unicode" />
|
||||||
|
|||||||
@@ -47,6 +47,31 @@
|
|||||||
android:title="@string/pref_delivery_vibrate"
|
android:title="@string/pref_delivery_vibrate"
|
||||||
android:widgetLayout="@layout/view_switch" />
|
android:widgetLayout="@layout/view_switch" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
<PreferenceCategory
|
||||||
|
android:layout="@layout/list_item_preference_category"
|
||||||
|
android:title="@string/pref_delete_old_messages">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="pref_key_delete_old_messages"
|
||||||
|
android:layout="@layout/list_item_preference"
|
||||||
|
android:summary="@string/pref_delete_old_messages_summary"
|
||||||
|
android:title="@string/pref_delete_old_messages"
|
||||||
|
android:widgetLayout="@layout/view_switch" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="7"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="pref_key_delete_old_unread_messages"
|
||||||
|
android:layout="@layout/list_item_preference"
|
||||||
|
android:summary="@string/pref_delete_old_messages_unread_summary"
|
||||||
|
android:title="@string/pref_delete_old_messages_unread" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="7"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="pref_key_delete_old_read_messages"
|
||||||
|
android:layout="@layout/list_item_preference"
|
||||||
|
android:summary="@string/pref_delete_old_messages_read_summary"
|
||||||
|
android:title="@string/pref_delete_old_messages_read" />
|
||||||
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:layout="@layout/list_item_preference_category"
|
android:layout="@layout/list_item_preference_category"
|
||||||
android:title="@string/pref_text">
|
android:title="@string/pref_text">
|
||||||
@@ -147,12 +172,12 @@
|
|||||||
android:title="@string/pref_key_timestamp_delay" />
|
android:title="@string/pref_key_timestamp_delay" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
|
android:disableDependentsState="true"
|
||||||
android:key="pref_key_force_timestamps"
|
android:key="pref_key_force_timestamps"
|
||||||
android:layout="@layout/list_item_preference"
|
android:layout="@layout/list_item_preference"
|
||||||
android:summary="@string/pref_force_timestamps_summary"
|
android:summary="@string/pref_force_timestamps_summary"
|
||||||
android:title="@string/pref_force_timestamps"
|
android:title="@string/pref_force_timestamps"
|
||||||
android:widgetLayout="@layout/view_switch"
|
android:widgetLayout="@layout/view_switch" />
|
||||||
android:disableDependentsState="true"/>
|
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="pref_key_compose_favorites"
|
android:key="pref_key_compose_favorites"
|
||||||
|
|||||||
Reference in New Issue
Block a user