1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-26 04:41:30 +00:00

Fix usage reporting dialog setting wrong version (fixes #1003)

This commit is contained in:
Felix Ableitner 2018-01-24 13:13:18 +09:00
parent 6c77b67bc2
commit 4705332a9a
4 changed files with 19 additions and 11 deletions

View file

@ -108,10 +108,12 @@ public class MainActivity extends StateDialogActivity
showBatteryOptimizationDialogIfNecessary();
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mDrawerFragment.requestGuiUpdate();
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
getApi().getOptions().isUsageReportingAccepted()) {
showUsageReportingDialog();
}
getApi().getSystemInfo(systemInfo -> {
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
!getApi().getOptions().isUsageReportingAccepted(systemInfo.urVersionMax)) {
showUsageReportingDialog();
}
});
break;
case ERROR:
finish();
@ -452,7 +454,9 @@ public class MainActivity extends StateDialogActivity
Options options = getApi().getOptions();
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
options.urAccepted = options.urVersionMax;
getApi().getSystemInfo(systemInfo -> {
options.urAccepted = systemInfo.urVersionMax;
});
break;
case DialogInterface.BUTTON_NEGATIVE:
options.urAccepted = Options.USAGE_REPORTING_DENIED;

View file

@ -239,7 +239,8 @@ public class SettingsActivity extends SyncthingActivity {
mRelaysEnabled.setChecked(mOptions.relaysEnabled);
mGlobalAnnounceServers.setText(joiner.join(mOptions.globalAnnounceServers));
mAddress.setText(mGui.address);
mUrAccepted.setChecked(mOptions.isUsageReportingAccepted());
mApi.getSystemInfo(systemInfo ->
mUrAccepted.setChecked(mOptions.isUsageReportingAccepted(systemInfo.urVersionMax)));
}
@Override
@ -281,9 +282,12 @@ public class SettingsActivity extends SyncthingActivity {
break;
case "address": mGui.address = (String) o; break;
case "urAccepted":
mOptions.urAccepted = ((boolean) o)
? mOptions.urVersionMax
: Options.USAGE_REPORTING_DENIED;
mApi.getSystemInfo(systemInfo -> {
mOptions.urAccepted = ((boolean) o)
? systemInfo.urVersionMax
: Options.USAGE_REPORTING_DENIED;
mApi.editSettings(mGui, mOptions, getActivity());
});
break;
default: throw new InvalidParameterException();
}

View file

@ -18,7 +18,6 @@ public class Options {
public int natRenewalMinutes;
public int natTimeoutSeconds;
public int urAccepted;
public int urVersionMax;
public String urUniqueId;
public String urURL;
public boolean urPostInsecurely;
@ -39,7 +38,7 @@ public class Options {
public static final int USAGE_REPORTING_UNDECIDED = 0;
public static final int USAGE_REPORTING_DENIED = -1;
public boolean isUsageReportingAccepted() {
public boolean isUsageReportingAccepted(int urVersionMax) {
return urAccepted == urVersionMax;
}
}

View file

@ -11,4 +11,5 @@ public class SystemInfo {
public boolean discoveryEnabled;
public int discoveryMethods;
public Map<String, String> discoveryErrors;
public int urVersionMax;
}