mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Moved FileViewerFragment out of chat nav scope to be able to display it fullscreen when in landscape
This commit is contained in:
parent
7cca8f1889
commit
6c72fb9689
8 changed files with 202 additions and 28 deletions
|
|
@ -361,14 +361,8 @@ class ConversationFragment : GenericFragment() {
|
|||
|
||||
viewModel.fileToDisplayEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { file ->
|
||||
if (findNavController().currentDestination?.id == R.id.conversationFragment) {
|
||||
Log.i("$TAG User clicked on file [$file], let's display it in file viewer")
|
||||
val action =
|
||||
ConversationFragmentDirections.actionConversationFragmentToFileViewerFragment(
|
||||
file
|
||||
)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
Log.i("$TAG User clicked on file [$file], let's display it in file viewer")
|
||||
sharedViewModel.displayFileEvent.value = Event(file)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.linphone.ui.main.chat.adapter.ConversationsListAdapter
|
|||
import org.linphone.ui.main.chat.viewmodel.ConversationsListViewModel
|
||||
import org.linphone.ui.main.fragment.AbstractTopBarFragment
|
||||
import org.linphone.ui.main.history.fragment.HistoryMenuDialogFragment
|
||||
import org.linphone.ui.main.viewer.fragment.FileViewerFragmentDirections
|
||||
import org.linphone.utils.Event
|
||||
|
||||
@UiThread
|
||||
|
|
@ -204,6 +205,17 @@ class ConversationsListFragment : AbstractTopBarFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
sharedViewModel.displayFileEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { path ->
|
||||
if (findNavController().currentDestination?.id == R.id.conversationsListFragment) {
|
||||
Log.i("$TAG Navigating to file viewer fragment with path [$path]")
|
||||
val action =
|
||||
FileViewerFragmentDirections.actionGlobalFileViewerFragment(path)
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TopBarFragment related
|
||||
|
||||
setViewModelAndTitle(
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.FileImageViewerFragmentBinding
|
||||
import org.linphone.databinding.FileViewerFragmentBinding
|
||||
import org.linphone.ui.main.fragment.GenericFragment
|
||||
import org.linphone.ui.main.viewer.adapter.PdfPagesListAdapter
|
||||
import org.linphone.ui.main.viewer.viewmodel.FileViewModel
|
||||
|
|
@ -22,7 +22,7 @@ class FileViewerFragment : GenericFragment() {
|
|||
private const val TAG = "[File Viewer Fragment]"
|
||||
}
|
||||
|
||||
private lateinit var binding: FileImageViewerFragmentBinding
|
||||
private lateinit var binding: FileViewerFragmentBinding
|
||||
|
||||
private lateinit var viewModel: FileViewModel
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ class FileViewerFragment : GenericFragment() {
|
|||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FileImageViewerFragmentBinding.inflate(layoutInflater)
|
||||
binding = FileViewerFragmentBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,4 +125,8 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
|||
val listOfSelectedSipUrisEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
|
||||
MutableLiveData<Event<ArrayList<String>>>()
|
||||
}
|
||||
|
||||
val displayFileEvent: MutableLiveData<Event<String>> by lazy {
|
||||
MutableLiveData<Event<String>>()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
164
app/src/main/res/layout-land/file_viewer_fragment.xml
Normal file
164
app/src/main/res/layout-land/file_viewer_fragment.xml
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
<?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="backClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="shareClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="saveClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.viewer.viewmodel.FileViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/black">
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/video_player"
|
||||
android:onClick="@{() -> viewModel.toggleFullScreen()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:visibility="@{viewModel.isVideo ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/play_pause_video_playback"
|
||||
android:onClick="@{() -> viewModel.playPauseVideo()}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:padding="8dp"
|
||||
android:src="@{viewModel.isVideoPlaying ? @drawable/pause_fill : @drawable/play_fill, default=@drawable/play_fill}"
|
||||
android:visibility="@{viewModel.isVideo && !viewModel.fullScreenMode ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintBottom_toTopOf="@id/file_name"
|
||||
app:layout_constraintStart_toStartOf="@id/pdf_view_pager"
|
||||
app:layout_constraintEnd_toEndOf="@id/pdf_view_pager"
|
||||
app:tint="@color/orange_main_500"/>
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/pdf_view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="@{viewModel.isPdf ? View.VISIBLE : View.GONE, default=gone}" />
|
||||
|
||||
<com.tbuonomo.viewpagerdotsindicator.DotsIndicator
|
||||
android:id="@+id/dots_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:visibility="@{viewModel.isPdf ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:dotsColor="@color/gray_main2_200"
|
||||
app:dotsCornerRadius="8dp"
|
||||
app:dotsSize="13dp"
|
||||
app:dotsSpacing="5dp"
|
||||
app:dotsWidthFactor="2.5"
|
||||
app:selectedDotColor="@color/orange_main_500"
|
||||
app:progressMode="false"
|
||||
app:layout_constraintBottom_toTopOf="@id/file_name"
|
||||
app:layout_constraintStart_toStartOf="@id/pdf_view_pager"
|
||||
app:layout_constraintEnd_toEndOf="@id/pdf_view_pager" />
|
||||
|
||||
<com.github.chrisbanes.photoview.PhotoView
|
||||
android:id="@+id/image"
|
||||
android:onClick="@{() -> viewModel.toggleFullScreen()}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/illu"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
coilFile="@{viewModel.path}"
|
||||
android:visibility="@{viewModel.isPdf || viewModel.isVideo ? View.GONE : View.VISIBLE}" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:onClick="@{backClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:background="@color/white"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/caret_left"
|
||||
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
|
||||
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:background="@color/white"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text=""
|
||||
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintEnd_toStartOf="@id/share"
|
||||
app:layout_constraintStart_toEndOf="@id/back"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share"
|
||||
android:onClick="@{shareClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:background="@color/white"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/share_network"
|
||||
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
|
||||
app:tint="@color/orange_main_500"
|
||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||
app:layout_constraintEnd_toStartOf="@id/save"
|
||||
app:layout_constraintTop_toTopOf="@id/title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/save"
|
||||
android:onClick="@{saveClickListener}"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:background="@color/white"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:src="@drawable/download_simple"
|
||||
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
|
||||
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_300"
|
||||
android:id="@+id/file_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@{viewModel.fileName, default=`nomdufichier.jpg\nenvoyé le 02/05/2023 à 11h05`}"
|
||||
android:textSize="12sp"
|
||||
android:textColor="@color/gray_main2_400"
|
||||
android:textAlignment="center"
|
||||
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -29,13 +29,6 @@
|
|||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
<action
|
||||
android:id="@+id/action_conversationFragment_to_fileViewerFragment"
|
||||
app:destination="@id/fileViewerFragment"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:popEnterAnim="@anim/slide_in_left"
|
||||
app:popExitAnim="@anim/slide_out_right" />
|
||||
</fragment>
|
||||
|
||||
<action
|
||||
|
|
@ -69,14 +62,4 @@
|
|||
android:label="AddParticipantsFragment"
|
||||
tools:layout="@layout/generic_add_participants_fragment" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fileViewerFragment"
|
||||
android:name="org.linphone.ui.main.viewer.fragment.FileViewerFragment"
|
||||
android:label="FileViewerFragment"
|
||||
tools:layout="@layout/file_image_viewer_fragment">
|
||||
<argument
|
||||
android:name="path"
|
||||
app:argType="string" />
|
||||
</fragment>
|
||||
|
||||
</navigation>
|
||||
|
|
@ -304,4 +304,21 @@
|
|||
app:argType="string" />
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/fileViewerFragment"
|
||||
android:name="org.linphone.ui.main.viewer.fragment.FileViewerFragment"
|
||||
android:label="FileViewerFragment"
|
||||
tools:layout="@layout/file_viewer_fragment">
|
||||
<argument
|
||||
android:name="path"
|
||||
app:argType="string" />
|
||||
</fragment>
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_fileViewerFragment"
|
||||
app:destination="@id/fileViewerFragment"
|
||||
app:enterAnim="@anim/slide_in"
|
||||
app:popExitAnim="@anim/slide_out"
|
||||
app:launchSingleTop="true"/>
|
||||
|
||||
</navigation>
|
||||
Loading…
Add table
Reference in a new issue