mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 20:34:49 +01:00
Allow disabling update check
This commit is contained in:
@@ -573,10 +573,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
}
|
||||
|
||||
private void checkUpdate() {
|
||||
final long now = new Date().getTime();
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
long now = new Date().getTime();
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (!prefs.getBoolean("updates", true))
|
||||
return;
|
||||
if (prefs.getLong("last_update_check", 0) + UPDATE_INTERVAL > now)
|
||||
return;
|
||||
prefs.edit().putLong("last_update_check", now).apply();
|
||||
|
||||
new SimpleTask<UpdateInfo>() {
|
||||
@Override
|
||||
@@ -593,17 +596,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
json.append(line);
|
||||
|
||||
JSONObject jroot = new JSONObject(json.toString());
|
||||
|
||||
if (jroot.has("tag_name") &&
|
||||
jroot.has("html_url") &&
|
||||
jroot.has("assets")) {
|
||||
prefs.edit().putLong("last_update_check", now).apply();
|
||||
|
||||
// Get update info
|
||||
UpdateInfo info = new UpdateInfo();
|
||||
info.tag_name = jroot.getString("tag_name");
|
||||
info.html_url = jroot.getString("html_url");
|
||||
if (TextUtils.isEmpty(info.html_url))
|
||||
return null;
|
||||
|
||||
// Check if new release
|
||||
JSONArray jassets = jroot.getJSONArray("assets");
|
||||
for (int i = 0; i < jassets.length(); i++) {
|
||||
JSONObject jasset = jassets.getJSONObject(i);
|
||||
@@ -622,12 +626,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} finally {
|
||||
if (urlConnection != null)
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,6 +53,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
private SwitchCompat swSender;
|
||||
private SwitchCompat swInsecure;
|
||||
private Spinner spDownload;
|
||||
private SwitchCompat swUpdates;
|
||||
private SwitchCompat swDebug;
|
||||
|
||||
@Override
|
||||
@@ -75,6 +76,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
swSender = view.findViewById(R.id.swSender);
|
||||
swInsecure = view.findViewById(R.id.swInsecure);
|
||||
spDownload = view.findViewById(R.id.spDownload);
|
||||
swUpdates = view.findViewById(R.id.swUpdates);
|
||||
swDebug = view.findViewById(R.id.swDebug);
|
||||
|
||||
// Wire controls
|
||||
@@ -222,6 +224,15 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
}
|
||||
});
|
||||
|
||||
swUpdates.setChecked(prefs.getBoolean("updates", true));
|
||||
swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("updates", checked).apply();
|
||||
}
|
||||
});
|
||||
swUpdates.setVisibility(Helper.isPlayStoreInstall(getContext()) ? View.GONE : View.VISIBLE);
|
||||
|
||||
swDebug.setChecked(prefs.getBoolean("debug", false));
|
||||
swDebug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user