Skip to content

Commit

Permalink
Renamed sleep interval variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ImranR98 committed Oct 29, 2024
1 parent f6736e6 commit 5595985
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
mSyncDurationMinutes =
(EditTextPreference) findPreference(Constants.PREF_SYNC_DURATION_MINUTES);
mSyncIntervalMinutes =
(EditTextPreference) findPreference(Constants.PREF_SYNC_INTERVAL_MINUTES);
(EditTextPreference) findPreference(Constants.PREF_SLEEP_INTERVAL_MINUTES);

mRunOnMeteredWifi.setEnabled(mRunOnWifi.isChecked());
mUseWifiWhitelist.setEnabled(mRunOnWifi.isChecked());
Expand Down Expand Up @@ -612,7 +612,7 @@ public boolean onRunConditionPreferenceChange(Preference preference, Object o) {
}
preference.setSummary(getString(R.string.sync_duration_minutes_summary, durationMinutes));
break;
case Constants.PREF_SYNC_INTERVAL_MINUTES:
case Constants.PREF_SLEEP_INTERVAL_MINUTES:
String intervalMinutes = o.toString();
if (TextUtils.isEmpty(intervalMinutes)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private PowerSource() { }
public static final String PREF_RUN_IN_FLIGHT_MODE = "run_in_flight_mode";
public static final String PREF_RUN_ON_TIME_SCHEDULE = "run_on_time_schedule";
public static final String PREF_SYNC_DURATION_MINUTES = "sync_duration_minutes";
public static final String PREF_SYNC_INTERVAL_MINUTES = "sync_interval_minutes";
public static final String PREF_SLEEP_INTERVAL_MINUTES = "sync_interval_minutes";

// Preferences - User Interface
public static final String PREF_APP_THEME = "app_theme";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public RunConditionMonitor(Context context,
*/
if (lastSyncTimeSinceBootMillisecs > elapsedRealtime) {
SharedPreferences.Editor editor = mPreferences.edit();
editor.putLong(Constants.PREF_LAST_RUN_TIME, -Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60 * 1000);
editor.putLong(Constants.PREF_LAST_RUN_TIME, -Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60 * 1000);
editor.apply();
lastSyncTimeSinceBootMillisecs = 0;
}
Expand All @@ -206,7 +206,7 @@ public RunConditionMonitor(Context context,
* mTimeConditionMatch is set to true during updateShouldRunDecision().
* Thus the false case cannot be triggered if the delay for scheduleSyncTriggerServiceJob would be negative
*/
(Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60) - elapsedSecondsSinceLastSync,
(Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60) - elapsedSecondsSinceLastSync,
!mTimeConditionMatch
);
}
Expand Down Expand Up @@ -281,7 +281,7 @@ public void onReceive(Context context, Intent intent) {
JobUtils.cancelAllScheduledJobs(context);
JobUtils.scheduleSyncTriggerServiceJob(
context,
Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60,
Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60,
true
);
return;
Expand Down Expand Up @@ -313,9 +313,9 @@ public void onReceive(Context context, Intent intent) {
* corrected immediately
*/
long lastRunTimeMillis = mPreferences.getLong(Constants.PREF_LAST_RUN_TIME, 0);
if (lastDeterminedShouldRun && SystemClock.elapsedRealtime() - lastRunTimeMillis > Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60 * 1000) {
if (lastDeterminedShouldRun && SystemClock.elapsedRealtime() - lastRunTimeMillis > Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60 * 1000) {
SharedPreferences.Editor editor = mPreferences.edit();
editor.putLong(Constants.PREF_LAST_RUN_TIME, SystemClock.elapsedRealtime() - Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60 * 1000 + 60*1000);
editor.putLong(Constants.PREF_LAST_RUN_TIME, SystemClock.elapsedRealtime() - Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60 * 1000 + 60*1000);
editor.apply();
}
}
Expand All @@ -341,7 +341,7 @@ public void onReceive(Context context, Intent intent) {
JobUtils.cancelAllScheduledJobs(context);
JobUtils.scheduleSyncTriggerServiceJob(
context,
Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60,
Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60,
true
);
} else {
Expand Down Expand Up @@ -572,7 +572,7 @@ private boolean decideShouldRun() {

// PREF_RUN_ON_TIME_SCHEDULE
// set mTimeConditionMatch to true if the last run was more than WAIT_FOR_NEXT_SYNC_DELAY_SECS ago
if (SystemClock.elapsedRealtime() - mPreferences.getLong(Constants.PREF_LAST_RUN_TIME,0) > Integer.parseInt(mPreferences.getString(Constants.PREF_SYNC_INTERVAL_MINUTES,"60")) * 60 * 1000)
if (SystemClock.elapsedRealtime() - mPreferences.getLong(Constants.PREF_LAST_RUN_TIME,0) > Integer.parseInt(mPreferences.getString(Constants.PREF_SLEEP_INTERVAL_MINUTES,"60")) * 60 * 1000)
mTimeConditionMatch = true;
if (prefRunOnTimeSchedule && !mTimeConditionMatch) {
// Currently, we aren't within a "SyncthingNative should run" time frame.
Expand Down

0 comments on commit 5595985

Please sign in to comment.