From 77331e9b94e8e68794c5dadf08d282768f4dbe4d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 5 Sep 2022 15:06:57 +0200 Subject: [PATCH] Allow to long press conference info to select many of them & delete them at once + show cancelled conferences differently in meeting tab --- .../adapters/ScheduledConferencesAdapter.kt | 31 ++++++++++- .../data/ScheduledConferenceData.kt | 8 ++- .../fragments/ScheduledConferencesFragment.kt | 22 +++++--- .../ScheduledConferencesViewModel.kt | 15 ++++++ .../res/drawable/button_conference_info.xml | 2 + .../drawable/shape_round_red_background.xml | 5 ++ ...ound_red_background_with_orange_border.xml | 6 +++ .../res/layout/conference_schedule_cell.xml | 52 ++++++++++++++++--- .../layout/conferences_scheduled_fragment.xml | 11 +++- app/src/main/res/values-fr/strings.xml | 5 +- app/src/main/res/values-he/strings.xml | 2 +- app/src/main/res/values-ka/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 2 +- app/src/main/res/values-uk/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/colors.xml | 3 +- app/src/main/res/values/strings.xml | 9 +++- app/src/main/res/values/styles.xml | 2 +- 18 files changed, 154 insertions(+), 27 deletions(-) create mode 100644 app/src/main/res/drawable/shape_round_red_background.xml create mode 100644 app/src/main/res/drawable/shape_round_red_background_with_orange_border.xml diff --git a/app/src/main/java/org/linphone/activities/main/conference/adapters/ScheduledConferencesAdapter.kt b/app/src/main/java/org/linphone/activities/main/conference/adapters/ScheduledConferencesAdapter.kt index e65b88e92..8784ff34a 100644 --- a/app/src/main/java/org/linphone/activities/main/conference/adapters/ScheduledConferencesAdapter.kt +++ b/app/src/main/java/org/linphone/activities/main/conference/adapters/ScheduledConferencesAdapter.kt @@ -27,10 +27,11 @@ import androidx.databinding.DataBindingUtil import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.MutableLiveData import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import org.linphone.R +import org.linphone.activities.main.adapters.SelectionListAdapter import org.linphone.activities.main.conference.data.ScheduledConferenceData +import org.linphone.activities.main.viewmodels.ListTopBarViewModel import org.linphone.databinding.ConferenceScheduleCellBinding import org.linphone.databinding.ConferenceScheduleListHeaderBinding import org.linphone.utils.Event @@ -38,8 +39,9 @@ import org.linphone.utils.HeaderAdapter import org.linphone.utils.TimestampUtils class ScheduledConferencesAdapter( + selectionVM: ListTopBarViewModel, private val viewLifecycleOwner: LifecycleOwner -) : ListAdapter(ConferenceInfoDiffCallback()), +) : SelectionListAdapter(selectionVM, ConferenceInfoDiffCallback()), HeaderAdapter { val copyAddressToClipboardEvent: MutableLiveData> by lazy { MutableLiveData>() @@ -106,6 +108,31 @@ class ScheduledConferencesAdapter( lifecycleOwner = viewLifecycleOwner + // This is for item selection through ListTopBarFragment + selectionListViewModel = selectionViewModel + selectionViewModel.isEditionEnabled.observe( + viewLifecycleOwner + ) { + position = bindingAdapterPosition + } + + setClickListener { + if (selectionViewModel.isEditionEnabled.value == true) { + selectionViewModel.onToggleSelect(bindingAdapterPosition) + } else { + conferenceData.toggleExpand() + } + } + + setLongClickListener { + if (selectionViewModel.isEditionEnabled.value == false) { + selectionViewModel.isEditionEnabled.value = true + // Selection will be handled by click listener + true + } + false + } + setCopyAddressClickListener { val address = conferenceData.getAddressAsString() if (address.isNotEmpty()) { diff --git a/app/src/main/java/org/linphone/activities/main/conference/data/ScheduledConferenceData.kt b/app/src/main/java/org/linphone/activities/main/conference/data/ScheduledConferenceData.kt index 78294e863..dd12fc5fb 100644 --- a/app/src/main/java/org/linphone/activities/main/conference/data/ScheduledConferenceData.kt +++ b/app/src/main/java/org/linphone/activities/main/conference/data/ScheduledConferenceData.kt @@ -107,7 +107,13 @@ class ScheduledConferenceData(val conferenceInfo: ConferenceInfo, private val is } private fun computeBackgroundResId() { - backgroundResId.value = if (isFinished) { + backgroundResId.value = if (conferenceInfo.state == ConferenceInfoState.Cancelled) { + if (expanded.value == true) { + R.drawable.shape_round_red_background_with_orange_border + } else { + R.drawable.shape_round_red_background + } + } else if (isFinished) { if (expanded.value == true) { R.drawable.shape_round_dark_gray_background_with_orange_border } else { diff --git a/app/src/main/java/org/linphone/activities/main/conference/fragments/ScheduledConferencesFragment.kt b/app/src/main/java/org/linphone/activities/main/conference/fragments/ScheduledConferencesFragment.kt index 78c186384..3ebc5dd26 100644 --- a/app/src/main/java/org/linphone/activities/main/conference/fragments/ScheduledConferencesFragment.kt +++ b/app/src/main/java/org/linphone/activities/main/conference/fragments/ScheduledConferencesFragment.kt @@ -28,10 +28,11 @@ import android.view.View import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.LinearLayoutManager import org.linphone.R -import org.linphone.activities.GenericFragment import org.linphone.activities.main.MainActivity import org.linphone.activities.main.conference.adapters.ScheduledConferencesAdapter +import org.linphone.activities.main.conference.data.ScheduledConferenceData import org.linphone.activities.main.conference.viewmodels.ScheduledConferencesViewModel +import org.linphone.activities.main.fragments.MasterFragment import org.linphone.activities.main.viewmodels.DialogViewModel import org.linphone.activities.navigateToConferenceScheduling import org.linphone.activities.navigateToConferenceWaitingRoom @@ -41,9 +42,9 @@ import org.linphone.utils.DialogUtils import org.linphone.utils.Event import org.linphone.utils.RecyclerViewHeaderDecoration -class ScheduledConferencesFragment : GenericFragment() { +class ScheduledConferencesFragment : MasterFragment() { + override val dialogConfirmationMessageBeforeRemoval = R.plurals.conference_scheduled_delete_dialog private lateinit var viewModel: ScheduledConferencesViewModel - private lateinit var adapter: ScheduledConferencesAdapter override fun getLayoutId(): Int = R.layout.conferences_scheduled_fragment @@ -59,9 +60,7 @@ class ScheduledConferencesFragment : GenericFragment val dialogViewModel = - DialogViewModel(AppUtils.getString(R.string.conference_info_confirm_removal)) + DialogViewModel(AppUtils.getString(R.string.conference_scheduled_delete_one_dialog)) deleteConferenceInfoDialog = DialogUtils.getVoipDialog(requireContext(), dialogViewModel) @@ -140,4 +139,13 @@ class ScheduledConferencesFragment : GenericFragment) { + val list = ArrayList() + for (index in indexesOfItemToDelete) { + val conferenceData = adapter.currentList[index] + list.add(conferenceData) + } + viewModel.deleteConferencesInfo(list) + } } diff --git a/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ScheduledConferencesViewModel.kt b/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ScheduledConferencesViewModel.kt index aa441b365..7774c0c4b 100644 --- a/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ScheduledConferencesViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/conference/viewmodels/ScheduledConferencesViewModel.kt @@ -69,6 +69,21 @@ class ScheduledConferencesViewModel : ViewModel() { conferences.value = conferenceInfoList } + fun deleteConferencesInfo(toRemoveList: List) { + val conferenceInfoList = arrayListOf() + + for (confInfo in conferences.value.orEmpty()) { + if (confInfo in toRemoveList) { + confInfo.delete() + confInfo.destroy() + } else { + conferenceInfoList.add(confInfo) + } + } + + conferences.value = conferenceInfoList + } + private fun computeConferenceInfoList() { conferences.value.orEmpty().forEach(ScheduledConferenceData::destroy) diff --git a/app/src/main/res/drawable/button_conference_info.xml b/app/src/main/res/drawable/button_conference_info.xml index 89ec60ccc..d60f4e6fa 100644 --- a/app/src/main/res/drawable/button_conference_info.xml +++ b/app/src/main/res/drawable/button_conference_info.xml @@ -2,6 +2,8 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_round_red_background_with_orange_border.xml b/app/src/main/res/drawable/shape_round_red_background_with_orange_border.xml new file mode 100644 index 000000000..abb8a805f --- /dev/null +++ b/app/src/main/res/drawable/shape_round_red_background_with_orange_border.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/conference_schedule_cell.xml b/app/src/main/res/layout/conference_schedule_cell.xml index eec84fece..415a9a595 100644 --- a/app/src/main/res/layout/conference_schedule_cell.xml +++ b/app/src/main/res/layout/conference_schedule_cell.xml @@ -5,6 +5,12 @@ + + @@ -17,6 +23,12 @@ + + @@ -25,7 +37,8 @@ @@ -35,6 +48,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginTop="5dp" + android:background="@drawable/shape_round_gray_background" backgroundImage="@{data.backgroundResId, default=@drawable/shape_round_gray_background}"> - + + + + @@ -141,6 +177,7 @@ android:layout_marginEnd="10dp" android:layout_marginBottom="10dp" android:selected="@{true}" + android:enabled="@{!selectionListViewModel.isEditionEnabled}" android:contentDescription="@string/content_description_toggle_conference_info_details" android:src="@drawable/button_conference_info" /> @@ -172,7 +209,6 @@ android:visibility="@{data.expanded ? View.VISIBLE : View.GONE, default=gone}" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="10dp" android:orientation="vertical"> + android:orientation="horizontal" + android:visibility="@{data.isConferenceCancelled ? View.GONE : View.VISIBLE}"> - + @@ -56,6 +57,14 @@ + + La vidéo est actuellement désactivée Réunions Aucune réunion planifiée pour le moment. - Voulez-vous supprimer cette réunion \? + Voulez-vous supprimer cette réunion ? + Voulez-vous supprimer ces réunions ? Vous êtes actuellement seul dans cet appel de groupe Vous avez été invité à une réunion Invitation à une réunion @@ -750,4 +751,6 @@ Adresse du serveur de conversation de groupe/sécurisées Adresse du serveur de conférence audio/vidéo URL du serveur de clés pour le chiffrement de bout en bout + L\'organisateur a annulé la conférence + Vous avez annulé la conférence \ No newline at end of file diff --git a/app/src/main/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml index 6545e9cce..b5e01c501 100644 --- a/app/src/main/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -169,7 +169,7 @@ %s הוא מנהל %s כבר לא מנהל ועידה תוזמנה - האם ברצונך למחוק ועידה זו\? + האם ברצונך למחוק ועידה זו\? מידע אודות הועידה נמחק הזמנה לועידה רוחב פס נמוך,מבטל וידאו diff --git a/app/src/main/res/values-ka/strings.xml b/app/src/main/res/values-ka/strings.xml index 13da8d584..39ae92c4c 100644 --- a/app/src/main/res/values-ka/strings.xml +++ b/app/src/main/res/values-ka/strings.xml @@ -189,7 +189,7 @@ ორგანიზატორი: %s აწი ადმინისტრატორია %s აღარ არის ადმინისტრატორი - დარწმუნებული ხართ, რომ გსურთ ამ შეხვედრის წაშლა\? + დარწმუნებული ხართ, რომ გსურთ ამ შეხვედრის წაშლა\? თქვენ ამ მომენტისთვის მარტო ხართ ამ ჯგუფურ ზარში შეხვედრის მოწვევა თქვენ პირველი შეუერთდით ჯგუფურ ზარს diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index aa26b2fad..fa05ff43a 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -670,7 +670,7 @@ %s - сейчас администратор %s больше не администратор Встреча была запланирована - Вы действительно хотите удалить эту встречу\? + Вы действительно хотите удалить эту встречу\? Информация о встречи удалена Простой Использовать TLS diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index a1b8327d5..7ab3e9979 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -307,7 +307,7 @@ Ви не можете змінити схему групового виклику, оскільки забагато учасників Припинених зустрічей ще немає. Зустріч була призначена - Ви справді хочете видалити цю зустріч\? + Ви справді хочете видалити цю зустріч\? Інформацію про зустріч видалено Виявлено низьку пропускну здатність, відео вимикається Вхідний груповий виклик diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index f3bd65803..fa7745519 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -735,7 +735,7 @@ 未安排會議。 主辦人: 會議聊天室 - 您真的要刪除這場會議嗎? + 您真的要刪除這場會議嗎? 您是目前通話中唯一的與會者 您已受邀加入會議 會議邀請 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 21199c801..eda6f6da2 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -37,7 +37,8 @@ #6E8596 #A2A2A2 #EFAE00 - #FF0000 + #FF0000 + #FFE6E6 #F7F7F7 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3a3d5ffd6..fe5d9e168 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -293,7 +293,6 @@ %s is now admin %s is no longer admin Meeting has been scheduled - Do you really want to delete this meeting? Meeting info has been deleted You are currently alone in this group call You have been invited to a meeting @@ -308,6 +307,14 @@ Start Terminated Scheduled + Do you want to delete this meeting? + Do you want to delete these meetings? + + @string/conference_scheduled_delete_one_dialog + @string/conference_scheduled_delete_many_dialog + + Conference has been cancelled by organizer + You have cancelled the conference Incoming Call diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0130e12d5..5db7fb1a5 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -152,7 +152,7 @@