Improved touch size of some buttons

This commit is contained in:
Sylvain Berfini 2023-10-10 13:28:43 +02:00
parent b6bdca7b89
commit 7c28c37d0b
11 changed files with 272 additions and 22 deletions

View file

@ -24,9 +24,11 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.UiThread
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.databinding.MeetingScheduleFragmentBinding
import org.linphone.ui.main.fragment.GenericFragment
import org.linphone.ui.main.meetings.viewmodel.ScheduleMeetingViewModel
import org.linphone.utils.Event
@UiThread
@ -37,6 +39,8 @@ class ScheduleMeetingFragment : GenericFragment() {
private lateinit var binding: MeetingScheduleFragmentBinding
private lateinit var viewModel: ScheduleMeetingViewModel
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -48,7 +52,7 @@ class ScheduleMeetingFragment : GenericFragment() {
override fun goBack(): Boolean {
sharedViewModel.closeSlidingPaneEvent.value = Event(true)
// If not done, when going back to ConversationsFragment this fragment will be created again
// If not done, when going back to MeetingsList this fragment will be created again
return findNavController().popBackStack()
}
@ -56,5 +60,18 @@ class ScheduleMeetingFragment : GenericFragment() {
super.onViewCreated(view, savedInstanceState)
binding.lifecycleOwner = viewLifecycleOwner
viewModel = requireActivity().run {
ViewModelProvider(this)[ScheduleMeetingViewModel::class.java]
}
binding.viewModel = viewModel
sharedViewModel.isSlidingPaneSlideable.observe(viewLifecycleOwner) { slideable ->
viewModel.showBackButton.value = slideable
}
binding.setBackClickListener {
goBack()
}
}
}

View file

@ -0,0 +1,58 @@
/*
* 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.meetings.viewmodel
import androidx.annotation.UiThread
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class ScheduleMeetingViewModel @UiThread constructor() : ViewModel() {
companion object {
private const val TAG = "[Schedule Meeting ViewModel]"
}
val showBackButton = MutableLiveData<Boolean>()
val isBroadcastSelected = MutableLiveData<Boolean>()
val showBroadcastHelp = MutableLiveData<Boolean>()
init {
isBroadcastSelected.value = false
showBroadcastHelp.value = false
}
@UiThread
fun selectMeeting() {
isBroadcastSelected.value = false
showBroadcastHelp.value = false
}
@UiThread
fun selectBroadcast() {
isBroadcastSelected.value = true
showBroadcastHelp.value = true
}
@UiThread
fun closeBroadcastHelp() {
showBroadcastHelp.value = false
}
}

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/white" />
<item android:state_pressed="true" android:color="@color/white" />
<item android:color="@color/white"/>
<item android:state_enabled="false"
android:color="@color/white" />
<item android:state_pressed="true"
android:color="@color/white" />
<item
android:color="@color/white"/>
</selector>

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:color="@color/orange_main_500" />
<item android:state_pressed="true" android:color="@color/white" />
<item android:color="@color/orange_main_500"/>
<item android:state_enabled="false"
android:color="@color/orange_main_500" />
<item android:state_pressed="true"
android:color="@color/white" />
<item
android:color="@color/orange_main_500"/>
</selector>

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="50dp" />
<solid android:color="@color/gray_main2_100"/>
</shape>

View file

@ -90,9 +90,10 @@
<ImageView
android:id="@+id/info"
android:layout_width="@dimen/icon_size"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/info"
app:layout_constraintTop_toTopOf="@id/title"
app:layout_constraintBottom_toBottomOf="@id/title"
@ -100,9 +101,10 @@
<ImageView
android:id="@+id/video_call"
android:layout_width="@dimen/icon_size"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/video_camera"
app:layout_constraintTop_toTopOf="@id/title"
app:layout_constraintBottom_toBottomOf="@id/title"
@ -110,9 +112,10 @@
<ImageView
android:id="@+id/call"
android:layout_width="@dimen/icon_size"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="16dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/phone"
app:layout_constraintTop_toTopOf="@id/title"
app:layout_constraintBottom_toBottomOf="@id/title"

View file

@ -56,8 +56,8 @@
android:id="@+id/edit"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/pencil_simple"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/invisible_title"

View file

@ -52,10 +52,10 @@
<ImageView
android:onClick="@{() -> viewModel.saveChanges()}"
android:id="@+id/save"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginEnd="10dp"
android:padding="5dp"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/check"
app:tint="@color/primary_color_selector"
app:layout_constraintEnd_toEndOf="parent"

View file

@ -51,9 +51,10 @@
<ImageView
android:onClick="@{menuClickListener}"
android:id="@+id/menu"
android:layout_width="@dimen/icon_size"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginEnd="10dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/dots_three_vertical"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"

View file

@ -7,6 +7,9 @@
<variable
name="backClickListener"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.main.meetings.viewmodel.ScheduleMeetingViewModel" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
@ -16,9 +19,161 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="80dp"
android:background="@color/white">
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:onClick="@{backClickListener}"
android:visibility="@{viewModel.showBackButton ? View.VISIBLE : View.GONE}"
android:src="@drawable/caret_left"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/title"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/main_page_title_style"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="@dimen/top_bar_height"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:text="@string/meeting_schedule_title"
app:layout_constraintEnd_toStartOf="@id/schedule"
app:layout_constraintStart_toEndOf="@id/back"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/schedule"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:padding="15dp"
android:adjustViewBounds="true"
android:src="@drawable/check"
app:tint="@color/orange_main_500"
app:layout_constraintBottom_toBottomOf="@id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/title" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/meeting"
android:onClick="@{() -> viewModel.selectMeeting()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/meeting_schedule_meeting_label"
android:textColor="@{viewModel.isBroadcastSelected ? @color/secondary_button_label_color : @color/primary_button_label_color, default=@color/primary_button_label_color}"
android:textSize="16sp"
android:gravity="center"
android:drawableStart="@drawable/users_three"
android:drawableTint="@{viewModel.isBroadcastSelected ? @color/secondary_button_label_color : @color/primary_button_label_color, default=@color/primary_button_label_color}"
android:drawablePadding="5dp"
android:background="@{viewModel.isBroadcastSelected ? @drawable/secondary_button_background : @drawable/primary_button_background, default=@drawable/primary_button_background}"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/broadcast"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/broadcast"
android:onClick="@{() -> viewModel.selectBroadcast()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@string/meeting_schedule_broadcast_label"
android:textColor="@{viewModel.isBroadcastSelected ? @color/primary_button_label_color : @color/secondary_button_label_color, default=@color/secondary_button_label_color}"
android:textSize="16sp"
android:gravity="center"
android:drawableStart="@drawable/slideshow"
android:drawableTint="@{viewModel.isBroadcastSelected ? @color/primary_button_label_color : @color/secondary_button_label_color, default=@color/secondary_button_label_color}"
android:drawablePadding="5dp"
android:background="@{viewModel.isBroadcastSelected ? @drawable/primary_button_background : @drawable/secondary_button_background, default=@drawable/secondary_button_background}"
android:paddingTop="@dimen/primary_secondary_buttons_label_padding"
android:paddingBottom="@dimen/primary_secondary_buttons_label_padding"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintStart_toEndOf="@id/meeting"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/broadcast_help"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="@string/meeting_schedule_broadcast_help"
android:textSize="14sp"
android:textColor="@color/gray_main2_500"
android:drawableStart="@drawable/info"
android:drawablePadding="5dp"
android:gravity="center"
android:background="@drawable/shape_squircle_main2_100_background"
android:visibility="@{viewModel.showBroadcastHelp ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toBottomOf="@id/meeting"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/close_broadcast_help"
android:onClick="@{() -> viewModel.closeBroadcastHelp()}"
android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size"
android:layout_marginEnd="16dp"
android:src="@drawable/x"
android:visibility="@{viewModel.showBroadcastHelp ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toTopOf="@id/broadcast_help"
app:layout_constraintBottom_toBottomOf="@id/broadcast_help"
app:layout_constraintEnd_toEndOf="@id/broadcast_help" />
<androidx.appcompat.widget.AppCompatEditText
style="@style/default_text_style_800"
android:id="@+id/subject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:hint="@string/meeting_schedule_subject_hint"
android:textSize="20sp"
android:textColor="@color/gray_main2_600"
android:inputType="text|textCapSentences"
android:drawableStart="@{viewModel.isBroadcastSelected ? @drawable/slideshow : @drawable/users_three, default=@drawable/users_three}"
android:drawablePadding="8dp"
android:background="@color/transparent_color"
app:layout_constraintTop_toBottomOf="@id/broadcast_help"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<View
android:id="@+id/separator"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="10dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/subject"
android:background="@color/gray_main2_200" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -332,6 +332,11 @@
<string name="conversation_text_field_hint">Say something…</string>
<string name="meetings_list_empty">No meeting for the moment…</string>
<string name="meeting_schedule_title">New meeting</string>
<string name="meeting_schedule_meeting_label">Meeting</string>
<string name="meeting_schedule_broadcast_label">Broadcast</string>
<string name="meeting_schedule_broadcast_help">Info about broadcast. <u>Learn more</u></string>
<string name="meeting_schedule_subject_hint">Add title…</string>
<string name="operation_in_progress_overlay">Operation in progress, please wait</string>