rework design colors and make it compatible with older ROMs

This commit is contained in:
Christian Schneppe 2019-11-16 15:11:29 +01:00
parent da925991c1
commit 0d649e48bb
No known key found for this signature in database
GPG key ID: F30B8D686B44D87E
27 changed files with 84 additions and 253 deletions

View file

@ -1164,7 +1164,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
binding.textinput.addTextChangedListener(new StylingHelper.MessageEditorStyler(binding.textinput));
binding.textinput.setOnEditorActionListener(mEditorActionListener);
binding.textinput.setRichContentListener(new String[]{"image/*"}, mEditorContentListener);
binding.messageInputBox.setBackgroundResource(messageInputBubble(false));
binding.textSendButton.setOnClickListener(this.mSendButtonListener);
binding.textSendButton.setOnLongClickListener(this.mSendButtonLongListener);
@ -2638,7 +2637,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
public void updateSendButton() {
updateChatMsgHint();
binding.messageInputBox.setBackgroundResource(messageInputBubble(isPrivateMessage()));
messageListAdapter.setBubbleBackgroundColor(binding.messageInputBox, activity.getThemeColor(), 0, isPrivateMessage(), true);
boolean hasAttachments = mediaPreviewAdapter != null && mediaPreviewAdapter.hasAttachments();
boolean useSendButtonToIndicateStatus = activity != null && PreferenceManager.getDefaultSharedPreferences(activity).getBoolean("send_button_status", getResources().getBoolean(R.bool.send_button_status));
final Conversation c = this.conversation;
@ -3094,10 +3093,6 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
private int messageInputBubble(final boolean isPrivate) {
return isPrivate ? activity.isOrangeTheme() ? activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange_private : R.drawable.message_bubble_sent_orange_private : activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_private : R.drawable.message_bubble_sent_private : activity.isOrangeTheme() ? activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange : R.drawable.message_bubble_sent_orange : activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark : R.drawable.message_bubble_sent;
}
public Conversation getConversation() {
return conversation;
}

View file

@ -25,6 +25,7 @@ import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.Uri;
@ -50,6 +51,7 @@ import android.widget.Toast;
import androidx.annotation.BoolRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatDelegate;
@ -426,6 +428,19 @@ public abstract class XmppActivity extends ActionBarActivity {
return getStringPreference("theme_color", R.string.theme_color).equals("orange");
}
public String getThemeColor() {
return getStringPreference("theme_color", R.string.theme_color);
}
public void setBubbleColor(final View v, final int backgroundColor, final int borderColor) {
GradientDrawable shape = (GradientDrawable)v.getBackground();
shape.setColor(backgroundColor);
if (borderColor != -1) {
shape.setStroke(2, borderColor);
}
v.setBackground(shape);
}
public int getThemeResource(int r_attr_name, int r_drawable_def) {
int[] attrs = {r_attr_name};
TypedArray ta = this.getTheme().obtainStyledAttributes(attrs);

View file

@ -7,6 +7,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.text.Editable;
@ -82,6 +83,7 @@ import de.pixart.messenger.utils.Emoticons;
import de.pixart.messenger.utils.GeoHelper;
import de.pixart.messenger.utils.RichPreview;
import de.pixart.messenger.utils.StylingHelper;
import de.pixart.messenger.utils.ThemeHelper;
import de.pixart.messenger.utils.UIHelper;
import de.pixart.messenger.xmpp.mam.MamReference;
import pl.droidsonroids.gif.GifImageView;
@ -726,7 +728,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
viewHolder.richlinkview.setLayoutParams(layoutParams);
final String url = body.toString();
String weburl;
final String lcUrl = url.toLowerCase(Locale.US);
final String lcUrl = url.toLowerCase(Locale.US).trim();
if (lcUrl.startsWith("http://") || lcUrl.startsWith("https://")) {
weburl = removeTrailingBracket(url);
} else {
@ -872,6 +874,11 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
private void toggleWhisperInfo(ViewHolder viewHolder, final Message message, final boolean includeBody, final boolean darkBackground) {
SpannableStringBuilder messageBody = new SpannableStringBuilder(replaceYoutube(activity.getApplicationContext(), message.getBody()));
Editable body;
if (darkBackground) {
viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_OnDark);
} else {
viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1);
}
if (message.isPrivateMessage()) {
final String privateMarker;
if (message.getStatus() <= Message.STATUS_RECEIVED) {
@ -1000,7 +1007,6 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
boolean darkBackground = activity.isDarkTheme();
boolean isOrange = activity.isOrangeTheme();
if (type == DATE_SEPARATOR) {
if (UIHelper.today(message.getTimeSent())) {
@ -1140,23 +1146,11 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
if (type == RECEIVED) {
if (isInValidSession) {
if (message.isPrivateMessage()) {
if (activity.isOrangeTheme()) {
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_orange_dark_private : R.drawable.message_bubble_received_light_orange_private);
} else {
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_dark_private : R.drawable.message_bubble_received_light_private);
}
} else {
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_light_dark : R.drawable.message_bubble_received_light);
}
setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession);
viewHolder.encryption.setVisibility(View.GONE);
viewHolder.encryption.setTextColor(this.getMessageTextColor(darkBackground, false));
} else {
if (message.isPrivateMessage()) {
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_warning_dark : R.drawable.message_bubble_received_warning);
} else {
viewHolder.message_box.setBackgroundResource(darkBackground ? R.drawable.message_bubble_received_warning_dark : R.drawable.message_bubble_received_warning);
}
setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession);
viewHolder.encryption.setVisibility(View.VISIBLE);
viewHolder.encryption.setTextColor(this.getWarningTextColor(darkBackground));
if (omemoEncryption && !message.isTrusted()) {
@ -1168,19 +1162,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
}
if (type == SENT) {
if (message.isPrivateMessage()) {
if (activity.isOrangeTheme()) {
viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange_private : R.drawable.message_bubble_sent_orange_private);
} else {
viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_private : R.drawable.message_bubble_sent_private);
}
} else {
if (activity.isOrangeTheme()) {
viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark_orange : R.drawable.message_bubble_sent_orange );
} else {
viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.message_bubble_sent_dark : R.drawable.message_bubble_sent);
}
}
setBubbleBackgroundColor(viewHolder.message_box, activity.getThemeColor(), type, message.isPrivateMessage(), isInValidSession);
}
displayStatus(viewHolder, message, type, darkBackground);
return view;
@ -1374,4 +1356,36 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
public void onDestroyActionMode(ActionMode mode) {
}
}
public void setBubbleBackgroundColor(final View viewHolder, final String themeColor, final int type, final boolean isPrivateMessage, final boolean isInValidSession) {
if (type == RECEIVED) {
if (isInValidSession) {
if (isPrivateMessage) {
viewHolder.setBackgroundResource(R.drawable.message_bubble_received_light_private);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_light), StyledAttributes.getColor(activity, R.attr.colorAccent));
} else {
viewHolder.setBackgroundResource(R.drawable.message_bubble_received_light);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_light), -1);
}
} else {
if (isPrivateMessage) {
viewHolder.setBackgroundResource(R.drawable.message_bubble_received_warning_private);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_warning), StyledAttributes.getColor(activity, R.attr.colorAccent));
} else {
viewHolder.setBackgroundResource(R.drawable.message_bubble_received_warning);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_warning), -1);
}
}
}
if (type == SENT) {
if (isPrivateMessage) {
viewHolder.setBackgroundResource(R.drawable.message_bubble_sent_private);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_dark), StyledAttributes.getColor(activity, R.attr.colorAccent));
} else {
viewHolder.setBackgroundResource(R.drawable.message_bubble_sent);
activity.setBubbleColor(viewHolder, StyledAttributes.getColor(activity, R.attr.color_bubble_dark), -1);
}
}
}
}

View file

@ -61,7 +61,7 @@ public class ThemeHelper {
final String themeColor = sharedPreferences.getString("theme_color", resources.getString(R.string.theme_color));
final String fontSize = sharedPreferences.getString("font_size", resources.getString(R.string.default_font_size));
switch (themeColor) {
case "c":
case "blue":
switch (fontSize) {
case "medium":
return dark ? R.style.ConversationsTheme_Dark_Medium : R.style.ConversationsTheme_Medium;

View file

@ -10,5 +10,5 @@
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/lightwhite" />
<solid android:color="@color/lightblue" />
</shape>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="2dp"
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/darkwhite" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="2dp"
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/darkwhite" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="2dp"
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/darkwhite" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="2dp"
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/lightwhite" />
</shape>

View file

@ -11,5 +11,5 @@
android:left="6dp"
android:right="6dp"
android:top="2dp" />
<solid android:color="@color/lightwhite" />
<solid android:color="@color/lightblue" />
</shape>

View file

@ -10,5 +10,5 @@
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightred" />
<solid android:color="?attr/color_bubble_warning" />
</shape>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkred" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkred" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkred" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
android:bottomRightRadius="5dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightred" />
</shape>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent"/>
<stroke android:width="2dp" android:color="?attr/colorAccent"/>
<corners
android:topLeftRadius="0dp"
android:topRightRadius="5dp"
@ -11,5 +11,5 @@
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightred" />
<solid android:color="?attr/color_bubble_warning" />
</shape>

View file

@ -10,5 +10,5 @@
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightblue" />
<solid android:color="@color/darkblue" />
</shape>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkblue" />
</shape>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkorange" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkorange" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/darkblue" />
</shape>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightorange" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<stroke android:width="2dp" android:color="@color/accent_orange"/>
<corners
android:topLeftRadius="5dp"
android:topRightRadius="5dp"
android:bottomRightRadius="0dp"
android:bottomLeftRadius="5dp" />
<padding
android:bottom="4dp"
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightorange" />
</shape>

View file

@ -11,5 +11,5 @@
android:left="6dp"
android:right="6dp"
android:top="4dp" />
<solid android:color="@color/lightblue" />
<solid android:color="@color/darkblue" />
</shape>

View file

@ -113,7 +113,7 @@
<attr name="popupOverlayStyle" format="reference" />
<attr name="color_bubble_light" format="reference|color" />
<attr name="color_bubble_blue" format="reference|color" />
<attr name="color_bubble_dark" format="reference|color" />
<attr name="color_bubble_date" format="reference|color" />
<attr name="color_bubble_warning" format="reference|color" />

View file

@ -8,7 +8,7 @@
<color name="primary_dark_orange">#ffB27300</color>
<color name="primary_orange_dark">#ffce8500</color>
<color name="primary_dark_orange_dark">#ffa06700</color>
<color name="accent_orange">#ffffa500 </color>
<color name="accent_orange">#ffffa500</color>
<color name="accent">#ff0091ea</color> <!-- light blue accent -->
<color name="black">#ff000000</color>
@ -51,7 +51,9 @@
<color name="darkred">#ffb71c1c</color> <!-- red 900 -->
<color name="darkgreen">#ff1b5e20</color> <!-- green 900 -->
<color name="lightorange">#fffff6e5</color> <!-- blue 100 -->
<color name="lightorange">#ffffb732</color>
<color name="lightorange2">#ffcc8400</color>
<color name="middleorange">#ff996300</color>
<color name="darkorange">#ff4c3100</color>
<color name="online">#ff388e3c</color> <!-- green 700 -->

View file

@ -26,7 +26,7 @@
<item name="EmojiColor">@color/realblack</item>
<item name="color_bubble_light">@color/lightwhite</item>
<item name="color_bubble_blue">@color/lightblue</item>
<item name="color_bubble_dark">@color/lightblue</item>
<item name="color_bubble_date">@color/lightgreen</item>
<item name="color_bubble_warning">@color/lightred</item>
@ -185,7 +185,7 @@
<item name="EmojiColor">@color/realwhite</item>
<item name="color_bubble_light">@color/darkwhite</item>
<item name="color_bubble_blue">@color/darkblue</item>
<item name="color_bubble_dark">@color/darkblue</item>
<item name="color_bubble_date">@color/darkgreen</item>
<item name="color_bubble_warning">@color/darkred</item>
@ -325,6 +325,11 @@
<item name="colorAccent">@color/accent_orange</item>
<item name="colorControlNormal">@color/accent_orange</item>
<item name="colorControlActivated">@color/accent_orange</item>
<item name="color_bubble_light">@color/lightorange</item>
<item name="color_bubble_dark">@color/lightorange2</item>
<item name="color_bubble_date">@color/darkred</item>
<item name="color_bubble_warning">@color/darkgreen</item>
</style>
<style name="ConversationsTheme.Orange.Dark" parent="ConversationsTheme.Dark">
@ -333,6 +338,11 @@
<item name="colorAccent">@color/accent_orange</item>
<item name="colorControlNormal">@color/accent_orange</item>
<item name="colorControlActivated">@color/accent_orange</item>
<item name="color_bubble_light">@color/middleorange</item>
<item name="color_bubble_dark">@color/darkorange</item>
<item name="color_bubble_date">@color/darkred</item>
<item name="color_bubble_warning">@color/darkgreen</item>
</style>
<style name="ConversationsTheme.Dialog" parent="@style/Theme.AppCompat.Light.Dialog">