mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Added dependency injections for FileUtils and removed redundant code
This commit is contained in:
@@ -45,7 +45,6 @@ import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
import org.briarproject.system.AndroidFileUtils;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@@ -71,12 +70,14 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class CrashReportActivity extends Activity implements OnClickListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CrashReportActivity.class.getName());
|
||||
|
||||
private final FileUtils fileUtils = new AndroidFileUtils();
|
||||
@Inject private FileUtils fileUtils;
|
||||
private final AndroidExecutor androidExecutor = new AndroidExecutorImpl();
|
||||
|
||||
private ScrollView scroll = null;
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.system.AndroidFileUtils;
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@@ -41,6 +41,7 @@ public class PasswordActivity extends BaseActivity {
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseConfig databaseConfig;
|
||||
@Inject private FileUtils fileUtils;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -72,7 +73,7 @@ public class PasswordActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void clearDbPrefs() {
|
||||
super.clearDbPrefs();
|
||||
AndroidFileUtils.deleteFileOrDir(databaseConfig.getDatabaseDirectory());
|
||||
fileUtils.deleteFileOrDir(databaseConfig.getDatabaseDirectory());
|
||||
gotoAndFinish(SetupActivity.class, RESULT_CANCELED);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.briarproject.system;
|
||||
|
||||
import org.briarproject.api.system.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidFileUtils implements FileUtils {
|
||||
|
||||
public long getTotalSpace(File f) throws IOException {
|
||||
return f.getTotalSpace();
|
||||
}
|
||||
|
||||
public long getFreeSpace(File f) throws IOException {
|
||||
return f.getUsableSpace();
|
||||
}
|
||||
|
||||
public static void deleteFileOrDir(File f) {
|
||||
if (f.isFile())
|
||||
f.delete();
|
||||
else if (f.isDirectory())
|
||||
for (File child : f.listFiles())
|
||||
deleteFileOrDir(child);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class AndroidSystemModule extends AbstractModule {
|
||||
bind(Clock.class).to(SystemClock.class);
|
||||
bind(Timer.class).to(SystemTimer.class);
|
||||
bind(SeedProvider.class).to(AndroidSeedProvider.class);
|
||||
bind(FileUtils.class).to(AndroidFileUtils.class);
|
||||
bind(FileUtils.class).to(FileUtilsImpl.class);
|
||||
bind(LocationUtils.class).to(AndroidLocationUtils.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user