From acab89d24fd7eab73dcfc7442dd12fd02b7084b1 Mon Sep 17 00:00:00 2001 From: bit-world Date: Tue, 23 Feb 2021 23:17:01 +0300 Subject: [PATCH 01/18] Invite and search users feature --- Houseclub/src/main/AndroidManifest.xml | 1 + .../houseclub/api/methods/InviteToApp.java | 26 ++ .../houseclub/api/methods/SearchPeople.java | 30 ++ .../fragments/InviteListFragment.java | 273 ++++++++++++++++++ .../fragments/SearchListFragment.java | 104 +++++++ .../drawable/ic_baseline_person_add_24.xml | 10 + .../main/res/drawable/ic_search_people.xml | 15 + .../src/main/res/layout/search_panel.xml | 21 ++ Houseclub/src/main/res/menu/menu_home.xml | 32 ++ Houseclub/src/main/res/values-ru/strings.xml | 77 +++++ Houseclub/src/main/res/values/strings.xml | 13 +- 11 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java create mode 100644 Houseclub/src/main/res/drawable/ic_baseline_person_add_24.xml create mode 100644 Houseclub/src/main/res/drawable/ic_search_people.xml create mode 100644 Houseclub/src/main/res/layout/search_panel.xml create mode 100644 Houseclub/src/main/res/menu/menu_home.xml create mode 100644 Houseclub/src/main/res/values-ru/strings.xml diff --git a/Houseclub/src/main/AndroidManifest.xml b/Houseclub/src/main/AndroidManifest.xml index 890f7467..2773dca2 100644 --- a/Houseclub/src/main/AndroidManifest.xml +++ b/Houseclub/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java new file mode 100644 index 00000000..c1ae7544 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java @@ -0,0 +1,26 @@ +package me.grishka.houseclub.api.methods; + +import me.grishka.houseclub.api.BaseResponse; +import me.grishka.houseclub.api.ClubhouseAPIRequest; +import me.grishka.houseclub.api.model.FullUser; + +public class InviteToApp extends ClubhouseAPIRequest { + + public InviteToApp(String name, String phone_number, String message){ + super("POST", "invite_to_app", BaseResponse.class); + requestBody=new InviteToApp.Body(name, phone_number, message); + } + + private static class Body{ + public String name; + public String phone_number; + public String message; + + public Body(String name, String phone_number, String message){ + this.name=name; + this.phone_number=phone_number; + this.message=message; + } + } + +} \ No newline at end of file diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java new file mode 100644 index 00000000..29ae9aa7 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java @@ -0,0 +1,30 @@ +package me.grishka.houseclub.api.methods; + +import java.util.List; + +import me.grishka.houseclub.api.ClubhouseAPIRequest; +import me.grishka.houseclub.api.model.FullUser; + +public class SearchPeople extends ClubhouseAPIRequest { + + public SearchPeople(String query) { + super("POST", "search_users", Resp.class); + requestBody = new Body(query); + } + + private static class Body { + public boolean cofollowsOnly; + public boolean followingOnly; + public boolean followersOnly; + public String query; + + public Body(String query) { + this.query = query; + } + } + + public static class Resp { + public List users; + public int count; + } +} \ No newline at end of file diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java new file mode 100644 index 00000000..b8c8cb99 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -0,0 +1,273 @@ +package me.grishka.houseclub.fragments; + +import android.app.AlertDialog; +import android.content.ContentResolver; +import android.content.DialogInterface; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.provider.ContactsContract; +import android.text.TextUtils; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +import me.grishka.appkit.Nav; +import me.grishka.appkit.api.Callback; +import me.grishka.appkit.api.ErrorResponse; +import me.grishka.appkit.api.SimpleCallback; +import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; +import me.grishka.appkit.imageloader.ImageLoaderViewHolder; +import me.grishka.appkit.utils.BindableViewHolder; +import me.grishka.appkit.views.UsableRecyclerView; +import me.grishka.houseclub.R; +import me.grishka.houseclub.api.BaseResponse; +import me.grishka.houseclub.api.methods.InviteToApp; +import me.grishka.houseclub.api.methods.SearchPeople; +import me.grishka.houseclub.api.model.FullUser; + +import static android.Manifest.permission.READ_CONTACTS; + +public class InviteListFragment extends SearchListFragment { + + private InviteListAdapter adapter; + + private static final int REQUEST_READ_CONTACTS = 0; + + public InviteListFragment() { + min_query_lenght = 0; + } + + @Override + protected RecyclerView.Adapter getAdapter(){ + if(adapter==null){ + adapter=new InviteListAdapter(); + } + return adapter; + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { + if (requestCode == REQUEST_READ_CONTACTS) { + if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + getContactList(""); + } + } + } + + private boolean askContactsPermission() { + + if (getContext().checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) { + return true; + } + requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS); + return false; + } + + private void readContacts(String query) { + if (!askContactsPermission()) { + return; + } else { + getContactList(query); + } + } + + private void getContactList(String query) { + + List users = new ArrayList<>(); + int count = 0, limit = 10; + + ContentResolver cr = getContext().getContentResolver(); + Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, + null, null, null, null); + + if ((cur != null ? cur.getCount() : 0) > 0) { + while (cur != null && cur.moveToNext()) { + + String id = cur.getString( + cur.getColumnIndex(ContactsContract.Contacts._ID)); + + String name = cur.getString(cur.getColumnIndex( + ContactsContract.Contacts.DISPLAY_NAME)); + + if (cur.getInt(cur.getColumnIndex( + ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0) { + Cursor pCur = cr.query( + ContactsContract.CommonDataKinds.Phone.CONTENT_URI, + null, + ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", + new String[]{id}, null); + while (pCur.moveToNext()) { + String phoneNo = pCur.getString(pCur.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.NUMBER)); + + if (query.equals("") || ( + Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(name).find() || + Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(phoneNo).find())) { + + FullUser u = new FullUser(); + u.name = name; + u.bio = phoneNo; + users.add(u); + + count++; + if (count > limit) { + pCur.moveToLast(); + cur.moveToLast(); + } + + } + } + pCur.close(); + } + + + } + } + if (cur != null) { + cur.close(); + } + + + data.clear(); + onDataLoaded(users, false); + + } + + + @Override + protected void doLoadData(int offset, int count) { + + if(searchQuery != null) + readContacts(searchQuery); + else + readContacts(""); + + + + } + + + + + + private class InviteListAdapter extends RecyclerView.Adapter implements ImageLoaderRecyclerAdapter { + + @NonNull + @Override + public IviteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ + return new IviteViewHolder(); + } + + @Override + public void onBindViewHolder(@NonNull IviteViewHolder holder, int position){ + holder.bind(data.get(position)); + } + + @Override + public int getItemCount(){ + return data.size(); + } + + @Override + public int getImageCountForItem(int position){ + return data.get(position).photoUrl!=null ? 1 : 0; + } + + @Override + public String getImageURL(int position, int image){ + return data.get(position).photoUrl; + } + } + + private class IviteViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{ + + public TextView name, bio; + public Button followBtn; + public ImageView photo; + private Drawable placeholder=new ColorDrawable(0xFF808080); + + public IviteViewHolder(){ + super(getActivity(), R.layout.user_list_row); + + name=findViewById(R.id.name); + bio=findViewById(R.id.bio); + followBtn=findViewById(R.id.follow_btn); + photo=findViewById(R.id.photo); + } + + @Override + public void onBind(FullUser item){ + name.setText(item.name); + bio.setText(item.bio); + followBtn.setVisibility(View.GONE); + photo.setVisibility(View.GONE); + } + + @Override + public void setImage(int index, Bitmap bitmap){ + photo.setImageBitmap(bitmap); + } + + @Override + public void clearImage(int index){ + photo.setImageDrawable(placeholder); + } + + @Override + public void onClick(){ + + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(R.string.invite_dialog_title); + builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.bio)); + + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new InviteToApp(item.name, item.bio, "") + .wrapProgress(getActivity()) + + .setCallback(new Callback(){ + @Override + public void onSuccess(BaseResponse result){ + Toast.makeText(getContext(), R.string.invite_ok, Toast.LENGTH_SHORT).show(); + } + + @Override + public void onError(ErrorResponse error){ + Toast.makeText(getContext(), getString(R.string.invite_err, ""), Toast.LENGTH_SHORT).show(); + error.showToast(getContext()); + } + }) + .exec(); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }); + + builder.show(); + } + } + + + +} \ No newline at end of file diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java new file mode 100644 index 00000000..70785ed4 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java @@ -0,0 +1,104 @@ +package me.grishka.houseclub.fragments; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.SearchView; + +import me.grishka.appkit.api.SimpleCallback; +import me.grishka.houseclub.R; +import me.grishka.houseclub.api.methods.SearchPeople; + +public class SearchListFragment extends UserListFragment { + + private SearchView searchView; + private SearchView.OnQueryTextListener onQueryTextListener; + + protected static int min_query_lenght = 2; + protected String searchQuery; + private static final long DELAY = 200; + private long timestamp = System.currentTimeMillis(); + + @Override + public void onAttach(Activity activity){ + super.onAttach(activity); + setTitle(R.string.search_people_hint); + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + View search_panel = view.inflate(getContext(), R.layout.search_panel, null); + + searchView = search_panel.findViewById(R.id.searchView); + searchView.setQueryHint(getString(R.string.search_people_hint)); + onQueryTextListener = new OnSearchQueryTextListener(); + + getToolbar().addView(search_panel); + } + + protected void onQueryChanged(String query) { + long currentTimeStamp = System.currentTimeMillis(); + if (currentTimeStamp - timestamp < DELAY) { + timestamp = currentTimeStamp; + return; + } + + if (query == null && min_query_lenght > 0 || query.length() <= min_query_lenght) { + timestamp = currentTimeStamp; + return; + } + timestamp = currentTimeStamp; + searchQuery = query; + loadData(); + } + + private class OnSearchQueryTextListener implements SearchView.OnQueryTextListener { + @Override + public boolean onQueryTextSubmit(String query) { + onQueryChanged(query); + return false; + } + + @Override + public boolean onQueryTextChange(String newText) { + onQueryChanged(newText); + return false; + } + } + + @Override + public void onResume() { + super.onResume(); + + searchView.setOnQueryTextListener(onQueryTextListener); + } + + @Override + public void onPause() { + super.onPause(); + + searchView.setOnQueryTextListener(null); + } + + @Override + protected void doLoadData(int offset, int count) { + if (currentRequest != null) { + currentRequest.cancel(); + } + + currentRequest = new SearchPeople(searchQuery) + .setCallback(new SimpleCallback(this) { + @Override + public void onSuccess(SearchPeople.Resp result) { + currentRequest=null; + data.clear(); + onDataLoaded(result.users, false); + } + }) + .exec(); + } + + +} \ No newline at end of file diff --git a/Houseclub/src/main/res/drawable/ic_baseline_person_add_24.xml b/Houseclub/src/main/res/drawable/ic_baseline_person_add_24.xml new file mode 100644 index 00000000..6656fe91 --- /dev/null +++ b/Houseclub/src/main/res/drawable/ic_baseline_person_add_24.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/Houseclub/src/main/res/drawable/ic_search_people.xml b/Houseclub/src/main/res/drawable/ic_search_people.xml new file mode 100644 index 00000000..927e94a5 --- /dev/null +++ b/Houseclub/src/main/res/drawable/ic_search_people.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/Houseclub/src/main/res/layout/search_panel.xml b/Houseclub/src/main/res/layout/search_panel.xml new file mode 100644 index 00000000..4772412a --- /dev/null +++ b/Houseclub/src/main/res/layout/search_panel.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/Houseclub/src/main/res/menu/menu_home.xml b/Houseclub/src/main/res/menu/menu_home.xml new file mode 100644 index 00000000..d63be5b0 --- /dev/null +++ b/Houseclub/src/main/res/menu/menu_home.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Houseclub/src/main/res/values-ru/strings.xml b/Houseclub/src/main/res/values-ru/strings.xml new file mode 100644 index 00000000..2cb95b85 --- /dev/null +++ b/Houseclub/src/main/res/values-ru/strings.xml @@ -0,0 +1,77 @@ + + Номер телефона + + Введите ваш номер телефона + Код из СМС + Не получили код? + Отправить повторно + Далее + Внимание! + + Это неофициальное приложение. За его использование Ваш аккаунт Clubhouse может быть заблокирован! Действуйте на свой страх и риск. + Понятно + Загрузка... + Ошибка загрузки данных + Авторизация + Зал ожидания + Вам еще не прислали приглашения. Аккаунт пока не активен. + Выйти + Текущий разговор + Покинуть комнату + Посетить эту комнату? + Войти + Отмена + Выступают + Остальные в комнате + %s приглашает Вас выступить, готовы? + Регистрация + Имя + Фамилия + Имя пользователя + Регистрация завершена + Все поля обязательны для заполнения + Имя пользователя не может быть длиннее 16 символов + Регистрация в этом неофициальном приложении - такая же экспериментальная функция, как и само приложение. Всегда существует ненулевая вероятность бана, если Вы не используете официальное приложение для регистрации. Было бы лучше, если бы Вы одолжили у кого-то устройство iOS, но Вы все равно можете попробовать зарегистрироваться с Android. Помните, что Вы сможете изменить свое имя только один раз после регистрации. Пожалуйста, используйте свое настоящее имя. + Добро пожаловать в Clubhouse! + + %d подписчик + %d подписчика + %d подписчиков + %d подписчиков + + + %d подписка + %d подписки + %d подписок + %d подписок + + Уведомления + Подписан на Вас + Подписаться + Вы подписаны + Подписчики + Подписки + Вы уверены, что желаете отписаться от %s? + Да + Нет + Присоедилися %s + Приглашен пользователем %s + Обновить информацию о себе + Обновить имя пользователя + Сохранить + Мероприятие ещё не началось + Мероприятие закончилось + Для активации аккаунта, повторно войдите в приложение. + OK + + Найти людей + Найти сообщества + Отмена + Пользователи не найдены + Сообщества не найдены + + Отправить приглашение + Пригласить %s (%s) в Clubhouse + Приглашение успешно отправлено + Непредвиденная ошибка: %s + \ No newline at end of file diff --git a/Houseclub/src/main/res/values/strings.xml b/Houseclub/src/main/res/values/strings.xml index 5d4b63ce..a758db38 100644 --- a/Houseclub/src/main/res/values/strings.xml +++ b/Houseclub/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - Houseclub + Houseclub Login Phone number Enter your phone # @@ -58,4 +58,15 @@ This event has already ended Please log in again to activate your account. OK + + Find people + Find clubs + Cancel + No users found + No clubs found + + Send invite + Invite %s (%s) to Clubhouse + Invite sent successfully + Unexpected error: %s From 7dbc3573213ec8c289f1d3e80b8c88f866ec01cc Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 00:39:18 +0300 Subject: [PATCH 02/18] Update InviteListFragment.java --- .../fragments/InviteListFragment.java | 106 ++++++++++++------ 1 file changed, 74 insertions(+), 32 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index b8c8cb99..c3aae3dc 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -9,6 +9,8 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.provider.ContactsContract; import android.text.TextUtils; import android.view.LayoutInflater; @@ -38,20 +40,27 @@ import me.grishka.houseclub.api.BaseResponse; import me.grishka.houseclub.api.methods.InviteToApp; import me.grishka.houseclub.api.methods.SearchPeople; +import me.grishka.houseclub.api.model.Contact; import me.grishka.houseclub.api.model.FullUser; import static android.Manifest.permission.READ_CONTACTS; public class InviteListFragment extends SearchListFragment { - private InviteListAdapter adapter; + private List contacts = null; private static final int REQUEST_READ_CONTACTS = 0; + private static final int limit = 50; + public InviteListFragment() { min_query_lenght = 0; } + private InviteListAdapter adapter; + + + @Override protected RecyclerView.Adapter getAdapter(){ if(adapter==null){ @@ -65,7 +74,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis @NonNull int[] grantResults) { if (requestCode == REQUEST_READ_CONTACTS) { if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - getContactList(""); + getContactList(); } } } @@ -79,25 +88,60 @@ private boolean askContactsPermission() { return false; } - private void readContacts(String query) { + private void readContacts() { if (!askContactsPermission()) { return; } else { - getContactList(query); + getContactList(); } } - private void getContactList(String query) { + + private void searchContacts(String query) { List users = new ArrayList<>(); - int count = 0, limit = 10; + + users.clear(); + + int i =0; + for (Contact contact : contacts) { + + if (query.equals("") || ( + Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(contact.name + contact.phone).find())) { + + FullUser user = new FullUser(); + user.name = contact.name; + user.bio = contact.phone; + users.add(user); + + i++; + if(i > limit) break; + } + + } + + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + data.clear(); + onDataLoaded(users, false); + } + }); + + + + } + + private List getContactList() { + + List m_contacts = new ArrayList<>(); ContentResolver cr = getContext().getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if ((cur != null ? cur.getCount() : 0) > 0) { - while (cur != null && cur.moveToNext()) { + while (cur.moveToNext()) { String id = cur.getString( cur.getColumnIndex(ContactsContract.Contacts._ID)); @@ -116,22 +160,8 @@ private void getContactList(String query) { String phoneNo = pCur.getString(pCur.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER)); - if (query.equals("") || ( - Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(name).find() || - Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(phoneNo).find())) { - - FullUser u = new FullUser(); - u.name = name; - u.bio = phoneNo; - users.add(u); - - count++; - if (count > limit) { - pCur.moveToLast(); - cur.moveToLast(); - } + m_contacts.add(new Contact(name, phoneNo)); - } } pCur.close(); } @@ -143,9 +173,7 @@ private void getContactList(String query) { cur.close(); } - - data.clear(); - onDataLoaded(users, false); + return m_contacts; } @@ -153,13 +181,27 @@ private void getContactList(String query) { @Override protected void doLoadData(int offset, int count) { - if(searchQuery != null) - readContacts(searchQuery); - else - readContacts(""); + showProgress(); + + Runnable r = new Runnable() { + public void run() { + + if(contacts == null) + contacts = getContactList(); + + if(searchQuery != null) + searchContacts(searchQuery); + else + searchContacts(""); + + } + }; + + new Thread(r).start(); + } @@ -236,7 +278,7 @@ public void onClick(){ builder.setTitle(R.string.invite_dialog_title); builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.bio)); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + builder.setPositiveButton(R.string.button_positive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new InviteToApp(item.name, item.bio, "") @@ -257,7 +299,7 @@ public void onError(ErrorResponse error){ .exec(); } }); - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + builder.setNegativeButton(R.string.button_negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); @@ -270,4 +312,4 @@ public void onClick(DialogInterface dialog, int which) { -} \ No newline at end of file +} From 744d351d92bc8c47b9b7b2072caf8bc41a04b5c9 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 00:42:13 +0300 Subject: [PATCH 03/18] Delete strings.xml --- Houseclub/src/main/res/values-ru/strings.xml | 77 -------------------- 1 file changed, 77 deletions(-) delete mode 100644 Houseclub/src/main/res/values-ru/strings.xml diff --git a/Houseclub/src/main/res/values-ru/strings.xml b/Houseclub/src/main/res/values-ru/strings.xml deleted file mode 100644 index 2cb95b85..00000000 --- a/Houseclub/src/main/res/values-ru/strings.xml +++ /dev/null @@ -1,77 +0,0 @@ - - Номер телефона - - Введите ваш номер телефона - Код из СМС - Не получили код? - Отправить повторно - Далее - Внимание! - - Это неофициальное приложение. За его использование Ваш аккаунт Clubhouse может быть заблокирован! Действуйте на свой страх и риск. - Понятно - Загрузка... - Ошибка загрузки данных - Авторизация - Зал ожидания - Вам еще не прислали приглашения. Аккаунт пока не активен. - Выйти - Текущий разговор - Покинуть комнату - Посетить эту комнату? - Войти - Отмена - Выступают - Остальные в комнате - %s приглашает Вас выступить, готовы? - Регистрация - Имя - Фамилия - Имя пользователя - Регистрация завершена - Все поля обязательны для заполнения - Имя пользователя не может быть длиннее 16 символов - Регистрация в этом неофициальном приложении - такая же экспериментальная функция, как и само приложение. Всегда существует ненулевая вероятность бана, если Вы не используете официальное приложение для регистрации. Было бы лучше, если бы Вы одолжили у кого-то устройство iOS, но Вы все равно можете попробовать зарегистрироваться с Android. Помните, что Вы сможете изменить свое имя только один раз после регистрации. Пожалуйста, используйте свое настоящее имя. - Добро пожаловать в Clubhouse! - - %d подписчик - %d подписчика - %d подписчиков - %d подписчиков - - - %d подписка - %d подписки - %d подписок - %d подписок - - Уведомления - Подписан на Вас - Подписаться - Вы подписаны - Подписчики - Подписки - Вы уверены, что желаете отписаться от %s? - Да - Нет - Присоедилися %s - Приглашен пользователем %s - Обновить информацию о себе - Обновить имя пользователя - Сохранить - Мероприятие ещё не началось - Мероприятие закончилось - Для активации аккаунта, повторно войдите в приложение. - OK - - Найти людей - Найти сообщества - Отмена - Пользователи не найдены - Сообщества не найдены - - Отправить приглашение - Пригласить %s (%s) в Clubhouse - Приглашение успешно отправлено - Непредвиденная ошибка: %s - \ No newline at end of file From aaf582a355a33ff66a727b6d788061bd054ee0e6 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 00:43:04 +0300 Subject: [PATCH 04/18] Update strings.xml --- Houseclub/src/main/res/values/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Houseclub/src/main/res/values/strings.xml b/Houseclub/src/main/res/values/strings.xml index a758db38..886631af 100644 --- a/Houseclub/src/main/res/values/strings.xml +++ b/Houseclub/src/main/res/values/strings.xml @@ -69,4 +69,7 @@ Invite %s (%s) to Clubhouse Invite sent successfully Unexpected error: %s + + Ok + Cancel From 3b476089f6e395afdfb9bfcd21618dacec556d59 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 00:48:18 +0300 Subject: [PATCH 05/18] Update InviteListFragment.java 2 --- .../me/grishka/houseclub/fragments/InviteListFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index c3aae3dc..8f668013 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -13,6 +13,7 @@ import android.os.Looper; import android.provider.ContactsContract; import android.text.TextUtils; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -106,8 +107,9 @@ private void searchContacts(String query) { int i =0; for (Contact contact : contacts) { + Pattern pattern = Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE); if (query.equals("") || ( - Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(contact.name + contact.phone).find())) { + pattern.matcher(contact.name + contact.phone).find())) { FullUser user = new FullUser(); user.name = contact.name; @@ -194,7 +196,8 @@ public void run() { else searchContacts(""); - + if(searchQuery != null) + Log.d("tag", searchQuery); } From ce5b2c73a719bfbef7fc1f0bf5645a790aa11a71 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 00:49:41 +0300 Subject: [PATCH 06/18] Update InviteListFragment.java 3 --- .../me/grishka/houseclub/fragments/InviteListFragment.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index 8f668013..2884a38e 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -195,10 +195,7 @@ public void run() { searchContacts(searchQuery); else searchContacts(""); - - if(searchQuery != null) - Log.d("tag", searchQuery); - + } }; From 5155eacbd5c0d28350c1fb41168451a85bac5c5b Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 01:12:32 +0300 Subject: [PATCH 07/18] Update InviteListFragment.java --- .../fragments/InviteListFragment.java | 104 ++++++++++++------ 1 file changed, 73 insertions(+), 31 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index b8c8cb99..8e8cfc62 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -9,6 +9,8 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.provider.ContactsContract; import android.text.TextUtils; import android.view.LayoutInflater; @@ -38,20 +40,27 @@ import me.grishka.houseclub.api.BaseResponse; import me.grishka.houseclub.api.methods.InviteToApp; import me.grishka.houseclub.api.methods.SearchPeople; +import me.grishka.houseclub.api.model.Contact; import me.grishka.houseclub.api.model.FullUser; import static android.Manifest.permission.READ_CONTACTS; public class InviteListFragment extends SearchListFragment { - private InviteListAdapter adapter; + private List contacts = null; private static final int REQUEST_READ_CONTACTS = 0; + private static final int limit = 50; + public InviteListFragment() { min_query_lenght = 0; } + private InviteListAdapter adapter; + + + @Override protected RecyclerView.Adapter getAdapter(){ if(adapter==null){ @@ -65,7 +74,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis @NonNull int[] grantResults) { if (requestCode == REQUEST_READ_CONTACTS) { if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - getContactList(""); + getContactList(); } } } @@ -79,25 +88,60 @@ private boolean askContactsPermission() { return false; } - private void readContacts(String query) { + private void readContacts() { if (!askContactsPermission()) { return; } else { - getContactList(query); + getContactList(); } } - private void getContactList(String query) { + + private void searchContacts(String query) { List users = new ArrayList<>(); - int count = 0, limit = 10; + + users.clear(); + + int i =0; + for (Contact contact : contacts) { + + if (query.equals("") || ( + Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(contact.name + contact.phone).find())) { + + FullUser user = new FullUser(); + user.name = contact.name; + user.bio = contact.phone; + users.add(user); + + i++; + if(i > limit) break; + } + + } + + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + data.clear(); + onDataLoaded(users, false); + } + }); + + + + } + + private List getContactList() { + + List m_contacts = new ArrayList<>(); ContentResolver cr = getContext().getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); if ((cur != null ? cur.getCount() : 0) > 0) { - while (cur != null && cur.moveToNext()) { + while (cur.moveToNext()) { String id = cur.getString( cur.getColumnIndex(ContactsContract.Contacts._ID)); @@ -116,22 +160,8 @@ private void getContactList(String query) { String phoneNo = pCur.getString(pCur.getColumnIndex( ContactsContract.CommonDataKinds.Phone.NUMBER)); - if (query.equals("") || ( - Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(name).find() || - Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE).matcher(phoneNo).find())) { - - FullUser u = new FullUser(); - u.name = name; - u.bio = phoneNo; - users.add(u); - - count++; - if (count > limit) { - pCur.moveToLast(); - cur.moveToLast(); - } + m_contacts.add(new Contact(name, phoneNo)); - } } pCur.close(); } @@ -143,9 +173,7 @@ private void getContactList(String query) { cur.close(); } - - data.clear(); - onDataLoaded(users, false); + return m_contacts; } @@ -153,13 +181,27 @@ private void getContactList(String query) { @Override protected void doLoadData(int offset, int count) { - if(searchQuery != null) - readContacts(searchQuery); - else - readContacts(""); + showProgress(); + + Runnable r = new Runnable() { + public void run() { + + if(contacts == null) + contacts = getContactList(); + + if(searchQuery != null) + searchContacts(searchQuery); + else + searchContacts(""); + + } + }; + + new Thread(r).start(); + } @@ -236,7 +278,7 @@ public void onClick(){ builder.setTitle(R.string.invite_dialog_title); builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.bio)); - builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + builder.setPositiveButton(R.string.button_positive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new InviteToApp(item.name, item.bio, "") @@ -257,7 +299,7 @@ public void onError(ErrorResponse error){ .exec(); } }); - builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + builder.setNegativeButton(R.string.button_negative, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); From b4d8c76ddc0a38c9ff806ba722cb5f72795df144 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 01:17:51 +0300 Subject: [PATCH 08/18] Add model/Contact.java --- .../grishka/houseclub/api/model/Contact.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java b/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java new file mode 100644 index 00000000..f3b8e6d6 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java @@ -0,0 +1,19 @@ +package me.grishka.houseclub.api.model; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Date; + +public class Contact { + public String name, phone_number; + + public Contact(){ + } + + public Contact(String name, String phone_number){ + this.name=name; + this.phone_number=phone_number; + } + +} From 5fe781d90349047975619bd128c40d6e99015956 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 02:20:12 +0300 Subject: [PATCH 09/18] Get_suggested_invites implementation --- .../api/methods/GetSuggestedInvites.java | 33 +++++++ .../grishka/houseclub/api/model/Contact.java | 2 + .../houseclub/fragments/HomeFragment.java | 30 +++++-- .../fragments/InviteListFragment.java | 89 +++++++++++++------ Houseclub/src/main/res/values/strings.xml | 8 +- 5 files changed, 125 insertions(+), 37 deletions(-) create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/methods/GetSuggestedInvites.java diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/GetSuggestedInvites.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/GetSuggestedInvites.java new file mode 100644 index 00000000..0d450ac6 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/GetSuggestedInvites.java @@ -0,0 +1,33 @@ +package me.grishka.houseclub.api.methods; + +import java.util.List; + +import me.grishka.appkit.api.SimpleCallback; +import me.grishka.houseclub.api.BaseResponse; +import me.grishka.houseclub.api.ClubhouseAPIRequest; +import me.grishka.houseclub.api.model.Contact; +import me.grishka.houseclub.api.model.FullUser; + +public class GetSuggestedInvites extends ClubhouseAPIRequest { + + public GetSuggestedInvites(List contacts){ + super("POST", "get_suggested_invites", Response.class); + requestBody=new GetSuggestedInvites.Body(contacts); + } + + private static class Body{ + public boolean upload_contacts; + public List contacts; + + public Body(List contacts){ + this.upload_contacts=true; + this.contacts=contacts; + } + } + + public static class Response{ + public List suggested_invites; + public int num_invites; + } + +} diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java b/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java index f3b8e6d6..5482a490 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/model/Contact.java @@ -7,6 +7,8 @@ public class Contact { public String name, phone_number; + public boolean in_app, is_invited; + public int num_friends; public Contact(){ } diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java index c402653f..95992c19 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java @@ -113,20 +113,34 @@ public boolean wantsLightStatusBar(){ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ - menu.add(0,0,0,"").setIcon(R.drawable.ic_notifications).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); - menu.add(0,1,0,"").setIcon(R.drawable.ic_baseline_person_24).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + inflater.inflate(R.menu.menu_home, menu); } @Override public boolean onOptionsItemSelected(MenuItem item){ - Bundle args=new Bundle(); - args.putInt("id", Integer.parseInt(ClubhouseSession.userID)); - if(item.getItemId()==0) { - Nav.go(getActivity(), NotificationListFragment.class, args); - } else if(item.getItemId()==1){ + if (item.getItemId() == R.id.homeMenuProfile) { + Bundle args=new Bundle(); + args.putInt("id", Integer.parseInt(ClubhouseSession.userID)); Nav.go(getActivity(), ProfileFragment.class, args); + return true; + } else if (item.getItemId() == R.id.homeMenuSearchPeople) { + Bundle args = new Bundle(); + //args.putInt(BaseSearchFragment.KEY_SEARCH_TYPE, BaseSearchFragment.SearchType.PEOPLE.ordinal()); + //Nav.go(getActivity(), SearchPeopleFragment.class, args); + Nav.go(getActivity(), SearchListFragment.class, args); + return true; + } else if (item.getItemId() == R.id.homeMenuNotifications) { + Bundle args = new Bundle(); + args.putInt("id", Integer.parseInt(ClubhouseSession.userID)); + Nav.go(getActivity(), NotificationListFragment.class, args); + return true; + } else if(item.getItemId() == R.id.homeMenuInvite) { + + Bundle args = new Bundle(); + Nav.go(getActivity(), InviteListFragment.class, args); + } - return true; + return false; } private class ChannelAdapter extends RecyclerView.Adapter implements ImageLoaderRecyclerAdapter{ diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index 42d7e113..bb5be0f1 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -8,13 +8,9 @@ import android.graphics.Bitmap; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.provider.ContactsContract; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -26,10 +22,11 @@ import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; -import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.api.SimpleCallback; @@ -39,8 +36,9 @@ import me.grishka.appkit.views.UsableRecyclerView; import me.grishka.houseclub.R; import me.grishka.houseclub.api.BaseResponse; +import me.grishka.houseclub.api.methods.GetFollowers; +import me.grishka.houseclub.api.methods.GetSuggestedInvites; import me.grishka.houseclub.api.methods.InviteToApp; -import me.grishka.houseclub.api.methods.SearchPeople; import me.grishka.houseclub.api.model.Contact; import me.grishka.houseclub.api.model.FullUser; @@ -49,6 +47,8 @@ public class InviteListFragment extends SearchListFragment { private List contacts = null; + private final Map a_contacts = new HashMap<>(); + private List r_contacts = null; private static final int REQUEST_READ_CONTACTS = 0; @@ -75,7 +75,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis @NonNull int[] grantResults) { if (requestCode == REQUEST_READ_CONTACTS) { if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - getContactList(); + readContacts(); } } } @@ -93,27 +93,44 @@ private void readContacts() { if (!askContactsPermission()) { return; } else { - getContactList(); + contacts = getContactList(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + reqestData(); + } + }); } } private void searchContacts(String query) { + if(query == null) + query = ""; + List users = new ArrayList<>(); users.clear(); int i =0; - for (Contact contact : contacts) { + for (Contact contact : r_contacts) { + + contact.name = a_contacts.get(contact.phone_number); Pattern pattern = Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE); if (query.equals("") || ( - pattern.matcher(contact.name + contact.phone).find())) { + pattern.matcher(contact.name + contact.phone_number).find())) { FullUser user = new FullUser(); user.name = contact.name; - user.bio = contact.phone; + user.dsplayname = contact.phone_number; + String in_app = contact.in_app ? getString(R.string.yes) : getString(R.string.no); + String is_invited = contact.is_invited ? getString(R.string.yes) : getString(R.string.no); + user.bio = contact.phone_number + getString(R.string.contact_separator) + + getString(R.string.contact_in_app, in_app) + getString(R.string.contact_separator) + + getString(R.string.contact_is_invited, is_invited) + getString(R.string.contact_separator) + + getString(R.string.contact_num_friends, contact.num_friends); users.add(user); i++; @@ -163,6 +180,7 @@ private List getContactList() { ContactsContract.CommonDataKinds.Phone.NUMBER)); m_contacts.add(new Contact(name, phoneNo)); + a_contacts.put(phoneNo, name); } pCur.close(); @@ -180,27 +198,42 @@ private List getContactList() { } - @Override - protected void doLoadData(int offset, int count) { + void reqestData() { - showProgress(); + currentRequest=new GetSuggestedInvites(contacts) + .setCallback(new SimpleCallback(this){ + @Override + public void onSuccess(GetSuggestedInvites.Response result){ + currentRequest=null; + r_contacts = result.suggested_invites; - Runnable r = new Runnable() { - public void run() { + Toast.makeText(getContext(), getString(R.string.contact_invites, result.num_invites), Toast.LENGTH_SHORT).show(); - if(contacts == null) - contacts = getContactList(); + searchContacts(searchQuery); + } + }) + .exec(); - if(searchQuery != null) - searchContacts(searchQuery); - else - searchContacts(""); + } - } - }; + @Override + protected void doLoadData(int offset, int count) { + + showProgress(); + + if(r_contacts == null) { + Runnable r = () -> { + if (contacts == null) { + readContacts(); + } + }; + new Thread(r).start(); + } else { + searchContacts(searchQuery); + } + - new Thread(r).start(); } @@ -276,12 +309,12 @@ public void onClick(){ AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(R.string.invite_dialog_title); - builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.bio)); + builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.dsplayname)); builder.setPositiveButton(R.string.button_positive, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new InviteToApp(item.name, item.bio, "") + new InviteToApp(item.name, item.dsplayname, "") .wrapProgress(getActivity()) .setCallback(new Callback(){ @@ -312,4 +345,4 @@ public void onClick(DialogInterface dialog, int which) { -} +} \ No newline at end of file diff --git a/Houseclub/src/main/res/values/strings.xml b/Houseclub/src/main/res/values/strings.xml index 886631af..335df675 100644 --- a/Houseclub/src/main/res/values/strings.xml +++ b/Houseclub/src/main/res/values/strings.xml @@ -69,7 +69,13 @@ Invite %s (%s) to Clubhouse Invite sent successfully Unexpected error: %s - + + You have %d invites + In Clubhouse: %s + Is invited: %s + %d friends on Clubhouse + + Ok Cancel From 97edde17de5d79b3ea5f990288f7a0626280433e Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 14:23:33 +0300 Subject: [PATCH 10/18] Update strings.xml --- Houseclub/src/main/res/values/strings.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Houseclub/src/main/res/values/strings.xml b/Houseclub/src/main/res/values/strings.xml index 335df675..cb939ec0 100644 --- a/Houseclub/src/main/res/values/strings.xml +++ b/Houseclub/src/main/res/values/strings.xml @@ -75,7 +75,4 @@ Is invited: %s %d friends on Clubhouse - - Ok - Cancel From 67927e6afcb4ec3cca634d4012a43f1aa1e5bdc9 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 14:23:39 +0300 Subject: [PATCH 11/18] Update InviteListFragment.java --- .../me/grishka/houseclub/fragments/InviteListFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index bb5be0f1..62c55f59 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -311,7 +311,7 @@ public void onClick(){ builder.setTitle(R.string.invite_dialog_title); builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.dsplayname)); - builder.setPositiveButton(R.string.button_positive, new DialogInterface.OnClickListener() { + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new InviteToApp(item.name, item.dsplayname, "") @@ -332,7 +332,7 @@ public void onError(ErrorResponse error){ .exec(); } }); - builder.setNegativeButton(R.string.button_negative, new DialogInterface.OnClickListener() { + builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); From b1ee174c2330a306550d069735692d4aecf2ec5f Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 14:23:42 +0300 Subject: [PATCH 12/18] Update HomeFragment.java --- .../java/me/grishka/houseclub/fragments/HomeFragment.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java index 95992c19..51e6cccf 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/HomeFragment.java @@ -125,8 +125,6 @@ public boolean onOptionsItemSelected(MenuItem item){ return true; } else if (item.getItemId() == R.id.homeMenuSearchPeople) { Bundle args = new Bundle(); - //args.putInt(BaseSearchFragment.KEY_SEARCH_TYPE, BaseSearchFragment.SearchType.PEOPLE.ordinal()); - //Nav.go(getActivity(), SearchPeopleFragment.class, args); Nav.go(getActivity(), SearchListFragment.class, args); return true; } else if (item.getItemId() == R.id.homeMenuNotifications) { @@ -135,12 +133,11 @@ public boolean onOptionsItemSelected(MenuItem item){ Nav.go(getActivity(), NotificationListFragment.class, args); return true; } else if(item.getItemId() == R.id.homeMenuInvite) { - Bundle args = new Bundle(); Nav.go(getActivity(), InviteListFragment.class, args); - + return true; } - return false; + return super.onOptionsItemSelected(item); } private class ChannelAdapter extends RecyclerView.Adapter implements ImageLoaderRecyclerAdapter{ From 53ba0e8eb934400d9596472311955bb696685e6d Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 14:28:35 +0300 Subject: [PATCH 13/18] Update InviteListFragment.java --- .../java/me/grishka/houseclub/fragments/InviteListFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index 62c55f59..bb6d03e6 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -325,7 +325,7 @@ public void onSuccess(BaseResponse result){ @Override public void onError(ErrorResponse error){ - Toast.makeText(getContext(), getString(R.string.invite_err, ""), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), R.string.invite_err, Toast.LENGTH_SHORT).show(); error.showToast(getContext()); } }) From 7f290dd56137502bf86fcffc9518e3303981cba5 Mon Sep 17 00:00:00 2001 From: bit-world Date: Wed, 24 Feb 2021 21:49:41 +0300 Subject: [PATCH 14/18] to tabs --- .../houseclub/api/methods/InviteToApp.java | 2 +- .../fragments/InviteListFragment.java | 410 +++++++++--------- .../fragments/SearchListFragment.java | 176 ++++---- 3 files changed, 294 insertions(+), 294 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java index c1ae7544..68856dfe 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/InviteToApp.java @@ -17,7 +17,7 @@ private static class Body{ public String message; public Body(String name, String phone_number, String message){ - this.name=name; + this.name=name; this.phone_number=phone_number; this.message=message; } diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index bb6d03e6..13ad8930 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -46,266 +46,266 @@ public class InviteListFragment extends SearchListFragment { - private List contacts = null; - private final Map a_contacts = new HashMap<>(); - private List r_contacts = null; - - private static final int REQUEST_READ_CONTACTS = 0; - - private static final int limit = 50; - - public InviteListFragment() { - min_query_lenght = 0; - } - - private InviteListAdapter adapter; - - - - @Override - protected RecyclerView.Adapter getAdapter(){ - if(adapter==null){ - adapter=new InviteListAdapter(); - } - return adapter; - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, - @NonNull int[] grantResults) { - if (requestCode == REQUEST_READ_CONTACTS) { - if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - readContacts(); - } - } - } - - private boolean askContactsPermission() { - - if (getContext().checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) { - return true; - } - requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS); - return false; - } - - private void readContacts() { - if (!askContactsPermission()) { - return; - } else { - contacts = getContactList(); - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { - reqestData(); - } - }); - } - } + private List contacts = null; + private final Map a_contacts = new HashMap<>(); + private List r_contacts = null; + + private static final int REQUEST_READ_CONTACTS = 0; + + private static final int limit = 50; + + public InviteListFragment() { + min_query_lenght = 0; + } + + private InviteListAdapter adapter; + + + + @Override + protected RecyclerView.Adapter getAdapter(){ + if(adapter==null){ + adapter=new InviteListAdapter(); + } + return adapter; + } + + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { + if (requestCode == REQUEST_READ_CONTACTS) { + if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + readContacts(); + } + } + } + + private boolean askContactsPermission() { + + if (getContext().checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) { + return true; + } + requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS); + return false; + } + + private void readContacts() { + if (!askContactsPermission()) { + return; + } else { + contacts = getContactList(); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + reqestData(); + } + }); + } + } - private void searchContacts(String query) { + private void searchContacts(String query) { - if(query == null) - query = ""; + if(query == null) + query = ""; - List users = new ArrayList<>(); + List users = new ArrayList<>(); - users.clear(); + users.clear(); - int i =0; - for (Contact contact : r_contacts) { + int i =0; + for (Contact contact : r_contacts) { - contact.name = a_contacts.get(contact.phone_number); + contact.name = a_contacts.get(contact.phone_number); - Pattern pattern = Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE); - if (query.equals("") || ( - pattern.matcher(contact.name + contact.phone_number).find())) { + Pattern pattern = Pattern.compile(Pattern.quote(query), Pattern.CASE_INSENSITIVE); + if (query.equals("") || ( + pattern.matcher(contact.name + contact.phone_number).find())) { - FullUser user = new FullUser(); - user.name = contact.name; - user.dsplayname = contact.phone_number; - String in_app = contact.in_app ? getString(R.string.yes) : getString(R.string.no); - String is_invited = contact.is_invited ? getString(R.string.yes) : getString(R.string.no); - user.bio = contact.phone_number + getString(R.string.contact_separator) + - getString(R.string.contact_in_app, in_app) + getString(R.string.contact_separator) + - getString(R.string.contact_is_invited, is_invited) + getString(R.string.contact_separator) + - getString(R.string.contact_num_friends, contact.num_friends); - users.add(user); + FullUser user = new FullUser(); + user.name = contact.name; + user.dsplayname = contact.phone_number; + String in_app = contact.in_app ? getString(R.string.yes) : getString(R.string.no); + String is_invited = contact.is_invited ? getString(R.string.yes) : getString(R.string.no); + user.bio = contact.phone_number + getString(R.string.contact_separator) + + getString(R.string.contact_in_app, in_app) + getString(R.string.contact_separator) + + getString(R.string.contact_is_invited, is_invited) + getString(R.string.contact_separator) + + getString(R.string.contact_num_friends, contact.num_friends); + users.add(user); - i++; - if(i > limit) break; - } + i++; + if(i > limit) break; + } - } + } - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { - data.clear(); - onDataLoaded(users, false); - } - }); + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + data.clear(); + onDataLoaded(users, false); + } + }); - } + } - private List getContactList() { + private List getContactList() { - List m_contacts = new ArrayList<>(); + List m_contacts = new ArrayList<>(); - ContentResolver cr = getContext().getContentResolver(); - Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, - null, null, null, null); + ContentResolver cr = getContext().getContentResolver(); + Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, + null, null, null, null); - if ((cur != null ? cur.getCount() : 0) > 0) { - while (cur.moveToNext()) { + if ((cur != null ? cur.getCount() : 0) > 0) { + while (cur.moveToNext()) { - String id = cur.getString( - cur.getColumnIndex(ContactsContract.Contacts._ID)); + String id = cur.getString( + cur.getColumnIndex(ContactsContract.Contacts._ID)); - String name = cur.getString(cur.getColumnIndex( - ContactsContract.Contacts.DISPLAY_NAME)); + String name = cur.getString(cur.getColumnIndex( + ContactsContract.Contacts.DISPLAY_NAME)); - if (cur.getInt(cur.getColumnIndex( - ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0) { - Cursor pCur = cr.query( - ContactsContract.CommonDataKinds.Phone.CONTENT_URI, - null, - ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", - new String[]{id}, null); - while (pCur.moveToNext()) { - String phoneNo = pCur.getString(pCur.getColumnIndex( - ContactsContract.CommonDataKinds.Phone.NUMBER)); + if (cur.getInt(cur.getColumnIndex( + ContactsContract.Contacts.HAS_PHONE_NUMBER)) > 0) { + Cursor pCur = cr.query( + ContactsContract.CommonDataKinds.Phone.CONTENT_URI, + null, + ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", + new String[]{id}, null); + while (pCur.moveToNext()) { + String phoneNo = pCur.getString(pCur.getColumnIndex( + ContactsContract.CommonDataKinds.Phone.NUMBER)); - m_contacts.add(new Contact(name, phoneNo)); - a_contacts.put(phoneNo, name); + m_contacts.add(new Contact(name, phoneNo)); + a_contacts.put(phoneNo, name); - } - pCur.close(); - } + } + pCur.close(); + } - } - } - if (cur != null) { - cur.close(); - } + } + } + if (cur != null) { + cur.close(); + } - return m_contacts; + return m_contacts; - } + } - void reqestData() { + void reqestData() { - currentRequest=new GetSuggestedInvites(contacts) - .setCallback(new SimpleCallback(this){ - @Override - public void onSuccess(GetSuggestedInvites.Response result){ - currentRequest=null; - r_contacts = result.suggested_invites; + currentRequest=new GetSuggestedInvites(contacts) + .setCallback(new SimpleCallback(this){ + @Override + public void onSuccess(GetSuggestedInvites.Response result){ + currentRequest=null; + r_contacts = result.suggested_invites; - Toast.makeText(getContext(), getString(R.string.contact_invites, result.num_invites), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), getString(R.string.contact_invites, result.num_invites), Toast.LENGTH_SHORT).show(); - searchContacts(searchQuery); - } - }) - .exec(); + searchContacts(searchQuery); + } + }) + .exec(); - } + } - @Override - protected void doLoadData(int offset, int count) { + @Override + protected void doLoadData(int offset, int count) { - showProgress(); + showProgress(); - if(r_contacts == null) { - Runnable r = () -> { - if (contacts == null) { - readContacts(); - } - }; - new Thread(r).start(); - } else { - searchContacts(searchQuery); - } + if(r_contacts == null) { + Runnable r = () -> { + if (contacts == null) { + readContacts(); + } + }; + new Thread(r).start(); + } else { + searchContacts(searchQuery); + } - } + } - private class InviteListAdapter extends RecyclerView.Adapter implements ImageLoaderRecyclerAdapter { + private class InviteListAdapter extends RecyclerView.Adapter implements ImageLoaderRecyclerAdapter { - @NonNull - @Override - public IviteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ - return new IviteViewHolder(); - } + @NonNull + @Override + public IviteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){ + return new IviteViewHolder(); + } - @Override - public void onBindViewHolder(@NonNull IviteViewHolder holder, int position){ - holder.bind(data.get(position)); - } + @Override + public void onBindViewHolder(@NonNull IviteViewHolder holder, int position){ + holder.bind(data.get(position)); + } - @Override - public int getItemCount(){ - return data.size(); - } + @Override + public int getItemCount(){ + return data.size(); + } - @Override - public int getImageCountForItem(int position){ - return data.get(position).photoUrl!=null ? 1 : 0; - } + @Override + public int getImageCountForItem(int position){ + return data.get(position).photoUrl!=null ? 1 : 0; + } - @Override - public String getImageURL(int position, int image){ - return data.get(position).photoUrl; - } - } + @Override + public String getImageURL(int position, int image){ + return data.get(position).photoUrl; + } + } - private class IviteViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{ + private class IviteViewHolder extends BindableViewHolder implements ImageLoaderViewHolder, UsableRecyclerView.Clickable{ - public TextView name, bio; - public Button followBtn; - public ImageView photo; - private Drawable placeholder=new ColorDrawable(0xFF808080); + public TextView name, bio; + public Button followBtn; + public ImageView photo; + private Drawable placeholder=new ColorDrawable(0xFF808080); - public IviteViewHolder(){ - super(getActivity(), R.layout.user_list_row); + public IviteViewHolder(){ + super(getActivity(), R.layout.user_list_row); - name=findViewById(R.id.name); - bio=findViewById(R.id.bio); - followBtn=findViewById(R.id.follow_btn); - photo=findViewById(R.id.photo); - } + name=findViewById(R.id.name); + bio=findViewById(R.id.bio); + followBtn=findViewById(R.id.follow_btn); + photo=findViewById(R.id.photo); + } - @Override - public void onBind(FullUser item){ - name.setText(item.name); - bio.setText(item.bio); - followBtn.setVisibility(View.GONE); - photo.setVisibility(View.GONE); - } + @Override + public void onBind(FullUser item){ + name.setText(item.name); + bio.setText(item.bio); + followBtn.setVisibility(View.GONE); + photo.setVisibility(View.GONE); + } - @Override - public void setImage(int index, Bitmap bitmap){ - photo.setImageBitmap(bitmap); - } + @Override + public void setImage(int index, Bitmap bitmap){ + photo.setImageBitmap(bitmap); + } - @Override - public void clearImage(int index){ - photo.setImageDrawable(placeholder); - } + @Override + public void clearImage(int index){ + photo.setImageDrawable(placeholder); + } - @Override - public void onClick(){ + @Override + public void onClick(){ AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(R.string.invite_dialog_title); @@ -325,8 +325,8 @@ public void onSuccess(BaseResponse result){ @Override public void onError(ErrorResponse error){ - Toast.makeText(getContext(), R.string.invite_err, Toast.LENGTH_SHORT).show(); - error.showToast(getContext()); + Toast.makeText(getContext(), R.string.invite_err, Toast.LENGTH_SHORT).show(); + error.showToast(getContext()); } }) .exec(); @@ -340,8 +340,8 @@ public void onClick(DialogInterface dialog, int which) { }); builder.show(); - } - } + } + } diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java index 70785ed4..c761a198 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java @@ -11,94 +11,94 @@ public class SearchListFragment extends UserListFragment { - private SearchView searchView; - private SearchView.OnQueryTextListener onQueryTextListener; - - protected static int min_query_lenght = 2; - protected String searchQuery; - private static final long DELAY = 200; - private long timestamp = System.currentTimeMillis(); - - @Override - public void onAttach(Activity activity){ - super.onAttach(activity); - setTitle(R.string.search_people_hint); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - View search_panel = view.inflate(getContext(), R.layout.search_panel, null); - - searchView = search_panel.findViewById(R.id.searchView); - searchView.setQueryHint(getString(R.string.search_people_hint)); - onQueryTextListener = new OnSearchQueryTextListener(); - - getToolbar().addView(search_panel); - } - - protected void onQueryChanged(String query) { - long currentTimeStamp = System.currentTimeMillis(); - if (currentTimeStamp - timestamp < DELAY) { - timestamp = currentTimeStamp; - return; - } - - if (query == null && min_query_lenght > 0 || query.length() <= min_query_lenght) { - timestamp = currentTimeStamp; - return; - } - timestamp = currentTimeStamp; - searchQuery = query; - loadData(); - } - - private class OnSearchQueryTextListener implements SearchView.OnQueryTextListener { - @Override - public boolean onQueryTextSubmit(String query) { - onQueryChanged(query); - return false; - } - - @Override - public boolean onQueryTextChange(String newText) { - onQueryChanged(newText); - return false; - } - } - - @Override - public void onResume() { - super.onResume(); - - searchView.setOnQueryTextListener(onQueryTextListener); - } - - @Override - public void onPause() { - super.onPause(); - - searchView.setOnQueryTextListener(null); - } - - @Override - protected void doLoadData(int offset, int count) { - if (currentRequest != null) { - currentRequest.cancel(); - } - - currentRequest = new SearchPeople(searchQuery) - .setCallback(new SimpleCallback(this) { - @Override - public void onSuccess(SearchPeople.Resp result) { - currentRequest=null; - data.clear(); - onDataLoaded(result.users, false); - } - }) - .exec(); - } + private SearchView searchView; + private SearchView.OnQueryTextListener onQueryTextListener; + + protected static int min_query_lenght = 2; + protected String searchQuery; + private static final long DELAY = 200; + private long timestamp = System.currentTimeMillis(); + + @Override + public void onAttach(Activity activity){ + super.onAttach(activity); + setTitle(R.string.search_people_hint); + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + View search_panel = view.inflate(getContext(), R.layout.search_panel, null); + + searchView = search_panel.findViewById(R.id.searchView); + searchView.setQueryHint(getString(R.string.search_people_hint)); + onQueryTextListener = new OnSearchQueryTextListener(); + + getToolbar().addView(search_panel); + } + + protected void onQueryChanged(String query) { + long currentTimeStamp = System.currentTimeMillis(); + if (currentTimeStamp - timestamp < DELAY) { + timestamp = currentTimeStamp; + return; + } + + if (query == null && min_query_lenght > 0 || query.length() <= min_query_lenght) { + timestamp = currentTimeStamp; + return; + } + timestamp = currentTimeStamp; + searchQuery = query; + loadData(); + } + + private class OnSearchQueryTextListener implements SearchView.OnQueryTextListener { + @Override + public boolean onQueryTextSubmit(String query) { + onQueryChanged(query); + return false; + } + + @Override + public boolean onQueryTextChange(String newText) { + onQueryChanged(newText); + return false; + } + } + + @Override + public void onResume() { + super.onResume(); + + searchView.setOnQueryTextListener(onQueryTextListener); + } + + @Override + public void onPause() { + super.onPause(); + + searchView.setOnQueryTextListener(null); + } + + @Override + protected void doLoadData(int offset, int count) { + if (currentRequest != null) { + currentRequest.cancel(); + } + + currentRequest = new SearchPeople(searchQuery) + .setCallback(new SimpleCallback(this) { + @Override + public void onSuccess(SearchPeople.Resp result) { + currentRequest=null; + data.clear(); + onDataLoaded(result.users, false); + } + }) + .exec(); + } } \ No newline at end of file From 47862cdc5461991b898e3b59e069ebf9a733ebe5 Mon Sep 17 00:00:00 2001 From: bit-world Date: Sat, 27 Feb 2021 23:36:01 +0300 Subject: [PATCH 15/18] Update InviteListFragment.java remove other characters from the phone number --- .../me/grishka/houseclub/fragments/InviteListFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java index 13ad8930..6a829691 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/InviteListFragment.java @@ -307,14 +307,16 @@ public void clearImage(int index){ @Override public void onClick(){ + String numberOnly= item.dsplayname.replaceAll("[^0-9+]", ""); + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setTitle(R.string.invite_dialog_title); - builder.setMessage(getString(R.string.invite_dialog_text, item.name, item.dsplayname)); + builder.setMessage(getString(R.string.invite_dialog_text, item.name, numberOnly)); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new InviteToApp(item.name, item.dsplayname, "") + new InviteToApp("", numberOnly, "") .wrapProgress(getActivity()) .setCallback(new Callback(){ From 17ec2b29ac4903a7cca8e167814d012ccbb7cbd7 Mon Sep 17 00:00:00 2001 From: bit-world Date: Mon, 1 Mar 2021 03:07:04 +0300 Subject: [PATCH 16/18] Create SearchUsers.java --- .../houseclub/api/methods/SearchUsers.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchUsers.java diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchUsers.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchUsers.java new file mode 100644 index 00000000..a21bf124 --- /dev/null +++ b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchUsers.java @@ -0,0 +1,30 @@ +package me.grishka.houseclub.api.methods; + +import java.util.List; + +import me.grishka.houseclub.api.ClubhouseAPIRequest; +import me.grishka.houseclub.api.model.FullUser; + +public class SearchUsers extends ClubhouseAPIRequest { + + public SearchUsers(String query) { + super("POST", "search_users", Resp.class); + requestBody = new Body(query); + } + + private static class Body { + public boolean cofollowsOnly; + public boolean followingOnly; + public boolean followersOnly; + public String query; + + public Body(String query) { + this.query = query; + } + } + + public static class Resp { + public List users; + public int count; + } +} \ No newline at end of file From 2dd85e3bb4a016dc34787740b29dc1c314d7e806 Mon Sep 17 00:00:00 2001 From: bit-world Date: Mon, 1 Mar 2021 03:07:09 +0300 Subject: [PATCH 17/18] Delete SearchPeople.java --- .../houseclub/api/methods/SearchPeople.java | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java diff --git a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java b/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java deleted file mode 100644 index 29ae9aa7..00000000 --- a/Houseclub/src/main/java/me/grishka/houseclub/api/methods/SearchPeople.java +++ /dev/null @@ -1,30 +0,0 @@ -package me.grishka.houseclub.api.methods; - -import java.util.List; - -import me.grishka.houseclub.api.ClubhouseAPIRequest; -import me.grishka.houseclub.api.model.FullUser; - -public class SearchPeople extends ClubhouseAPIRequest { - - public SearchPeople(String query) { - super("POST", "search_users", Resp.class); - requestBody = new Body(query); - } - - private static class Body { - public boolean cofollowsOnly; - public boolean followingOnly; - public boolean followersOnly; - public String query; - - public Body(String query) { - this.query = query; - } - } - - public static class Resp { - public List users; - public int count; - } -} \ No newline at end of file From 12c6669cca5244d4f22438f1489eeb69e5290361 Mon Sep 17 00:00:00 2001 From: bit-world Date: Mon, 1 Mar 2021 03:07:14 +0300 Subject: [PATCH 18/18] Update SearchListFragment.java --- .../grishka/houseclub/fragments/SearchListFragment.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java index c761a198..dbb246cb 100644 --- a/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java +++ b/Houseclub/src/main/java/me/grishka/houseclub/fragments/SearchListFragment.java @@ -7,7 +7,7 @@ import me.grishka.appkit.api.SimpleCallback; import me.grishka.houseclub.R; -import me.grishka.houseclub.api.methods.SearchPeople; +import me.grishka.houseclub.api.methods.SearchUsers; public class SearchListFragment extends UserListFragment { @@ -88,10 +88,10 @@ protected void doLoadData(int offset, int count) { currentRequest.cancel(); } - currentRequest = new SearchPeople(searchQuery) - .setCallback(new SimpleCallback(this) { + currentRequest = new SearchUsers(searchQuery) + .setCallback(new SimpleCallback(this) { @Override - public void onSuccess(SearchPeople.Resp result) { + public void onSuccess(SearchUsers.Resp result) { currentRequest=null; data.clear(); onDataLoaded(result.users, false);