Fixed auto update downloaded times

pull/214/head
M66B 9 months ago
parent 02ccd0d93a
commit ef2578bd83

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

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

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

Loading…
Cancel
Save