mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 14:21:16 +00:00
Fix crash related to usage reporting update (fixes #978)
This commit is contained in:
parent
6c542600fa
commit
09efecaead
3 changed files with 7 additions and 12 deletions
|
@ -109,7 +109,7 @@ public class MainActivity extends StateDialogActivity
|
||||||
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 &&
|
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
|
||||||
getApi().getOptions().getUsageReportValue() == Options.USAGE_REPORTING_UNDECIDED) {
|
getApi().getOptions().isUsageReportingAccepted()) {
|
||||||
showUsageReportingDialog();
|
showUsageReportingDialog();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -452,7 +452,7 @@ 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.USAGE_REPORTING_ACCEPTED;
|
options.urAccepted = options.urVersionMax;
|
||||||
break;
|
break;
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
options.urAccepted = Options.USAGE_REPORTING_DENIED;
|
options.urAccepted = Options.USAGE_REPORTING_DENIED;
|
||||||
|
|
|
@ -234,7 +234,7 @@ 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.getUsageReportValue() == Options.USAGE_REPORTING_ACCEPTED);
|
mUrAccepted.setChecked(mOptions.isUsageReportingAccepted());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -277,7 +277,7 @@ public class SettingsActivity extends SyncthingActivity {
|
||||||
case "address": mGui.address = (String) o; break;
|
case "address": mGui.address = (String) o; break;
|
||||||
case "urAccepted":
|
case "urAccepted":
|
||||||
mOptions.urAccepted = ((boolean) o)
|
mOptions.urAccepted = ((boolean) o)
|
||||||
? Options.USAGE_REPORTING_ACCEPTED
|
? mOptions.urVersionMax
|
||||||
: Options.USAGE_REPORTING_DENIED;
|
: Options.USAGE_REPORTING_DENIED;
|
||||||
break;
|
break;
|
||||||
default: throw new InvalidParameterException();
|
default: throw new InvalidParameterException();
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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;
|
||||||
|
@ -36,15 +37,9 @@ public class Options {
|
||||||
public int tempIndexMinBlocks;
|
public int tempIndexMinBlocks;
|
||||||
|
|
||||||
public static final int USAGE_REPORTING_UNDECIDED = 0;
|
public static final int USAGE_REPORTING_UNDECIDED = 0;
|
||||||
public static final int USAGE_REPORTING_ACCEPTED = 2;
|
|
||||||
public static final int USAGE_REPORTING_DENIED = -1;
|
public static final int USAGE_REPORTING_DENIED = -1;
|
||||||
|
|
||||||
public int getUsageReportValue() {
|
public boolean isUsageReportingAccepted() {
|
||||||
if (urAccepted > USAGE_REPORTING_ACCEPTED)
|
return urAccepted == urVersionMax;
|
||||||
throw new RuntimeException("Inalid usage reporting value");
|
|
||||||
|
|
||||||
return (urAccepted == USAGE_REPORTING_ACCEPTED || urAccepted == USAGE_REPORTING_DENIED)
|
|
||||||
? urAccepted
|
|
||||||
: USAGE_REPORTING_UNDECIDED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue