mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Started call history detail popup menu
This commit is contained in:
parent
7c4b6d5b20
commit
74a15cd0a1
6 changed files with 196 additions and 0 deletions
|
|
@ -19,18 +19,28 @@
|
|||
*/
|
||||
package org.linphone.ui.main.calls.fragment
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.PopupWindow
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.CallFragmentBinding
|
||||
import org.linphone.databinding.CallPopupMenuBinding
|
||||
import org.linphone.ui.main.calls.viewmodel.CallLogViewModel
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.utils.Event
|
||||
import org.linphone.utils.slideInToastFromTopForDuration
|
||||
|
||||
class CallFragment : GenericFragment() {
|
||||
private lateinit var binding: CallFragmentBinding
|
||||
|
|
@ -70,6 +80,10 @@ class CallFragment : GenericFragment() {
|
|||
goBack()
|
||||
}
|
||||
|
||||
binding.setMenuClickListener {
|
||||
showPopupMenu()
|
||||
}
|
||||
|
||||
sharedViewModel.isSlidingPaneSlideable.observe(viewLifecycleOwner) { slideable ->
|
||||
viewModel.showBackButton.value = slideable
|
||||
}
|
||||
|
|
@ -81,4 +95,44 @@ class CallFragment : GenericFragment() {
|
|||
sharedViewModel.openSlidingPaneEvent.value = Event(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyNumberOrAddressToClipboard(value: String) {
|
||||
val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val label = "SIP address"
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(label, value))
|
||||
|
||||
binding.greenToast.message = "Numéro copié dans le presse-papier"
|
||||
binding.greenToast.icon = R.drawable.check
|
||||
|
||||
val target = binding.greenToast.root
|
||||
target.slideInToastFromTopForDuration(binding.root as ViewGroup, lifecycleScope)
|
||||
}
|
||||
|
||||
private fun showPopupMenu() {
|
||||
val popupView: CallPopupMenuBinding = DataBindingUtil.inflate(
|
||||
LayoutInflater.from(requireContext()),
|
||||
R.layout.call_popup_menu,
|
||||
null,
|
||||
false
|
||||
)
|
||||
|
||||
popupView.setDeleteAllHistoryClickListener {
|
||||
viewModel.deleteHistory()
|
||||
}
|
||||
|
||||
popupView.setCopyNumberClickListener {
|
||||
copyNumberOrAddressToClipboard(viewModel.callLogModel.value?.displayedAddress.orEmpty())
|
||||
}
|
||||
|
||||
val popupWindow = PopupWindow(
|
||||
popupView.root,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
true
|
||||
)
|
||||
|
||||
// Elevation is for showing a shadow around the popup
|
||||
popupWindow.elevation = 20f
|
||||
popupWindow.showAsDropDown(binding.menu, 0, 0, Gravity.BOTTOM)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,13 @@ class CallLogViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
fun deleteHistory() {
|
||||
// UI thread
|
||||
// TODO
|
||||
}
|
||||
|
||||
fun startAudioCall() {
|
||||
// UI thread
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val params = core.createCallParams(null)
|
||||
params?.isVideoEnabled = false
|
||||
|
|
@ -52,6 +58,7 @@ class CallLogViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun startVideoCall() {
|
||||
// UI thread
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val params = core.createCallParams(null)
|
||||
params?.isVideoEnabled = true
|
||||
|
|
@ -60,6 +67,7 @@ class CallLogViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
fun sendMessage() {
|
||||
// UI thread
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
app/src/main/res/drawable/contact.xml
Normal file
20
app/src/main/res/drawable/contact.xml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="20"
|
||||
android:viewportHeight="20">
|
||||
<group android:name="group">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 10 0 C 4.48 0 0 4.48 0 10 C 0 15.52 4.48 20 10 20 C 15.52 20 20 15.52 20 10 C 20 4.48 15.52 0 10 0 Z M 5.35 16.5 C 6.66 15.56 8.26 15 10 15 C 11.74 15 13.34 15.56 14.65 16.5 C 13.34 17.44 11.74 18 10 18 C 8.26 18 6.66 17.44 5.35 16.5 Z M 16.14 15.12 C 14.45 13.8 12.32 13 10 13 C 7.68 13 5.55 13.8 3.86 15.12 C 2.7 13.73 2 11.95 2 10 C 2 5.58 5.58 2 10 2 C 14.42 2 18 5.58 18 10 C 18 11.95 17.3 13.73 16.14 15.12 Z"
|
||||
android:fillColor="#000"
|
||||
android:strokeWidth="1"/>
|
||||
<path
|
||||
android:name="path_1"
|
||||
android:pathData="M 10 4 C 8.07 4 6.5 5.57 6.5 7.5 C 6.5 9.43 8.07 11 10 11 C 11.93 11 13.5 9.43 13.5 7.5 C 13.5 5.57 11.93 4 10 4 Z M 10 9 C 9.17 9 8.5 8.33 8.5 7.5 C 8.5 6.67 9.17 6 10 6 C 10.83 6 11.5 6.67 11.5 7.5 C 11.5 8.33 10.83 9 10 9 Z"
|
||||
android:fillColor="#000"
|
||||
android:strokeWidth="1"/>
|
||||
</group>
|
||||
</vector>
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
android:textColor="@color/gray_1"
|
||||
android:drawableStart="@drawable/manage_profile"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_8"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
<variable
|
||||
name="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="menuClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.calls.viewmodel.CallLogViewModel" />
|
||||
|
|
@ -35,6 +38,7 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/menu"/>
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{menuClickListener}"
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
|
|
|
|||
109
app/src/main/res/layout/call_popup_menu.xml
Normal file
109
app/src/main/res/layout/call_popup_menu.xml
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
<?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="copyNumberClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="deleteAllHistoryClickListener"
|
||||
type="View.OnClickListener" />
|
||||
</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
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/add_to_contact"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="Ajouter aux contats"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:drawableStart="@drawable/add"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_8"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/go_to_contact"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/go_to_contact"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="Voir le contact"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:drawableStart="@drawable/contact"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_8"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/add_to_contact"
|
||||
app:layout_constraintBottom_toTopOf="@id/copy_number"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{copyNumberClickListener}"
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/copy_number"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="Copier le numéro"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_1"
|
||||
android:drawableStart="@drawable/copy"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/gray_8"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/go_to_contact"
|
||||
app:layout_constraintBottom_toTopOf="@id/delete_history"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{deleteAllHistoryClickListener}"
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/delete_history"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="left|center_vertical"
|
||||
android:text="Delete all history"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/red_danger"
|
||||
android:drawableStart="@drawable/delete"
|
||||
android:drawablePadding="5dp"
|
||||
app:drawableTint="@color/red_danger"
|
||||
app:layout_constraintWidth_min="170dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/copy_number"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
Loading…
Add table
Reference in a new issue