mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Change coloring
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
08f44a04e1
commit
d7467b4fb6
@ -411,7 +411,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
.headingTvColor(getResources().getColor(R.color.colorPrimary))
|
||||
.headingTvSize(20)
|
||||
.headingTvText(getString(R.string.nc_push_to_talk))
|
||||
.subHeadingTvColor(getResources().getColor(R.color.nc_white_color_complete))
|
||||
.subHeadingTvColor(getResources().getColor(R.color.white))
|
||||
.subHeadingTvSize(16)
|
||||
.subHeadingTvText(getString(R.string.nc_push_to_talk_desc))
|
||||
.maskColor(Color.parseColor("#dc000000"))
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
@ -77,7 +78,7 @@ public class MagicIncomingTextMessageViewHolder
|
||||
|
||||
HashMap<String, HashMap<String, String>> messageParameters = message.getMessageParameters();
|
||||
|
||||
String messageString = message.getText();
|
||||
Spannable messageString = new SpannableString(message.getText());
|
||||
|
||||
if (messageParameters != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
@ -85,21 +86,23 @@ public class MagicIncomingTextMessageViewHolder
|
||||
if (individualHashMap.get("type").equals("user")) {
|
||||
int color;
|
||||
|
||||
if (messageParameters.get(key).get("id").equals(currentUser.getUserId())) {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.colorAccent);
|
||||
} else {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.colorAccentComplement);
|
||||
}
|
||||
if (!individualHashMap.get("id").equals(message.getActorId())) {
|
||||
if (individualHashMap.get("id").equals(currentUser.getUserId())) {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_you);
|
||||
} else {
|
||||
color = NextcloudTalkApplication.getSharedApplication().getResources().getColor(R.color
|
||||
.nc_incoming_text_mention_others);
|
||||
}
|
||||
|
||||
messageString = DisplayUtils.searchAndColor(messageString,
|
||||
"@" + messageParameters.get(key).get("name"), color);
|
||||
messageString = DisplayUtils.searchAndColor(messageText.getText().toString(),
|
||||
messageString, "@" + individualHashMap.get("name"), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
messageText.setText(Html.fromHtml(messageString));
|
||||
messageText.setText(messageString);
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program 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/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.adapters.messages;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
import com.stfalcon.chatkit.messages.MessageHolders;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class MagicOutcomingTextMessageViewHolder extends MessageHolders.OutcomingTextMessageViewHolder<ChatMessage> {
|
||||
@BindView(R.id.messageText)
|
||||
TextView messageText;
|
||||
|
||||
@Inject
|
||||
UserUtils userUtils;
|
||||
|
||||
private UserEntity currentUser;
|
||||
|
||||
public MagicOutcomingTextMessageViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
currentUser = userUtils.getCurrentUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBind(ChatMessage message) {
|
||||
super.onBind(message);
|
||||
|
||||
HashMap<String, HashMap<String, String>> messageParameters = message.getMessageParameters();
|
||||
|
||||
Spannable messageString = new SpannableString(message.getText());
|
||||
|
||||
if (messageParameters != null && message.getMessageParameters().size() > 0) {
|
||||
for (String key : message.getMessageParameters().keySet()) {
|
||||
HashMap<String, String> individualHashMap = message.getMessageParameters().get(key);
|
||||
if (individualHashMap.get("type").equals("user")) {
|
||||
if (!individualHashMap.get("id").equals(currentUser.getUserId())) {
|
||||
messageString = DisplayUtils.searchAndColor(messageText.getText().toString(),
|
||||
messageString, "@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_mention_others));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
messageText.setText(messageString);
|
||||
}
|
||||
|
||||
}
|
@ -46,6 +46,7 @@ import com.bumptech.glide.request.RequestOptions;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.activities.CallActivity;
|
||||
import com.nextcloud.talk.adapters.messages.MagicIncomingTextMessageViewHolder;
|
||||
import com.nextcloud.talk.adapters.messages.MagicOutcomingTextMessageViewHolder;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.callbacks.MentionAutocompleteCallback;
|
||||
@ -154,6 +155,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
|
||||
MessagesListAdapter.HoldersConfig holdersConfig = new MessagesListAdapter.HoldersConfig();
|
||||
holdersConfig.setIncoming(MagicIncomingTextMessageViewHolder.class,
|
||||
R.layout.item_custom_incoming_text_message);
|
||||
holdersConfig.setOutcomingTextHolder(MagicOutcomingTextMessageViewHolder.class);
|
||||
|
||||
adapter = new MessagesListAdapter<>(currentUser.getUserId(), holdersConfig, new ImageLoader() {
|
||||
@Override
|
||||
|
@ -112,12 +112,14 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
||||
internalUserItemList.add(new MentionAutocompleteItem(mention.getId(), mention
|
||||
.getLabel(), currentUser));
|
||||
}
|
||||
userItemList = internalUserItemList;
|
||||
adapter.updateDataSet(internalUserItemList, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
userItemList = new ArrayList<>();
|
||||
adapter.updateDataSet(new ArrayList<>(), false);
|
||||
}
|
||||
|
||||
@ -127,6 +129,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
||||
}
|
||||
});
|
||||
} else {
|
||||
userItemList = new ArrayList<>();
|
||||
adapter.updateDataSet(new ArrayList<>(), false);
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,24 @@ package com.nextcloud.talk.utils;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.v7.widget.AppCompatDrawableManager;
|
||||
import android.text.Spannable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -81,26 +89,26 @@ public class DisplayUtils {
|
||||
}
|
||||
|
||||
|
||||
public static String searchAndColor(String text, String searchText, @ColorInt int color) {
|
||||
public static Spannable searchAndColor(String text, Spannable spannable, String searchText, @ColorInt int color) {
|
||||
|
||||
if (TextUtils.isEmpty(text) || TextUtils.isEmpty(searchText)) {
|
||||
return text;
|
||||
return spannable;
|
||||
}
|
||||
|
||||
Matcher m = Pattern.compile(searchText, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
||||
.matcher(text);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
int textSize = NextcloudTalkApplication.getSharedApplication().getResources().getDimensionPixelSize(R.dimen
|
||||
.chat_text_size);
|
||||
while (m.find()) {
|
||||
String replacement = m.group().replace(
|
||||
m.group(),
|
||||
"<font color='" + color + "'><b>" + m.group() + "</b></font>"
|
||||
);
|
||||
m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
|
||||
int start = text.indexOf(m.group());
|
||||
int end = text.indexOf(m.group()) + m.group().length();
|
||||
spannable.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
spannable.setSpan(new StyleSpan(Typeface.BOLD), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
spannable.setSpan(new AbsoluteSizeSpan(textSize) , start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
m.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
return spannable;
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
android:background="@color/nc_darkRed"
|
||||
android:text="@string/nc_contacts_clear"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/nc_white_color_complete"/>
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/done_button"
|
||||
@ -53,7 +53,7 @@
|
||||
android:background="@color/nc_darkGreen"
|
||||
android:text="@string/nc_contacts_done"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/nc_white_color_complete"/>
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
@ -32,13 +32,15 @@
|
||||
app:incomingDefaultBubbleColor="@color/white_two"
|
||||
app:incomingDefaultBubblePressedColor="@color/white_two"
|
||||
app:incomingDefaultBubbleSelectedColor="@color/colorPrimaryDark"
|
||||
app:incomingTextSize="14sp"
|
||||
app:incomingTextSize="@dimen/chat_text_size"
|
||||
app:incomingTimeTextSize="12sp"
|
||||
app:outcomingDefaultBubbleColor="@color/colorPrimary"
|
||||
app:outcomingDefaultBubblePressedColor="@color/colorPrimary"
|
||||
app:outcomingDefaultBubbleSelectedColor="@color/colorPrimaryDark"
|
||||
app:outcomingTextSize="14sp"
|
||||
app:outcomingTextSize="@dimen/chat_text_size"
|
||||
app:outcomingTimeTextSize="12sp"
|
||||
app:outcomingTextColor="@color/nc_outcoming_text_default"
|
||||
app:incomingTextColor="@color/nc_incoming_text_default"
|
||||
app:textAutoLink="all"/>
|
||||
|
||||
<View
|
||||
|
@ -43,11 +43,11 @@
|
||||
android:layout_below="@id/image_logo"
|
||||
android:layout_marginEnd="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
app:errorColor="@color/nc_white_color_complete"
|
||||
app:errorColor="@android:color/white"
|
||||
app:helperText=" "
|
||||
app:labelText="@string/nc_server_url"
|
||||
app:panelBackgroundColor="@color/colorPrimary"
|
||||
app:primaryColor="@color/nc_white_color_complete">
|
||||
app:primaryColor="@android:color/white">
|
||||
|
||||
<studio.carbonylgroup.textfieldboxes.ExtendedEditText
|
||||
android:id="@+id/extended_edit_text"
|
||||
@ -56,7 +56,7 @@
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textUri"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/nc_white_color_complete"/>
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes>
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
android:layout_marginStart="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="24dp"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateTint="@color/nc_white_color_complete"
|
||||
android:indeterminateTint="@android:color/white"
|
||||
android:indeterminateTintMode="src_in"
|
||||
android:keepScreenOn="true"
|
||||
android:visibility="invisible"/>
|
||||
|
@ -59,6 +59,7 @@
|
||||
android:id="@id/messageText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/chat_text_size"
|
||||
app:layout_alignSelf="flex_start"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_wrapBefore="true"/>
|
||||
@ -68,8 +69,9 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textSize="12sp"
|
||||
app:layout_alignSelf="center"/>
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
@ -59,6 +59,6 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textColor="@color/nc_white_color_complete"/>
|
||||
android:textColor="@android:color/white"/>
|
||||
|
||||
</RelativeLayout>
|
@ -3,12 +3,16 @@
|
||||
<color name="colorPrimary">#0082C9</color>
|
||||
<color name="colorPrimaryDark">#006AA3</color>
|
||||
<color name="colorAccent">#007CC2</color>
|
||||
<color name="colorAccentComplement">#C34700</color>
|
||||
<color name="secondaryColorAccent">#7CC4E6</color>
|
||||
<color name="nc_outcoming_text_default">#99DBFF</color>
|
||||
<color name="nc_outcoming_text_mention_others">@color/white</color>
|
||||
<color name="nc_incoming_text_default">#27292B</color>
|
||||
<color name="nc_incoming_text_mention_you">#C98879</color>
|
||||
<color name="nc_incoming_text_mention_others">#1D1F20</color>
|
||||
|
||||
<color name="nc_darkRed">#D32F2F</color>
|
||||
<color name="nc_darkGreen">#006400</color>
|
||||
<color name="nc_white_color">@color/per70white</color>
|
||||
<color name="nc_white_color_complete">#FFFFFF</color>
|
||||
<color name="nc_light_blue_color">#7FC0E3</color>
|
||||
<color name="nc_material_yellow">#FFEB3B</color>
|
||||
<color name="nc_light_grey">#E8E8E8</color>
|
||||
|
@ -18,4 +18,6 @@
|
||||
<dimen name="avatar_size_big">80dp</dimen>
|
||||
<dimen name="avatar_corner_radius">20dp</dimen>
|
||||
|
||||
<dimen name="chat_text_size">14sp</dimen>
|
||||
|
||||
</resources>
|
||||
|
@ -28,5 +28,4 @@
|
||||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
|
||||
<string name="google_storage_bucket" translatable="false">nextcloud-a7dea.appspot.com</string>
|
||||
<string name="project_id" translatable="false">nextcloud-a7dea</string>
|
||||
|
||||
</resources>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="colorAccent">@color/colorPrimary</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user