Started devices trust in contact details

This commit is contained in:
Sylvain Berfini 2023-08-08 17:07:18 +02:00
parent e147efd358
commit 2565d8155d
12 changed files with 251 additions and 8 deletions

17
.idea/deploymentTargetDropDown.xml generated Normal file
View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="1A051FDEE005XG" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-08-08T14:19:41.977381455Z" />
</component>
</project>

View file

@ -83,6 +83,9 @@ dependencies {
// https://github.com/GetStream/avatarview-android/blob/main/LICENSE Apache v2.0 // https://github.com/GetStream/avatarview-android/blob/main/LICENSE Apache v2.0
implementation "io.getstream:avatarview-coil:1.0.7" implementation "io.getstream:avatarview-coil:1.0.7"
// https://github.com/akexorcist/RoundCornerProgressBar/blob/master/LICENSE.txt
implementation 'com.akexorcist:round-corner-progress-bar:2.2.1'
implementation platform('com.google.firebase:firebase-bom:30.3.2') implementation platform('com.google.firebase:firebase-bom:30.3.2')
implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-messaging'

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2010-2020 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.contacts.model
class ContactDeviceModel(
val name: String,
val trusted: Boolean
)

View file

@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.linphone.ui.contacts package org.linphone.ui.contacts.model
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import org.linphone.core.Address import org.linphone.core.Address

View file

@ -23,9 +23,10 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.core.Address import org.linphone.core.Address
import org.linphone.ui.contacts.ContactNumberOrAddressClickListener import org.linphone.ui.contacts.model.ContactDeviceModel
import org.linphone.ui.contacts.ContactNumberOrAddressModel
import org.linphone.ui.contacts.model.ContactModel import org.linphone.ui.contacts.model.ContactModel
import org.linphone.ui.contacts.model.ContactNumberOrAddressClickListener
import org.linphone.ui.contacts.model.ContactNumberOrAddressModel
import org.linphone.utils.Event import org.linphone.utils.Event
class ContactViewModel : ViewModel() { class ContactViewModel : ViewModel() {
@ -33,6 +34,8 @@ class ContactViewModel : ViewModel() {
val sipAddressesAndPhoneNumbers = MutableLiveData<ArrayList<ContactNumberOrAddressModel>>() val sipAddressesAndPhoneNumbers = MutableLiveData<ArrayList<ContactNumberOrAddressModel>>()
val devices = MutableLiveData<ArrayList<ContactDeviceModel>>()
val company = MutableLiveData<String>() val company = MutableLiveData<String>()
val showBackButton = MutableLiveData<Boolean>() val showBackButton = MutableLiveData<Boolean>()
@ -63,6 +66,7 @@ class ContactViewModel : ViewModel() {
} }
override fun onLongPress(model: ContactNumberOrAddressModel) { override fun onLongPress(model: ContactNumberOrAddressModel) {
// UI thread
showLongPressMenuForNumberOrAddress.value = Event(model) showLongPressMenuForNumberOrAddress.value = Event(model)
} }
} }
@ -106,6 +110,15 @@ class ContactViewModel : ViewModel() {
addressesAndNumbers.add(data) addressesAndNumbers.add(data)
} }
sipAddressesAndPhoneNumbers.postValue(addressesAndNumbers) sipAddressesAndPhoneNumbers.postValue(addressesAndNumbers)
val devicesList = arrayListOf<ContactDeviceModel>()
// TODO FIXME
devicesList.add(ContactDeviceModel("Pixel 6 Pro de Sylvain", true))
devicesList.add(ContactDeviceModel("Sylvain Galaxy Tab S9 Pro+ Ultra", true))
devicesList.add(ContactDeviceModel("MacBook Pro de Marcel", false))
devicesList.add(ContactDeviceModel("sylvain@fedora-linux-38", true))
devices.postValue(devicesList)
contactFoundEvent.postValue(Event(true)) contactFoundEvent.postValue(Event(true))
} }
} }

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="48dp" />
<solid android:color="@color/warning_orange_background"/>
</shape>

View file

@ -0,0 +1,23 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="path"
android:pathData="M 2.5 3 L 21.5 3 L 21.5 16 L 18 20 L 12 21 L 6.5 20 L 2.5 16 L 2.5 3 Z"
android:fillColor="#4aa8ff"
android:strokeWidth="1"/>
<path
android:name="path_1"
android:pathData="M 8.707 9.293 C 8.317 8.902 7.683 8.902 7.293 9.293 C 6.902 9.683 6.902 10.317 7.293 10.707 L 11.293 14.707 C 11.683 15.098 12.317 15.098 12.707 14.707 L 16.707 10.707 C 17.098 10.317 17.098 9.683 16.707 9.293 C 16.317 8.902 15.683 8.902 15.293 9.293 L 12 12.586 L 8.707 9.293 Z"
android:fillColor="#364860"
android:strokeWidth="1"/>
<path
android:name="path_2"
android:pathData="M 20 2 L 4 2 C 3.204 2 2.441 2.316 1.879 2.879 C 1.316 3.441 1 4.204 1 5 L 1 11 C 1 13.917 2.159 16.715 4.222 18.778 C 5.243 19.8 6.456 20.61 7.79 21.163 C 9.125 21.715 10.556 22 12 22 C 14.917 22 17.715 20.841 19.778 18.778 C 21.841 16.715 23 13.917 23 11 L 23 5 C 23 4.204 22.684 3.441 22.121 2.879 C 21.559 2.316 20.796 2 20 2 Z M 3.293 4.293 C 3.48 4.105 3.735 4 4 4 L 20 4 C 20.265 4 20.52 4.105 20.707 4.293 C 20.895 4.48 21 4.735 21 5 L 21 11 C 21 13.387 20.052 15.676 18.364 17.364 C 16.676 19.052 14.387 20 12 20 C 10.818 20 9.648 19.767 8.556 19.315 C 7.464 18.863 6.472 18.2 5.636 17.364 C 3.948 15.676 3 13.387 3 11 L 3 5 C 3 4.735 3.105 4.48 3.293 4.293 Z"
android:fillColor="#364860"
android:strokeWidth="1"/>
</vector>

View file

@ -0,0 +1,13 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="14dp"
android:height="14dp"
android:viewportWidth="14"
android:viewportHeight="14">
<path
android:name="path"
android:pathData="M 6.417 8.75 L 7.583 8.75 L 7.583 9.916 L 6.417 9.916 L 6.417 8.75 Z M 6.417 4.083 L 7.583 4.083 L 7.583 7.583 L 6.417 7.583 L 6.417 4.083 Z M 6.994 1.167 C 3.774 1.167 1.167 3.78 1.167 7 C 1.167 10.22 3.774 12.833 6.994 12.833 C 10.22 12.833 12.833 10.22 12.833 7 C 12.833 3.78 10.22 1.167 6.994 1.167 Z M 7 11.666 C 4.422 11.666 2.333 9.578 2.333 7 C 2.333 4.421 4.422 2.333 7 2.333 C 9.578 2.333 11.667 4.421 11.667 7 C 11.667 9.578 9.578 11.666 7 11.666 Z"
android:fillColor="#fe5e00"
android:strokeWidth="1"/>
</vector>

View file

@ -0,0 +1,80 @@
<?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="model"
type="org.linphone.ui.contacts.model.ContactDeviceModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="@drawable/cell_background">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/end_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="verify_device, trusted"
app:barrierDirection="start" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/device_name"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="10dp"
android:text="@{model.name, default=`Pixel 6 Pro de Sylvain`}"
android:textColor="@color/gray_9"
android:textSize="14sp"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="@id/end_barrier"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
<ImageView
android:id="@+id/trusted"
android:visibility="@{model.trusted ? View.VISIBLE : View.GONE}"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="10dp"
android:src="@drawable/trusted"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/verify_device"
android:visibility="@{model.trusted ? View.GONE : View.VISIBLE}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="@drawable/shape_round_orange_background"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:gravity="center"
android:drawableStart="@drawable/warning"
android:drawablePadding="8dp"
android:text="Vérifier l'appareil"
android:textColor="@color/primary_color"
android:textSize="12sp"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android" <layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:bind="http://schemas.android.com/tools">
<data> <data>
<import type="android.view.View" /> <import type="android.view.View" />
@ -78,7 +79,7 @@
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
android:layout_marginTop="38dp" android:layout_marginTop="32dp"
android:adjustViewBounds="true" android:adjustViewBounds="true"
contactAvatar="@{viewModel.contact}" contactAvatar="@{viewModel.contact}"
app:avatarViewBorderWidth="0dp" app:avatarViewBorderWidth="0dp"
@ -95,7 +96,7 @@
app:avatarViewShape="circle" app:avatarViewShape="circle"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/background" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/name" android:id="@+id/name"
@ -294,6 +295,67 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_background"/> app:layout_constraintTop_toBottomOf="@id/info_background"/>
<ImageView
android:id="@+id/trust_background"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="9dp"
android:layout_marginStart="17dp"
android:layout_marginEnd="17dp"
android:src="@drawable/shape_round_white_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/trust_label"
app:layout_constraintBottom_toBottomOf="@id/devices"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/trusted_devices_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="17dp"
android:layout_marginEnd="17dp"
android:layout_marginTop="20dp"
android:textSize="14sp"
android:textStyle="bold"
android:text="Nombre d'appareils vérifiés :"
app:layout_constraintStart_toStartOf="@id/trust_background"
app:layout_constraintEnd_toEndOf="@id/trust_background"
app:layout_constraintTop_toTopOf="@id/trust_background" />
<com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar
android:id="@+id/trusted_devices_progress"
android:layout_width="0dp"
android:layout_height="28dp"
android:layout_marginTop="10dp"
android:layout_marginStart="17dp"
android:layout_marginEnd="17dp"
app:rcBackgroundColor="#EEF6F8"
app:rcBackgroundPadding="2dp"
app:rcMax="100"
app:rcProgress="75"
app:rcProgressColor="#4AA8FF"
app:rcRadius="50dp"
app:rcTextProgress="75%"
app:rcTextProgressColor="@color/white"
app:rcTextPositionPriority="inside"
app:layout_constraintStart_toStartOf="@id/trust_background"
app:layout_constraintEnd_toEndOf="@id/trust_background"
app:layout_constraintTop_toBottomOf="@id/trusted_devices_count"/>
<LinearLayout
android:id="@+id/devices"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:padding="10dp"
app:entries="@{viewModel.devices}"
app:layout="@{@layout/contact_device_trust_list_cell}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/trusted_devices_progress" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actions" android:id="@+id/actions"
android:layout_width="0dp" android:layout_width="0dp"
@ -308,7 +370,7 @@
android:textColor="@color/gray_9" android:textColor="@color/gray_9"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/trust_label"/> app:layout_constraintTop_toBottomOf="@id/trust_background"/>
<ImageView <ImageView
android:id="@+id/actions_background" android:id="@+id/actions_background"

View file

@ -8,7 +8,7 @@
<import type="android.graphics.Typeface" /> <import type="android.graphics.Typeface" />
<variable <variable
name="model" name="model"
type="org.linphone.ui.contacts.ContactNumberOrAddressModel" /> type="org.linphone.ui.contacts.model.ContactNumberOrAddressModel" />
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View file

@ -9,6 +9,8 @@
<color name="blue_filter">#09C5F4</color> <color name="blue_filter">#09C5F4</color>
<color name="blue_outgoing_message">#DFECF2</color> <color name="blue_outgoing_message">#DFECF2</color>
<color name="gray_incoming_message">#F4F4F7</color> <color name="gray_incoming_message">#F4F4F7</color>
<color name="trusted_blue">#4AA8FF</color>
<color name="warning_orange_background">#FFEACB</color>
<color name="gray_1">#6C7A87</color> <color name="gray_1">#6C7A87</color>
<color name="gray_2">#F9F9F9</color> <color name="gray_2">#F9F9F9</color>