From 838471ec3a4dca2f4c652a43ea73d063559a00d1 Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 12 Aug 2015 21:07:47 -0400 Subject: initialize & getRepositoryDirectory take context arguments so that service can use them too --- .../java/com/zeapo/pwdstore/utils/PasswordRepository.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/src/main/java/com/zeapo') diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index c571e5a5..6638d4cf 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -1,6 +1,6 @@ package com.zeapo.pwdstore.utils; -import android.app.Activity; +import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.util.Log; @@ -114,9 +114,9 @@ public class PasswordRepository { repository = null; } - public static File getRepositoryDirectory(Activity callingActivity) { + public static File getRepositoryDirectory(Context context) { File dir = null; - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext()); + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); if (settings.getBoolean("git_external", false)) { String external_repo = settings.getString("git_external_repo", null); @@ -124,15 +124,15 @@ public class PasswordRepository { dir = new File(external_repo); } } else { - dir = new File(callingActivity.getFilesDir() + "/store"); + dir = new File(context.getFilesDir() + "/store"); } return dir; } - public static Repository initialize(Activity callingActivity) { - File dir = getRepositoryDirectory(callingActivity); - SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(callingActivity.getApplicationContext()); + public static Repository initialize(Context context) { + File dir = getRepositoryDirectory(context); + SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); if (dir == null) { return null; -- cgit v1.2.3