mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added contacts list filter popup menu
This commit is contained in:
parent
027e5dd61b
commit
d58e5f9fc2
6 changed files with 143 additions and 7 deletions
|
|
@ -33,7 +33,6 @@ import androidx.emoji2.text.EmojiCompat
|
|||
import androidx.lifecycle.MutableLiveData
|
||||
import java.util.*
|
||||
import org.linphone.BuildConfig
|
||||
import org.linphone.LinphoneApplication
|
||||
import org.linphone.LinphoneApplication.Companion.corePreferences
|
||||
import org.linphone.contacts.ContactsManager
|
||||
import org.linphone.core.tools.Log
|
||||
|
|
|
|||
|
|
@ -265,10 +265,14 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
// TODO FIXME: Remote is call being transferred, not transferee !
|
||||
if (state == Call.State.OutgoingProgress) {
|
||||
val displayName = coreContext.contactsManager.findDisplayName(transfered.remoteAddress)
|
||||
val displayName = coreContext.contactsManager.findDisplayName(
|
||||
transfered.remoteAddress
|
||||
)
|
||||
transferInProgressEvent.postValue(Event(displayName))
|
||||
} else if (LinphoneUtils.isCallEnding(state)) {
|
||||
val displayName = coreContext.contactsManager.findDisplayName(transfered.remoteAddress)
|
||||
val displayName = coreContext.contactsManager.findDisplayName(
|
||||
transfered.remoteAddress
|
||||
)
|
||||
transferFailedEvent.postValue(Event(displayName))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,18 +22,22 @@ package org.linphone.ui.main.contacts.fragment
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.ContactsContract
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import java.io.File
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ContactsListFilterPopupMenuBinding
|
||||
import org.linphone.databinding.ContactsListFragmentBinding
|
||||
import org.linphone.ui.main.contacts.adapter.ContactsListAdapter
|
||||
import org.linphone.ui.main.contacts.viewmodel.ContactsListViewModel
|
||||
|
|
@ -133,8 +137,7 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
}
|
||||
|
||||
binding.setFilterClickListener {
|
||||
// TODO FIXME: show context menu first to let user decides which filter to use
|
||||
listViewModel.toggleContactsFilter()
|
||||
showFilterPopupMenu(binding.filter)
|
||||
}
|
||||
|
||||
sharedViewModel.defaultAccountChangedEvent.observe(viewLifecycleOwner) {
|
||||
|
|
@ -230,4 +233,39 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
|
||||
private fun showFilterPopupMenu(view: View) {
|
||||
val popupView: ContactsListFilterPopupMenuBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(requireContext()),
|
||||
R.layout.contacts_list_filter_popup_menu,
|
||||
null,
|
||||
false
|
||||
)
|
||||
popupView.seeAllSelected = listViewModel.areAllContactsDisplayed()
|
||||
|
||||
val popupWindow = PopupWindow(
|
||||
popupView.root,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
true
|
||||
)
|
||||
|
||||
popupView.setNoFilterClickListener {
|
||||
if (!listViewModel.areAllContactsDisplayed()) {
|
||||
listViewModel.changeContactsFilter(onlyLinphoneContacts = false)
|
||||
}
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
popupView.setLinphoneOnlyClickListener {
|
||||
if (listViewModel.areAllContactsDisplayed()) {
|
||||
listViewModel.changeContactsFilter(onlyLinphoneContacts = true)
|
||||
}
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
// Elevation is for showing a shadow around the popup
|
||||
popupWindow.elevation = 20f
|
||||
popupWindow.showAsDropDown(view, 0, 0, Gravity.BOTTOM)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,11 +120,15 @@ class ContactsListViewModel @UiThread constructor() : AbstractTopBarViewModel()
|
|||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleContactsFilter() {
|
||||
limitSearchToLinphoneAccounts = !limitSearchToLinphoneAccounts
|
||||
fun changeContactsFilter(onlyLinphoneContacts: Boolean) {
|
||||
limitSearchToLinphoneAccounts = onlyLinphoneContacts
|
||||
applyFilter(currentFilter)
|
||||
}
|
||||
|
||||
fun areAllContactsDisplayed(): Boolean {
|
||||
return !limitSearchToLinphoneAccounts
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleFavouritesVisibility() {
|
||||
showFavourites.value = showFavourites.value == false
|
||||
|
|
|
|||
89
app/src/main/res/layout/contacts_list_filter_popup_menu.xml
Normal file
89
app/src/main/res/layout/contacts_list_filter_popup_menu.xml
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="android.graphics.Typeface" />
|
||||
<variable
|
||||
name="noFilterClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="linphoneOnlyClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="seeAllSelected"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/shape_round_popup_menu_background">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/no_filter"
|
||||
android:onClick="@{noFilterClickListener}"
|
||||
style="@style/default_text_style"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:text="@string/contacts_list_filter_popup_see_all"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/no_filter_selected"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/linphone_filter"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/no_filter_selected"
|
||||
android:onClick="@{noFilterClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/check_fat_fill"
|
||||
android:visibility="@{seeAllSelected ? View.VISIBLE : View.INVISIBLE, default=invisible}"
|
||||
app:tint="@color/green_success_500"
|
||||
app:layout_constraintTop_toTopOf="@id/no_filter"
|
||||
app:layout_constraintBottom_toBottomOf="@id/no_filter"
|
||||
app:layout_constraintStart_toStartOf="@id/linphone_filter_selected"
|
||||
app:layout_constraintEnd_toEndOf="@id/linphone_filter_selected"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/linphone_filter"
|
||||
android:onClick="@{linphoneOnlyClickListener}"
|
||||
style="@style/default_text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:text="@string/contacts_list_filter_popup_see_linphone_only"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_main2_500"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/no_filter"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/linphone_filter_selected"
|
||||
android:onClick="@{linphoneOnlyClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:src="@drawable/check_fat_fill"
|
||||
android:visibility="@{seeAllSelected ? View.INVISIBLE : View.VISIBLE}"
|
||||
app:tint="@color/green_success_500"
|
||||
app:layout_constraintTop_toTopOf="@id/linphone_filter"
|
||||
app:layout_constraintBottom_toBottomOf="@id/linphone_filter"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/linphone_filter"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -243,6 +243,8 @@
|
|||
<string name="contacts_list_empty">No contact for the moment…</string>
|
||||
<string name="contacts_list_favourites_title">Favourites</string>
|
||||
<string name="contacts_list_all_contacts_title">All contacts</string>
|
||||
<string name="contacts_list_filter_popup_see_all">See all</string>
|
||||
<string name="contacts_list_filter_popup_see_linphone_only">See &appName; contacts</string>
|
||||
|
||||
<string name="contact_new_title">New contact</string>
|
||||
<string name="contact_edit_title">Edit contact</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue