From 1665c4de22e1476bef38ac5c4c79246417d045be Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 14 Sep 2023 12:13:33 +0200 Subject: [PATCH] Started devices in account profile --- .../main/settings/model/AccountDeviceModel.kt | 29 +++++ .../viewmodel/AccountProfileViewModel.kt | 35 ++++++ app/src/main/res/drawable/calendar_blank.xml | 9 ++ app/src/main/res/drawable/clock.xml | 9 ++ .../account_profile_device_list_cell.xml | 107 ++++++++++++++++++ .../res/layout/account_profile_fragment.xml | 47 +++++++- app/src/main/res/values/strings.xml | 1 + 7 files changed, 234 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt create mode 100644 app/src/main/res/drawable/calendar_blank.xml create mode 100644 app/src/main/res/drawable/clock.xml create mode 100644 app/src/main/res/layout/account_profile_device_list_cell.xml diff --git a/app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt b/app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt new file mode 100644 index 000000000..0a173f5ca --- /dev/null +++ b/app/src/main/java/org/linphone/ui/main/settings/model/AccountDeviceModel.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-android + * (see https://www.linphone.org). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.linphone.ui.main.settings.model + +import androidx.annotation.WorkerThread + +class AccountDeviceModel @WorkerThread constructor( + val name: String, + val lastConnectionDate: String, + val lastConnectionTime: String, + private val onRemove: () -> (Unit) +) diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt index 97e440d48..af06059a5 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/AccountProfileViewModel.kt @@ -8,6 +8,7 @@ import org.linphone.R import org.linphone.core.Account import org.linphone.core.tools.Log import org.linphone.ui.main.model.AccountModel +import org.linphone.ui.main.settings.model.AccountDeviceModel import org.linphone.utils.AppUtils import org.linphone.utils.Event @@ -26,12 +27,16 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() { val currentMode = MutableLiveData() + val devices = MutableLiveData>() + val internationalPrefix = MutableLiveData() val accountFoundEvent = MutableLiveData>() val expandDetails = MutableLiveData() + val expandDevices = MutableLiveData() + val accountRemovedEvent: MutableLiveData> by lazy { MutableLiveData>() } @@ -40,6 +45,7 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() { init { expandDetails.value = true + expandDevices.value = false // TODO: set to true when feature will be available } @UiThread @@ -70,6 +76,30 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() { displayName.postValue(account.params.identityAddress?.displayName) internationalPrefix.postValue(account.params.internationalPrefix) + val devicesList = arrayListOf() + // TODO FIXME: use real devices list from API + devicesList.add( + AccountDeviceModel("Pixel 6 Pro de Sylvain", "03/10/2023", "9h25") { + } + ) + devicesList.add( + AccountDeviceModel( + "Sylvain Galaxy Tab S9 Pro+ Ultra", + "03/10/2023", + "9h25" + ) { + } + ) + devicesList.add( + AccountDeviceModel("MacBook Pro de Marcel", "03/10/2023", "9h25") { + } + ) + devicesList.add( + AccountDeviceModel("sylvain@fedora-linux-38", "03/10/2023", "9h25") { + } + ) + devices.postValue(devicesList) + accountFoundEvent.postValue(Event(true)) } else { accountFoundEvent.postValue(Event(false)) @@ -147,6 +177,11 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() { expandDetails.value = expandDetails.value == false } + @UiThread + fun toggleDevicesExpand() { + expandDevices.value = expandDevices.value == false + } + @UiThread fun toggleRegister() { coreContext.postOnCoreThread { diff --git a/app/src/main/res/drawable/calendar_blank.xml b/app/src/main/res/drawable/calendar_blank.xml new file mode 100644 index 000000000..d67ddb206 --- /dev/null +++ b/app/src/main/res/drawable/calendar_blank.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/clock.xml b/app/src/main/res/drawable/clock.xml new file mode 100644 index 000000000..750dbdd78 --- /dev/null +++ b/app/src/main/res/drawable/clock.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/account_profile_device_list_cell.xml b/app/src/main/res/layout/account_profile_device_list_cell.xml new file mode 100644 index 000000000..abae22553 --- /dev/null +++ b/app/src/main/res/layout/account_profile_device_list_cell.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/account_profile_fragment.xml b/app/src/main/res/layout/account_profile_fragment.xml index 09084e2b4..c15c57f2b 100644 --- a/app/src/main/res/layout/account_profile_fragment.xml +++ b/app/src/main/res/layout/account_profile_fragment.xml @@ -101,6 +101,7 @@ android:id="@+id/avatar_trust_badge" android:layout_width="@dimen/avatar_presence_badge_big_size" android:layout_height="@dimen/avatar_presence_badge_big_size" + android:layout_marginStart="@dimen/avatar_presence_badge_big_end_margin" android:src="@drawable/trusted" app:layout_constraintStart_toStartOf="@id/avatar" app:layout_constraintBottom_toBottomOf="@id/avatar"/> @@ -182,12 +183,13 @@ android:paddingTop="8dp" android:paddingBottom="8dp" android:text="@={viewModel.sipAddress, default=`sip:johndoe@sip.example.org`}" - android:textSize="14sp" + android:textSize="13sp" android:maxLines="1" android:ellipsize="end" app:layout_constraintStart_toEndOf="@id/sip_address_label" app:layout_constraintEnd_toEndOf="@id/details_background" - app:layout_constraintTop_toTopOf="@id/details_background"/> + app:layout_constraintTop_toTopOf="@id/sip_address_label" + app:layout_constraintBottom_toBottomOf="@id/sip_address_label"/> + + + + + app:layout_constraintTop_toBottomOf="@id/devices_list"/> Manage account Details + Devices Add a picture Edit picture This account in online, everybody can call you.