Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/acomminos/Plumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Comminos <andrew@comminos.com>2016-01-12 04:47:24 +0300
committerAndrew Comminos <andrew@comminos.com>2016-01-12 04:47:24 +0300
commit1c1547785632e407679335719c7e761d06752090 (patch)
tree6e5827189c7c924858cb8092d31db35f5f2f14f6
parentdee00fc458feefbece3b3393f6307a228ffe049d (diff)
Added settings method to fetch default certificate ID.
-rw-r--r--app/src/main/java/com/morlunk/mumbleclient/Settings.java45
1 files changed, 15 insertions, 30 deletions
diff --git a/app/src/main/java/com/morlunk/mumbleclient/Settings.java b/app/src/main/java/com/morlunk/mumbleclient/Settings.java
index 15aac3f..feb68a5 100644
--- a/app/src/main/java/com/morlunk/mumbleclient/Settings.java
+++ b/app/src/main/java/com/morlunk/mumbleclient/Settings.java
@@ -93,8 +93,16 @@ public class Settings {
public static final String ARRAY_THEME_SOLARIZED_LIGHT = "solarizedLight";
public static final String ARRAY_THEME_SOLARIZED_DARK = "solarizedDark";
- public static final String PREF_CERT = "certificatePath";
- public static final String PREF_CERT_PASSWORD = "certificatePassword";
+ /** @deprecated use {@link #PREF_CERT_ID } */
+ public static final String PREF_CERT_DEPRECATED = "certificatePath";
+ /** @deprecated use {@link #PREF_CERT_ID } */
+ public static final String PREF_CERT_PASSWORD_DEPRECATED = "certificatePassword";
+
+ /**
+ * The DB identifier for the default certificate.
+ * @see com.morlunk.mumbleclient.db.DatabaseCertificate
+ */
+ public static final String PREF_CERT_ID = "certificateId";
public static final String PREF_DEFAULT_USERNAME = "defaultUsername";
public static final String DEFAULT_DEFAULT_USERNAME = "Plumble_User"; // funny var name
@@ -257,29 +265,12 @@ public class Settings {
}
/**
- * Attempts to read the certificate from the path specified in settings.
- * @return The parsed bytes of the certificate, or null otherwise.
+ * Returns a database identifier for the default certificate, or a negative number if there is
+ * no default certificate set.
+ * @return The default certificate's ID, or a negative integer if not set.
*/
- public byte[] getCertificate() {
- try {
- FileInputStream inputStream = new FileInputStream(preferences.getString(PREF_CERT, ""));
- byte[] buffer = new byte[inputStream.available()];
- inputStream.read(buffer);
- return buffer;
- } catch (FileNotFoundException e) {
- return null;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public boolean isUsingCertificate() {
- return preferences.contains(PREF_CERT);
- }
-
- public String getCertificatePassword() {
- return preferences.getString(PREF_CERT_PASSWORD, "");
+ public long getDefaultCertificate() {
+ return preferences.getLong(PREF_CERT_ID, -1);
}
public String getDefaultUsername() {
@@ -345,12 +336,6 @@ public class Settings {
editor.apply();
}
- public void setCertificatePath(String path) {
- Editor editor = preferences.edit();
- editor.putString(PREF_CERT, path);
- editor.apply();
- }
-
public void setFirstRun(boolean run) {
preferences.edit().putBoolean(PREF_FIRST_RUN, run).apply();
}