Add fullscreen mode to homework dialog (#806)

This commit is contained in:
Mikołaj Pich 2020-05-16 22:06:00 +02:00 committed by GitHub
parent 52d66ac30b
commit f7b5b9c413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 1 deletions

View File

@ -1,6 +1,8 @@
package io.github.wulkanowy.ui.modules.homework.details
import android.view.LayoutInflater
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import io.github.wulkanowy.data.db.entities.Homework
@ -29,6 +31,10 @@ class HomeworkDetailsAdapter @Inject constructor() :
var onAttachmentClickListener: (url: String) -> Unit = {}
var onFullScreenClickListener = {}
var onFullScreenExitClickListener = {}
override fun getItemCount() = 1 + if (attachments.isNotEmpty()) attachments.size + 1 else 0
override fun getItemViewType(position: Int) = when (position) {
@ -61,6 +67,16 @@ class HomeworkDetailsAdapter @Inject constructor() :
homeworkDialogSubject.text = homework?.subject
homeworkDialogTeacher.text = homework?.teacher
homeworkDialogContent.text = homework?.content
homeworkDialogFullScreen.setOnClickListener {
homeworkDialogFullScreen.visibility = GONE
homeworkDialogFullScreenExit.visibility = VISIBLE
onFullScreenClickListener()
}
homeworkDialogFullScreenExit.setOnClickListener {
homeworkDialogFullScreen.visibility = VISIBLE
homeworkDialogFullScreenExit.visibility = GONE
onFullScreenExitClickListener()
}
}
}

View File

@ -5,6 +5,8 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.recyclerview.widget.LinearLayoutManager
import io.github.wulkanowy.R
import io.github.wulkanowy.data.db.entities.Homework
@ -63,6 +65,8 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
layoutManager = LinearLayoutManager(context)
adapter = detailsAdapter.apply {
onAttachmentClickListener = { context.openInternetBrowser(it, ::showMessage) }
onFullScreenClickListener = { dialog?.window?.setLayout(MATCH_PARENT, MATCH_PARENT) }
onFullScreenExitClickListener = { dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT) }
homework = this@HomeworkDetailsDialog.homework
}
}

View File

@ -195,7 +195,6 @@ class LoginRecoverFragment :
}
override fun onDestroyView() {
binding.loginRecoverWebView.destroy()
presenter.onDetachView()
super.onDestroyView()

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7,14L5,14v5h5v-2L7,17v-3zM5,10h2L7,7h3L10,5L5,5v5zM17,17h-3v2h5v-5h-2v3zM14,5v2h3v3h2L19,5h-5z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M5,16h3v3h2v-5L5,14v2zM8,8L5,8v2h5L10,5L8,5v3zM14,19h2v-3h3v-2h-5v5zM16,8L16,5h-2v5h5L19,8h-3z"/>
</vector>

View File

@ -1,4 +1,5 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -7,6 +8,29 @@
android:paddingTop="20dp"
android:paddingEnd="20dp">
<ImageButton
android:id="@+id/homework_dialog_full_screen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="?selectableItemBackgroundBorderless"
android:padding="5dp"
app:srcCompat="@drawable/ic_fullscreen"
app:tint="?colorOnBackground"
tools:ignore="ContentDescription" />
<ImageButton
android:id="@+id/homework_dialog_full_screen_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="?selectableItemBackgroundBorderless"
android:padding="5dp"
android:visibility="gone"
app:srcCompat="@drawable/ic_fullscreen_exit"
app:tint="?colorOnBackground"
tools:ignore="ContentDescription" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"