improved profile image density
This commit is contained in:
parent
a4a6237aeb
commit
d818127993
|
@ -33,6 +33,7 @@ import android.graphics.PorterDuffXfermode;
|
|||
import android.graphics.RectF;
|
||||
import android.graphics.SweepGradient;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
|
@ -122,6 +123,7 @@ public class ShapedImageView extends AppCompatImageView {
|
|||
setBackgroundColor(color);
|
||||
} else {
|
||||
mBackgroundPaint.setColor(color);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +181,6 @@ public class ShapedImageView extends AppCompatImageView {
|
|||
|
||||
@Override
|
||||
protected void onDraw(@NonNull Canvas canvas) {
|
||||
|
||||
mDestination.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(),
|
||||
getHeight() - getPaddingBottom());
|
||||
|
||||
|
@ -234,6 +235,12 @@ public class ShapedImageView extends AppCompatImageView {
|
|||
updateBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(@FloatRange(from = 0.0, to = 1.0) final float alpha) {
|
||||
super.setAlpha(alpha);
|
||||
mBackgroundPaint.setAlpha(Math.round(alpha * 255));
|
||||
}
|
||||
|
||||
private void drawBorder(@NonNull final Canvas canvas, @NonNull final RectF dest) {
|
||||
if (mBorderColors == null) return;
|
||||
final RectF transitionSrc = mTransitionSource, transitionDst = mTransitionDestination;
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.mariotaku.twidere.activity.UserSelectorActivity
|
|||
import org.mariotaku.twidere.adapter.BaseRecyclerViewAdapter
|
||||
import org.mariotaku.twidere.adapter.iface.IItemCountsAdapter
|
||||
import org.mariotaku.twidere.annotation.AccountType
|
||||
import org.mariotaku.twidere.annotation.ProfileImageSize
|
||||
import org.mariotaku.twidere.constant.IntentConstants
|
||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
|
@ -160,11 +161,11 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
conversationAvatar.style = profileImageStyle
|
||||
|
||||
val avatarBackground = ChameleonUtils.getColorDependent(theme.colorToolbar)
|
||||
appBarIcon.setBackgroundColor(avatarBackground)
|
||||
appBarIcon.setShapeBackground(avatarBackground)
|
||||
appBarTitle.setTextColor(ChameleonUtils.getColorDependent(theme.colorToolbar))
|
||||
appBarSubtitle.setTextColor(ChameleonUtils.getColorDependent(theme.colorToolbar))
|
||||
|
||||
conversationAvatar.setBackgroundColor(avatarBackground)
|
||||
conversationAvatar.setShapeBackground(avatarBackground)
|
||||
conversationTitle.setTextColor(ChameleonUtils.getColorDependent(theme.colorToolbar))
|
||||
conversationSubtitle.setTextColor(ChameleonUtils.getColorDependent(theme.colorToolbar))
|
||||
|
||||
|
@ -249,7 +250,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment,
|
|||
|
||||
val requestManager = Glide.with(this)
|
||||
requestManager.loadProfileImage(context, data).into(conversationAvatar)
|
||||
requestManager.loadProfileImage(context, data).into(appBarIcon)
|
||||
requestManager.loadProfileImage(context, data, size = ProfileImageSize.REASONABLY_SMALL).into(appBarIcon)
|
||||
appBarTitle.text = name
|
||||
conversationTitle.text = name
|
||||
if (summary != null) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.util.Log
|
|||
import org.mariotaku.microblog.library.MicroBlog
|
||||
import org.mariotaku.microblog.library.MicroBlogException
|
||||
import org.mariotaku.microblog.library.twitter.model.User
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.TwidereConstants
|
||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||
import org.mariotaku.twidere.model.AccountDetails
|
||||
|
@ -42,6 +43,8 @@ abstract class MicroBlogAPIUsersLoader(
|
|||
fromUser: Boolean
|
||||
) : ParcelableUsersLoader(context, data, fromUser) {
|
||||
|
||||
private val profileImageSize = context.getString(R.string.profile_image_size)
|
||||
|
||||
override fun loadInBackground(): List<ParcelableUser> {
|
||||
if (accountKey == null) {
|
||||
return ListResponse.getListInstance(MicroBlogException("No Account"))
|
||||
|
@ -64,7 +67,8 @@ abstract class MicroBlogAPIUsersLoader(
|
|||
if (hasId(user.id)) {
|
||||
continue
|
||||
}
|
||||
val item = ParcelableUserUtils.fromUser(user, accountKey, pos.toLong())
|
||||
val item = ParcelableUserUtils.fromUser(user, accountKey, pos.toLong(),
|
||||
profileImageSize = profileImageSize)
|
||||
processUser(item)
|
||||
data.add(item)
|
||||
pos++
|
||||
|
|
|
@ -164,10 +164,12 @@ class GetMessagesTask(
|
|||
conversations.addLocalConversations(context, accountKey, conversationIds)
|
||||
|
||||
received.forEachIndexed { i, dm ->
|
||||
addConversationMessage(insertMessages, conversations, details, dm, i, received.size, false)
|
||||
addConversationMessage(insertMessages, conversations, details, dm, i, received.size,
|
||||
false, profileImageSize)
|
||||
}
|
||||
sent.forEachIndexed { i, dm ->
|
||||
addConversationMessage(insertMessages, conversations, details, dm, i, sent.size, true)
|
||||
addConversationMessage(insertMessages, conversations, details, dm, i, sent.size,
|
||||
true, profileImageSize)
|
||||
}
|
||||
return DatabaseUpdateData(conversations.values, insertMessages)
|
||||
}
|
||||
|
@ -385,7 +387,7 @@ class GetMessagesTask(
|
|||
val recentMessage = messagesMap[k]?.maxBy(ParcelableMessage::message_timestamp)
|
||||
val participants = respUsers.filterKeys { userId ->
|
||||
v.participants.any { it.userId == userId }
|
||||
}.values.map { ParcelableUserUtils.fromUser(it, accountKey) }
|
||||
}.values.map { ParcelableUserUtils.fromUser(it, accountKey, profileImageSize = profileImageSize) }
|
||||
val conversationType = when (v.type?.toUpperCase(Locale.US)) {
|
||||
DMResponse.Conversation.Type.ONE_TO_ONE -> ConversationType.ONE_TO_ONE
|
||||
DMResponse.Conversation.Type.GROUP_DM -> ConversationType.GROUP
|
||||
|
@ -543,13 +545,16 @@ class GetMessagesTask(
|
|||
|
||||
internal fun addConversationMessage(messages: MutableCollection<ParcelableMessage>,
|
||||
conversations: MutableMap<String, ParcelableMessageConversation>,
|
||||
details: AccountDetails, dm: DirectMessage, index: Int, size: Int, outgoing: Boolean) {
|
||||
details: AccountDetails, dm: DirectMessage, index: Int, size: Int,
|
||||
outgoing: Boolean, profileImageSize: String = "normal") {
|
||||
val accountKey = details.key
|
||||
val message = ParcelableMessageUtils.fromMessage(accountKey, dm, outgoing,
|
||||
1.0 - (index.toDouble() / size))
|
||||
messages.add(message)
|
||||
val sender = ParcelableUserUtils.fromUser(dm.sender, accountKey)
|
||||
val recipient = ParcelableUserUtils.fromUser(dm.recipient, accountKey)
|
||||
val sender = ParcelableUserUtils.fromUser(dm.sender, accountKey,
|
||||
profileImageSize = profileImageSize)
|
||||
val recipient = ParcelableUserUtils.fromUser(dm.recipient, accountKey,
|
||||
profileImageSize = profileImageSize)
|
||||
val conversation = conversations.addConversation(message.conversation_id, details,
|
||||
message, setOf(sender, recipient)) ?: return
|
||||
conversation.conversation_extras_type = ParcelableMessageConversation.ExtrasType.DEFAULT
|
||||
|
|
Loading…
Reference in New Issue