mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
modifications based on Akwizgran's comments
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.briarproject.android.controller;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ConfigControllerImpl implements ConfigController {
|
||||
|
||||
private final static String PREF_DB_KEY = "key";
|
||||
|
||||
@Inject
|
||||
protected SharedPreferences briarPrefs;
|
||||
@Inject
|
||||
protected volatile DatabaseConfig databaseConfig;
|
||||
|
||||
@Inject
|
||||
public ConfigControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
public String getEncryptedDatabaseKey() {
|
||||
return briarPrefs.getString(PREF_DB_KEY, null);
|
||||
}
|
||||
|
||||
public void clearPrefs() {
|
||||
SharedPreferences.Editor editor = briarPrefs.edit();
|
||||
editor.clear();
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initialized() {
|
||||
String hex = getEncryptedDatabaseKey();
|
||||
if (hex != null && databaseConfig.databaseExists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user