Fixed auto update downloaded times

This commit is contained in:
M66B 2024-03-22 08:30:07 +01:00
parent 02ccd0d93a
commit ef2578bd83
3 changed files with 10 additions and 10 deletions

View File

@ -20,10 +20,12 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;
import org.json.JSONException;
@ -40,6 +42,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
@ -403,6 +406,9 @@ public class Adguard {
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
Helper.copy(connection.getInputStream(), os);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putLong("adguard_last", new Date().getTime()).apply();
} finally {
connection.disconnect();
}

View File

@ -37,6 +37,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -132,6 +133,9 @@ public class DisconnectBlacklist {
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
Helper.copy(connection.getInputStream(), os);
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putLong("disconnect_last", new Date().getTime()).apply();
} finally {
connection.disconnect();
}

View File

@ -255,11 +255,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
return null;
}
@Override
protected void onExecuted(Bundle args, Void data) {
prefs.edit().putLong("adguard_last", new Date().getTime()).apply();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex, !(ex instanceof IOException));
@ -527,11 +522,6 @@ public class FragmentOptionsPrivacy extends FragmentBase implements SharedPrefer
return null;
}
@Override
protected void onExecuted(Bundle args, Void data) {
prefs.edit().putLong("disconnect_last", new Date().getTime()).apply();
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex, !(ex instanceof IOException));