mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-04 00:05:08 +00:00
initialize & getRepositoryDirectory take context arguments so that service can use them too
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
package com.zeapo.pwdstore.utils;
|
package com.zeapo.pwdstore.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -114,9 +114,9 @@ public class PasswordRepository {
|
|||||||
repository = null;
|
repository = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getRepositoryDirectory(Activity callingActivity) {
|
public static File getRepositoryDirectory(Context context) {
|
||||||
File dir = null;
|
File dir = null;
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||||
|
|
||||||
if (settings.getBoolean("git_external", false)) {
|
if (settings.getBoolean("git_external", false)) {
|
||||||
String external_repo = settings.getString("git_external_repo", null);
|
String external_repo = settings.getString("git_external_repo", null);
|
||||||
@@ -124,15 +124,15 @@ public class PasswordRepository {
|
|||||||
dir = new File(external_repo);
|
dir = new File(external_repo);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir = new File(callingActivity.getFilesDir() + "/store");
|
dir = new File(context.getFilesDir() + "/store");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Repository initialize(Activity callingActivity) {
|
public static Repository initialize(Context context) {
|
||||||
File dir = getRepositoryDirectory(callingActivity);
|
File dir = getRepositoryDirectory(context);
|
||||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext());
|
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||||
|
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user