use of com.fsck.k9.K9 in project k-9 by k9mail.
the class Accounts method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!K9.isHideSpecialAccounts()) {
createSpecialAccounts();
}
List<Account> accounts = Preferences.getPreferences(this).getAccounts();
Intent intent = getIntent();
// see if we should show the welcome message
if (ACTION_IMPORT_SETTINGS.equals(intent.getAction())) {
onImport();
} else if (accounts.size() < 1) {
WelcomeMessage.showWelcomeMessage(this);
finish();
return;
}
if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
finish();
return;
}
boolean startup = intent.getBooleanExtra(EXTRA_STARTUP, true);
if (startup && K9.startIntegratedInbox() && !K9.isHideSpecialAccounts()) {
onOpenAccount(mUnifiedInboxAccount);
finish();
return;
} else if (startup && accounts.size() == 1 && onOpenAccount(accounts.get(0))) {
finish();
return;
}
requestWindowFeature(Window.FEATURE_PROGRESS);
mActionBar = getActionBar();
initializeActionBar();
setContentView(R.layout.accounts);
ListView listView = getListView();
listView.setOnItemClickListener(this);
listView.setItemsCanFocus(false);
listView.setScrollingCacheEnabled(false);
registerForContextMenu(listView);
if (icicle != null && icicle.containsKey(SELECTED_CONTEXT_ACCOUNT)) {
String accountUuid = icicle.getString("selectedContextAccount");
mSelectedContextAccount = Preferences.getPreferences(this).getAccount(accountUuid);
}
restoreAccountStats(icicle);
mHandler.setViewTitle();
// Handle activity restarts because of a configuration change (e.g. rotating the screen)
mNonConfigurationInstance = (NonConfigurationInstance) getLastNonConfigurationInstance();
if (mNonConfigurationInstance != null) {
mNonConfigurationInstance.restore(this);
}
ChangeLog cl = new ChangeLog(this);
if (cl.isFirstRun()) {
cl.getLogDialog().show();
}
}
use of com.fsck.k9.K9 in project k-9 by k9mail.
the class MessageProviderTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
mMockResolver = getMockContentResolver();
mContext = K9.app;
Preferences preferences = Preferences.getPreferences(getMockContext());
List<Account> accountList = preferences.getAccounts();
for (Account account : accountList) {
preferences.deleteAccount(account);
}
}
use of com.fsck.k9.K9 in project k-9 by k9mail.
the class MessageList method onToggleTheme.
private void onToggleTheme() {
if (K9.getK9MessageViewTheme() == K9.Theme.DARK) {
K9.setK9MessageViewThemeSetting(K9.Theme.LIGHT);
} else {
K9.setK9MessageViewThemeSetting(K9.Theme.DARK);
}
new Thread(new Runnable() {
@Override
public void run() {
Context appContext = getApplicationContext();
Preferences prefs = Preferences.getPreferences(appContext);
StorageEditor editor = prefs.getStorage().edit();
K9.save(editor);
editor.commit();
}
}).start();
recreate();
}
use of com.fsck.k9.K9 in project k-9 by k9mail.
the class MessageProvider method delete.
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
if (K9.app == null) {
return 0;
}
Timber.v("MessageProvider/delete: %s", uri);
// Note: can only delete a message
List<String> segments = uri.getPathSegments();
int accountId = Integer.parseInt(segments.get(1));
String folderName = segments.get(2);
String msgUid = segments.get(3);
// get account
Account myAccount = null;
for (Account account : Preferences.getPreferences(getContext()).getAccounts()) {
if (account.getAccountNumber() == accountId) {
myAccount = account;
if (!account.isAvailable(getContext())) {
Timber.w("not deleting messages because account is unavailable at the moment");
return 0;
}
}
}
if (myAccount == null) {
Timber.e("Could not find account with id %d", accountId);
}
if (myAccount != null) {
MessageReference messageReference = new MessageReference(myAccount.getUuid(), folderName, msgUid, null);
MessagingController controller = MessagingController.getInstance(getContext());
controller.deleteMessage(messageReference, null);
}
// FIXME return the actual number of deleted messages
return 0;
}
use of com.fsck.k9.K9 in project k-9 by k9mail.
the class CoreService method addWakeLock.
/**
* Adds a new wake lock to the specified intent.
*
* <p>
* This will add the wake lock to the central wake lock registry managed by this class.
* </p>
*
* @param context
* A {@link Context} instance. Never {@code null}.
* @param intent
* The {@link Intent} to add the wake lock registry ID as extra to. Never {@code null}.
*/
protected static void addWakeLock(Context context, Intent intent) {
TracingWakeLock wakeLock = acquireWakeLock(context, "CoreService addWakeLock", K9.MAIL_SERVICE_WAKE_LOCK_TIMEOUT);
Integer tmpWakeLockId = registerWakeLock(wakeLock);
intent.putExtra(WAKE_LOCK_ID, tmpWakeLockId);
}
Aggregations