Added full-screen support for image & video viewers

This commit is contained in:
Sylvain Berfini 2022-05-30 16:28:36 +02:00
parent cc36a18d2c
commit 9e2b52b4d2
7 changed files with 35 additions and 1 deletions

View file

@ -15,6 +15,7 @@ Group changes to describe their impact on the project, as follows:
### Added
- Conference creation with scheduling, video, different layouts, showing who is speaking and who is muted, etc...
- Chat rooms can be individually muted (no notification when receiving a chat message)
- Image & Video in-app viewers allow for full-screen display
### Changed
- In-call views have been re-designed

View file

@ -246,6 +246,10 @@ class MainActivity : GenericActivity(), SnackBarActivity, NavController.OnDestin
currentFocus?.hideKeyboard()
}
fun hideStatusFragment(hide: Boolean) {
statusFragment.visibility = if (hide) View.GONE else View.VISIBLE
}
private fun updateTabsFragmentVisibility() {
tabsFragment.visibility = if (tabsFragmentVisible1 && tabsFragmentVisible2) View.VISIBLE else View.GONE
}

View file

@ -25,8 +25,10 @@ import android.view.View
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.R
import org.linphone.activities.main.MainActivity
import org.linphone.activities.main.files.viewmodels.ImageFileViewModel
import org.linphone.activities.main.files.viewmodels.ImageFileViewModelFactory
import org.linphone.compatibility.Compatibility
import org.linphone.core.tools.Log
import org.linphone.databinding.FileImageViewerFragmentBinding
@ -53,5 +55,12 @@ class ImageViewerFragment : GenericViewerFragment<FileImageViewerFragmentBinding
ImageFileViewModelFactory(content)
)[ImageFileViewModel::class.java]
binding.viewModel = viewModel
viewModel.fullScreenMode.observe(
viewLifecycleOwner
) { hide ->
Compatibility.hideAndroidSystemUI(hide, requireActivity().window)
(requireActivity() as MainActivity).hideStatusFragment(hide)
}
}
}

View file

@ -26,8 +26,10 @@ import android.widget.MediaController
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import org.linphone.R
import org.linphone.activities.main.MainActivity
import org.linphone.activities.main.files.viewmodels.VideoFileViewModel
import org.linphone.activities.main.files.viewmodels.VideoFileViewModelFactory
import org.linphone.compatibility.Compatibility
import org.linphone.core.tools.Log
import org.linphone.databinding.FileVideoViewerFragmentBinding
@ -67,6 +69,13 @@ class VideoViewerFragment : GenericViewerFragment<FileVideoViewerFragmentBinding
}
}
initMediaController()
viewModel.fullScreenMode.observe(
viewLifecycleOwner
) { hide ->
Compatibility.hideAndroidSystemUI(hide, requireActivity().window)
(requireActivity() as MainActivity).hideStatusFragment(hide)
}
}
override fun onResume() {

View file

@ -19,6 +19,7 @@
*/
package org.linphone.activities.main.files.viewmodels
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import org.linphone.core.Content
import org.linphone.core.tools.Log
@ -28,6 +29,8 @@ open class FileViewerViewModel(val content: Content) : ViewModel() {
val filePath: String
private val deleteAfterUse: Boolean = content.isFileEncrypted
val fullScreenMode = MutableLiveData<Boolean>()
init {
filePath = if (deleteAfterUse) {
Log.i("[File Viewer] Content is encrypted, requesting plain file path")
@ -45,4 +48,8 @@ open class FileViewerViewModel(val content: Content) : ViewModel() {
super.onCleared()
}
fun toggleFullScreen() {
fullScreenMode.value = fullScreenMode.value != true
}
}

View file

@ -20,6 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
tools:layout="@layout/file_viewer_top_bar_fragment" />
<LinearLayout
@ -32,6 +33,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:onClick="@{() -> viewModel.toggleFullScreen()}"
android:scaleType="fitCenter"
coil="@{viewModel.filePath}"/>

View file

@ -20,6 +20,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="@{viewModel.fullScreenMode ? View.GONE : View.VISIBLE}"
tools:layout="@layout/file_viewer_top_bar_fragment" />
<RelativeLayout
@ -31,7 +32,8 @@
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"/>
android:layout_centerInParent="true"
android:onClick="@{() -> viewModel.toggleFullScreen()}"/>
</RelativeLayout>