Moved fragments in dedicated folders + started calls by creating empty files

This commit is contained in:
Sylvain Berfini 2023-08-07 10:45:14 +02:00
parent 5803fe18ed
commit f104d5c891
27 changed files with 271 additions and 39 deletions

View file

@ -0,0 +1,24 @@
/*
* 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.calls.fragment
import androidx.fragment.app.Fragment
class CallsFragment : Fragment()

View file

@ -0,0 +1,24 @@
/*
* 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.calls.fragment
import androidx.fragment.app.Fragment
class CallsListFragment : Fragment()

View file

@ -0,0 +1,24 @@
/*
* 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.calls.fragment
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
class CallsListMenuDialogFragment : BottomSheetDialogFragment()

View file

@ -0,0 +1,24 @@
/*
* 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.calls.fragment
import androidx.fragment.app.Fragment
class StartCallFragment : Fragment()

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.contacts.fragment
import android.os.Bundle
import android.view.LayoutInflater

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.contacts.fragment
import android.os.Bundle
import android.view.LayoutInflater
@ -107,5 +107,14 @@ class ContactsFragment : Fragment() {
}
}
}
sharedViewModel.navigateToCallsEvent.observe(viewLifecycleOwner) {
it.consume {
if (findNavController().currentDestination?.id == R.id.contactsFragment) {
val action = ContactsFragmentDirections.actionContactsFragmentToCallsFragment()
findNavController().navigate(action)
}
}
}
}
}

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.contacts.fragment
import android.content.res.Configuration
import android.os.Bundle
@ -146,6 +146,10 @@ class ContactsListFragment : Fragment() {
sharedViewModel.navigateToConversationsEvent.value = Event(true)
}
binding.setOnCallsClicked {
sharedViewModel.navigateToCallsEvent.value = Event(true)
}
binding.setOnAvatarClickListener {
(requireActivity() as MainActivity).toggleDrawerMenu()
}

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.contacts.fragment
import android.content.DialogInterface
import android.os.Bundle

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.contacts.fragment
import android.os.Bundle
import android.view.LayoutInflater

View file

@ -28,7 +28,6 @@ import android.view.animation.AnimationUtils
import androidx.core.os.bundleOf
import androidx.core.view.doOnPreDraw
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import androidx.navigation.navGraphViewModels
import androidx.recyclerview.widget.LinearLayoutManager

View file

@ -17,7 +17,7 @@
* 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
package org.linphone.ui.fragment
import android.os.Bundle
import android.view.LayoutInflater

View file

@ -32,6 +32,8 @@ class SharedMainViewModel : ViewModel() {
val navigateToConversationsEvent = MutableLiveData<Event<Boolean>>()
val navigateToCallsEvent = MutableLiveData<Event<Boolean>>()
/* Contacts related */
val showContactEvent = MutableLiveData<Event<String>>()

View file

@ -37,7 +37,6 @@ import io.getstream.avatarview.coil.loadImage
import org.linphone.R
import org.linphone.contacts.ContactData
import org.linphone.core.ConsolidatedPresence
import org.linphone.core.tools.Log
import org.linphone.ui.contacts.model.ContactModel
/**
@ -120,7 +119,6 @@ fun AvatarView.loadContactPicture(contact: ContactModel?) {
indicatorEnabled = true
val uri = contact.getAvatarUri()
Log.i("[Data binding Utils] Loading URI [$uri]")
loadImage(
data = uri,
onStart = {

View file

@ -9,9 +9,15 @@
<variable
name="onContactsClicked"
type="View.OnClickListener" />
<variable
name="onCallsClicked"
type="View.OnClickListener" />
<variable
name="onConversationsClicked"
type="View.OnClickListener" />
<variable
name="onMeetingsClicked"
type="View.OnClickListener" />
<variable
name="contactsSelected"
type="Boolean" />
@ -28,7 +34,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottom_nav_bar"
android:layout_width="75dp"
android:layout_width="@dimen/landscape_nav_bar_width"
android:layout_height="match_parent"
android:background="@color/white">
@ -53,6 +59,7 @@
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{onCallsClicked}"
android:id="@+id/calls"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -92,6 +99,7 @@
app:layout_constraintTop_toBottomOf="@id/calls" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{onMeetingsClicked}"
android:id="@+id/meetings"
android:layout_width="0dp"
android:layout_height="wrap_content"

View file

@ -0,0 +1,43 @@
<?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" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.slidingpanelayout.widget.SlidingPaneLayout
android:id="@+id/sliding_pane_layout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/calls_left_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="@dimen/sliding_pane_left_fragment_with_nav_width"
android:layout_height="match_parent"
app:defaultNavHost="false"
app:navGraph="@navigation/calls_left_nav_graph"/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/calls_right_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
app:defaultNavHost="false"
app:navGraph="@navigation/calls_right_nav_graph"/>
</androidx.slidingpanelayout.widget.SlidingPaneLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -22,7 +22,7 @@
<androidx.fragment.app.FragmentContainerView
android:id="@+id/contacts_left_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="355dp"
android:layout_width="@dimen/sliding_pane_left_fragment_with_nav_width"
android:layout_height="match_parent"
app:defaultNavHost="false"
app:navGraph="@navigation/contact_left_nav_graph"/>
@ -34,11 +34,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
app:defaultNavHost="false"
app:navGraph="@navigation/contact_right_nav_graph"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/contactsList"
app:layout_constraintEnd_toEndOf="parent"/>
app:navGraph="@navigation/contact_right_nav_graph"/>
</androidx.slidingpanelayout.widget.SlidingPaneLayout>

View file

@ -14,6 +14,9 @@
<variable
name="onConversationsClicked"
type="View.OnClickListener" />
<variable
name="onCallsClicked"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.contacts.viewmodel.ContactsListViewModel" />
@ -32,6 +35,7 @@
<include
bind:onConversationsClicked="@{onConversationsClicked}"
bind:onCallsClicked="@{onCallsClicked}"
bind:contactsSelected="@{true}"
android:id="@+id/bottom_nav_bar"
android:visibility="@{viewModel.bottomNavBarVisible ? View.VISIBLE : View.GONE}"

View file

@ -9,9 +9,15 @@
<variable
name="onContactsClicked"
type="View.OnClickListener" />
<variable
name="onCallsClicked"
type="View.OnClickListener" />
<variable
name="onConversationsClicked"
type="View.OnClickListener" />
<variable
name="onMeetingsClicked"
type="View.OnClickListener" />
<variable
name="contactsSelected"
type="Boolean" />
@ -55,6 +61,7 @@
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{onCallsClicked}"
android:id="@+id/calls"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -100,6 +107,7 @@
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:onClick="@{onMeetingsClicked}"
android:id="@+id/meetings"
android:layout_width="0dp"
android:layout_height="wrap_content"

View file

@ -0,0 +1,33 @@
<?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" />
</data>
<androidx.slidingpanelayout.widget.SlidingPaneLayout
android:id="@+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/calls_left_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="@dimen/sliding_pane_left_fragment_width"
android:layout_height="match_parent"
app:defaultNavHost="false"
app:navGraph="@navigation/calls_left_nav_graph"/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/calls_right_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="@dimen/sliding_pane_right_fragment_width"
android:layout_height="match_parent"
android:layout_weight="1"
app:defaultNavHost="false"
app:navGraph="@navigation/calls_right_nav_graph"/>
</androidx.slidingpanelayout.widget.SlidingPaneLayout>
</layout>

View file

@ -11,29 +11,18 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="280dp"
<androidx.fragment.app.FragmentContainerView
android:id="@+id/contacts_left_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="@dimen/sliding_pane_left_fragment_width"
android:layout_height="match_parent"
android:background="@color/primary_color">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/contacts_left_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="false"
app:navGraph="@navigation/contact_left_nav_graph"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
app:defaultNavHost="false"
app:navGraph="@navigation/contact_left_nav_graph"/>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/contacts_right_nav_container"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="300dp"
android:layout_width="@dimen/sliding_pane_right_fragment_width"
android:layout_height="match_parent"
android:layout_weight="1"
app:defaultNavHost="false"

View file

@ -14,6 +14,9 @@
<variable
name="onConversationsClicked"
type="View.OnClickListener" />
<variable
name="onCallsClicked"
type="View.OnClickListener" />
<variable
name="viewModel"
type="org.linphone.ui.contacts.viewmodel.ContactsListViewModel" />
@ -87,6 +90,7 @@
<include
bind:onConversationsClicked="@{onConversationsClicked}"
bind:onCallsClicked="@{onCallsClicked}"
bind:contactsSelected="@{true}"
android:id="@+id/bottom_nav_bar"
android:visibility="@{viewModel.bottomNavBarVisible ? View.VISIBLE : View.GONE}"

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calls_left_nav_graph">
</navigation>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/calls_right_nav_graph">
</navigation>

View file

@ -8,7 +8,7 @@
<fragment
android:id="@+id/contactsListFragment"
android:name="org.linphone.ui.contacts.ContactsListFragment"
android:name="org.linphone.ui.contacts.fragment.ContactsListFragment"
android:label="ContactsListFragment"
tools:layout="@layout/contacts_list_fragment">
<action
@ -21,7 +21,7 @@
<fragment
android:id="@+id/newContactFragment"
android:name="org.linphone.ui.contacts.NewContactFragment"
android:name="org.linphone.ui.contacts.fragment.NewContactFragment"
android:label="NewContactFragment"
tools:layout="@layout/new_contact_fragment"/>
</navigation>

View file

@ -7,13 +7,13 @@
<fragment
android:id="@+id/emptyFragment"
android:name="org.linphone.ui.EmptyFragment"
android:name="org.linphone.ui.fragment.EmptyFragment"
android:label="EmptyFragment"
tools:layout="@layout/empty_fragment" />
<fragment
android:id="@+id/contactFragment"
android:name="org.linphone.ui.contacts.ContactFragment"
android:name="org.linphone.ui.contacts.fragment.ContactFragment"
android:label="ContactFragment"
tools:layout="@layout/contact_fragment" >
<argument

View file

@ -27,6 +27,9 @@
app:launchSingleTop="true"
app:popUpTo="@id/contactsFragment"
app:popUpToInclusive="true" />
<action
android:id="@+id/action_conversationsFragment_to_callsFragment"
app:destination="@id/callsFragment" />
</fragment>
<fragment
@ -57,12 +60,28 @@
<fragment
android:id="@+id/contactsFragment"
android:name="org.linphone.ui.contacts.ContactsFragment"
android:name="org.linphone.ui.contacts.fragment.ContactsFragment"
android:label="ContactsFragment"
tools:layout="@layout/contacts_fragment">
<action
android:id="@+id/action_contactsFragment_to_conversationsFragment"
app:destination="@id/conversationsFragment" />
<action
android:id="@+id/action_contactsFragment_to_callsFragment"
app:destination="@id/callsFragment" />
</fragment>
<fragment
android:id="@+id/callsFragment"
android:name="org.linphone.ui.calls.fragment.CallsFragment"
android:label="CallsFragment"
tools:layout="@layout/calls_fragment">
<action
android:id="@+id/action_callsFragment_to_contactsFragment"
app:destination="@id/contactsFragment" />
<action
android:id="@+id/action_callsFragment_to_conversationsFragment"
app:destination="@id/conversationsFragment" />
</fragment>
</navigation>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="landscape_nav_bar_width">75dp</dimen>
<dimen name="sliding_pane_left_fragment_width">280dp</dimen>
<!-- This value is the result of the above two added together -->
<dimen name="sliding_pane_left_fragment_with_nav_width">355dp</dimen>
<dimen name="sliding_pane_right_fragment_width">300dp</dimen>
</resources>