Merge request changes

- Moved certificate-related utilities to separate class

- Added settings method to return an entire SSLSettings object; refactored
  methods using separate parameters to take single SSLSettings parameter

- Advanced Settings section on login page now hides / shows along with
  other buttons to prevent it from showing up in front of the loading
  spinner

- Fixed star imports

- Refactored applySslSettings as per code from merge request

- Fixed formatting
This commit is contained in:
Galen Abell
2018-11-08 17:43:12 -05:00
parent 2d14ef1b6f
commit 8e2d90ef50
10 changed files with 274 additions and 209 deletions

View File

@@ -2,6 +2,7 @@ package com.github.gotify;
import android.content.Context;
import android.content.SharedPreferences;
import com.github.gotify.api.CertUtils;
import com.github.gotify.client.model.User;
public class Settings {
@@ -60,12 +61,23 @@ public class Settings {
sharedPreferences.edit().putString("version", version).apply();
}
// Default to always validating SSL.
public boolean validateSSL() { return sharedPreferences.getBoolean("validateSSL", true); }
private boolean validateSSL() {
return sharedPreferences.getBoolean("validateSSL", true);
}
public void validateSSL(boolean validateSSL) { sharedPreferences.edit().putBoolean("validateSSL", validateSSL).apply(); }
public void validateSSL(boolean validateSSL) {
sharedPreferences.edit().putBoolean("validateSSL", validateSSL).apply();
}
public String cert() { return sharedPreferences.getString("cert", null); }
private String cert() {
return sharedPreferences.getString("cert", null);
}
public void cert(String cert) { sharedPreferences.edit().putString("cert", cert).apply(); }
public void cert(String cert) {
sharedPreferences.edit().putString("cert", cert).apply();
}
public CertUtils.SSLSettings sslSettings() {
return new CertUtils.SSLSettings(validateSSL(), cert());
}
}