Improved search bars + disable some features if default proxy config domain isn't sip.linphone.org
This commit is contained in:
parent
a404543789
commit
a5287df9c8
7 changed files with 55 additions and 87 deletions
|
@ -132,28 +132,18 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp">
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<EditText
|
<SearchView
|
||||||
android:id="@+id/searchField"
|
android:id="@+id/searchField"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:background="@drawable/resizable_textfield"
|
|
||||||
android:hint="@string/chat_room_creation_filter_hint"
|
|
||||||
android:contentDescription="@string/content_description_search_contact"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:inputType="textPersonName"
|
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
|
android:iconifiedByDefault="false"
|
||||||
|
android:queryBackground="@android:color/transparent"
|
||||||
|
android:queryHint="@string/chat_room_creation_filter_hint"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:textCursorDrawable="@null"/>
|
android:background="@drawable/resizable_textfield"
|
||||||
|
android:inputType="textPersonName"/>
|
||||||
<ImageView
|
|
||||||
android:id="@+id/clearSearchField"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"
|
|
||||||
android:src="@drawable/clean_field"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
|
@ -92,29 +92,19 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp">
|
android:layout_margin="10dp">
|
||||||
|
|
||||||
<EditText
|
<SearchView
|
||||||
android:contentDescription="@string/content_description_search_contact"
|
|
||||||
android:hint="@string/chat_room_creation_filter_hint"
|
|
||||||
android:textCursorDrawable="@null"
|
|
||||||
android:id="@+id/searchField"
|
android:id="@+id/searchField"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:background="@drawable/resizable_textfield"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
|
android:iconifiedByDefault="false"
|
||||||
|
android:queryBackground="@android:color/transparent"
|
||||||
|
android:queryHint="@string/chat_room_creation_filter_hint"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:background="@drawable/resizable_textfield"
|
||||||
android:inputType="textPersonName"/>
|
android:inputType="textPersonName"/>
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/clearSearchField"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:src="@drawable/clean_field_default"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:paddingLeft="5dp"
|
|
||||||
android:paddingRight="5dp"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|
|
@ -30,12 +30,12 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.HorizontalScrollView;
|
import android.widget.HorizontalScrollView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.SearchView;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
private LinearLayout mContactsSelectedLayout;
|
private LinearLayout mContactsSelectedLayout;
|
||||||
private HorizontalScrollView mContactsSelectLayout;
|
private HorizontalScrollView mContactsSelectLayout;
|
||||||
private ArrayList<ContactAddress> mContactsSelected;
|
private ArrayList<ContactAddress> mContactsSelected;
|
||||||
private ImageView mAllContactsButton, mLinphoneContactsButton, mClearSearchFieldButton, mBackButton, mNextButton;
|
private ImageView mAllContactsButton, mLinphoneContactsButton, mBackButton, mNextButton;
|
||||||
private boolean mOnlyDisplayLinphoneContacts;
|
private boolean mOnlyDisplayLinphoneContacts;
|
||||||
private View mAllContactsSelected, mLinphoneContactsSelected;
|
private View mAllContactsSelected, mLinphoneContactsSelected;
|
||||||
private RelativeLayout mSearchLayout, mWaitLayout, mLinphoneContactsToggle, mAllContactsToggle;
|
private RelativeLayout mSearchLayout, mWaitLayout, mLinphoneContactsToggle, mAllContactsToggle;
|
||||||
private EditText mSearchField;
|
private SearchView mSearchField;
|
||||||
private ProgressBar mContactsFetchInProgress;
|
private ProgressBar mContactsFetchInProgress;
|
||||||
private SearchContactsListAdapter mSearchAdapter;
|
private SearchContactsListAdapter mSearchAdapter;
|
||||||
private String mChatRoomSubject, mChatRoomAddress;
|
private String mChatRoomSubject, mChatRoomAddress;
|
||||||
|
@ -125,31 +125,22 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
mNextButton.setEnabled(false);
|
mNextButton.setEnabled(false);
|
||||||
mSearchLayout = view.findViewById(R.id.layoutSearchField);
|
mSearchLayout = view.findViewById(R.id.layoutSearchField);
|
||||||
|
|
||||||
mClearSearchFieldButton = view.findViewById(R.id.clearSearchField);
|
|
||||||
mClearSearchFieldButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
||||||
mContactsFetchInProgress.setVisibility(View.VISIBLE);
|
mContactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mSearchAdapter = new SearchContactsListAdapter(null, mContactsFetchInProgress, this, mCreateGroupChatRoom == false);
|
mSearchAdapter = new SearchContactsListAdapter(null, mContactsFetchInProgress, this, mCreateGroupChatRoom == false);
|
||||||
|
|
||||||
mSearchField = view.findViewById(R.id.searchField);
|
mSearchField = view.findViewById(R.id.searchField);
|
||||||
mSearchField.addTextChangedListener(new TextWatcher() {
|
mSearchField.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
if (before > count) {
|
return true;
|
||||||
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
|
mSearchAdapter.searchContacts(newText, mContactsList);
|
||||||
}
|
return true;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -326,7 +317,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateList() {
|
private void updateList() {
|
||||||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
mSearchAdapter.searchContacts(mSearchField.getQuery().toString(), mContactsList);
|
||||||
mSearchAdapter.notifyDataSetChanged();
|
mSearchAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +345,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
|
|
||||||
private void resetAndResearch() {
|
private void resetAndResearch() {
|
||||||
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
||||||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
mSearchAdapter.searchContacts(mSearchField.getQuery().toString(), mContactsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSelectedContactAddress(ContactAddress ca) {
|
private void addSelectedContactAddress(ContactAddress ca) {
|
||||||
|
@ -453,7 +444,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
LinphoneActivity.instance().goToChatGroupInfos(mChatRoomAddress, mContactsSelected, mChatRoomSubject, true, true, mShareInfos, mSecurityToggle.isChecked());
|
LinphoneActivity.instance().goToChatGroupInfos(mChatRoomAddress, mContactsSelected, mChatRoomSubject, true, true, mShareInfos, mSecurityToggle.isChecked());
|
||||||
}
|
}
|
||||||
} else if (id == R.id.clearSearchField) {
|
} else if (id == R.id.clearSearchField) {
|
||||||
mSearchField.setText("");
|
mSearchField.setQuery("", false);
|
||||||
mSearchAdapter.searchContacts("", mContactsList);
|
mSearchAdapter.searchContacts("", mContactsList);
|
||||||
} else if (id == R.id.contactChatDelete) {
|
} else if (id == R.id.contactChatDelete) {
|
||||||
ContactAddress ca = (ContactAddress) view.getTag();
|
ContactAddress ca = (ContactAddress) view.getTag();
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.linphone.core.ChatRoomListenerStub;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.CoreListenerStub;
|
import org.linphone.core.CoreListenerStub;
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
|
import org.linphone.core.ProxyConfig;
|
||||||
import org.linphone.fragments.FragmentsAvailable;
|
import org.linphone.fragments.FragmentsAvailable;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.SelectableHelper;
|
import org.linphone.ui.SelectableHelper;
|
||||||
|
@ -210,6 +211,9 @@ public class ChatListFragment extends Fragment implements ContactsUpdatedListene
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshChatRoomsList();
|
refreshChatRoomsList();
|
||||||
|
|
||||||
|
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||||
|
mNewGroupDiscussionButton.setEnabled(lpc != null && lpc.getConferenceFactoryUri() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,9 +33,9 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.SearchView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
|
@ -56,8 +56,7 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
private int lastKnownPosition;
|
private int lastKnownPosition;
|
||||||
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
||||||
private String sipAddressToAdd, displayName = null;
|
private String sipAddressToAdd, displayName = null;
|
||||||
private ImageView clearSearchField;
|
private SearchView mSearchView;
|
||||||
private EditText searchField;
|
|
||||||
private ProgressBar contactsFetchInProgress;
|
private ProgressBar contactsFetchInProgress;
|
||||||
private LinearLayoutManager layoutManager;
|
private LinearLayoutManager layoutManager;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@ -149,27 +148,17 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSearchField = view.findViewById(R.id.clearSearchField);
|
mSearchView = view.findViewById(R.id.searchField);
|
||||||
clearSearchField.setOnClickListener(new View.OnClickListener() {
|
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
searchField.setText("");
|
return true;
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchField = view.findViewById(R.id.searchField);
|
|
||||||
searchField.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
}
|
searchContacts(newText.toString());
|
||||||
|
return true;
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
searchContacts(searchField.getText().toString());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -232,7 +221,7 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
noContact.setVisibility(View.GONE);
|
noContact.setVisibility(View.GONE);
|
||||||
contactsList.setVisibility(View.VISIBLE);
|
contactsList.setVisibility(View.VISIBLE);
|
||||||
boolean isEditionEnabled = false;
|
boolean isEditionEnabled = false;
|
||||||
if (searchField.getText().toString() == "") {
|
if (mSearchView.getQuery().toString() == "") {
|
||||||
if (onlyDisplayLinphoneContacts) {
|
if (onlyDisplayLinphoneContacts) {
|
||||||
listContact = ContactsManager.getInstance().getSIPContacts();
|
listContact = ContactsManager.getInstance().getSIPContacts();
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,9 +229,9 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (onlyDisplayLinphoneContacts) {
|
if (onlyDisplayLinphoneContacts) {
|
||||||
listContact = ContactsManager.getInstance().getSIPContacts(searchField.getText().toString());
|
listContact = ContactsManager.getInstance().getSIPContacts(mSearchView.getQuery().toString());
|
||||||
} else {
|
} else {
|
||||||
listContact = ContactsManager.getInstance().getContacts(searchField.getText().toString());
|
listContact = ContactsManager.getInstance().getContacts(mSearchView.getQuery().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,8 +256,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
} else if (onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
|
} else if (onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
|
||||||
noSipContact.setVisibility(View.VISIBLE);
|
noSipContact.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeContactsToggle() {
|
private void changeContactsToggle() {
|
||||||
|
@ -365,8 +352,8 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
if (searchField != null && searchField.getText().toString().length() > 0) {
|
if (mSearchView != null && mSearchView.getQuery().toString().length() > 0) {
|
||||||
searchContacts(searchField.getText().toString());
|
searchContacts(mSearchView.getQuery().toString());
|
||||||
} else {
|
} else {
|
||||||
changeContactsAdapter();
|
changeContactsAdapter();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
|
|
||||||
private List<LinphoneContact> mContacts, mSipContacts;
|
private List<LinphoneContact> mContacts, mSipContacts;
|
||||||
private MagicSearch magicSearch;
|
private MagicSearch magicSearch;
|
||||||
private boolean preferLinphoneContacts = false;
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private HashMap<String, LinphoneContact> mAndroidContactsCache;
|
private HashMap<String, LinphoneContact> mAndroidContactsCache;
|
||||||
private Bitmap defaultAvatar;
|
private Bitmap defaultAvatar;
|
||||||
|
@ -202,12 +201,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
return contactsR && !mActivity.getResources().getBoolean(R.bool.force_use_of_linphone_friends);
|
return contactsR && !mActivity.getResources().getBoolean(R.bool.force_use_of_linphone_friends);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLinphoneContactsPrefered(boolean isPrefered) {
|
|
||||||
preferLinphoneContacts = isPrefered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLinphoneContactsPrefered() {
|
public boolean isLinphoneContactsPrefered() {
|
||||||
return preferLinphoneContacts;
|
ProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
|
if (lpc != null && lpc.getIdentityAddress().getDomain().equals(getString(R.string.default_domain))) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeContactManager(Activity activity) {
|
public void initializeContactManager(Activity activity) {
|
||||||
|
|
|
@ -85,7 +85,8 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private boolean mOnlySipContact = false;
|
private boolean mOnlySipContact = false;
|
||||||
private ViewHolder.ClickListener mListener;
|
private ViewHolder.ClickListener mListener;
|
||||||
private boolean mHideSelectionMark = false;
|
private boolean mHideSelectionMark;
|
||||||
|
private String mPreviousSearch;
|
||||||
|
|
||||||
public List<ContactAddress> getContacts() {
|
public List<ContactAddress> getContacts() {
|
||||||
return contacts;
|
return contacts;
|
||||||
|
@ -105,6 +106,7 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
progressBar = pB;
|
progressBar = pB;
|
||||||
setContactsSelectedList(null);
|
setContactsSelectedList(null);
|
||||||
setContactsList(contactsList);
|
setContactsList(contactsList);
|
||||||
|
mPreviousSearch = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -259,6 +261,13 @@ public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContac
|
||||||
public void searchContacts(String search, RecyclerView resultContactsSearch) {
|
public void searchContacts(String search, RecyclerView resultContactsSearch) {
|
||||||
List<ContactAddress> result = new ArrayList<>();
|
List<ContactAddress> result = new ArrayList<>();
|
||||||
|
|
||||||
|
if (mPreviousSearch != null) {
|
||||||
|
if (mPreviousSearch.length() > search.length()) {
|
||||||
|
ContactsManager.getInstance().getMagicSearch().resetSearchCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mPreviousSearch = search;
|
||||||
|
|
||||||
String domain = "";
|
String domain = "";
|
||||||
ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig();
|
ProxyConfig prx = LinphoneManager.getLc().getDefaultProxyConfig();
|
||||||
if (prx != null) domain = prx.getDomain();
|
if (prx != null) domain = prx.getDomain();
|
||||||
|
|
Loading…
Reference in a new issue