aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-06 09:18:42 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-06 09:18:42 +0000
commit3ef4b90a63a55e712babecf1ad9ac8972a255a91 (patch)
treec125db45ce994fa5624c2b6edbf34446efada14a /app/src/main/java
parent933e928faf9bbe95b85a643f73b77a11043cc03f (diff)
downloadinfinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar.gz
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar.bz2
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar.lz
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar.xz
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.tar.zst
infinity-for-reddit-3ef4b90a63a55e712babecf1ad9ac8972a255a91.zip
Set color of received and sent messages, and send message button.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java15
3 files changed, 37 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
index e78cdc47..3f8835e9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
@@ -40,10 +39,10 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.RepliedToPrivateMessageEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Message.Message;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Message.ReadMessage;
-import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Message.ReplyMessage;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
@@ -294,7 +293,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
mEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
mEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
mEditTextLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- mSendImageView.setColorFilter(Color.parseColor("#4185F4"), android.graphics.PorterDuff.Mode.SRC_IN);
+ mSendImageView.setColorFilter(mCustomThemeWrapper.getSendMessageIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
index 1d8abf5c..572db144 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
@@ -51,9 +51,11 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
private Markwon mMarkwon;
private boolean mShowElapsedTime;
private String mTimeFormatPattern;
- private int mMessageBackgroundColor;
private int mSecondaryTextColor;
- private int mUnreadMessageBackgroundColor;
+ private int mReceivedMessageTextColor;
+ private int mSentMessageTextColor;
+ private int mReceivedMessageBackgroundColor;
+ private int mSentMessageBackgroundColor;
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity,
SharedPreferences sharedPreferences, Locale locale,
@@ -96,9 +98,11 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
.build();
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
- mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor();
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
- mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor();
+ mReceivedMessageTextColor = customThemeWrapper.getReceivedMessageTextColor();
+ mSentMessageTextColor = customThemeWrapper.getSentMessageTextColor();
+ mReceivedMessageBackgroundColor = customThemeWrapper.getReceivedMessageBackgroundColor();
+ mSentMessageBackgroundColor = customThemeWrapper.getSentMessageBackgroundColor();
}
@Override
@@ -151,7 +155,8 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
}
if (holder instanceof SentMessageViewHolder) {
- ((SentMessageViewHolder) holder).messageTextView.setBackgroundResource(R.drawable.private_message_ballon_sent);
+ ((SentMessageViewHolder) holder).messageTextView.setBackground(Utils.getTintedDrawable(mViewPrivateMessagesActivity,
+ R.drawable.private_message_ballon, mSentMessageBackgroundColor));
} else if (holder instanceof ReceivedMessageViewHolder) {
mViewPrivateMessagesActivity.fetchUserAvatar(message.getAuthor(), userAvatarUrl -> {
if (userAvatarUrl == null || userAvatarUrl.equals("")) {
@@ -172,7 +177,10 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
mViewPrivateMessagesActivity.startActivity(intent);
});
- ((ReceivedMessageViewHolder) holder).messageTextView.setBackgroundResource(R.drawable.private_message_ballon_received);
+
+ ((ReceivedMessageViewHolder) holder).messageTextView.setBackground(
+ Utils.getTintedDrawable(mViewPrivateMessagesActivity,
+ R.drawable.private_message_ballon, mReceivedMessageBackgroundColor));
}
}
}
@@ -244,6 +252,9 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
super(itemView);
ButterKnife.bind(this, itemView);
setBaseView(messageTextView, timeTextView);
+
+ messageTextView.setTextColor(mSentMessageTextColor);
+
}
}
@@ -259,6 +270,8 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
super(itemView);
ButterKnife.bind(this, itemView);
setBaseView(messageTextView, timeTextView);
+
+ messageTextView.setTextColor(mReceivedMessageTextColor);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
index d5d7530f..14cdb57a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/Utils.java
@@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Utils;
import android.app.Activity;
import android.content.Context;
+import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
@@ -11,7 +12,9 @@ import android.util.DisplayMetrics;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
+import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
+import androidx.core.graphics.drawable.DrawableCompat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -139,4 +142,16 @@ public class Utils {
public static float convertDpToPixel(float dp, Context context){
return dp * ((float) context.getResources().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
}
+
+ @Nullable
+ public static Drawable getTintedDrawable(Context context, int drawableId, int color) {
+ Drawable drawable = context.getDrawable(drawableId);
+ if (drawable != null) {
+ Drawable wrappedDrawable = DrawableCompat.wrap(drawable).mutate();
+ DrawableCompat.setTint(wrappedDrawable, color);
+ return wrappedDrawable;
+ }
+
+ return null;
+ }
}