mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 06:25:14 +01:00
Bug fixes
This commit is contained in:
parent
e5def002f7
commit
d03fa95568
9 changed files with 67 additions and 42 deletions
|
@ -80,7 +80,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 371
|
||||
versionName "1.9.5"
|
||||
versionCode 372
|
||||
versionName "1.9.6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.ArrayList;
|
|||
|
||||
public class BaseContactsSearchAdapter extends BaseFragmentAdapter {
|
||||
|
||||
protected ArrayList<TLRPC.User> globalSearch;
|
||||
protected ArrayList<TLRPC.User> globalSearch = new ArrayList<TLRPC.User>();
|
||||
private long reqId = 0;
|
||||
private int lastReqId;
|
||||
protected String lastFoundUsername = null;
|
||||
|
@ -29,7 +29,7 @@ public class BaseContactsSearchAdapter extends BaseFragmentAdapter {
|
|||
ConnectionsManager.getInstance().cancelRpc(reqId, true);
|
||||
reqId = 0;
|
||||
}
|
||||
globalSearch = null;
|
||||
globalSearch.clear();
|
||||
lastReqId = 0;
|
||||
notifyDataSetChanged();
|
||||
return;
|
||||
|
|
|
@ -36,17 +36,21 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
private ArrayList<TLRPC.User> searchResult;
|
||||
private ArrayList<CharSequence> searchResultNames;
|
||||
private Timer searchTimer;
|
||||
private boolean allowUsernameSearch;
|
||||
|
||||
public ContactsActivitySearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1) {
|
||||
public ContactsActivitySearchAdapter(Context context, HashMap<Integer, TLRPC.User> arg1, boolean usernameSearch) {
|
||||
mContext = context;
|
||||
ignoreUsers = arg1;
|
||||
allowUsernameSearch = usernameSearch;
|
||||
}
|
||||
|
||||
public void searchDialogs(final String query) {
|
||||
if (query == null) {
|
||||
searchResult = null;
|
||||
searchResultNames = null;
|
||||
queryServerSearch(null);
|
||||
searchResult.clear();
|
||||
searchResultNames.clear();
|
||||
if (allowUsernameSearch) {
|
||||
queryServerSearch(null);
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
try {
|
||||
|
@ -76,7 +80,9 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
queryServerSearch(query);
|
||||
if (allowUsernameSearch) {
|
||||
queryServerSearch(query);
|
||||
}
|
||||
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
|
||||
contactsCopy.addAll(ContactsController.getInstance().contacts);
|
||||
Utilities.searchQueue.postRunnable(new Runnable() {
|
||||
|
@ -128,13 +134,13 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return i != (searchResult == null ? 0 : searchResult.size());
|
||||
return i != searchResult.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
int count = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int count = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (globalCount != 0) {
|
||||
count += globalCount + 1;
|
||||
}
|
||||
|
@ -142,8 +148,8 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
}
|
||||
|
||||
public boolean isGlobalSearch(int i) {
|
||||
int localCount = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return false;
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
|
@ -154,8 +160,8 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public TLRPC.User getItem(int i) {
|
||||
int localCount = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return searchResult.get(i);
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
|
@ -176,7 +182,7 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (i == (searchResult == null ? 0 : searchResult.size())) {
|
||||
if (i == searchResult.size()) {
|
||||
if (view == null) {
|
||||
view = new SettingsSectionLayout(mContext);
|
||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||
|
@ -192,7 +198,12 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
if (user != null) {
|
||||
CharSequence username = null;
|
||||
if (i > searchResult.size() && user.username != null) {
|
||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||
try {
|
||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||
} catch (Exception e) {
|
||||
username = user.username;
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
((ChatOrUserCell) view).setData(user, null, null, i < searchResult.size() ? searchResultNames.get(i) : null, username);
|
||||
|
@ -211,7 +222,7 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == (searchResult == null ? 0 : searchResult.size())) {
|
||||
if (i == searchResult.size()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -224,6 +235,6 @@ public class ContactsActivitySearchAdapter extends BaseContactsSearchAdapter {
|
|||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (searchResult == null || searchResult.size() == 0) && (globalSearch == null || globalSearch.isEmpty());
|
||||
return searchResult.isEmpty() && globalSearch.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -477,6 +477,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
args.putBoolean("destroyAfterSelect", true);
|
||||
args.putBoolean("usersAsSections", true);
|
||||
args.putBoolean("returnAsResult", true);
|
||||
args.putBoolean("allowUsernameSearch", false);
|
||||
if (chat_id > 0) {
|
||||
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
private String inviteText;
|
||||
private boolean updatingInviteText = false;
|
||||
private boolean allowUsernameSearch = true;
|
||||
private ContactsActivityDelegate delegate;
|
||||
|
||||
public static interface ContactsActivityDelegate {
|
||||
|
@ -92,11 +93,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatCreated);
|
||||
if (arguments != null) {
|
||||
onlyUsers = getArguments().getBoolean("onlyUsers", false);
|
||||
destroyAfterSelect = getArguments().getBoolean("destroyAfterSelect", false);
|
||||
usersAsSections = getArguments().getBoolean("usersAsSections", false);
|
||||
returnAsResult = getArguments().getBoolean("returnAsResult", false);
|
||||
createSecretChat = getArguments().getBoolean("createSecretChat", false);
|
||||
destroyAfterSelect = arguments.getBoolean("destroyAfterSelect", false);
|
||||
usersAsSections = arguments.getBoolean("usersAsSections", false);
|
||||
returnAsResult = arguments.getBoolean("returnAsResult", false);
|
||||
createSecretChat = arguments.getBoolean("createSecretChat", false);
|
||||
selectAlertString = arguments.getString("selectAlertString");
|
||||
allowUsernameSearch = arguments.getBoolean("allowUsernameSearch", true);
|
||||
}
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
|
@ -200,7 +202,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
emptyTextView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
|
||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers);
|
||||
searchListViewAdapter = new ContactsActivitySearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
|
||||
|
||||
listView = (PinnedHeaderListView)fragmentView.findViewById(R.id.listView);
|
||||
listView.setEmptyView(emptyTextView);
|
||||
|
|
|
@ -787,6 +787,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
|
||||
public void fixLayout() {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (actionBarLayout == null) {
|
||||
return;
|
||||
}
|
||||
actionBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
|
|
@ -619,8 +619,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
private Context mContext;
|
||||
private Timer searchTimer;
|
||||
private ArrayList<TLObject> searchResult;
|
||||
private ArrayList<CharSequence> searchResultNames;
|
||||
private ArrayList<TLObject> searchResult = new ArrayList<TLObject>();
|
||||
private ArrayList<CharSequence> searchResultNames = new ArrayList<CharSequence>();
|
||||
|
||||
public MessagesAdapter(Context context) {
|
||||
mContext = context;
|
||||
|
@ -656,8 +656,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
public boolean isGlobalSearch(int i) {
|
||||
if (searching && searchWas) {
|
||||
int localCount = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return false;
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
|
@ -669,8 +669,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
public void searchDialogs(final String query) {
|
||||
if (query == null) {
|
||||
searchResult = null;
|
||||
searchResultNames = null;
|
||||
searchResult.clear();
|
||||
searchResultNames.clear();
|
||||
queryServerSearch(null);
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
|
@ -710,14 +710,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return !(searching && searchWas) || i != (searchResult == null ? 0 : searchResult.size());
|
||||
return !(searching && searchWas) || i != searchResult.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (searching && searchWas) {
|
||||
int count = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int count = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (globalCount != 0) {
|
||||
count += globalCount + 1;
|
||||
}
|
||||
|
@ -741,8 +741,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public TLObject getItem(int i) {
|
||||
if (searching && searchWas) {
|
||||
int localCount = searchResult == null ? 0 : searchResult.size();
|
||||
int globalCount = globalSearch == null ? 0 : globalSearch.size();
|
||||
int localCount = searchResult.size();
|
||||
int globalCount = globalSearch.size();
|
||||
if (i >= 0 && i < localCount) {
|
||||
return searchResult.get(i);
|
||||
} else if (i > localCount && i <= globalCount + localCount) {
|
||||
|
@ -776,7 +776,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (searching && searchWas) {
|
||||
if (i == (searchResult == null ? 0 : searchResult.size())) {
|
||||
if (i == searchResult.size()) {
|
||||
if (view == null) {
|
||||
view = new SettingsSectionLayout(mContext);
|
||||
((SettingsSectionLayout) view).setText(LocaleController.getString("GlobalSearch", R.string.GlobalSearch));
|
||||
|
@ -805,8 +805,13 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
|
||||
CharSequence username = null;
|
||||
if (i > searchResult.size() && user.username != null) {
|
||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||
if (i > searchResult.size() && user != null && user.username != null) {
|
||||
try {
|
||||
username = Html.fromHtml(String.format("<font color=\"#357aa8\">@%s</font>%s", user.username.substring(0, lastFoundUsername.length()), user.username.substring(lastFoundUsername.length())));
|
||||
} catch (Exception e) {
|
||||
username = user.username;
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
((ChatOrUserCell) view).setData(user, chat, encryptedChat, i < searchResult.size() ? searchResultNames.get(i) : null, username);
|
||||
|
@ -847,7 +852,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (searching && searchWas) {
|
||||
if (i == (searchResult == null ? 0 : searchResult.size())) {
|
||||
if (i == searchResult.size()) {
|
||||
return 3;
|
||||
}
|
||||
return 2;
|
||||
|
@ -866,7 +871,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (searching && searchWas) {
|
||||
return (searchResult == null || searchResult.size() == 0) && (globalSearch == null || globalSearch.isEmpty());
|
||||
return searchResult.size() == 0 && globalSearch.isEmpty();
|
||||
}
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
return false;
|
||||
|
|
|
@ -279,6 +279,9 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
|||
int count = listView.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View view = listView.getChildAt(a);
|
||||
if (view.getTag() == null) {
|
||||
continue;
|
||||
}
|
||||
int num = (Integer)view.getTag();
|
||||
if (num < 0 || num >= selectedAlbum.photos.size()) {
|
||||
continue;
|
||||
|
|
|
@ -239,7 +239,7 @@ public class SettingsChangeUsernameActivity extends BaseFragment {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || a == '_')) {
|
||||
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
|
||||
if (alert) {
|
||||
showErrorAlert(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue