mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
44 lines
963 B
Java
44 lines
963 B
Java
package org.briarproject.android.controller;
|
|
|
|
import android.content.Context;
|
|
import android.content.SharedPreferences;
|
|
|
|
import org.briarproject.android.util.AndroidUtils;
|
|
import org.briarproject.api.db.DatabaseConfig;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
public class ConfigControllerImpl implements ConfigController {
|
|
|
|
private static final String PREF_DB_KEY = "key";
|
|
|
|
@Inject
|
|
protected SharedPreferences briarPrefs;
|
|
@Inject
|
|
protected volatile DatabaseConfig databaseConfig;
|
|
|
|
@Inject
|
|
public ConfigControllerImpl() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public String getEncryptedDatabaseKey() {
|
|
return briarPrefs.getString(PREF_DB_KEY, null);
|
|
}
|
|
|
|
@Override
|
|
public void deleteAccount(Context ctx) {
|
|
SharedPreferences.Editor editor = briarPrefs.edit();
|
|
editor.clear();
|
|
editor.apply();
|
|
AndroidUtils.deleteAppData(ctx);
|
|
}
|
|
|
|
@Override
|
|
public boolean accountExists() {
|
|
String hex = getEncryptedDatabaseKey();
|
|
return hex != null && databaseConfig.databaseExists();
|
|
}
|
|
}
|