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:
parent
6c77b67bc2
commit
4705332a9a
4 changed files with 19 additions and 11 deletions
|
@ -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();
|
||||||
|
getApi().getSystemInfo(systemInfo -> {
|
||||||
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
|
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
|
||||||
getApi().getOptions().isUsageReportingAccepted()) {
|
!getApi().getOptions().isUsageReportingAccepted(systemInfo.urVersionMax)) {
|
||||||
showUsageReportingDialog();
|
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;
|
||||||
|
|
|
@ -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":
|
||||||
|
mApi.getSystemInfo(systemInfo -> {
|
||||||
mOptions.urAccepted = ((boolean) o)
|
mOptions.urAccepted = ((boolean) o)
|
||||||
? mOptions.urVersionMax
|
? systemInfo.urVersionMax
|
||||||
: Options.USAGE_REPORTING_DENIED;
|
: Options.USAGE_REPORTING_DENIED;
|
||||||
|
mApi.editSettings(mGui, mOptions, getActivity());
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default: throw new InvalidParameterException();
|
default: throw new InvalidParameterException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue