mirror of https://github.com/M66B/FairEmail.git
Added setting for weekly update check
This commit is contained in:
parent
50e4188ebe
commit
cd0333d61b
|
@ -139,7 +139,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
|
||||
private static final int UPDATE_TIMEOUT = 15 * 1000; // milliseconds
|
||||
private static final long EXIT_DELAY = 2500L; // milliseconds
|
||||
static final long UPDATE_INTERVAL = (BuildConfig.BETA_RELEASE ? 4 : 12) * 3600 * 1000L; // milliseconds
|
||||
static final long UPDATE_DAILY = (BuildConfig.BETA_RELEASE ? 4 : 12) * 3600 * 1000L; // milliseconds
|
||||
static final long UPDATE_WEEKLY = 7 * 24 * 3600 * 1000L; // milliseconds
|
||||
|
||||
@Override
|
||||
@SuppressLint("MissingSuperCall")
|
||||
|
@ -856,11 +857,17 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
return;
|
||||
|
||||
long now = new Date().getTime();
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if (!always && !prefs.getBoolean("updates", true))
|
||||
boolean updates = prefs.getBoolean("updates", true);
|
||||
boolean weekly = prefs.getBoolean("weekly", false);
|
||||
long last_update_check = prefs.getLong("last_update_check", 0);
|
||||
|
||||
if (!always && !updates)
|
||||
return;
|
||||
if (!always && prefs.getLong("last_update_check", 0) + UPDATE_INTERVAL > now)
|
||||
if (!always && last_update_check + (weekly ? UPDATE_WEEKLY : UPDATE_DAILY) > now)
|
||||
return;
|
||||
|
||||
prefs.edit().putLong("last_update_check", now).apply();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
|
|
|
@ -95,6 +95,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private ImageButton ibResetLanguage;
|
||||
private SwitchCompat swWatchdog;
|
||||
private SwitchCompat swUpdates;
|
||||
private SwitchCompat swCheckWeekly;
|
||||
private SwitchCompat swExperiments;
|
||||
private TextView tvExperimentsHint;
|
||||
private SwitchCompat swCrashReports;
|
||||
|
@ -126,6 +127,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private Button btnCiphers;
|
||||
private Button btnFiles;
|
||||
|
||||
private Group grpUpdates;
|
||||
private Group grpDebug;
|
||||
|
||||
private NumberFormat NF = NumberFormat.getNumberInstance();
|
||||
|
@ -193,6 +195,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
ibResetLanguage = view.findViewById(R.id.ibResetLanguage);
|
||||
swWatchdog = view.findViewById(R.id.swWatchdog);
|
||||
swUpdates = view.findViewById(R.id.swUpdates);
|
||||
swCheckWeekly = view.findViewById(R.id.swWeekly);
|
||||
swExperiments = view.findViewById(R.id.swExperiments);
|
||||
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
|
||||
swCrashReports = view.findViewById(R.id.swCrashReports);
|
||||
|
@ -224,6 +227,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
btnCiphers = view.findViewById(R.id.btnCiphers);
|
||||
btnFiles = view.findViewById(R.id.btnFiles);
|
||||
|
||||
grpUpdates = view.findViewById(R.id.grpUpdates);
|
||||
grpDebug = view.findViewById(R.id.grpDebug);
|
||||
|
||||
setOptions();
|
||||
|
@ -401,6 +405,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("updates", checked).apply();
|
||||
swCheckWeekly.setEnabled(checked);
|
||||
if (!checked) {
|
||||
NotificationManager nm = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
nm.cancel(Helper.NOTIFICATION_UPDATE);
|
||||
|
@ -408,6 +413,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
swCheckWeekly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("weekly", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
tvExperimentsHint.setPaintFlags(tvExperimentsHint.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
tvExperimentsHint.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -898,9 +910,11 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
|
||||
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
|
||||
swUpdates.setChecked(prefs.getBoolean("updates", true));
|
||||
swUpdates.setVisibility(
|
||||
Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext())
|
||||
? View.GONE : View.VISIBLE);
|
||||
swCheckWeekly.setChecked(prefs.getBoolean("weekly", false));
|
||||
swCheckWeekly.setEnabled(swUpdates.isChecked());
|
||||
grpUpdates.setVisibility(!BuildConfig.DEBUG &&
|
||||
(Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext()))
|
||||
? View.GONE : View.VISIBLE);
|
||||
swExperiments.setChecked(prefs.getBoolean("experiments", false));
|
||||
swCrashReports.setChecked(prefs.getBoolean("crash_reports", false));
|
||||
tvUuid.setText(prefs.getString("uuid", null));
|
||||
|
|
|
@ -279,6 +279,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swWatchdog"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swWeekly"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_check_weekly"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swUpdates"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swExperiments"
|
||||
android:layout_width="0dp"
|
||||
|
@ -287,7 +298,7 @@
|
|||
android:text="@string/title_advanced_experiments"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swUpdates"
|
||||
app:layout_constraintTop_toBottomOf="@id/swWeekly"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<eu.faircode.email.FixedTextView
|
||||
|
@ -671,6 +682,12 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnCiphers" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpUpdates"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="swUpdates,swWeekly" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpDebug"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -534,6 +534,7 @@
|
|||
<string name="title_advanced_auth_sasl" translatable="false">SASL (debug only)</string>
|
||||
<string name="title_advanced_optimize">Automatically optimize</string>
|
||||
<string name="title_advanced_updates">Check for GitHub updates</string>
|
||||
<string name="title_advanced_check_weekly">Check weekly instead of daily</string>
|
||||
<string name="title_advanced_experiments">Try experimental features</string>
|
||||
<string name="title_advanced_query_threads">Limit parallel database access</string>
|
||||
<string name="title_advanced_wal">WAL (debug only)</string>
|
||||
|
|
Loading…
Reference in New Issue