Loading k9mail/src/main/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.K9.Startup" android:theme="@android:style/Theme.Material.Light.NoActionBar" android:resizeableActivity="true" android:allowBackup="false"> Loading k9mail/src/main/java/io/eelo/mail/Account.java +16 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,8 @@ public class Account implements BaseAccount, AccountConfig { TEXT, HTML, AUTO } private boolean isDeviceAccount; protected Account(Context context) { accountUuid = UUID.randomUUID().toString(); localStorageProviderId = StorageManager.getInstance(context).getDefaultProviderId(); Loading Loading @@ -323,6 +325,7 @@ public class Account implements BaseAccount, AccountConfig { isEnabled = true; markMessageAsReadOnView = true; alwaysShowCcBcc = false; isDeviceAccount = false; searchableFolders = Searchable.ALL; Loading Loading @@ -499,6 +502,8 @@ public class Account implements BaseAccount, AccountConfig { markMessageAsReadOnView = storage.getBoolean(accountUuid + ".markMessageAsReadOnView", true); alwaysShowCcBcc = storage.getBoolean(accountUuid + ".alwaysShowCcBcc", false); isDeviceAccount = storage.getBoolean(accountUuid + ".isDeviceAccount", false); cacheChips(); // Use email address as account description if necessary Loading Loading @@ -598,6 +603,7 @@ public class Account implements BaseAccount, AccountConfig { editor.remove(accountUuid + ".messageFormat"); editor.remove(accountUuid + ".messageReadReceipt"); editor.remove(accountUuid + ".notifyMailCheck"); editor.remove(accountUuid + ".isDeviceAccount"); for (NetworkType type : NetworkType.values()) { editor.remove(accountUuid + ".useCompression." + type.name()); } Loading Loading @@ -775,6 +781,8 @@ public class Account implements BaseAccount, AccountConfig { editor.putBoolean(accountUuid + ".led", notificationSetting.isLedEnabled()); editor.putInt(accountUuid + ".ledColor", notificationSetting.getLedColor()); editor.putBoolean(accountUuid + ".isDeviceAccount", isDeviceAccount); for (NetworkType type : NetworkType.values()) { Boolean useCompression = compressionMap.get(type); if (useCompression != null) { Loading Loading @@ -2023,4 +2031,12 @@ public class Account implements BaseAccount, AccountConfig { } return name; } public boolean isDeviceAccount() { return this.isDeviceAccount; } public void setDeviceAccount(boolean deviceAccount) { this.isDeviceAccount = deviceAccount; } } k9mail/src/main/java/io/eelo/mail/activity/Accounts.java +66 −11 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; import android.text.Editable; import android.text.TextWatcher; Loading Loading @@ -463,6 +464,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener //onNewIntent(intent); accountManager = AccountManager.get(this); removeOldAccountsAutomatically(accounts); accounts = Preferences.getPreferences(this).getAccounts(); if (addNewAccountsAutomatically(accounts)) { Accounts.listAccounts(this); finish(); Loading Loading @@ -544,18 +549,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener android.accounts.Account[] googleAccounts = getGoogleAccountsOnDevice(); boolean accountWasAdded = false; // Check if there are any new accounts to be added ArrayList<String> signedInEmailAddresses = new ArrayList<>(); for (int i = 0; i < accounts.size(); i++) { signedInEmailAddresses.add(accounts.get(i).getEmail()); } for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ADDRESS_KEY); boolean accountIsSignedIn = false; for (String signedInEmail : signedInEmailAddresses) { if (emailId.equals(signedInEmail)) { for (Account account : accounts) { if (emailId.equals(account.getEmail())) { accountIsSignedIn = true; break; } Loading @@ -571,8 +570,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ADDRESS_KEY); boolean accountIsSignedIn = false; for (String signedInEmail : signedInEmailAddresses) { if (emailId.equals(signedInEmail)) { for (Account account : accounts) { if (emailId.equals(account.getEmail())) { accountIsSignedIn = true; break; } Loading @@ -592,6 +591,57 @@ public class Accounts extends K9ListActivity implements OnItemClickListener } } private void removeOldAccountsAutomatically(List<Account> accounts){ try { android.accounts.Account[] eeloAccounts = getEeloAccountsOnDevice(); android.accounts.Account[] googleAccounts = getGoogleAccountsOnDevice(); for (Account account : accounts) { if (account.isDeviceAccount()) { boolean accountIsSignedInOnDevice = false; for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ADDRESS_KEY); if (account.getEmail().equals(emailId)) { accountIsSignedInOnDevice = true; break; } } for (android.accounts.Account googleAccount : googleAccounts) { String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ADDRESS_KEY); if (account.getEmail().equals(emailId)) { accountIsSignedInOnDevice = true; break; } } if (!accountIsSignedInOnDevice) { selectedContextAccount = account; Account realAccount = (Account) selectedContextAccount; try { realAccount.getLocalStore().delete(); } catch (Exception e) { // Ignore, this may lead to localStores on sd-cards that // are currently not inserted to be left } MessagingController.getInstance(getApplication()) .deleteAccount(realAccount); Preferences.getPreferences(Accounts.this) .deleteAccount(realAccount); } } } } catch (SecurityException e) { e.printStackTrace(); } } private void initializeActionBar() { actionBar.setDisplayShowCustomEnabled(true); Loading Loading @@ -1298,8 +1348,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener private void onDeleteAccount(Account account) { selectedContextAccount = account; if (account.isDeviceAccount()) { startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS)); } else { showDialog(DIALOG_REMOVE_ACCOUNT); } } private void onEditAccount(Account account) { Loading k9mail/src/main/java/io/eelo/mail/activity/setup/EeloAccountCreator.java +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class EeloAccountCreator { ":" + password + "@mail.eelo.io"); Account account = preferences.newAccount(); account.setDeviceAccount(true); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); Loading k9mail/src/main/java/io/eelo/mail/activity/setup/GoogleAccountCreator.java +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class GoogleAccountCreator { "::XOAUTH2@smtp.gmail.com"); Account account = preferences.newAccount(); account.setDeviceAccount(true); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); Loading Loading
k9mail/src/main/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.K9.Startup" android:theme="@android:style/Theme.Material.Light.NoActionBar" android:resizeableActivity="true" android:allowBackup="false"> Loading
k9mail/src/main/java/io/eelo/mail/Account.java +16 −0 Original line number Diff line number Diff line Loading @@ -277,6 +277,8 @@ public class Account implements BaseAccount, AccountConfig { TEXT, HTML, AUTO } private boolean isDeviceAccount; protected Account(Context context) { accountUuid = UUID.randomUUID().toString(); localStorageProviderId = StorageManager.getInstance(context).getDefaultProviderId(); Loading Loading @@ -323,6 +325,7 @@ public class Account implements BaseAccount, AccountConfig { isEnabled = true; markMessageAsReadOnView = true; alwaysShowCcBcc = false; isDeviceAccount = false; searchableFolders = Searchable.ALL; Loading Loading @@ -499,6 +502,8 @@ public class Account implements BaseAccount, AccountConfig { markMessageAsReadOnView = storage.getBoolean(accountUuid + ".markMessageAsReadOnView", true); alwaysShowCcBcc = storage.getBoolean(accountUuid + ".alwaysShowCcBcc", false); isDeviceAccount = storage.getBoolean(accountUuid + ".isDeviceAccount", false); cacheChips(); // Use email address as account description if necessary Loading Loading @@ -598,6 +603,7 @@ public class Account implements BaseAccount, AccountConfig { editor.remove(accountUuid + ".messageFormat"); editor.remove(accountUuid + ".messageReadReceipt"); editor.remove(accountUuid + ".notifyMailCheck"); editor.remove(accountUuid + ".isDeviceAccount"); for (NetworkType type : NetworkType.values()) { editor.remove(accountUuid + ".useCompression." + type.name()); } Loading Loading @@ -775,6 +781,8 @@ public class Account implements BaseAccount, AccountConfig { editor.putBoolean(accountUuid + ".led", notificationSetting.isLedEnabled()); editor.putInt(accountUuid + ".ledColor", notificationSetting.getLedColor()); editor.putBoolean(accountUuid + ".isDeviceAccount", isDeviceAccount); for (NetworkType type : NetworkType.values()) { Boolean useCompression = compressionMap.get(type); if (useCompression != null) { Loading Loading @@ -2023,4 +2031,12 @@ public class Account implements BaseAccount, AccountConfig { } return name; } public boolean isDeviceAccount() { return this.isDeviceAccount; } public void setDeviceAccount(boolean deviceAccount) { this.isDeviceAccount = deviceAccount; } }
k9mail/src/main/java/io/eelo/mail/activity/Accounts.java +66 −11 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.provider.Settings; import android.text.Editable; import android.text.TextWatcher; Loading Loading @@ -463,6 +464,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener //onNewIntent(intent); accountManager = AccountManager.get(this); removeOldAccountsAutomatically(accounts); accounts = Preferences.getPreferences(this).getAccounts(); if (addNewAccountsAutomatically(accounts)) { Accounts.listAccounts(this); finish(); Loading Loading @@ -544,18 +549,12 @@ public class Accounts extends K9ListActivity implements OnItemClickListener android.accounts.Account[] googleAccounts = getGoogleAccountsOnDevice(); boolean accountWasAdded = false; // Check if there are any new accounts to be added ArrayList<String> signedInEmailAddresses = new ArrayList<>(); for (int i = 0; i < accounts.size(); i++) { signedInEmailAddresses.add(accounts.get(i).getEmail()); } for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ADDRESS_KEY); boolean accountIsSignedIn = false; for (String signedInEmail : signedInEmailAddresses) { if (emailId.equals(signedInEmail)) { for (Account account : accounts) { if (emailId.equals(account.getEmail())) { accountIsSignedIn = true; break; } Loading @@ -571,8 +570,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ADDRESS_KEY); boolean accountIsSignedIn = false; for (String signedInEmail : signedInEmailAddresses) { if (emailId.equals(signedInEmail)) { for (Account account : accounts) { if (emailId.equals(account.getEmail())) { accountIsSignedIn = true; break; } Loading @@ -592,6 +591,57 @@ public class Accounts extends K9ListActivity implements OnItemClickListener } } private void removeOldAccountsAutomatically(List<Account> accounts){ try { android.accounts.Account[] eeloAccounts = getEeloAccountsOnDevice(); android.accounts.Account[] googleAccounts = getGoogleAccountsOnDevice(); for (Account account : accounts) { if (account.isDeviceAccount()) { boolean accountIsSignedInOnDevice = false; for (android.accounts.Account eeloAccount : eeloAccounts) { String emailId = accountManager.getUserData(eeloAccount, ACCOUNT_EMAIL_ADDRESS_KEY); if (account.getEmail().equals(emailId)) { accountIsSignedInOnDevice = true; break; } } for (android.accounts.Account googleAccount : googleAccounts) { String emailId = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ADDRESS_KEY); if (account.getEmail().equals(emailId)) { accountIsSignedInOnDevice = true; break; } } if (!accountIsSignedInOnDevice) { selectedContextAccount = account; Account realAccount = (Account) selectedContextAccount; try { realAccount.getLocalStore().delete(); } catch (Exception e) { // Ignore, this may lead to localStores on sd-cards that // are currently not inserted to be left } MessagingController.getInstance(getApplication()) .deleteAccount(realAccount); Preferences.getPreferences(Accounts.this) .deleteAccount(realAccount); } } } } catch (SecurityException e) { e.printStackTrace(); } } private void initializeActionBar() { actionBar.setDisplayShowCustomEnabled(true); Loading Loading @@ -1298,8 +1348,13 @@ public class Accounts extends K9ListActivity implements OnItemClickListener private void onDeleteAccount(Account account) { selectedContextAccount = account; if (account.isDeviceAccount()) { startActivity(new Intent(Settings.ACTION_SYNC_SETTINGS)); } else { showDialog(DIALOG_REMOVE_ACCOUNT); } } private void onEditAccount(Account account) { Loading
k9mail/src/main/java/io/eelo/mail/activity/setup/EeloAccountCreator.java +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class EeloAccountCreator { ":" + password + "@mail.eelo.io"); Account account = preferences.newAccount(); account.setDeviceAccount(true); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); Loading
k9mail/src/main/java/io/eelo/mail/activity/setup/GoogleAccountCreator.java +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ public class GoogleAccountCreator { "::XOAUTH2@smtp.gmail.com"); Account account = preferences.newAccount(); account.setDeviceAccount(true); account.loadConfig(accountConfig); MessagingController.getInstance(context).listFoldersSynchronous(account, true, null); Loading