mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Started devices in account profile
This commit is contained in:
parent
62cb1fb3f1
commit
1665c4de22
7 changed files with 234 additions and 3 deletions
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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)
|
||||
)
|
||||
|
|
@ -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<String>()
|
||||
|
||||
val devices = MutableLiveData<ArrayList<AccountDeviceModel>>()
|
||||
|
||||
val internationalPrefix = MutableLiveData<String>()
|
||||
|
||||
val accountFoundEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val expandDetails = MutableLiveData<Boolean>()
|
||||
|
||||
val expandDevices = MutableLiveData<Boolean>()
|
||||
|
||||
val accountRemovedEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
@ -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<AccountDeviceModel>()
|
||||
// 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 {
|
||||
|
|
|
|||
9
app/src/main/res/drawable/calendar_blank.xml
Normal file
9
app/src/main/res/drawable/calendar_blank.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="256"
|
||||
android:viewportHeight="256">
|
||||
<path
|
||||
android:pathData="M208,32H184V24a8,8 0,0 0,-16 0v8H88V24a8,8 0,0 0,-16 0v8H48A16,16 0,0 0,32 48V208a16,16 0,0 0,16 16H208a16,16 0,0 0,16 -16V48A16,16 0,0 0,208 32ZM72,48v8a8,8 0,0 0,16 0V48h80v8a8,8 0,0 0,16 0V48h24V80H48V48ZM208,208H48V96H208V208Z"
|
||||
android:fillColor="#4e6074"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/clock.xml
Normal file
9
app/src/main/res/drawable/clock.xml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="256"
|
||||
android:viewportHeight="256">
|
||||
<path
|
||||
android:pathData="M128,24A104,104 0,1 0,232 128,104.11 104.11,0 0,0 128,24ZM128,216a88,88 0,1 1,88 -88A88.1,88.1 0,0 1,128 216ZM192,128a8,8 0,0 1,-8 8L128,136a8,8 0,0 1,-8 -8L120,72a8,8 0,0 1,16 0v48h48A8,8 0,0 1,192 128Z"
|
||||
android:fillColor="#4e6074"/>
|
||||
</vector>
|
||||
107
app/src/main/res/layout/account_profile_device_list_cell.xml
Normal file
107
app/src/main/res/layout/account_profile_device_list_cell.xml
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?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" />
|
||||
<variable
|
||||
name="model"
|
||||
type="org.linphone.ui.main.settings.model.AccountDeviceModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="15dp"
|
||||
android:paddingBottom="27dp"
|
||||
android:background="@drawable/shape_squircle_gray_2_background">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_700"
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="23dp"
|
||||
android:layout_marginTop="34dp"
|
||||
android:text="@{model.name, default=`Pixel 6 Pro`}"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/gray_9"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="17dp"
|
||||
android:background="@drawable/tertiary_button_background"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:gravity="center"
|
||||
android:text="Remove"
|
||||
android:textColor="@color/tertiary_button_label_color"
|
||||
android:textSize="13sp"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:drawableStart="@drawable/trash_simple"
|
||||
android:drawableTint="@color/tertiary_button_label_color"
|
||||
android:drawablePadding="8dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/name"
|
||||
app:layout_constraintBottom_toBottomOf="@id/name"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_700"
|
||||
android:id="@+id/last_connection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="23dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="Last connection:"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/gray_9"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintTop_toBottomOf="@id/name"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/last_connection_date"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/last_connection_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="@{model.lastConnectionDate, default=`03/10/2023`}"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableStart="@drawable/calendar_blank"
|
||||
android:drawablePadding="6dp"
|
||||
app:layout_constraintTop_toTopOf="@id/last_connection"
|
||||
app:layout_constraintBottom_toBottomOf="@id/last_connection"
|
||||
app:layout_constraintStart_toEndOf="@id/last_connection"
|
||||
app:layout_constraintEnd_toStartOf="@id/last_connection_time"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/last_connection_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:text="@{model.lastConnectionTime, default=`9h25`}"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_9"
|
||||
android:drawableStart="@drawable/clock"
|
||||
android:drawablePadding="6dp"
|
||||
app:layout_constraintTop_toTopOf="@id/last_connection"
|
||||
app:layout_constraintBottom_toBottomOf="@id/last_connection"
|
||||
app:layout_constraintStart_toEndOf="@id/last_connection_date"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
@ -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"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_700"
|
||||
|
|
@ -338,6 +340,45 @@
|
|||
app:layout_constraintTop_toTopOf="@id/mode_background"
|
||||
app:layout_constraintBottom_toBottomOf="@id/mode_background"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:onClick="@{() -> viewModel.toggleDevicesExpand()}"
|
||||
android:id="@+id/devices"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:layout_marginStart="26dp"
|
||||
android:layout_marginEnd="26dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/manage_account_devices_title"
|
||||
android:drawableEnd="@{viewModel.expandDevices ? @drawable/caret_up : @drawable/caret_down, default=@drawable/caret_up}"
|
||||
android:drawableTint="@color/gray_9"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/mode_background"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/devices_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingTop="6dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="21dp"
|
||||
android:background="@drawable/shape_squircle_white_background"
|
||||
android:visibility="@{viewModel.expandDevices ? View.VISIBLE : View.GONE}"
|
||||
app:entries="@{viewModel.devices}"
|
||||
app:layout="@{@layout/account_profile_device_list_cell}"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/devices" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_800"
|
||||
android:id="@+id/actions"
|
||||
|
|
@ -351,7 +392,7 @@
|
|||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/mode_background"/>
|
||||
app:layout_constraintTop_toBottomOf="@id/devices_list"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/actions_background"
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@
|
|||
|
||||
<string name="manage_account_title">Manage account</string>
|
||||
<string name="manage_account_details_title">Details</string>
|
||||
<string name="manage_account_devices_title">Devices</string>
|
||||
<string name="manage_account_add_picture">Add a picture</string>
|
||||
<string name="manage_account_edit_picture">Edit picture</string>
|
||||
<string name="manage_account_status_connected_summary">This account in online, everybody can call you.</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue