Commit be204938 authored by Grigory Fedorov's avatar Grigory Fedorov

Account color list option added to account preferences.

parent 4dfd2422
......@@ -14,12 +14,6 @@
*/
package com.xabber.android.data.account;
import java.security.KeyPair;
import java.util.Date;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.connection.ConnectionItem;
......@@ -29,6 +23,12 @@ import com.xabber.android.data.connection.ProxyType;
import com.xabber.android.data.connection.TLSMode;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import java.security.KeyPair;
import java.util.Date;
/**
* Represent account settings and status.
*
......@@ -51,7 +51,7 @@ public class AccountItem extends ConnectionItem {
*/
private final String account;
private final int colorIndex;
private int colorIndex;
/**
* Whether account is enabled.
......@@ -436,4 +436,7 @@ public class AccountItem extends ConnectionItem {
return Math.min(128, Math.max(-128, priority));
}
public void setColorIndex(int colorIndex) {
this.colorIndex = colorIndex;
}
}
......@@ -489,13 +489,18 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
String userName, boolean storePassword, String password, String resource,
int priority, boolean enabled, boolean saslEnabled, TLSMode tlsMode,
boolean compression, ProxyType proxyType, String proxyHost, int proxyPort,
String proxyUser, String proxyPassword, boolean syncable, ArchiveMode archiveMode) {
String proxyUser, String proxyPassword, boolean syncable,
ArchiveMode archiveMode, int colorIndex) {
AccountItem result;
AccountItem accountItem = getAccount(account);
if (accountItem.getConnectionSettings().getServerName().equals(serverName)
&& accountItem.getConnectionSettings().getUserName().equals(userName)
&& accountItem.getConnectionSettings().getResource().equals(resource)) {
result = accountItem;
result.setColorIndex(colorIndex);
boolean reconnect = false;
if (accountItem.getConnectionSettings().isCustom() != custom
|| !accountItem.getConnectionSettings().getHost().equals(host)
......@@ -558,7 +563,6 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
}
requestToWriteAccount(result);
} else {
int colorIndex = accountItem.getColorIndex();
StatusMode statusMode = accountItem.getRawStatusMode();
String statusText = accountItem.getStatusText();
AccountProtocol protocol = accountItem.getConnectionSettings().getProtocol();
......@@ -609,7 +613,9 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
connectionSettings.getProxyUser(),
connectionSettings.getProxyPassword(),
syncable,
accountItem.getArchiveMode());
accountItem.getArchiveMode(),
accountItem.getColorIndex()
);
}
public void setPassword(String account, boolean storePassword, String password) {
......@@ -636,7 +642,8 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
connectionSettings.getProxyUser(),
connectionSettings.getProxyPassword(),
accountItem.isSyncable(),
accountItem.getArchiveMode()
accountItem.getArchiveMode(),
accountItem.getColorIndex()
);
}
......@@ -664,7 +671,8 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
connectionSettings.getProxyUser(),
connectionSettings.getProxyPassword(),
accountItem.isSyncable(),
archiveMode
archiveMode,
accountItem.getColorIndex()
);
}
......
......@@ -124,6 +124,7 @@ public class AccountEditorFragment extends BaseSettingsFragment
putValue(source, R.string.account_store_password_key, accountItem.isStorePassword());
putValue(source, R.string.account_syncable_key, accountItem.isSyncable());
putValue(source, R.string.account_archive_mode_key, accountItem.getArchiveMode().ordinal());
putValue(source, R.string.account_color_key, accountItem.getColorIndex());
com.xabber.android.data.connection.ConnectionSettings connectionSettings = accountItem.getConnectionSettings();
putValue(source, R.string.account_custom_key, connectionSettings.isCustom());
......@@ -182,7 +183,9 @@ public class AccountEditorFragment extends BaseSettingsFragment
getString(result, R.string.account_proxy_user_key),
getString(result, R.string.account_proxy_password_key),
getBoolean(result, R.string.account_syncable_key),
ArchiveMode.values()[getInt(result, R.string.account_archive_mode_key)]);
ArchiveMode.values()[getInt(result, R.string.account_archive_mode_key)],
getInt(result, R.string.account_color_key)
);
return true;
}
......
......@@ -162,4 +162,10 @@
<string name="orbot_required_message">Для использования TOR необходимо установить приложение Orbot и активировать в нём передачу данных. Вы хотите установить его из Google Play?</string>
<string name="orbot_required_title">Установить Orbot?</string>
<string name="ACCOUNT_REGISTER_FAILED">Не удалось зарегистрировать аккаунт на сервере.</string>
<string name="account_color_name_green">Зеленый</string>
<string name="account_color_name_orange">Оранжевый</string>
<string name="account_color_name_red">Красный</string>
<string name="account_color_name_blue">Синий</string>
<string name="account_color">Цвет учётной записи</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_02.png -->
<string name="account_compression">Use compression</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/account_editor_01.png -->
......@@ -162,4 +162,10 @@
<string name="orbot_required_message">In order to process using TOR you must have Orbot installed and activated to proxy traffic through it. Would you like to install it from Google Play?</string>
<string name="orbot_required_title">Install Orbot?</string>
<string name="ACCOUNT_REGISTER_FAILED">Failed to register account on the server.</string>
<string name="account_color_name_green">Green</string>
<string name="account_color_name_orange">Orange</string>
<string name="account_color_name_red">Red</string>
<string name="account_color_name_blue">Blue</string>
<string name="account_color">Account color</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="account_color_names">
<item>@string/account_color_name_green</item>
<item>@string/account_color_name_orange</item>
<item>@string/account_color_name_red</item>
<item>@string/account_color_name_blue</item>
</array>
<array name="account_action_bar">
<item>@color/teal_500</item>
<item>@color/deep_orange_500</item>
......
......@@ -397,6 +397,7 @@
<string name="account_proxy_password_key">account_proxy_password</string>
<string name="account_custom_key">account_custom</string>
<string name="account_archive_mode_key">account_archive_mode</string>
<string name="account_color_key">account_color_key</string>
<string-array name="account_tls_entries">
<item>@string/account_tls_enable</item>
......
......@@ -19,6 +19,12 @@
android:summary="@string/account_enabled_summary"
android:key="@string/account_enabled_key"
/>
<ListPreference
android:title="@string/account_color"
android:key="@string/account_color_key"
android:entries="@array/account_color_names"
android:entryValues="@array/account_color_names"
/>
<CheckBoxPreference
android:title="@string/account_syncable"
android:summary="@string/account_syncable_summary"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment