1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-25 22:01:16 +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(); showBatteryOptimizationDialogIfNecessary();
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mDrawerFragment.requestGuiUpdate(); mDrawerFragment.requestGuiUpdate();
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY && getApi().getSystemInfo(systemInfo -> {
getApi().getOptions().isUsageReportingAccepted()) { if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
showUsageReportingDialog(); !getApi().getOptions().isUsageReportingAccepted(systemInfo.urVersionMax)) {
} showUsageReportingDialog();
}
});
break; break;
case ERROR: case ERROR:
finish(); finish();
@ -452,7 +454,9 @@ public class MainActivity extends StateDialogActivity
Options options = getApi().getOptions(); Options options = getApi().getOptions();
switch (which) { switch (which) {
case DialogInterface.BUTTON_POSITIVE: case DialogInterface.BUTTON_POSITIVE:
options.urAccepted = options.urVersionMax; getApi().getSystemInfo(systemInfo -> {
options.urAccepted = systemInfo.urVersionMax;
});
break; break;
case DialogInterface.BUTTON_NEGATIVE: case DialogInterface.BUTTON_NEGATIVE:
options.urAccepted = Options.USAGE_REPORTING_DENIED; options.urAccepted = Options.USAGE_REPORTING_DENIED;

View file

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

View file

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

View file

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