Remove default account setting
The first account in the account list is now the default account.
This commit is contained in:
parent
51e6820d92
commit
9990908640
8 changed files with 6 additions and 55 deletions
|
@ -185,27 +185,8 @@ class Preferences internal constructor(
|
|||
notifyAccountsChangeListeners()
|
||||
}
|
||||
|
||||
var defaultAccount: Account?
|
||||
get() {
|
||||
return getDefaultAccountOrNull() ?: accounts.firstOrNull()?.also { newDefaultAccount ->
|
||||
defaultAccount = newDefaultAccount
|
||||
}
|
||||
}
|
||||
set(account) {
|
||||
requireNotNull(account)
|
||||
|
||||
createStorageEditor()
|
||||
.putString("defaultAccountUuid", account.uuid)
|
||||
.commit()
|
||||
}
|
||||
|
||||
private fun getDefaultAccountOrNull(): Account? {
|
||||
return synchronized(accountLock) {
|
||||
storage.getString("defaultAccountUuid", null)?.let { defaultAccountUuid ->
|
||||
getAccount(defaultAccountUuid)
|
||||
}
|
||||
}
|
||||
}
|
||||
val defaultAccount: Account?
|
||||
get() = accounts.firstOrNull()
|
||||
|
||||
fun saveAccount(account: Account) {
|
||||
ensureAssignedAccountNumber(account)
|
||||
|
|
|
@ -266,11 +266,6 @@ public class SettingsImporter {
|
|||
|
||||
StorageEditor editor = preferences.createStorageEditor();
|
||||
|
||||
String defaultAccountUuid = storage.getString("defaultAccountUuid", null);
|
||||
if (defaultAccountUuid == null) {
|
||||
putString(editor, "defaultAccountUuid", accountUuids.get(0));
|
||||
}
|
||||
|
||||
if (!editor.commit()) {
|
||||
throw new SettingsImportExportException("Failed to set default account");
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
clientCertificateAlias);
|
||||
mAccount.setOutgoingServerSettings(transportServer);
|
||||
|
||||
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount, mMakeDefault);
|
||||
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ import com.fsck.k9.ui.base.K9Activity;
|
|||
public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
||||
|
||||
private Spinner mCheckFrequencyView;
|
||||
|
||||
private Spinner mDisplayCountView;
|
||||
|
@ -32,10 +30,9 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
|||
|
||||
private Account mAccount;
|
||||
|
||||
public static void actionOptions(Context context, Account account, boolean makeDefault) {
|
||||
public static void actionOptions(Context context, Account account) {
|
||||
Intent i = new Intent(context, AccountSetupOptions.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
|
@ -115,10 +112,6 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
|||
mAccount.setFolderPushMode(Account.FolderMode.NONE);
|
||||
|
||||
Preferences.getPreferences(getApplicationContext()).saveAccount(mAccount);
|
||||
if (mAccount.equals(Preferences.getPreferences(this).getDefaultAccount()) ||
|
||||
getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false)) {
|
||||
Preferences.getPreferences(this).setDefaultAccount(mAccount);
|
||||
}
|
||||
Core.setServicesEnabled(this);
|
||||
AccountSetupNames.actionSetNames(this, mAccount);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
OnCheckedChangeListener {
|
||||
private static final String EXTRA_ACCOUNT = "account";
|
||||
|
||||
private static final String EXTRA_MAKE_DEFAULT = "makeDefault";
|
||||
private static final String STATE_SECURITY_TYPE_POSITION = "stateSecurityTypePosition";
|
||||
private static final String STATE_AUTH_TYPE_POSITION = "authTypePosition";
|
||||
|
||||
|
@ -70,12 +69,10 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
private AuthTypeAdapter mAuthTypeAdapter;
|
||||
private Button mNextButton;
|
||||
private Account mAccount;
|
||||
private boolean mMakeDefault;
|
||||
|
||||
public static void actionOutgoingSettings(Context context, Account account, boolean makeDefault) {
|
||||
public static void actionOutgoingSettings(Context context, Account account) {
|
||||
Intent i = new Intent(context, AccountSetupOutgoing.class);
|
||||
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
|
||||
i.putExtra(EXTRA_MAKE_DEFAULT, makeDefault);
|
||||
context.startActivity(i);
|
||||
}
|
||||
|
||||
|
@ -138,7 +135,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
//FIXME: get Account object again?
|
||||
accountUuid = getIntent().getStringExtra(EXTRA_ACCOUNT);
|
||||
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
|
||||
mMakeDefault = getIntent().getBooleanExtra(EXTRA_MAKE_DEFAULT, false);
|
||||
|
||||
/*
|
||||
* If we're being reloaded we override the original account with the one
|
||||
|
@ -477,7 +473,7 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
Preferences.getPreferences(getApplicationContext()).saveAccount(mAccount);
|
||||
finish();
|
||||
} else {
|
||||
AccountSetupOptions.actionOptions(this, mAccount, mMakeDefault);
|
||||
AccountSetupOptions.actionOptions(this, mAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ class AccountSettingsDataStore(
|
|||
|
||||
override fun getBoolean(key: String, defValue: Boolean): Boolean {
|
||||
return when (key) {
|
||||
"account_default" -> account == preferences.defaultAccount
|
||||
"mark_message_as_read_on_view" -> account.isMarkMessageAsReadOnView
|
||||
"mark_message_as_read_on_delete" -> account.isMarkMessageAsReadOnDelete
|
||||
"account_sync_remote_deletetions" -> account.isSyncRemoteDeletions
|
||||
|
@ -44,12 +43,6 @@ class AccountSettingsDataStore(
|
|||
|
||||
override fun putBoolean(key: String, value: Boolean) {
|
||||
when (key) {
|
||||
"account_default" -> {
|
||||
executorService.execute {
|
||||
preferences.defaultAccount = account
|
||||
}
|
||||
return
|
||||
}
|
||||
"mark_message_as_read_on_view" -> account.isMarkMessageAsReadOnView = value
|
||||
"mark_message_as_read_on_delete" -> account.isMarkMessageAsReadOnDelete = value
|
||||
"account_sync_remote_deletetions" -> account.isSyncRemoteDeletions = value
|
||||
|
|
|
@ -504,8 +504,6 @@ Please submit bug reports, contribute new features and ask questions at
|
|||
|
||||
<string name="account_settings_push_advanced_title">Advanced</string>
|
||||
<string name="account_settings_title_fmt">Account settings</string>
|
||||
<string name="account_settings_default_label">Default account</string>
|
||||
<string name="account_settings_default_summary">Send mail from this account by default</string>
|
||||
<string name="account_settings_notify_label">New mail notifications</string>
|
||||
|
||||
<string name="account_settings_folder_notify_new_mail_mode_label">Notifications folders</string>
|
||||
|
|
|
@ -16,11 +16,6 @@
|
|||
android:key="account_description"
|
||||
android:title="@string/account_settings_description_label" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="account_default"
|
||||
android:summary="@string/account_settings_default_summary"
|
||||
android:title="@string/account_settings_default_label" />
|
||||
|
||||
<com.takisoft.preferencex.ColorPickerPreference
|
||||
android:key="chip_color"
|
||||
android:summary="@string/account_settings_color_summary"
|
||||
|
|
Loading…
Reference in a new issue