Commit 21294b02 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'release/1.0.9'

parents 74bb67fa e9870e69
...@@ -7,8 +7,8 @@ android { ...@@ -7,8 +7,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 22 targetSdkVersion 22
versionCode 180 versionCode 181
versionName '1.0.8' versionName '1.0.9'
} }
compileOptions { compileOptions {
......
...@@ -14,12 +14,6 @@ ...@@ -14,12 +14,6 @@
*/ */
package com.xabber.android.data; package com.xabber.android.data;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import android.database.DatabaseUtils; import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
...@@ -27,6 +21,12 @@ import android.database.sqlite.SQLiteOpenHelper; ...@@ -27,6 +21,12 @@ import android.database.sqlite.SQLiteOpenHelper;
import com.xabber.android.data.entity.AbstractAccountTable; import com.xabber.android.data.entity.AbstractAccountTable;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
/** /**
* Helps to open, create, and upgrade the database file. * Helps to open, create, and upgrade the database file.
* <p/> * <p/>
...@@ -38,13 +38,10 @@ public class DatabaseManager extends SQLiteOpenHelper implements ...@@ -38,13 +38,10 @@ public class DatabaseManager extends SQLiteOpenHelper implements
OnLoadListener, OnClearListener { OnLoadListener, OnClearListener {
private static final String DATABASE_NAME = "xabber.db"; private static final String DATABASE_NAME = "xabber.db";
private static final int DATABASE_VERSION = 66; private static final int DATABASE_VERSION = 67;
private static final SQLiteException DOWNGRAD_EXCEPTION = new SQLiteException( private static final SQLiteException DOWNGRAD_EXCEPTION = new SQLiteException(
"Database file was deleted"); "Database file was deleted");
private final ArrayList<DatabaseTable> registeredTables;
private final static DatabaseManager instance; private final static DatabaseManager instance;
static { static {
...@@ -52,15 +49,94 @@ public class DatabaseManager extends SQLiteOpenHelper implements ...@@ -52,15 +49,94 @@ public class DatabaseManager extends SQLiteOpenHelper implements
Application.getInstance().addManager(instance); Application.getInstance().addManager(instance);
} }
public static DatabaseManager getInstance() { private final ArrayList<DatabaseTable> registeredTables;
return instance;
}
private DatabaseManager() { private DatabaseManager() {
super(Application.getInstance(), DATABASE_NAME, null, DATABASE_VERSION); super(Application.getInstance(), DATABASE_NAME, null, DATABASE_VERSION);
registeredTables = new ArrayList<DatabaseTable>(); registeredTables = new ArrayList<DatabaseTable>();
} }
public static DatabaseManager getInstance() {
return instance;
}
/**
* Builds IN statement for specified collection of values.
*
* @param <T>
* @param column
* @param values
* @return "column IN (value1, ... valueN)" or
* "(column IS NULL AND column IS NOT NULL)" if ids is empty.
*/
public static <T> String in(String column, Collection<T> values) {
if (values.isEmpty())
return new StringBuilder("(").append(column)
.append(" IS NULL AND ").append(column)
.append(" IS NOT NULL)").toString();
StringBuilder builder = new StringBuilder(column);
builder.append(" IN (");
Iterator<T> iterator = values.iterator();
while (iterator.hasNext()) {
T value = iterator.next();
if (value instanceof String)
builder.append(DatabaseUtils.sqlEscapeString((String) value));
else
builder.append(value.toString());
if (iterator.hasNext())
builder.append(",");
}
builder.append(")");
return builder.toString();
}
public static void execSQL(SQLiteDatabase db, String sql) {
LogManager.iString(DatabaseManager.class.getName(), sql);
db.execSQL(sql);
}
public static void dropTable(SQLiteDatabase db, String table) {
execSQL(db, "DROP TABLE IF EXISTS " + table + ";");
}
public static void renameTable(SQLiteDatabase db, String table,
String newTable) {
execSQL(db, "ALTER TABLE " + table + " RENAME TO " + newTable + ";");
}
public static String commaSeparatedFromCollection(Collection<String> strings) {
StringBuilder builder = new StringBuilder();
for (String value : strings) {
if (builder.length() > 0)
builder.append(",");
builder.append(value.replace("\\", "\\\\").replace(",", "\\,"));
}
return builder.toString();
}
public static Collection<String> collectionFromCommaSeparated(String value) {
Collection<String> collection = new ArrayList<String>();
boolean escape = false;
StringBuilder builder = new StringBuilder();
for (int index = 0; index < value.length(); index++) {
char chr = value.charAt(index);
if (!escape) {
if (chr == '\\') {
escape = true;
continue;
} else if (chr == ',') {
collection.add(builder.toString());
builder = new StringBuilder();
continue;
}
}
escape = false;
builder.append(chr);
}
collection.add(builder.toString());
return Collections.unmodifiableCollection(collection);
}
/** /**
* Register new table. * Register new table.
* *
...@@ -146,81 +222,4 @@ public class DatabaseManager extends SQLiteOpenHelper implements ...@@ -146,81 +222,4 @@ public class DatabaseManager extends SQLiteOpenHelper implements
((AbstractAccountTable) table).removeAccount(account); ((AbstractAccountTable) table).removeAccount(account);
} }
/**
* Builds IN statement for specified collection of values.
*
* @param <T>
* @param column
* @param values
* @return "column IN (value1, ... valueN)" or
* "(column IS NULL AND column IS NOT NULL)" if ids is empty.
*/
public static <T> String in(String column, Collection<T> values) {
if (values.isEmpty())
return new StringBuilder("(").append(column)
.append(" IS NULL AND ").append(column)
.append(" IS NOT NULL)").toString();
StringBuilder builder = new StringBuilder(column);
builder.append(" IN (");
Iterator<T> iterator = values.iterator();
while (iterator.hasNext()) {
T value = iterator.next();
if (value instanceof String)
builder.append(DatabaseUtils.sqlEscapeString((String) value));
else
builder.append(value.toString());
if (iterator.hasNext())
builder.append(",");
}
builder.append(")");
return builder.toString();
}
public static void execSQL(SQLiteDatabase db, String sql) {
LogManager.iString(DatabaseManager.class.getName(), sql);
db.execSQL(sql);
}
public static void dropTable(SQLiteDatabase db, String table) {
execSQL(db, "DROP TABLE IF EXISTS " + table + ";");
}
public static void renameTable(SQLiteDatabase db, String table,
String newTable) {
execSQL(db, "ALTER TABLE " + table + " RENAME TO " + newTable + ";");
}
public static String commaSeparatedFromCollection(Collection<String> strings) {
StringBuilder builder = new StringBuilder();
for (String value : strings) {
if (builder.length() > 0)
builder.append(",");
builder.append(value.replace("\\", "\\\\").replace(",", "\\,"));
}
return builder.toString();
}
public static Collection<String> collectionFromCommaSeparated(String value) {
Collection<String> collection = new ArrayList<String>();
boolean escape = false;
StringBuilder builder = new StringBuilder();
for (int index = 0; index < value.length(); index++) {
char chr = value.charAt(index);
if (!escape) {
if (chr == '\\') {
escape = true;
continue;
} else if (chr == ',') {
collection.add(builder.toString());
builder = new StringBuilder();
continue;
}
}
escape = false;
builder.append(chr);
}
collection.add(builder.toString());
return Collections.unmodifiableCollection(collection);
}
} }
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
*/ */
package com.xabber.android.data.message.chat; package com.xabber.android.data.message.chat;
import java.util.HashSet;
import java.util.Set;
import android.database.Cursor; import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
...@@ -28,6 +25,9 @@ import com.xabber.android.data.account.OnAccountRemovedListener; ...@@ -28,6 +25,9 @@ import com.xabber.android.data.account.OnAccountRemovedListener;
import com.xabber.android.data.entity.BaseEntity; import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.entity.NestedMap; import com.xabber.android.data.entity.NestedMap;
import java.util.HashSet;
import java.util.Set;
/** /**
* Manage chat specific options. * Manage chat specific options.
* *
...@@ -39,63 +39,57 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener { ...@@ -39,63 +39,57 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
.parse("com.xabber.android.data.message.ChatManager.EMPTY_SOUND"); .parse("com.xabber.android.data.message.ChatManager.EMPTY_SOUND");
private static final Object PRIVATE_CHAT = new Object(); private static final Object PRIVATE_CHAT = new Object();
private final static ChatManager instance;
static {
instance = new ChatManager();
Application.getInstance().addManager(instance);
}
/** /**
* Stored input for user in account. * Stored input for user in account.
*/ */
private final NestedMap<ChatInput> chatInputs; private final NestedMap<ChatInput> chatInputs;
/** /**
* List of chats whose messages mustn't be saved for user in account. * List of chats whose messages mustn't be saved for user in account.
*/ */
private final NestedMap<Object> privateChats; private final NestedMap<Object> privateChats;
/** /**
* Whether notification in visible chat should be used for user in account. * Whether notification in visible chat should be used for user in account.
*/ */
private final NestedMap<Boolean> notifyVisible; private final NestedMap<Boolean> notifyVisible;
/** /**
* Whether text of incoming message should be shown in notification bar for * Whether text of incoming message should be shown in notification bar for
* user in account. * user in account.
*/ */
private final NestedMap<Boolean> showText; private final NestedMap<ShowMessageTextInNotification> showText;
/** /**
* Whether vibro notification should be used for user in account. * Whether vibro notification should be used for user in account.
*/ */
private final NestedMap<Boolean> makeVibro; private final NestedMap<Boolean> makeVibro;
/** /**
* Sound, associated with chat for user in account. * Sound, associated with chat for user in account.
*/ */
private final NestedMap<Uri> sounds; private final NestedMap<Uri> sounds;
private final static ChatManager instance;
static {
instance = new ChatManager();
Application.getInstance().addManager(instance);
}
public static ChatManager getInstance() {
return instance;
}
private ChatManager() { private ChatManager() {
chatInputs = new NestedMap<ChatInput>(); chatInputs = new NestedMap<ChatInput>();
privateChats = new NestedMap<Object>(); privateChats = new NestedMap<Object>();
sounds = new NestedMap<Uri>(); sounds = new NestedMap<Uri>();
showText = new NestedMap<Boolean>(); showText = new NestedMap<>();
makeVibro = new NestedMap<Boolean>(); makeVibro = new NestedMap<Boolean>();
notifyVisible = new NestedMap<Boolean>(); notifyVisible = new NestedMap<Boolean>();
} }
public static ChatManager getInstance() {
return instance;
}
@Override @Override
public void onLoad() { public void onLoad() {
final Set<BaseEntity> privateChats = new HashSet<BaseEntity>(); final Set<BaseEntity> privateChats = new HashSet<BaseEntity>();
final NestedMap<Boolean> notifyVisible = new NestedMap<Boolean>(); final NestedMap<Boolean> notifyVisible = new NestedMap<Boolean>();
final NestedMap<Boolean> showText = new NestedMap<Boolean>(); final NestedMap<ShowMessageTextInNotification> showText = new NestedMap<>();
final NestedMap<Boolean> makeVibro = new NestedMap<Boolean>(); final NestedMap<Boolean> makeVibro = new NestedMap<Boolean>();
final NestedMap<Uri> sounds = new NestedMap<Uri>(); final NestedMap<Uri> sounds = new NestedMap<Uri>();
Cursor cursor; Cursor cursor;
...@@ -174,7 +168,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener { ...@@ -174,7 +168,7 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
} }
private void onLoaded(Set<BaseEntity> privateChats, private void onLoaded(Set<BaseEntity> privateChats,
NestedMap<Boolean> notifyVisible, NestedMap<Boolean> showText, NestedMap<Boolean> notifyVisible, NestedMap<ShowMessageTextInNotification> showText,
NestedMap<Boolean> vibro, NestedMap<Uri> sounds) { NestedMap<Boolean> vibro, NestedMap<Uri> sounds) {
for (BaseEntity baseEntity : privateChats) for (BaseEntity baseEntity : privateChats)
this.privateChats.put(baseEntity.getAccount(), this.privateChats.put(baseEntity.getAccount(),
...@@ -316,14 +310,27 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener { ...@@ -316,14 +310,27 @@ public class ChatManager implements OnLoadListener, OnAccountRemovedListener {
* Common value if there is no user specific value. * Common value if there is no user specific value.
*/ */
public boolean isShowText(String account, String user) { public boolean isShowText(String account, String user) {
Boolean value = showText.get(account, user); switch (getShowText(account, user)) {
if (value == null) case show:
return SettingsManager.eventsShowText(); return true;
return value; case hide:
return false;
case default_settings:
default:
return SettingsManager.eventsShowText();
}
}
public ShowMessageTextInNotification getShowText(String account, String user) {
ShowMessageTextInNotification showMessageTextInNotification = showText.get(account, user);
if (showMessageTextInNotification == null) {
return ShowMessageTextInNotification.default_settings;
} else {
return showMessageTextInNotification;
}
} }
public void setShowText(final String account, final String user, public void setShowText(final String account, final String user, final ShowMessageTextInNotification value) {
final boolean value) {
showText.put(account, user, value); showText.put(account, user, value);
Application.getInstance().runInBackground(new Runnable() { Application.getInstance().runInBackground(new Runnable() {
@Override @Override
......
package com.xabber.android.data.message.chat;
public enum ShowMessageTextInNotification {
/**
* Show message text in notifications according to global settings.
*/
default_settings,
/**
* Always show message text in notifications.
*/
show,
/**
* Never show message text in notifications.
*/
hide;
public static ShowMessageTextInNotification fromInteger(int x) {
switch (x) {
case 0:
return default_settings;
case 1:
return show;
case 2:
return hide;
default:
return default_settings;
}
}
}
...@@ -19,13 +19,14 @@ import android.database.sqlite.SQLiteDatabase; ...@@ -19,13 +19,14 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement; import android.database.sqlite.SQLiteStatement;
import com.xabber.android.data.DatabaseManager; import com.xabber.android.data.DatabaseManager;
import com.xabber.android.data.SettingsManager;
/** /**
* Storage with settings to show text in notification for each chat. * Storage with settings to show text in notification for each chat.
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
class ShowTextTable extends AbstractChatPropertyTable<Boolean> { class ShowTextTable extends AbstractChatPropertyTable<ShowMessageTextInNotification> {
static final String NAME = "chat_show_text"; static final String NAME = "chat_show_text";
...@@ -36,12 +37,16 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> { ...@@ -36,12 +37,16 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> {
DatabaseManager.getInstance().addTable(instance); DatabaseManager.getInstance().addTable(instance);
} }
private ShowTextTable(DatabaseManager databaseManager) {
super(databaseManager);
}
public static ShowTextTable getInstance() { public static ShowTextTable getInstance() {
return instance; return instance;
} }
private ShowTextTable(DatabaseManager databaseManager) { static ShowMessageTextInNotification getValue(Cursor cursor) {
super(databaseManager); return ShowMessageTextInNotification.fromInteger((int) cursor.getLong(cursor.getColumnIndex(Fields.VALUE)));
} }
@Override @Override
...@@ -55,8 +60,8 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> { ...@@ -55,8 +60,8 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> {
} }
@Override @Override
void bindValue(SQLiteStatement writeStatement, Boolean value) { void bindValue(SQLiteStatement writeStatement, ShowMessageTextInNotification showMessageTextInNotification) {
writeStatement.bindLong(3, value ? 1 : 0); writeStatement.bindLong(3, showMessageTextInNotification.ordinal());
} }
@Override @Override
...@@ -66,13 +71,29 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> { ...@@ -66,13 +71,29 @@ class ShowTextTable extends AbstractChatPropertyTable<Boolean> {
case 52: case 52:
initialMigrate(db, "chat_show_text", "INTEGER"); initialMigrate(db, "chat_show_text", "INTEGER");
break; break;
case 67:
int trueMigrationValue;
int falseMigrationValue;
if (SettingsManager.eventsShowText()) {
trueMigrationValue = ShowMessageTextInNotification.default_settings.ordinal();
falseMigrationValue = ShowMessageTextInNotification.hide.ordinal();
} else {
trueMigrationValue = ShowMessageTextInNotification.show.ordinal();
falseMigrationValue = ShowMessageTextInNotification.default_settings.ordinal();
}
String sql = "UPDATE " + NAME
+ " SET " + Fields.VALUE + " = CASE WHEN (" + Fields.VALUE + "=1) THEN "
+ trueMigrationValue + " ELSE " + falseMigrationValue + " END;";
DatabaseManager.execSQL(db, sql);
default: default:
break; break;
} }
} }
static boolean getValue(Cursor cursor) {
return cursor.getLong(cursor.getColumnIndex(Fields.VALUE)) != 0;
}
} }
...@@ -260,7 +260,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem ...@@ -260,7 +260,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
} }
private void setSendButtonColor() { private void setSendButtonColor() {
boolean empty = inputView.getText().toString().isEmpty(); boolean empty = inputView.getText().toString().trim().isEmpty();
if (empty != isInputEmpty) { if (empty != isInputEmpty) {
isInputEmpty = empty; isInputEmpty = empty;
......
...@@ -10,6 +10,7 @@ import android.view.LayoutInflater; ...@@ -10,6 +10,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import com.xabber.android.R; import com.xabber.android.R;
...@@ -27,7 +28,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -27,7 +28,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
private ListView listView; private ListView listView;
private View divider; private View divider;
private View headerTitle; private View headerTitle;
private View drawerHeader; private ImageView drawerHeaderImage;
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
...@@ -40,7 +41,8 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -40,7 +41,8 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_list_drawer, container, false); View view = inflater.inflate(R.layout.contact_list_drawer, container, false);
drawerHeader = view.findViewById(R.id.drawer_header); View drawerHeader = view.findViewById(R.id.drawer_header);
drawerHeaderImage = (ImageView) drawerHeader.findViewById(R.id.drawer_header_image);
listView = (ListView) view.findViewById(R.id.drawer_account_list); listView = (ListView) view.findViewById(R.id.drawer_account_list);
...@@ -99,7 +101,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL ...@@ -99,7 +101,7 @@ public class ContactListDrawerFragment extends Fragment implements View.OnClickL
private void update() { private void update() {
adapter.onChange(); adapter.onChange();
drawerHeader.getBackground().setLevel(AccountPainter.getDefaultAccountColorLevel()); drawerHeaderImage.setImageLevel(AccountPainter.getDefaultAccountColorLevel());
if (adapter.getCount() == 0) { if (adapter.getCount() == 0) {
headerTitle.setVisibility(View.GONE); headerTitle.setVisibility(View.GONE);
......
...@@ -176,8 +176,6 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis ...@@ -176,8 +176,6 @@ public class ContactListFragment extends Fragment implements OnAccountChangedLis
GroupConfiguration groupConfiguration = (GroupConfiguration) object; GroupConfiguration groupConfiguration = (GroupConfiguration) object;
adapter.setExpanded(groupConfiguration.getAccount(), groupConfiguration.getUser(), adapter.setExpanded(groupConfiguration.getAccount(), groupConfiguration.getUser(),
!groupConfiguration.isExpanded()); !groupConfiguration.isExpanded());
} else {
throw new IllegalStateException();
} }
} }
......
...@@ -12,6 +12,8 @@ import com.xabber.android.data.account.AccountItem; ...@@ -12,6 +12,8 @@ import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.connection.ConnectionState; import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.AccountPainter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
...@@ -20,12 +22,11 @@ import java.util.List; ...@@ -20,12 +22,11 @@ import java.util.List;
public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String> { public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String> {
private final int[] accountColors; private final AccountPainter accountPainter;
public NavigationDrawerAccountAdapter(Activity activity) { public NavigationDrawerAccountAdapter(Activity activity) {
super(activity); super(activity);
accountPainter = new AccountPainter(activity);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
} }
@Override @Override
...@@ -39,13 +40,16 @@ public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String ...@@ -39,13 +40,16 @@ public class NavigationDrawerAccountAdapter extends BaseListEditorAdapter<String
} }
String account = getItem(position); String account = getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)]; ((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable((accountPainter.getAccountMainColor(account))));
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
TextView accountName = (TextView) view.findViewById(R.id.name);
accountName.setText(RosterManager.getInstance().getBestContact(account, accountManager.getVerboseName(account)).getName());
accountName.setTextColor(accountPainter.getAccountDarkestColor(account));
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor)); ((TextView) view.findViewById(R.id.account_jid)).setText(accountManager.getVerboseName(account));
((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
AccountItem accountItem = accountManager.getAccount(account); AccountItem accountItem = accountManager.getAccount(account);
ConnectionState state; ConnectionState state;
if (accountItem == null) { if (accountItem == null) {
......
...@@ -17,11 +17,13 @@ public class AccountPainter { ...@@ -17,11 +17,13 @@ public class AccountPainter {
private int[] accountMainColors; private int[] accountMainColors;
private int[] accountDarkColors; private int[] accountDarkColors;
private int[] accountDarkestColors;
public AccountPainter(Context context) { public AccountPainter(Context context) {
accountMainColors = context.getResources().getIntArray(R.array.account_action_bar); accountMainColors = context.getResources().getIntArray(R.array.account_action_bar);
accountDarkColors = context.getResources().getIntArray(R.array.account_status_bar); accountDarkColors = context.getResources().getIntArray(R.array.account_status_bar);
accountDarkestColors = context.getResources().getIntArray(R.array.account_900);
accountColorNames = context.getResources().getStringArray(R.array.account_color_names); accountColorNames = context.getResources().getStringArray(R.array.account_color_names);
...@@ -84,6 +86,11 @@ public class AccountPainter { ...@@ -84,6 +86,11 @@ public class AccountPainter {
return accountDarkColors[getAccountColorLevel(account)]; return accountDarkColors[getAccountColorLevel(account)];
} }
public int getAccountDarkestColor(String account) {
return accountDarkestColors[getAccountColorLevel(account)];
}
public int getDefaultDarkColor() { public int getDefaultDarkColor() {
String firstAccount = getFirstAccount(); String firstAccount = getFirstAccount();
if (firstAccount == null) { if (firstAccount == null) {
......
...@@ -8,6 +8,7 @@ import com.xabber.android.R; ...@@ -8,6 +8,7 @@ import com.xabber.android.R;
import com.xabber.android.data.account.AccountItem; import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.ArchiveMode; import com.xabber.android.data.account.ArchiveMode;
import com.xabber.android.data.message.chat.ChatManager; import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.android.data.message.chat.ShowMessageTextInNotification;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -46,7 +47,8 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment { ...@@ -46,7 +47,8 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment {
putValue(map, R.string.chat_events_visible_chat_key, ChatManager putValue(map, R.string.chat_events_visible_chat_key, ChatManager
.getInstance().isNotifyVisible(account, user)); .getInstance().isNotifyVisible(account, user));
putValue(map, R.string.chat_events_show_text_key, ChatManager putValue(map, R.string.chat_events_show_text_key, ChatManager
.getInstance().isShowText(account, user)); .getInstance().getShowText(account, user).ordinal());
putValue(map, R.string.chat_events_vibro_key, ChatManager.getInstance() putValue(map, R.string.chat_events_vibro_key, ChatManager.getInstance()
.isMakeVibro(account, user)); .isMakeVibro(account, user));
putValue(map, R.string.chat_events_sound_key, ChatManager.getInstance() putValue(map, R.string.chat_events_sound_key, ChatManager.getInstance()
...@@ -67,9 +69,10 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment { ...@@ -67,9 +69,10 @@ public class ChatContactSettingsFragment extends BaseSettingsFragment {
ChatManager.getInstance().setNotifyVisible(account, user, ChatManager.getInstance().setNotifyVisible(account, user,
getBoolean(result, R.string.chat_events_visible_chat_key)); getBoolean(result, R.string.chat_events_visible_chat_key));
if (hasChanges(source, result, R.string.chat_events_show_text_key)) if (hasChanges(source, result, R.string.chat_events_show_text_key)) {
ChatManager.getInstance().setShowText(account, user, ChatManager.getInstance().setShowText(account, user,
getBoolean(result, R.string.chat_events_show_text_key)); ShowMessageTextInNotification.fromInteger(getInt(result, R.string.chat_events_show_text_key)));
}
if (hasChanges(source, result, R.string.chat_events_vibro_key)) if (hasChanges(source, result, R.string.chat_events_vibro_key))
ChatManager.getInstance().setMakeVibro(account, user, ChatManager.getInstance().setMakeVibro(account, user,
......
...@@ -848,7 +848,7 @@ public class XMPPConnection extends Connection { ...@@ -848,7 +848,7 @@ public class XMPPConnection extends Connection {
throw new IllegalStateException(); throw new IllegalStateException();
context.init(kms, new TrustManager[]{new XMPPTrustManager( context.init(kms, new TrustManager[]{new XMPPTrustManager(
KeyStoreManager.getOrCreateKeyStore(config), KeyStoreManager.getOrCreateKeyStore(config),
getServiceName(), config.getCertificateListener(), getHost(), config.getCertificateListener(),
chainCheck, domainCheck, allowSelfSigned)}, SECURE_RANDOM); chainCheck, domainCheck, allowSelfSigned)}, SECURE_RANDOM);
} }
Socket plain = socket; Socket plain = socket;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/background_light" android:background="@android:color/background_light"
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <FrameLayout
android:id="@+id/drawer_header" android:id="@+id/drawer_header"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="170dp" android:layout_height="wrap_content">
android:background="@drawable/drawer_image">
<ImageView
android:id="@+id/drawer_header_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/drawer_image" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -19,26 +25,49 @@ ...@@ -19,26 +25,49 @@
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView"
android:layout_width="wrap_content" android:layout_width="64dp"
android:layout_height="wrap_content" android:layout_height="64dp"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:src="@drawable/ic_connect" /> android:src="@drawable/ic_connect" />
<TextView <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:orientation="vertical"
android:shadowColor="@color/grey_700" android:paddingTop="8dp">
android:shadowDx="1"
android:shadowDy="1" <TextView
android:shadowRadius="2" android:layout_width="wrap_content"
android:text="@string/application_title_short" android:layout_height="wrap_content"
android:textColor="@color/grey_50" android:layout_gravity="center_vertical"
android:textSize="40sp" /> android:layout_margin="0dp"
android:shadowColor="@color/grey_700"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/application_title_short"
android:textColor="@color/grey_50"
android:textSize="24sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="-8dp"
android:shadowColor="@color/grey_700"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="@string/about_open_source_xmpp_client"
android:textColor="@color/grey_300"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</RelativeLayout> </FrameLayout>
<ListView <ListView
android:id="@+id/drawer_account_list" android:id="@+id/drawer_account_list"
...@@ -46,5 +75,7 @@ ...@@ -46,5 +75,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:divider="@null" android:divider="@null"
android:dividerHeight="0dp" android:dividerHeight="0dp"
/> tools:listfooter="@layout/contact_list_drawer_footer"
tools:listheader="@layout/contact_list_drawer_header"
tools:listitem="@layout/contact_list_drawer_account_item" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
--> -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="48dp" android:layout_height="64dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="16dp"> android:paddingRight="16dp">
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/color" android:id="@+id/color"
android:layout_width="36dp" android:layout_width="40dp"
android:layout_height="36dp" android:layout_height="40dp"
android:src="@color/green_500" /> android:src="@color/green_500" />
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto" <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="36dp" android:layout_width="40dp"
android:layout_height="36dp" android:layout_height="40dp"
android:src="@drawable/ic_avatar_1" android:src="@drawable/ic_avatar_1"
app:border_color="@android:color/transparent" app:border_color="@android:color/transparent"
app:border_width="3dp" /> app:border_width="3dp" />
...@@ -40,10 +40,11 @@ ...@@ -40,10 +40,11 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="26dp"> android:paddingLeft="22dp">
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
...@@ -51,11 +52,23 @@ ...@@ -51,11 +52,23 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="bottom"
android:singleLine="true" android:singleLine="true"
android:text="test" android:text="Some Name"
android:textColor="?android:attr/textColorPrimary" android:textColor="@color/green_700"
android:textStyle="bold" /> android:textSize="18sp" />
<TextView
android:id="@+id/account_jid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="-2dp"
android:layout_marginTop="-4dp"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:text="example@example.com"
android:textColor="@color/grey_500"
android:textSize="14sp" />
<TextView <TextView
android:id="@+id/status" android:id="@+id/status"
...@@ -65,7 +78,7 @@ ...@@ -65,7 +78,7 @@
android:ellipsize="marquee" android:ellipsize="marquee"
android:gravity="top" android:gravity="top"
android:singleLine="true" android:singleLine="true"
android:text="@android:string/cancel" android:text="Online"
android:textColor="?android:attr/textColorSecondary" /> android:textColor="?android:attr/textColorSecondary" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -9,4 +9,6 @@ ...@@ -9,4 +9,6 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png -->
<string name="about_version">Версия: %s</string> <string name="about_version">Версия: %s</string>
<string name="about_license">Лицензия: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Программное обеспечение с открытым исходным кодом</a></string> <string name="about_license">Лицензия: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Программное обеспечение с открытым исходным кодом</a></string>
<string name="about_open_source_xmpp_client">open source XMPP client</string>
</resources> </resources>
\ No newline at end of file
...@@ -152,4 +152,8 @@ ...@@ -152,4 +152,8 @@
<string name="under_construction">В разработке</string> <string name="under_construction">В разработке</string>
<string name="under_construction_message">Этот экран находится в разработке</string> <string name="under_construction_message">Этот экран находится в разработке</string>
<string name="chat_events_show_text_global">Использовать глобальные настройки</string>
<string name="chat_events_show_text_always">Отображать текст сообщения</string>
<string name="chat_events_show_text_never">Скрывать текст сообщения</string>
</resources> </resources>
\ No newline at end of file
...@@ -9,4 +9,6 @@ ...@@ -9,4 +9,6 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png --> <!-- http://dl.dropbox.com/u/1029995/com.xabber.android/about_viewer.png -->
<string name="about_version">Version: %s</string> <string name="about_version">Version: %s</string>
<string name="about_license">License: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Open source software</a></string> <string name="about_license">License: GNU GPLv3\n<a href="https://github.com/redsolution/xabber-android">Open source software</a></string>
<string name="about_open_source_xmpp_client">open source XMPP client</string>
</resources> </resources>
\ No newline at end of file
...@@ -152,4 +152,9 @@ ...@@ -152,4 +152,9 @@
<string name="under_construction">Under construction</string> <string name="under_construction">Under construction</string>
<string name="under_construction_message">This screen is under construction</string> <string name="under_construction_message">This screen is under construction</string>
<string name="chat_events_show_text_global">Use global settings</string>
<string name="chat_events_show_text_always">Show message text</string>
<string name="chat_events_show_text_never">Hide message text</string>
</resources> </resources>
\ No newline at end of file
...@@ -67,6 +67,16 @@ ...@@ -67,6 +67,16 @@
<item>@color/teal_50</item> <item>@color/teal_50</item>
</array> </array>
<array name="account_900">
<item>@color/green_900</item>
<item>@color/orange_900</item>
<item>@color/red_900</item>
<item>@color/blue_900</item>
<item>@color/indigo_900</item>
<item>@color/blue_grey_900</item>
<item>@color/cyan_900</item>
<item>@color/teal_900</item>
</array>
<color name="color_primary_light">@color/grey_200</color> <color name="color_primary_light">@color/grey_200</color>
......
...@@ -485,7 +485,25 @@ ...@@ -485,7 +485,25 @@
<!-- preference_chat --> <!-- preference_chat -->
<string name="chat_save_history_key">chat_save_history</string> <string name="chat_save_history_key">chat_save_history</string>
<string name="chat_events_sound_key">chat_events_sound</string> <string name="chat_events_sound_key">chat_events_sound</string>
<string name="chat_events_show_text_key">chat_events_show_text</string> <string name="chat_events_show_text_key">chat_events_show_message_text</string>
<string-array name="chat_events_show_text_entries">
<item>@string/chat_events_show_text_global</item>
<item>@string/chat_events_show_text_always</item>
<item>@string/chat_events_show_text_never</item>
</string-array>
<string-array name="chat_events_show_text_entry_values">
<item>@string/chat_events_show_text_global_value</item>
<item>@string/chat_events_show_text_always_value</item>
<item>@string/chat_events_show_text_never_value</item>
</string-array>
<string name="chat_events_show_text_global_value">default</string>
<string name="chat_events_show_text_always_value">always</string>
<string name="chat_events_show_text_never_value">never</string>
<string name="chat_events_show_text_default">@string/chat_events_show_text_global_value</string>
<string name="chat_events_vibro_key">chat_events_vibro</string> <string name="chat_events_vibro_key">chat_events_vibro</string>
<string name="chat_events_visible_chat_key">chat_events_visible_chat</string> <string name="chat_events_visible_chat_key">chat_events_visible_chat</string>
......
...@@ -24,7 +24,11 @@ ...@@ -24,7 +24,11 @@
android:showDefault="true" android:showDefault="true"
android:showSilent="true" android:showSilent="true"
android:title="@string/events_sound" /> android:title="@string/events_sound" />
<CheckBoxPreference
<ListPreference
android:defaultValue="@string/chat_events_show_text_default"
android:entries="@array/chat_events_show_text_entries"
android:entryValues="@array/chat_events_show_text_entry_values"
android:key="@string/chat_events_show_text_key" android:key="@string/chat_events_show_text_key"
android:title="@string/events_show_text" android:title="@string/events_show_text"
/> />
......
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