mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-26 06:11:19 +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);
|
||||
mDrawerFragment.requestGuiUpdate();
|
||||
if (new Date().getTime() > getFirstStartTime() + USAGE_REPORTING_DIALOG_DELAY &&
|
||||
getApi().getOptions().getUsageReportValue() == Options.USAGE_REPORTING_UNDECIDED) {
|
||||
getApi().getOptions().isUsageReportingAccepted()) {
|
||||
showUsageReportingDialog();
|
||||
}
|
||||
break;
|
||||
|
@ -452,7 +452,7 @@ public class MainActivity extends StateDialogActivity
|
|||
Options options = getApi().getOptions();
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE:
|
||||
options.urAccepted = Options.USAGE_REPORTING_ACCEPTED;
|
||||
options.urAccepted = options.urVersionMax;
|
||||
break;
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
options.urAccepted = Options.USAGE_REPORTING_DENIED;
|
||||
|
|
|
@ -234,7 +234,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
mRelaysEnabled.setChecked(mOptions.relaysEnabled);
|
||||
mGlobalAnnounceServers.setText(joiner.join(mOptions.globalAnnounceServers));
|
||||
mAddress.setText(mGui.address);
|
||||
mUrAccepted.setChecked(mOptions.getUsageReportValue() == Options.USAGE_REPORTING_ACCEPTED);
|
||||
mUrAccepted.setChecked(mOptions.isUsageReportingAccepted());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -277,7 +277,7 @@ public class SettingsActivity extends SyncthingActivity {
|
|||
case "address": mGui.address = (String) o; break;
|
||||
case "urAccepted":
|
||||
mOptions.urAccepted = ((boolean) o)
|
||||
? Options.USAGE_REPORTING_ACCEPTED
|
||||
? mOptions.urVersionMax
|
||||
: Options.USAGE_REPORTING_DENIED;
|
||||
break;
|
||||
default: throw new InvalidParameterException();
|
||||
|
|
|
@ -18,6 +18,7 @@ public class Options {
|
|||
public int natRenewalMinutes;
|
||||
public int natTimeoutSeconds;
|
||||
public int urAccepted;
|
||||
public int urVersionMax;
|
||||
public String urUniqueId;
|
||||
public String urURL;
|
||||
public boolean urPostInsecurely;
|
||||
|
@ -36,15 +37,9 @@ public class Options {
|
|||
public int tempIndexMinBlocks;
|
||||
|
||||
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 int getUsageReportValue() {
|
||||
if (urAccepted > USAGE_REPORTING_ACCEPTED)
|
||||
throw new RuntimeException("Inalid usage reporting value");
|
||||
|
||||
return (urAccepted == USAGE_REPORTING_ACCEPTED || urAccepted == USAGE_REPORTING_DENIED)
|
||||
? urAccepted
|
||||
: USAGE_REPORTING_UNDECIDED;
|
||||
public boolean isUsageReportingAccepted() {
|
||||
return urAccepted == urVersionMax;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue