From 7b10cb33727fca7012e3ac7e00cc7b9708d0b1cc Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 20 Mar 2015 04:13:01 +0800 Subject: [PATCH] improved quick search bar - open user profile of screen name you typed directly, no need to open search screen added user-friendly error page for protected users --- .../support/QuickSearchBarActivity.java | 59 +++++++++++++++++- .../fragment/support/UserFragment.java | 8 +++ .../main/res/drawable-hdpi/ic_info_locked.png | Bin 0 -> 1230 bytes .../main/res/drawable-mdpi/ic_info_locked.png | Bin 0 -> 781 bytes .../res/drawable-xhdpi/ic_info_locked.png | Bin 0 -> 2041 bytes .../res/drawable-xxhdpi/ic_info_locked.png | Bin 0 -> 3249 bytes .../res/layout/fragment_content_pages.xml | 1 + twidere/src/main/res/values/strings.xml | 1 + 8 files changed, 67 insertions(+), 2 deletions(-) create mode 100755 twidere/src/main/res/drawable-hdpi/ic_info_locked.png create mode 100755 twidere/src/main/res/drawable-mdpi/ic_info_locked.png create mode 100755 twidere/src/main/res/drawable-xhdpi/ic_info_locked.png create mode 100755 twidere/src/main/res/drawable-xxhdpi/ic_info_locked.png diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java index 54342d546..723d5cfe2 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/QuickSearchBarActivity.java @@ -417,6 +417,10 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On return ITEM_VIEW_TYPE; } + public ParcelableUser getUser() { + return mUser; + } + @Override public void onItemClick(QuickSearchBarActivity activity, int position) { Utils.openUserProfile(activity, mUser, null); @@ -440,12 +444,53 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On final String nick = getUserNickname(context, user.id); text1.setText(TextUtils.isEmpty(nick) ? user.name : adapter.isNicknameOnly() ? nick : context.getString(R.string.name_with_nickname, user.name, nick)); + text2.setVisibility(View.VISIBLE); text2.setText("@" + user.screen_name); + icon.clearColorFilter(); loader.displayProfileImage(icon, user.profile_image_url); - } } + static class UserScreenNameItem extends BaseClickableItem { + + static final int ITEM_VIEW_TYPE = 3; + private final String mScreenName; + private final long mAccountId; + + public UserScreenNameItem(String screenName, long accountId) { + mScreenName = screenName; + mAccountId = accountId; + } + + @Override + public int getItemViewType() { + return ITEM_VIEW_TYPE; + } + + @Override + public void onItemClick(QuickSearchBarActivity activity, int position) { + Utils.openUserProfile(activity, mAccountId, -1, mScreenName, null); + activity.finish(); + } + + @Override + public final int getItemLayoutResource() { + return R.layout.list_item_suggestion_user; + } + + @Override + public void bindView(SuggestionsAdapter adapter, View view, int position) { + final ImageLoaderWrapper loader = adapter.getImageLoader(); + final ImageView icon = (ImageView) view.findViewById(android.R.id.icon); + final TextView text1 = (TextView) view.findViewById(android.R.id.text1); + final TextView text2 = (TextView) view.findViewById(android.R.id.text2); + text1.setText('@' + mScreenName); + text2.setVisibility(View.GONE); + icon.setColorFilter(text1.getCurrentTextColor(), Mode.SRC_ATOP); + loader.cancelDisplayTask(icon); + icon.setImageResource(R.drawable.ic_action_user); + } + } public static class SuggestionsAdapter extends BaseAdapter { @@ -581,9 +626,19 @@ public class QuickSearchBarActivity extends ThemedFragmentActivity implements On CachedUsers.COLUMNS, selection != null ? selection.getSQL() : null, selectionArgs, orderBy.getSQL()); final CachedIndices usersIndices = new CachedIndices(usersCursor); + final int screenNamePos = result.size(); + boolean hasName = false; for (int i = 0, j = Math.min(5, usersCursor.getCount()); i < j; i++) { usersCursor.moveToPosition(i); - result.add(new UserSuggestionItem(usersCursor, usersIndices, mAccountId)); + final UserSuggestionItem userSuggestionItem = new UserSuggestionItem(usersCursor, usersIndices, mAccountId); + final ParcelableUser user = userSuggestionItem.getUser(); + result.add(userSuggestionItem); + if (user.screen_name.equalsIgnoreCase(mQuery)) { + hasName = true; + } + } + if (!hasName) { + result.add(screenNamePos, new UserScreenNameItem(mQuery, mAccountId)); } usersCursor.close(); } else { diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java index 0a96f3516..40fffe64f 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/UserFragment.java @@ -338,6 +338,13 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener mPagesErrorContainer.setVisibility(View.VISIBLE); final String displayName = UserColorNameUtils.getDisplayName(getActivity(), user); mPagesErrorText.setText(getString(R.string.blocked_by_user_summary, displayName)); + mPagesErrorIcon.setImageResource(R.drawable.ic_info_error_generic); + mPagesContent.setVisibility(View.GONE); + } else if (!relationship.isSourceFollowingTarget()) { + mPagesErrorContainer.setVisibility(View.VISIBLE); + final String displayName = UserColorNameUtils.getDisplayName(getActivity(), user); + mPagesErrorText.setText(getString(R.string.user_protected_summary, displayName)); + mPagesErrorIcon.setImageResource(R.drawable.ic_info_locked); mPagesContent.setVisibility(View.GONE); } else { mPagesErrorContainer.setVisibility(View.GONE); @@ -1147,6 +1154,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener mUuckyFooter = headerView.findViewById(R.id.uucky_footer); mPagesContent = view.findViewById(R.id.pages_content); mPagesErrorContainer = view.findViewById(R.id.pages_error_container); + mPagesErrorIcon = (ImageView) view.findViewById(R.id.pages_error_icon); mPagesErrorText = (TextView) view.findViewById(R.id.pages_error_text); } diff --git a/twidere/src/main/res/drawable-hdpi/ic_info_locked.png b/twidere/src/main/res/drawable-hdpi/ic_info_locked.png new file mode 100755 index 0000000000000000000000000000000000000000..284da296c3625465b49ccaea11a99ad3b98a67c7 GIT binary patch literal 1230 zcmV;<1Tp)GP)!`LqkIg zm67Alc*QxZ)~?U0b6#=AaU(bF_w46pBM*ARH#T**=^Jl&&}b0>N4@BRVE2LxUUYP^ z08jc60E`7ukY#!M=P>~I(UXe;IO0v$02HDqs7+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UBIR(}B&S^yw3gzvZu zEbK2pEDJh7+YC0~#O=kOoKtqyf?ZX@H=nVp8SH zpEbdp$T|Hws)C#niJG#=n9S%0XsY+vR4byXl6*3<0h*d7^cIU%5RdLNAZRF&XxneU zHi?pkFuDP%@&Jz6;YL@v%8hn71|Y9GssUPp81RmD?(~X-4tm9%)_DgI3tFQYpdt_W z)Lq`x0nqWLyL<}BtBhiRfEYAAVy_eJ^@t{j5k@aSO$6BE1--mr4O6V@$N&z}Tk=VUQ4A0OE9ouyB#dH!q6n}??*uEY0Yr+U7a%797TIjviNqSvzW|^42#`}TEGlwtB7R)FZ#Iu0BpApke3kyzQR#r2JYRY0oz#;eAH*?=8d86$X0H|pplGQQyGTH)iiX_9|;N_Xz6MPxJ zaW0nz|zfHXiFVD$Y5 X%{fF+-EMeh00000NkvXXu0mjfHUOL9 literal 0 HcmV?d00001 diff --git a/twidere/src/main/res/drawable-xxhdpi/ic_info_locked.png b/twidere/src/main/res/drawable-xxhdpi/ic_info_locked.png new file mode 100755 index 0000000000000000000000000000000000000000..d9480ae9840e3cca774bd9e52705998fe8bc5fad GIT binary patch literal 3249 zcmV;i3{LZjP)G0000blNklC3hp6=?N>8|H`L)tF-(V@ye2B1p|^tD7{b zu4&UKq&9()*LjPRoNTA<{|Hd9SXbSozxtEs{mRe$R@+f8Ngc)VPIQj5oZ)0Um91Rs z9~qwUq@Vkp`555vmAu6j-r*F9)k{6+`@ZF8+A+Y&o!}xD`DZ%}#$Wu{_k7QON1dFb zOWx@|?FYW>Dmx6y4p;fIANaJ><>LgrvaaS^5B2h9Tv9u?B!VhDB;CLT!gV$MX-YgQ7m8@J_3n@nAE%sY?`)>zg0GRN3ACkA& zjF!ZNyw#aEB~>#Pu$cZ0!K2 zyVHrXX4RA(31v02vQBiT)3_j7gJ+nW3tuA?rOZ-m3qEPx5u=2s)a^Bvz)Y zA(beoN-Qna)Rjuq6s%0DuBs^bx%d0k)(epHSvL#1ri?3EiFpkaRIN-?7d3e+(J^g8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H-btvd5%hGii^T{DvbPfEl;D+FhR0HVoRHbC;{#Zib^F08RUR%q2eN0neC{+KN(B zp7FrTd%92403@k_syNkAc_HE jfG7rt0iqZn28jL-aQvO0*X*R>00000NkvXXu0mjfU-Kv@ literal 0 HcmV?d00001 diff --git a/twidere/src/main/res/layout/fragment_content_pages.xml b/twidere/src/main/res/layout/fragment_content_pages.xml index a23cb1049..bd0f4f052 100644 --- a/twidere/src/main/res/layout/fragment_content_pages.xml +++ b/twidere/src/main/res/layout/fragment_content_pages.xml @@ -58,6 +58,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" + android:padding="@dimen/element_spacing_large" android:orientation="vertical" android:visibility="gone"> diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index 37f9a61a0..531a76c3f 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -732,5 +732,6 @@ Import/Export settings Twidere took part in some research project, join these projects will make Twidere and some other application better. No tab + You need to send follow request to this protected user to see tweets \ No newline at end of file