mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Stop using K9.app where easily possible
This commit is contained in:
parent
328405419a
commit
e447257414
@ -265,7 +265,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
|
|
||||||
protected Account(Context context) {
|
protected Account(Context context) {
|
||||||
mUuid = UUID.randomUUID().toString();
|
mUuid = UUID.randomUUID().toString();
|
||||||
mLocalStorageProviderId = StorageManager.getInstance(K9.app).getDefaultProviderId();
|
mLocalStorageProviderId = StorageManager.getInstance(context).getDefaultProviderId();
|
||||||
mAutomaticCheckIntervalMinutes = -1;
|
mAutomaticCheckIntervalMinutes = -1;
|
||||||
mIdleRefreshMinutes = 24;
|
mIdleRefreshMinutes = 24;
|
||||||
mPushPollOnConnect = true;
|
mPushPollOnConnect = true;
|
||||||
@ -1701,7 +1701,7 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
if (localStorageProviderId == null) {
|
if (localStorageProviderId == null) {
|
||||||
return true; // defaults to internal memory
|
return true; // defaults to internal memory
|
||||||
}
|
}
|
||||||
return StorageManager.getInstance(K9.app).isReady(localStorageProviderId);
|
return StorageManager.getInstance(context).isReady(localStorageProviderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean isEnabled() {
|
public synchronized boolean isEnabled() {
|
||||||
|
@ -107,7 +107,7 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Account newAccount() {
|
public synchronized Account newAccount() {
|
||||||
newAccount = new Account(K9.app);
|
newAccount = new Account(mContext);
|
||||||
accounts.put(newAccount.getUuid(), newAccount);
|
accounts.put(newAccount.getUuid(), newAccount);
|
||||||
accountsInOrder.add(newAccount);
|
accountsInOrder.add(newAccount);
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
mLocalStorageProvider = (ListPreference) findPreference(PREFERENCE_LOCAL_STORAGE_PROVIDER);
|
mLocalStorageProvider = (ListPreference) findPreference(PREFERENCE_LOCAL_STORAGE_PROVIDER);
|
||||||
{
|
{
|
||||||
final Map<String, String> providers;
|
final Map<String, String> providers;
|
||||||
providers = StorageManager.getInstance(K9.app).getAvailableProviders();
|
providers = StorageManager.getInstance(this).getAvailableProviders();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
final String[] providerLabels = new String[providers.size()];
|
final String[] providerLabels = new String[providers.size()];
|
||||||
final String[] providerIds = new String[providers.size()];
|
final String[] providerIds = new String[providers.size()];
|
||||||
|
@ -365,7 +365,7 @@ public class MessagingController implements Runnable {
|
|||||||
|
|
||||||
|
|
||||||
private MessagingController(Context context) {
|
private MessagingController(Context context) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context;
|
||||||
mThread = new Thread(this);
|
mThread = new Thread(this);
|
||||||
mThread.setName("MessagingController");
|
mThread.setName("MessagingController");
|
||||||
mThread.start();
|
mThread.start();
|
||||||
@ -376,7 +376,7 @@ public class MessagingController implements Runnable {
|
|||||||
|
|
||||||
public synchronized static MessagingController getInstance(Context context) {
|
public synchronized static MessagingController getInstance(Context context) {
|
||||||
if (inst == null) {
|
if (inst == null) {
|
||||||
inst = new MessagingController(context);
|
inst = new MessagingController(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
* @throws UnavailableStorageException
|
* @throws UnavailableStorageException
|
||||||
* if not {@link StorageProvider#isReady(Context)}
|
* if not {@link StorageProvider#isReady(Context)}
|
||||||
*/
|
*/
|
||||||
public static LocalStore getInstance(Account account, Application application)
|
public static LocalStore getInstance(Account account, Context context)
|
||||||
throws MessagingException {
|
throws MessagingException {
|
||||||
|
|
||||||
String accountUuid = account.getUuid();
|
String accountUuid = account.getUuid();
|
||||||
@ -196,7 +196,7 @@ public class LocalStore extends Store implements Serializable {
|
|||||||
if (store == null) {
|
if (store == null) {
|
||||||
// Creating a LocalStore instance will create or upgrade the database if
|
// Creating a LocalStore instance will create or upgrade the database if
|
||||||
// necessary. This could take some time.
|
// necessary. This could take some time.
|
||||||
store = new LocalStore(account, application);
|
store = new LocalStore(account, context);
|
||||||
|
|
||||||
sLocalStores.put(accountUuid, store);
|
sLocalStores.put(accountUuid, store);
|
||||||
}
|
}
|
||||||
|
@ -496,7 +496,7 @@ public class StorageManager {
|
|||||||
|
|
||||||
public static synchronized StorageManager getInstance(final Context context) {
|
public static synchronized StorageManager getInstance(final Context context) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new StorageManager(context);
|
instance = new StorageManager(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@ -661,7 +661,7 @@ public class StorageManager {
|
|||||||
sync.unmounting = false;
|
sync.unmounting = false;
|
||||||
sync.writeLock.unlock();
|
sync.writeLock.unlock();
|
||||||
|
|
||||||
K9.setServicesEnabled(K9.app);
|
K9.setServicesEnabled(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -687,7 +687,7 @@ public class StorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX we should reset mail service ONLY if there are accounts using the storage (this is not done in a regular listener because it has to be invoked afterward)
|
// XXX we should reset mail service ONLY if there are accounts using the storage (this is not done in a regular listener because it has to be invoked afterward)
|
||||||
K9.setServicesEnabled(K9.app);
|
K9.setServicesEnabled(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -304,7 +304,7 @@ class StoreSchemaDefinition implements LockableDatabase.SchemaDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if old (pre v3.800) localized outbox folder exists
|
// Check if old (pre v3.800) localized outbox folder exists
|
||||||
String localizedOutbox = K9.app.getString(R.string.special_mailbox_name_outbox);
|
String localizedOutbox = localStore.context.getString(R.string.special_mailbox_name_outbox);
|
||||||
LocalFolder obsoleteOutbox = new LocalFolder(this.localStore, localizedOutbox);
|
LocalFolder obsoleteOutbox = new LocalFolder(this.localStore, localizedOutbox);
|
||||||
if (obsoleteOutbox.exists()) {
|
if (obsoleteOutbox.exists()) {
|
||||||
// Get all messages from the localized outbox ...
|
// Get all messages from the localized outbox ...
|
||||||
|
@ -215,7 +215,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
final AttachmentInfo attachmentInfo;
|
final AttachmentInfo attachmentInfo;
|
||||||
try {
|
try {
|
||||||
final Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
final Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
||||||
attachmentInfo = LocalStore.getInstance(account, K9.app).getAttachmentInfo(id);
|
attachmentInfo = LocalStore.getInstance(account, getContext()).getAttachmentInfo(id);
|
||||||
} catch (MessagingException e) {
|
} catch (MessagingException e) {
|
||||||
Log.e(K9.LOG_TAG, "Unable to retrieve attachment info from local store for ID: " + id, e);
|
Log.e(K9.LOG_TAG, "Unable to retrieve attachment info from local store for ID: " + id, e);
|
||||||
return null;
|
return null;
|
||||||
@ -269,7 +269,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
final Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
final Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final LocalStore localStore = LocalStore.getInstance(account, K9.app);
|
final LocalStore localStore = LocalStore.getInstance(account, getContext());
|
||||||
|
|
||||||
AttachmentInfo attachmentInfo = localStore.getAttachmentInfo(id);
|
AttachmentInfo attachmentInfo = localStore.getAttachmentInfo(id);
|
||||||
if (FORMAT_VIEW.equals(format) && mimeType != null) {
|
if (FORMAT_VIEW.equals(format) && mimeType != null) {
|
||||||
@ -289,7 +289,7 @@ public class AttachmentProvider extends ContentProvider {
|
|||||||
private File getFile(String dbName, String id) throws FileNotFoundException {
|
private File getFile(String dbName, String id) throws FileNotFoundException {
|
||||||
Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
Account account = Preferences.getPreferences(getContext()).getAccount(dbName);
|
||||||
|
|
||||||
File attachmentsDir = StorageManager.getInstance(K9.app).getAttachmentDirectory(dbName,
|
File attachmentsDir = StorageManager.getInstance(getContext()).getAttachmentDirectory(dbName,
|
||||||
account.getLocalStorageProviderId());
|
account.getLocalStorageProviderId());
|
||||||
|
|
||||||
File file = new File(attachmentsDir, id);
|
File file = new File(attachmentsDir, id);
|
||||||
|
@ -303,7 +303,7 @@ public class MessageProvider extends ContentProvider {
|
|||||||
|
|
||||||
// new code for integrated inbox, only execute this once as it will be processed afterwards via the listener
|
// new code for integrated inbox, only execute this once as it will be processed afterwards via the listener
|
||||||
final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
|
final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
|
||||||
final MessagingController msgController = MessagingController.getInstance(K9.app);
|
final MessagingController msgController = MessagingController.getInstance(getContext());
|
||||||
|
|
||||||
msgController.searchLocalMessages(integratedInboxAccount.getRelatedSearch(),
|
msgController.searchLocalMessages(integratedInboxAccount.getRelatedSearch(),
|
||||||
new MesssageInfoHolderRetrieverListener(queue));
|
new MesssageInfoHolderRetrieverListener(queue));
|
||||||
@ -1041,7 +1041,7 @@ public class MessageProvider extends ContentProvider {
|
|||||||
// get localstore parameter
|
// get localstore parameter
|
||||||
LocalMessage msg = null;
|
LocalMessage msg = null;
|
||||||
try {
|
try {
|
||||||
LocalFolder lf = LocalStore.getInstance(myAccount, K9.app).getFolder(folderName);
|
LocalFolder lf = LocalStore.getInstance(myAccount, getContext()).getFolder(folderName);
|
||||||
int msgCount = lf.getMessageCount();
|
int msgCount = lf.getMessageCount();
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
Log.d(K9.LOG_TAG, "folder msg count = " + msgCount);
|
Log.d(K9.LOG_TAG, "folder msg count = " + msgCount);
|
||||||
@ -1053,7 +1053,7 @@ public class MessageProvider extends ContentProvider {
|
|||||||
|
|
||||||
// launch command to delete the message
|
// launch command to delete the message
|
||||||
if ((myAccount != null) && (msg != null)) {
|
if ((myAccount != null) && (msg != null)) {
|
||||||
MessagingController controller = MessagingController.getInstance(K9.app);
|
MessagingController controller = MessagingController.getInstance(getContext());
|
||||||
controller.deleteMessages(Collections.singletonList(msg), null);
|
controller.deleteMessages(Collections.singletonList(msg), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
|
|||||||
|
|
||||||
if (searchAccount != null) {
|
if (searchAccount != null) {
|
||||||
account = searchAccount;
|
account = searchAccount;
|
||||||
MessagingController controller = MessagingController.getInstance(K9.app);
|
MessagingController controller = MessagingController.getInstance(context);
|
||||||
stats = controller.getSearchAccountStatsSynchronous(searchAccount, null);
|
stats = controller.getSearchAccountStatsSynchronous(searchAccount, null);
|
||||||
clickIntent = MessageList.intentDisplaySearch(context,
|
clickIntent = MessageList.intentDisplaySearch(context,
|
||||||
searchAccount.getRelatedSearch(), false, true, true);
|
searchAccount.getRelatedSearch(), false, true, true);
|
||||||
|
@ -35,9 +35,9 @@ public class StorageGoneReceiver extends BroadcastReceiver {
|
|||||||
final String path = uri.getPath();
|
final String path = uri.getPath();
|
||||||
|
|
||||||
if (Intent.ACTION_MEDIA_EJECT.equals(action)) {
|
if (Intent.ACTION_MEDIA_EJECT.equals(action)) {
|
||||||
StorageManager.getInstance(K9.app).onBeforeUnmount(path);
|
StorageManager.getInstance(context).onBeforeUnmount(path);
|
||||||
} else if (Intent.ACTION_MEDIA_UNMOUNTED.equals(action)) {
|
} else if (Intent.ACTION_MEDIA_UNMOUNTED.equals(action)) {
|
||||||
StorageManager.getInstance(K9.app).onAfterUnmount(path);
|
StorageManager.getInstance(context).onAfterUnmount(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class StorageReceiver extends BroadcastReceiver {
|
|||||||
final String path = uri.getPath();
|
final String path = uri.getPath();
|
||||||
|
|
||||||
if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) {
|
if (Intent.ACTION_MEDIA_MOUNTED.equals(action)) {
|
||||||
StorageManager.getInstance(K9.app).onMount(path,
|
StorageManager.getInstance(context).onMount(path,
|
||||||
intent.getBooleanExtra("read-only", true));
|
intent.getBooleanExtra("read-only", true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user