From 8451c50104a9e79103caabe04ddaa888bf70abb2 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sat, 6 Jun 2015 23:15:33 +0800 Subject: [PATCH] migrating to RoundedImageView --- .../fragment/support/StatusFragment.java | 5 +-- .../util/ThemedLayoutInflaterFactory.java | 9 +++- .../twidere/view/ProfileImageView.java | 42 +++++++++++++++++++ .../twidere/view/holder/StatusViewHolder.java | 8 +--- .../view/holder/UserListViewHolder.java | 7 ++-- .../twidere/view/holder/UserViewHolder.java | 7 ++-- ...ard_item_message_conversation_incoming.xml | 2 +- .../res/layout/card_item_status_common.xml | 2 +- .../res/layout/card_item_status_compact.xml | 2 +- .../src/main/res/layout/card_item_user.xml | 2 +- .../res/layout/card_item_user_compact.xml | 2 +- .../main/res/layout/card_item_user_list.xml | 2 +- .../layout/card_item_user_list_compact.xml | 2 +- .../main/res/layout/header_status_common.xml | 2 +- .../res/layout/list_item_auto_complete.xml | 2 +- .../src/main/res/layout/list_item_user.xml | 2 +- .../main/res/layout/list_item_user_list.xml | 2 +- 17 files changed, 70 insertions(+), 30 deletions(-) create mode 100644 twidere/src/main/java/org/mariotaku/twidere/view/ProfileImageView.java diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java index b64f5baaf..d1ed0d611 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java @@ -113,7 +113,6 @@ import org.mariotaku.twidere.view.CardMediaContainer; import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener; import org.mariotaku.twidere.view.ColorLabelRelativeLayout; import org.mariotaku.twidere.view.ForegroundColorView; -import org.mariotaku.twidere.view.ShapedImageView; import org.mariotaku.twidere.view.StatusTextView; import org.mariotaku.twidere.view.TwitterCardContainer; import org.mariotaku.twidere.view.holder.GapViewHolder; @@ -606,7 +605,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac private final StatusTextView textView; private final TextView quoteTextView; private final TextView quotedNameView, quotedScreenNameView; - private final ShapedImageView profileImageView; + private final ImageView profileImageView; private final ImageView profileTypeView; private final TextView timeSourceView; private final TextView retweetedByView; @@ -636,7 +635,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac nameView = (TextView) itemView.findViewById(R.id.name); screenNameView = (TextView) itemView.findViewById(R.id.screen_name); textView = (StatusTextView) itemView.findViewById(R.id.text); - profileImageView = (ShapedImageView) itemView.findViewById(R.id.profile_image); + profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); profileTypeView = (ImageView) itemView.findViewById(R.id.profile_type); timeSourceView = (TextView) itemView.findViewById(R.id.time_source); retweetedByView = (TextView) itemView.findViewById(R.id.retweeted_by); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java index 0af8a0b1c..2ee5cd14e 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java @@ -48,6 +48,7 @@ import org.mariotaku.twidere.R; import org.mariotaku.twidere.activity.AppCompatPreferenceActivity; import org.mariotaku.twidere.activity.iface.IThemedActivity; import org.mariotaku.twidere.util.support.ViewSupport; +import org.mariotaku.twidere.view.ProfileImageView; import org.mariotaku.twidere.view.ShapedImageView; import org.mariotaku.twidere.view.TwidereToolbar; import org.mariotaku.twidere.view.iface.ICustomTypefaceTextView; @@ -124,6 +125,10 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory { final ShapedImageView shapedImageView = (ShapedImageView) view; shapedImageView.setStyle(activity.getCurrentProfileImageStyle()); } + if (view instanceof ProfileImageView) { + final ProfileImageView profileImageView = (ProfileImageView) view; + profileImageView.setOval(activity.getCurrentProfileImageStyle() == ShapedImageView.SHAPE_CIRCLE); + } if (view instanceof TextView && (!(view instanceof ICustomTypefaceTextView))) { final String fontFamily = activity.getCurrentThemeFontFamily(); final TextView textView = (TextView) view; @@ -165,8 +170,8 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory { // View context is derived from ActionBar and it's light theme, so we use contrast color final int actionBarColor = activity.getCurrentThemeColor(); final int actionBarTheme = ThemeUtils.getActionBarThemeResource(activity.getThemeResourceId(), actionBarColor); - accentColor = ThemeUtils.getColorFromAttribute(viewContext,android.R.attr.colorForeground, 0); - noTintColor = ThemeUtils.getColorFromAttribute(viewContext,android.R.attr.colorBackground, 0); + accentColor = ThemeUtils.getColorFromAttribute(viewContext, android.R.attr.colorForeground, 0); + noTintColor = ThemeUtils.getColorFromAttribute(viewContext, android.R.attr.colorBackground, 0); backgroundTintColor = accentColor; backgroundColorApprox = Color.WHITE; isColorTint = false; diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ProfileImageView.java b/twidere/src/main/java/org/mariotaku/twidere/view/ProfileImageView.java new file mode 100644 index 000000000..5191e3a57 --- /dev/null +++ b/twidere/src/main/java/org/mariotaku/twidere/view/ProfileImageView.java @@ -0,0 +1,42 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.view; + +import android.content.Context; +import android.util.AttributeSet; + +import com.makeramen.roundedimageview.RoundedImageView; + +/** + * Created by mariotaku on 15/6/6. + */ +public class ProfileImageView extends RoundedImageView { + public ProfileImageView(final Context context) { + super(context); + } + + public ProfileImageView(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + + public ProfileImageView(final Context context, final AttributeSet attrs, final int defStyle) { + super(context, attrs, defStyle); + } +} diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java index 3119efe1c..c6762e52a 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/StatusViewHolder.java @@ -15,8 +15,6 @@ import android.view.View.OnLongClickListener; import android.widget.ImageView; import android.widget.TextView; -import com.makeramen.roundedimageview.RoundedImageView; - import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.R; import org.mariotaku.twidere.adapter.iface.ContentCardClickListener; @@ -39,7 +37,6 @@ import org.mariotaku.twidere.view.CardMediaContainer; import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener; import org.mariotaku.twidere.view.ForegroundColorView; import org.mariotaku.twidere.view.NameView; -import org.mariotaku.twidere.view.ShapedImageView; import org.mariotaku.twidere.view.ShortTimeView; import org.mariotaku.twidere.view.iface.IColorLabelView; @@ -60,7 +57,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi private final IStatusesAdapter adapter; private final ImageView replyRetweetIcon; - private final RoundedImageView profileImageView; + private final ImageView profileImageView; private final ImageView profileTypeView; private final ImageView extraTypeView; private final TextView textView; @@ -82,7 +79,7 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi super(itemView); this.adapter = adapter; itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content); - profileImageView = (RoundedImageView) itemView.findViewById(R.id.profile_image); + profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); profileTypeView = (ImageView) itemView.findViewById(R.id.profile_type); extraTypeView = (ImageView) itemView.findViewById(R.id.extra_type); textView = (TextView) itemView.findViewById(R.id.text); @@ -634,7 +631,6 @@ public class StatusViewHolder extends ViewHolder implements Constants, OnClickLi setTextSize(adapter.getTextSize()); mediaPreview.setStyle(adapter.getMediaPreviewStyle()); // profileImageView.setStyle(adapter.getProfileImageStyle()); - profileImageView.setOval(adapter.getProfileImageStyle() == ShapedImageView.SHAPE_CIRCLE); actionButtons.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE); itemMenu.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE); diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserListViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserListViewHolder.java index 12d110760..2516ea382 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserListViewHolder.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserListViewHolder.java @@ -23,6 +23,7 @@ import android.content.Context; import android.support.v7.widget.RecyclerView.ViewHolder; import android.text.TextUtils; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import org.mariotaku.twidere.R; @@ -32,7 +33,6 @@ import org.mariotaku.twidere.model.ParcelableUserList; import org.mariotaku.twidere.util.MediaLoaderWrapper; import org.mariotaku.twidere.util.UserColorNameManager; import org.mariotaku.twidere.util.Utils; -import org.mariotaku.twidere.view.ShapedImageView; import org.mariotaku.twidere.view.iface.IColorLabelView; import java.util.Locale; @@ -45,7 +45,7 @@ public class UserListViewHolder extends ViewHolder implements View.OnClickListen private final IUserListsAdapter adapter; private final IColorLabelView itemContent; - private final ShapedImageView profileImageView; + private final ImageView profileImageView; private final TextView nameView; private final TextView createdByView; private final TextView descriptionView; @@ -58,7 +58,7 @@ public class UserListViewHolder extends ViewHolder implements View.OnClickListen super(itemView); itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content); this.adapter = adapter; - profileImageView = (ShapedImageView) itemView.findViewById(R.id.profile_image); + profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); nameView = (TextView) itemView.findViewById(R.id.name); createdByView = (TextView) itemView.findViewById(R.id.created_by); descriptionView = (TextView) itemView.findViewById(R.id.description); @@ -125,7 +125,6 @@ public class UserListViewHolder extends ViewHolder implements View.OnClickListen public void setupViewOptions() { setTextSize(adapter.getTextSize()); - profileImageView.setStyle(adapter.getProfileImageStyle()); } public void setTextSize(final float textSize) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserViewHolder.java b/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserViewHolder.java index ae3ca7915..f060b84d1 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserViewHolder.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/holder/UserViewHolder.java @@ -46,7 +46,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon private final IUsersAdapter adapter; private final IColorLabelView itemContent; - private final ShapedImageView profileImageView; + private final ImageView profileImageView; private final ImageView profileTypeView; private final TextView nameView, screenNameView, descriptionView, locationView, urlView, statusesCountView, followersCountView, friendsCountView; @@ -57,7 +57,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon super(itemView); this.adapter = adapter; itemContent = (IColorLabelView) itemView.findViewById(R.id.item_content); - profileImageView = (ShapedImageView) itemView.findViewById(R.id.profile_image); + profileImageView = (ImageView) itemView.findViewById(R.id.profile_image); profileTypeView = (ImageView) itemView.findViewById(R.id.profile_type); nameView = (TextView) itemView.findViewById(R.id.name); screenNameView = (TextView) itemView.findViewById(R.id.screen_name); @@ -104,7 +104,7 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon } } - public ShapedImageView getProfileImageView() { + public ImageView getProfileImageView() { return profileImageView; } @@ -157,7 +157,6 @@ public class UserViewHolder extends ViewHolder implements OnClickListener, OnLon public void setupViewOptions() { setTextSize(adapter.getTextSize()); - profileImageView.setStyle(adapter.getProfileImageStyle()); } public interface UserClickListener extends ContentCardClickListener { diff --git a/twidere/src/main/res/layout/card_item_message_conversation_incoming.xml b/twidere/src/main/res/layout/card_item_message_conversation_incoming.xml index 5344ed5b3..c059baeb0 100644 --- a/twidere/src/main/res/layout/card_item_message_conversation_incoming.xml +++ b/twidere/src/main/res/layout/card_item_message_conversation_incoming.xml @@ -23,7 +23,7 @@ android:layout_height="wrap_content" android:padding="8dp"> - - - - - - - - - - -