diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 889f97a..86dec9f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -188,7 +188,8 @@ }); ActionBarMenu menu = actionBar.createMenu(); - ActionBarMenuItem item = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + ActionBarMenuItem item = menu.addItem(search_button, R.drawable.ic_ab_search).setIsSearchField(true) + .setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; @@ -247,7 +248,7 @@ //隐藏原来的标题栏,使用自己的标题栏 actionBar.setVisibility(View.GONE); View titleView = LayoutInflater.from(context).inflate(R.layout.view_title, (ViewGroup) fragmentView, false); - ((TextView)titleView.findViewById(R.id.tv_title)).setText(LocaleController.getString("Contacts", R.string.Contacts)); + ((TextView) titleView.findViewById(R.id.tv_title)).setText(LocaleController.getString("Contacts", R.string.Contacts)); //新增联系人 ImageView addImg = (ImageView) titleView.findViewById(R.id.iv_right); addImg.setImageResource(R.drawable.add_user); @@ -260,12 +261,12 @@ }); ((ViewGroup) fragmentView).addView(titleView); ((ViewGroup) fragmentView).addView(frameLayout); - ((FrameLayout.LayoutParams)frameLayout.getLayoutParams()).topMargin = AndroidUtilities.dp(56 +48); + ((FrameLayout.LayoutParams) frameLayout.getLayoutParams()).topMargin = AndroidUtilities.dp(56 + 48); //添加搜索欄 View searchView = LayoutInflater.from(context).inflate(R.layout.view_search, (ViewGroup) fragmentView, false); ((ViewGroup) fragmentView).addView(searchView); - ((FrameLayout.LayoutParams)searchView.getLayoutParams()).topMargin = AndroidUtilities.dp(56 ); - final EditText edView = (EditText)fragmentView.findViewById(R.id.et_search); + ((FrameLayout.LayoutParams) searchView.getLayoutParams()).topMargin = AndroidUtilities.dp(56); + final EditText edView = (EditText) fragmentView.findViewById(R.id.et_search); edView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -273,7 +274,30 @@ @Override public void onTextChanged(CharSequence s, int start, int before, int count) { -// textchange(edView); +// + String text = s.toString(); + if (text.length() != 0) { + searchWas = true; + if (listView != null) { + listView.setAdapter(searchListViewAdapter); + searchListViewAdapter.notifyDataSetChanged(); + listView.setFastScrollVisible(false); + listView.setVerticalScrollBarEnabled(true); + } + if (emptyView != null) { + emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult)); + } + searchListViewAdapter.searchDialogs(text); + } else { + searchListViewAdapter.searchDialogs(null); + searching = false; + searchWas = false; + listView.setAdapter(listViewAdapter); + listViewAdapter.notifyDataSetChanged(); + listView.setFastScrollVisible(true); + listView.setVerticalScrollBarEnabled(false); + } + } @Override @@ -351,7 +375,8 @@ Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, ContactsController.getInstance().getInviteText()); - getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("InviteFriends", R.string.InviteFriends)), 500); + getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString + ("InviteFriends", R.string.InviteFriends)), 500); } catch (Exception e) { FileLog.e(e); } @@ -377,7 +402,8 @@ if (!MessagesController.isFeatureEnabled("broadcast_create", ContactsActivity.this)) { return; } - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", + Activity.MODE_PRIVATE); if (!BuildVars.DEBUG_VERSION && preferences.getBoolean("channel_intro", false)) { Bundle args = new Bundle(); args.putInt("step", 0); @@ -467,7 +493,8 @@ } if (user.bot && user.bot_nochats && !addingToChannel) { try { - Toast.makeText(getParentActivity(), LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), Toast.LENGTH_SHORT).show(); + Toast.makeText(getParentActivity(), LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), + Toast.LENGTH_SHORT).show(); } catch (Exception e) { FileLog.e(e); } @@ -478,7 +505,8 @@ String message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)); EditText editText = null; if (!user.bot && needForwardCount) { - message = String.format("%s\n\n%s", message, LocaleController.getString("AddToTheGroupForwardCount", R.string.AddToTheGroupForwardCount)); + message = String.format("%s\n\n%s", message, LocaleController.getString("AddToTheGroupForwardCount", R.string + .AddToTheGroupForwardCount)); editText = new EditText(getParentActivity()); editText.setTextSize(18); editText.setText("50"); @@ -635,13 +663,14 @@ listViewAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.updateInterfaces) { - int mask = (Integer)args[0]; - if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { + int mask = (Integer) args[0]; + if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & + MessagesController.UPDATE_MASK_STATUS) != 0) { updateVisibleRows(mask); } } else if (id == NotificationCenter.encryptedChatCreated) { if (createSecretChat && creatingChat) { - TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0]; + TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0]; Bundle args2 = new Bundle(); args2.putInt("enc_id", encryptedChat.id); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); @@ -691,53 +720,61 @@ } }; - return new ThemeDescription[]{ - new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite), + return new ThemeDescription[]{new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme + .key_windowBackgroundWhite), new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault), new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault), - new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon), - new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle), - new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector), - new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch), - new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder), + new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme + .key_actionBarDefaultIcon), new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, + null, null, Theme.key_actionBarDefaultTitle), new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, + null, null, null, null, Theme.key_actionBarDefaultSelector), new ThemeDescription(actionBar, ThemeDescription + .FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch), new ThemeDescription(actionBar, + ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder), new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector), - new ThemeDescription(listView, ThemeDescription.FLAG_SECTIONS, new Class[]{LetterSectionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4), + new ThemeDescription(listView, ThemeDescription.FLAG_SECTIONS, new Class[]{LetterSectionCell.class}, new + String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4), new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider), new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder), - new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollActive), - new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollInactive), - new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollText), + new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollActive), new + ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollInactive), new + ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollText), - new ThemeDescription(listView, 0, new Class[]{UserCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), - new ThemeDescription(listView, 0, new Class[]{UserCell.class}, new String[]{"statusColor"}, null, null, сellDelegate, Theme.key_windowBackgroundWhiteGrayText), - new ThemeDescription(listView, 0, new Class[]{UserCell.class}, new String[]{"statusOnlineColor"}, null, null, сellDelegate, Theme.key_windowBackgroundWhiteBlueText), - new ThemeDescription(listView, 0, new Class[]{UserCell.class}, null, new Drawable[]{Theme.avatar_photoDrawable, Theme.avatar_broadcastDrawable}, null, Theme.key_avatar_text), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundRed), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundOrange), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundViolet), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundGreen), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundCyan), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundBlue), - new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundPink), + new ThemeDescription(listView, 0, new Class[]{UserCell.class}, new String[]{"nameTextView"}, null, null, null, Theme + .key_windowBackgroundWhiteBlackText), new ThemeDescription(listView, 0, new Class[]{UserCell.class}, new + String[]{"statusColor"}, null, null, сellDelegate, Theme.key_windowBackgroundWhiteGrayText), new ThemeDescription + (listView, 0, new Class[]{UserCell.class}, new String[]{"statusOnlineColor"}, null, null, сellDelegate, Theme + .key_windowBackgroundWhiteBlueText), new ThemeDescription(listView, 0, new Class[]{UserCell.class}, null, new + Drawable[]{Theme.avatar_photoDrawable, Theme.avatar_broadcastDrawable}, null, Theme.key_avatar_text), new + ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundRed), new ThemeDescription(null, 0, + null, null, null, сellDelegate, Theme.key_avatar_backgroundOrange), new ThemeDescription(null, 0, null, null, null, + сellDelegate, Theme.key_avatar_backgroundViolet), new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme + .key_avatar_backgroundGreen), new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme + .key_avatar_backgroundCyan), new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme + .key_avatar_backgroundBlue), new ThemeDescription(null, 0, null, null, null, сellDelegate, Theme.key_avatar_backgroundPink), - new ThemeDescription(listView, 0, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText), - new ThemeDescription(listView, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon), + new ThemeDescription(listView, 0, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme + .key_windowBackgroundWhiteBlackText), new ThemeDescription(listView, 0, new Class[]{TextCell.class}, new + String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayIcon), - new ThemeDescription(listView, 0, new Class[]{GraySectionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText2), - new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{GraySectionCell.class}, null, null, null, Theme.key_graySection), + new ThemeDescription(listView, 0, new Class[]{GraySectionCell.class}, new String[]{"textView"}, null, null, null, Theme + .key_windowBackgroundWhiteGrayText2), new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, + new Class[]{GraySectionCell.class}, null, null, null, Theme.key_graySection), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_groupDrawable, Theme.dialogs_broadcastDrawable, Theme.dialogs_botDrawable}, null, Theme.key_chats_nameIcon), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedCheckDrawable}, null, Theme.key_chats_verifiedCheck), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedDrawable}, null, Theme.key_chats_verifiedBackground), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_offlinePaint, null, null, Theme.key_windowBackgroundWhiteGrayText3), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_onlinePaint, null, null, Theme.key_windowBackgroundWhiteBlueText3), - new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_namePaint, null, null, Theme.key_chats_name), - }; + new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_groupDrawable, + Theme.dialogs_broadcastDrawable, Theme.dialogs_botDrawable}, null, Theme.key_chats_nameIcon), new + ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme + .dialogs_verifiedCheckDrawable}, null, Theme.key_chats_verifiedCheck), new ThemeDescription(listView, 0, new + Class[]{ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedDrawable}, null, Theme + .key_chats_verifiedBackground), new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme + .dialogs_offlinePaint, null, null, Theme.key_windowBackgroundWhiteGrayText3), new ThemeDescription(listView, 0, new + Class[]{ProfileSearchCell.class}, Theme.dialogs_onlinePaint, null, null, Theme.key_windowBackgroundWhiteBlueText3), new + ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_namePaint, null, null, Theme + .key_chats_name),}; } }