Commit 54bceeb0 authored by Grigory Fedorov's avatar Grigory Fedorov

ChatMessageAdapter: chat background replaced with simple colors with alpha channel.

parent 1aad2908
......@@ -15,6 +15,7 @@
package com.xabber.android.ui.adapter;
import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.method.LinkMovementMethod;
......@@ -79,6 +80,7 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
* Text with extra information.
*/
private String hint;
private final int[] backgroundColors;
public ChatMessageAdapter(Activity activity) {
this.activity = activity;
......@@ -94,6 +96,8 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
} else {
divider = " ";
}
backgroundColors = activity.getResources().getIntArray(R.array.accout_chat_background);
}
@Override
......@@ -180,8 +184,9 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
textView.setTextAppearance(activity, appearanceStyle);
if (incoming) {
textView.setBackgroundResource(R.drawable.chat_bg);
textView.getBackground().setLevel(AccountManager.getInstance().getColorLevel(account));
ColorDrawable colorDrawable = new ColorDrawable(backgroundColors[AccountManager.getInstance().getColorLevel(account)]);
colorDrawable.setAlpha(64);
textView.setBackgroundDrawable(colorDrawable);
}
Spannable text = messageItem.getSpannable();
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
This file is part of Xabber project; you can redistribute it and/or
modify it under the terms of the GNU General Public License, Version 3.
Xabber is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/chat_bg_1"
android:minLevel="0"
android:maxLevel="0" />
<item
android:drawable="@drawable/chat_bg_2"
android:minLevel="1"
android:maxLevel="1" />
<item
android:drawable="@drawable/chat_bg_3"
android:minLevel="2"
android:maxLevel="2" />
<item
android:drawable="@drawable/chat_bg_4"
android:minLevel="3"
android:maxLevel="3" />
</level-list>
\ No newline at end of file
......@@ -50,7 +50,6 @@
android:layout_marginLeft="4dp"
android:text="Some text\n line \nrgregrere"
android:background="@drawable/chat_bg"
/>
</RelativeLayout>
......@@ -14,6 +14,13 @@
<item>@color/dark_purple_700</item>
</array>
<array name="accout_chat_background">
<item>@color/teal_A100</item>
<item>@color/deep_orange_A100</item>
<item>@color/pink_A100</item>
<item>@color/dark_purple_A100</item>
</array>
<color name="account_disabled">@color/black_dividers</color>
<color name="group_expander">@color/blue_grey_800</color>
</resources>
\ No newline at end of file
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