mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-18 13:16:45 -06:00
Add "add homework" feature (#1564)
This commit is contained in:
parent
1839d7cb8f
commit
e8075e30e4
2322
app/schemas/io.github.wulkanowy.data.db.AppDatabase/41.json
Normal file
2322
app/schemas/io.github.wulkanowy.data.db.AppDatabase/41.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -97,6 +97,7 @@ import io.github.wulkanowy.data.db.migrations.Migration37
|
||||
import io.github.wulkanowy.data.db.migrations.Migration38
|
||||
import io.github.wulkanowy.data.db.migrations.Migration39
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
import io.github.wulkanowy.data.db.migrations.Migration41
|
||||
import io.github.wulkanowy.data.db.migrations.Migration40
|
||||
import io.github.wulkanowy.data.db.migrations.Migration5
|
||||
import io.github.wulkanowy.data.db.migrations.Migration6
|
||||
@ -146,7 +147,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 40
|
||||
const val VERSION_SCHEMA = 41
|
||||
|
||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
|
||||
Migration2(),
|
||||
@ -187,7 +188,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration37(),
|
||||
Migration38(),
|
||||
Migration39(),
|
||||
Migration40()
|
||||
Migration40(),
|
||||
Migration41()
|
||||
)
|
||||
|
||||
fun newInstance(
|
||||
|
@ -40,4 +40,7 @@ data class Homework(
|
||||
|
||||
@ColumnInfo(name = "is_notified")
|
||||
var isNotified: Boolean = true
|
||||
|
||||
@ColumnInfo(name = "is_added_by_user")
|
||||
var isAddedByUser: Boolean = false
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration41 : Migration(40, 41) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE Homework ADD COLUMN is_added_by_user INTEGER NOT NULL DEFAULT 0")
|
||||
}
|
||||
}
|
@ -61,8 +61,9 @@ class HomeworkRepository @Inject constructor(
|
||||
val homeWorkToSave = (new uniqueSubtract old).onEach {
|
||||
if (notify) it.isNotified = false
|
||||
}
|
||||
val filteredOld = old.filterNot { it.isAddedByUser }
|
||||
|
||||
homeworkDb.deleteAll(old uniqueSubtract new)
|
||||
homeworkDb.deleteAll(filteredOld uniqueSubtract new)
|
||||
homeworkDb.insertAll(homeWorkToSave)
|
||||
|
||||
refreshHelper.updateLastRefreshTimestamp(getRefreshKey(cacheKey, semester, start, end))
|
||||
@ -79,4 +80,8 @@ class HomeworkRepository @Inject constructor(
|
||||
homeworkDb.loadAll(semester.semesterId, semester.studentId, start.monday, end.sunday)
|
||||
|
||||
suspend fun updateHomework(homework: List<Homework>) = homeworkDb.updateAll(homework)
|
||||
|
||||
suspend fun saveHomework(homework: Homework) = homeworkDb.insertAll(listOf(homework))
|
||||
|
||||
suspend fun deleteHomework(homework: Homework) = homeworkDb.deleteAll(listOf(homework))
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Homework
|
||||
import io.github.wulkanowy.databinding.FragmentHomeworkBinding
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.homework.add.HomeworkAddDialog
|
||||
import io.github.wulkanowy.ui.modules.homework.details.HomeworkDetailsDialog
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
@ -64,6 +65,8 @@ class HomeworkFragment : BaseFragment<FragmentHomeworkBinding>(R.layout.fragment
|
||||
homeworkPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
homeworkNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
openAddHomeworkButton.setOnClickListener { presenter.onHomeworkAddButtonClicked() }
|
||||
|
||||
homeworkNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
}
|
||||
}
|
||||
@ -122,10 +125,14 @@ class HomeworkFragment : BaseFragment<FragmentHomeworkBinding>(R.layout.fragment
|
||||
binding.homeworkNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun showTimetableDialog(homework: Homework) {
|
||||
override fun showHomeworkDialog(homework: Homework) {
|
||||
(activity as? MainActivity)?.showDialogFragment(HomeworkDetailsDialog.newInstance(homework))
|
||||
}
|
||||
|
||||
override fun showAddHomeworkDialog() {
|
||||
(activity as? MainActivity)?.showDialogFragment(HomeworkAddDialog())
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putLong(SAVED_DATE_KEY, presenter.currentDate.toEpochDay())
|
||||
|
@ -78,7 +78,11 @@ class HomeworkPresenter @Inject constructor(
|
||||
|
||||
fun onHomeworkItemSelected(homework: Homework) {
|
||||
Timber.i("Select homework item ${homework.id}")
|
||||
view?.showTimetableDialog(homework)
|
||||
view?.showHomeworkDialog(homework)
|
||||
}
|
||||
|
||||
fun onHomeworkAddButtonClicked() {
|
||||
view?.showAddHomeworkDialog()
|
||||
}
|
||||
|
||||
private fun setBaseDateOnHolidays() {
|
||||
|
@ -33,5 +33,7 @@ interface HomeworkView : BaseView {
|
||||
|
||||
fun showNextButton(show: Boolean)
|
||||
|
||||
fun showTimetableDialog(homework: Homework)
|
||||
fun showHomeworkDialog(homework: Homework)
|
||||
|
||||
fun showAddHomeworkDialog()
|
||||
}
|
||||
|
@ -0,0 +1,124 @@
|
||||
package io.github.wulkanowy.ui.modules.homework.add
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.google.android.material.datepicker.CalendarConstraints
|
||||
import com.google.android.material.datepicker.MaterialDatePicker
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.databinding.DialogHomeworkAddBinding
|
||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import io.github.wulkanowy.utils.toLocalDateTime
|
||||
import io.github.wulkanowy.utils.toTimestamp
|
||||
import java.time.LocalDate
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class HomeworkAddDialog : BaseDialogFragment<DialogHomeworkAddBinding>(), HomeworkAddView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: HomeworkAddPresenter
|
||||
|
||||
private var date: LocalDate? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, 0)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = DialogHomeworkAddBinding.inflate(inflater).apply { binding = this }.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
with(binding) {
|
||||
homeworkDialogSubjectEdit.doOnTextChanged { _, _, _, _ ->
|
||||
homeworkDialogSubject.error = null
|
||||
homeworkDialogSubject.isErrorEnabled = false
|
||||
}
|
||||
homeworkDialogDateEdit.doOnTextChanged { _, _, _, _ ->
|
||||
homeworkDialogDate.error = null
|
||||
homeworkDialogDate.isErrorEnabled = false
|
||||
}
|
||||
homeworkDialogContentEdit.doOnTextChanged { _, _, _, _ ->
|
||||
homeworkDialogContent.error = null
|
||||
homeworkDialogContent.isErrorEnabled = false
|
||||
}
|
||||
homeworkDialogClose.setOnClickListener { dismiss() }
|
||||
homeworkDialogDateEdit.setOnClickListener { presenter.showDatePicker(date) }
|
||||
homeworkDialogAdd.setOnClickListener {
|
||||
presenter.onAddHomeworkClicked(
|
||||
subject = homeworkDialogSubjectEdit.text?.toString(),
|
||||
teacher = homeworkDialogTeacherEdit.text?.toString(),
|
||||
date = homeworkDialogDateEdit.text?.toString(),
|
||||
content = homeworkDialogContentEdit.text?.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun showSuccessMessage() {
|
||||
showMessage(getString(R.string.homework_add_success))
|
||||
}
|
||||
|
||||
override fun setErrorSubjectRequired() {
|
||||
with(binding.homeworkDialogSubject) {
|
||||
isErrorEnabled = true
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setErrorDateRequired() {
|
||||
with(binding.homeworkDialogDate) {
|
||||
isErrorEnabled = true
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setErrorContentRequired() {
|
||||
with(binding.homeworkDialogContent) {
|
||||
isErrorEnabled = true
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
override fun closeDialog() {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
override fun showDatePickerDialog(currentDate: LocalDate) {
|
||||
val constraintsBuilder = CalendarConstraints.Builder().apply {
|
||||
setStart(LocalDate.now().toEpochDay())
|
||||
}
|
||||
val datePicker =
|
||||
MaterialDatePicker.Builder.datePicker()
|
||||
.setCalendarConstraints(constraintsBuilder.build())
|
||||
.setSelection(currentDate.toTimestamp())
|
||||
.build()
|
||||
|
||||
datePicker.addOnPositiveButtonClickListener {
|
||||
date = it.toLocalDateTime().toLocalDate()
|
||||
binding.homeworkDialogDate.editText?.setText(date!!.toFormattedString())
|
||||
}
|
||||
|
||||
if (!parentFragmentManager.isStateSaved) {
|
||||
datePicker.show(this.parentFragmentManager, null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package io.github.wulkanowy.ui.modules.homework.add
|
||||
|
||||
import io.github.wulkanowy.data.Status
|
||||
import io.github.wulkanowy.data.db.entities.Homework
|
||||
import io.github.wulkanowy.data.repositories.HomeworkRepository
|
||||
import io.github.wulkanowy.data.repositories.SemesterRepository
|
||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.flowWithResource
|
||||
import io.github.wulkanowy.utils.toLocalDate
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import timber.log.Timber
|
||||
import java.time.LocalDate
|
||||
import javax.inject.Inject
|
||||
|
||||
class HomeworkAddPresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val homeworkRepository: HomeworkRepository,
|
||||
private val semesterRepository: SemesterRepository
|
||||
) : BasePresenter<HomeworkAddView>(errorHandler, studentRepository) {
|
||||
|
||||
override fun onAttachView(view: HomeworkAddView) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("Homework details view was initialized")
|
||||
}
|
||||
|
||||
fun showDatePicker(date: LocalDate?) {
|
||||
view?.showDatePickerDialog(date ?: LocalDate.now())
|
||||
}
|
||||
|
||||
fun onAddHomeworkClicked(subject: String?, teacher: String?, date: String?, content: String?) {
|
||||
var isError = false
|
||||
|
||||
if (subject.isNullOrBlank()) {
|
||||
view?.setErrorSubjectRequired()
|
||||
isError = true
|
||||
}
|
||||
|
||||
if (date.isNullOrBlank()) {
|
||||
view?.setErrorDateRequired()
|
||||
isError = true
|
||||
}
|
||||
|
||||
if (content.isNullOrBlank()) {
|
||||
view?.setErrorContentRequired()
|
||||
isError = true
|
||||
}
|
||||
|
||||
if (!isError) {
|
||||
saveHomework(subject!!, teacher.orEmpty(), date!!.toLocalDate(), content!!)
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveHomework(subject: String, teacher: String, date: LocalDate, content: String) {
|
||||
flowWithResource {
|
||||
val student = studentRepository.getCurrentStudent()
|
||||
val semester = semesterRepository.getCurrentSemester(student)
|
||||
val entryDate = LocalDate.now()
|
||||
homeworkRepository.saveHomework(
|
||||
Homework(
|
||||
semesterId = semester.semesterId,
|
||||
studentId = student.studentId,
|
||||
date = date,
|
||||
entryDate = entryDate,
|
||||
subject = subject,
|
||||
content = content,
|
||||
teacher = teacher,
|
||||
teacherSymbol = "",
|
||||
attachments = emptyList(),
|
||||
).apply { isAddedByUser = true }
|
||||
)
|
||||
}.onEach {
|
||||
when (it.status) {
|
||||
Status.LOADING -> Timber.i("Homework insert start")
|
||||
Status.SUCCESS -> {
|
||||
Timber.i("Homework insert: Success")
|
||||
view?.run {
|
||||
showSuccessMessage()
|
||||
closeDialog()
|
||||
}
|
||||
}
|
||||
Status.ERROR -> {
|
||||
Timber.i("Homework insert result: An exception occurred")
|
||||
errorHandler.dispatch(it.error!!)
|
||||
}
|
||||
}
|
||||
}.launch("add_homework")
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package io.github.wulkanowy.ui.modules.homework.add
|
||||
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
import java.time.LocalDate
|
||||
|
||||
interface HomeworkAddView : BaseView {
|
||||
|
||||
fun initView()
|
||||
|
||||
fun showSuccessMessage()
|
||||
|
||||
fun setErrorSubjectRequired()
|
||||
|
||||
fun setErrorDateRequired()
|
||||
|
||||
fun setErrorContentRequired()
|
||||
|
||||
fun closeDialog()
|
||||
|
||||
fun showDatePickerDialog(currentDate: LocalDate)
|
||||
}
|
@ -5,10 +5,12 @@ import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Homework
|
||||
import io.github.wulkanowy.databinding.ItemHomeworkDialogAttachmentBinding
|
||||
import io.github.wulkanowy.databinding.ItemHomeworkDialogAttachmentsHeaderBinding
|
||||
import io.github.wulkanowy.databinding.ItemHomeworkDialogDetailsBinding
|
||||
import io.github.wulkanowy.utils.ifNullOrBlank
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -37,6 +39,8 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
||||
|
||||
var onFullScreenExitClickListener = {}
|
||||
|
||||
var onDeleteClickListener: (homework: Homework) -> Unit = {}
|
||||
|
||||
override fun getItemCount() = 1 + if (attachments.isNotEmpty()) attachments.size + 1 else 0
|
||||
|
||||
override fun getItemViewType(position: Int) = when (position) {
|
||||
@ -49,9 +53,15 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
||||
val inflater = LayoutInflater.from(parent.context)
|
||||
|
||||
return when (viewType) {
|
||||
ViewType.ATTACHMENTS_HEADER.id -> AttachmentsHeaderViewHolder(ItemHomeworkDialogAttachmentsHeaderBinding.inflate(inflater, parent, false))
|
||||
ViewType.ATTACHMENT.id -> AttachmentViewHolder(ItemHomeworkDialogAttachmentBinding.inflate(inflater, parent, false))
|
||||
else -> DetailsViewHolder(ItemHomeworkDialogDetailsBinding.inflate(inflater, parent, false))
|
||||
ViewType.ATTACHMENTS_HEADER.id -> AttachmentsHeaderViewHolder(
|
||||
ItemHomeworkDialogAttachmentsHeaderBinding.inflate(inflater, parent, false)
|
||||
)
|
||||
ViewType.ATTACHMENT.id -> AttachmentViewHolder(
|
||||
ItemHomeworkDialogAttachmentBinding.inflate(inflater, parent, false)
|
||||
)
|
||||
else -> DetailsViewHolder(
|
||||
ItemHomeworkDialogDetailsBinding.inflate(inflater, parent, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,12 +73,15 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
||||
}
|
||||
|
||||
private fun bindDetailsViewHolder(holder: DetailsViewHolder) {
|
||||
val noDataString = holder.binding.root.context.getString(R.string.all_no_data)
|
||||
|
||||
with(holder.binding) {
|
||||
homeworkDialogDate.text = homework?.date?.toFormattedString()
|
||||
homeworkDialogEntryDate.text = homework?.entryDate?.toFormattedString()
|
||||
homeworkDialogSubject.text = homework?.subject
|
||||
homeworkDialogTeacher.text = homework?.teacher
|
||||
homeworkDialogContent.text = homework?.content
|
||||
homeworkDialogSubject.text = homework?.subject.ifNullOrBlank { noDataString }
|
||||
homeworkDialogTeacher.text = homework?.teacher.ifNullOrBlank { noDataString }
|
||||
homeworkDialogContent.text = homework?.content.ifNullOrBlank { noDataString }
|
||||
homeworkDialogDelete.visibility = if (homework?.isAddedByUser == true) VISIBLE else GONE
|
||||
homeworkDialogFullScreen.visibility = if (isHomeworkFullscreen) GONE else VISIBLE
|
||||
homeworkDialogFullScreenExit.visibility = if (isHomeworkFullscreen) VISIBLE else GONE
|
||||
homeworkDialogFullScreen.setOnClickListener {
|
||||
@ -81,6 +94,9 @@ class HomeworkDetailsAdapter @Inject constructor() :
|
||||
homeworkDialogFullScreenExit.visibility = GONE
|
||||
onFullScreenExitClickListener()
|
||||
}
|
||||
homeworkDialogDelete.setOnClickListener {
|
||||
onDeleteClickListener(homework!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
||||
@Inject
|
||||
lateinit var detailsAdapter: HomeworkDetailsAdapter
|
||||
|
||||
override val homeworkDeleteSuccess: String
|
||||
get() = getString(R.string.homework_delete_success)
|
||||
|
||||
private lateinit var homework: Homework
|
||||
|
||||
companion object {
|
||||
@ -82,12 +85,17 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
||||
dialog?.window?.setLayout(WRAP_CONTENT, WRAP_CONTENT)
|
||||
presenter.isHomeworkFullscreen = false
|
||||
}
|
||||
onDeleteClickListener = { homework -> presenter.deleteHomework(homework) }
|
||||
isHomeworkFullscreen = presenter.isHomeworkFullscreen
|
||||
homework = this@HomeworkDetailsDialog.homework
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun closeDialog() {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
override fun updateMarkAsDoneLabel(isDone: Boolean) {
|
||||
binding.homeworkDialogRead.text =
|
||||
view?.context?.getString(if (isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done)
|
||||
|
@ -33,6 +33,25 @@ class HomeworkDetailsPresenter @Inject constructor(
|
||||
Timber.i("Homework details view was initialized")
|
||||
}
|
||||
|
||||
fun deleteHomework(homework: Homework) {
|
||||
flowWithResource { homeworkRepository.deleteHomework(homework) }.onEach {
|
||||
when (it.status) {
|
||||
Status.LOADING -> Timber.i("Homework delete start")
|
||||
Status.SUCCESS -> {
|
||||
Timber.i("Homework delete: Success")
|
||||
view?.run {
|
||||
showMessage(homeworkDeleteSuccess)
|
||||
closeDialog()
|
||||
}
|
||||
}
|
||||
Status.ERROR -> {
|
||||
Timber.i("Homework delete result: An exception occurred")
|
||||
errorHandler.dispatch(it.error!!)
|
||||
}
|
||||
}
|
||||
}.launch("delete")
|
||||
}
|
||||
|
||||
fun toggleDone(homework: Homework) {
|
||||
flowWithResource { homeworkRepository.toggleDone(homework) }.onEach {
|
||||
when (it.status) {
|
||||
|
@ -4,7 +4,11 @@ import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface HomeworkDetailsView : BaseView {
|
||||
|
||||
val homeworkDeleteSuccess: String
|
||||
|
||||
fun initView()
|
||||
|
||||
fun closeDialog()
|
||||
|
||||
fun updateMarkAsDoneLabel(isDone: Boolean)
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorUsernameRequired() {
|
||||
with(binding.loginFormUsernameLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorPassRequired(focus: Boolean) {
|
||||
with(binding.loginFormPassLayout) {
|
||||
if (focus) requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorPinRequired() {
|
||||
with(binding.loginFormPinLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorSymbolRequired() {
|
||||
with(binding.loginFormSymbolLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ class LoginAdvancedFragment :
|
||||
override fun setErrorTokenRequired() {
|
||||
with(binding.loginFormTokenLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
|
||||
override fun setErrorUsernameRequired() {
|
||||
with(binding.loginFormUsernameLayout) {
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ class LoginFormFragment : BaseFragment<FragmentLoginFormBinding>(R.layout.fragme
|
||||
|
||||
override fun setErrorPassRequired(focus: Boolean) {
|
||||
with(binding.loginFormPassLayout) {
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class LoginRecoverFragment :
|
||||
override fun setErrorNameRequired() {
|
||||
with(bindingLocal.loginRecoverNameLayout) {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class LoginSymbolFragment :
|
||||
override fun setErrorSymbolRequire() {
|
||||
binding.loginSymbolNameLayout.apply {
|
||||
requestFocus()
|
||||
error = getString(R.string.login_field_required)
|
||||
error = getString(R.string.error_field_required)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
android:id="@+id/parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minWidth="300dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
@ -17,8 +18,8 @@
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:background="@drawable/ic_all_divider"
|
||||
android:layout_height="1dp" />
|
||||
android:layout_height="1dp"
|
||||
android:background="@drawable/ic_all_divider" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -32,6 +33,9 @@
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -40,9 +44,6 @@
|
||||
android:insetRight="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:minWidth="88dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="@string/homework_mark_as_done"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
@ -52,6 +53,9 @@
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
@ -60,9 +64,6 @@
|
||||
android:insetRight="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:minWidth="88dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:text="@string/all_close"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
134
app/src/main/res/layout/dialog_homework_add.xml
Normal file
134
app/src/main/res/layout/dialog_homework_add.xml
Normal file
@ -0,0 +1,134 @@
|
||||
<ScrollView 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="match_parent"
|
||||
android:fillViewport="true"
|
||||
android:minWidth="300dp"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="300dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/addHomeworkHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:text="@string/homework_add"
|
||||
android:textSize="21sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/homeworkDialogDate"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="28dp"
|
||||
android:hint="@string/all_date"
|
||||
app:startIconDrawable="@drawable/ic_main_timetable">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/homeworkDialogDateEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="false"
|
||||
android:editable="false"
|
||||
android:focusable="false"
|
||||
android:inputType="none"
|
||||
tools:ignore="Deprecated" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/homeworkDialogSubject"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:hint="@string/all_subject">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/homeworkDialogSubjectEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/homeworkDialogTeacher"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:hint="@string/all_teacher">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/homeworkDialogTeacherEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/homeworkDialogContent"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:hint="@string/all_content">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/homeworkDialogContentEdit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minHeight="62dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/homeworkDialogClose"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginLeft="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:insetLeft="0dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetRight="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:text="@string/all_close"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/homeworkDialogAdd"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:insetLeft="0dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetRight="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:text="@string/all_add"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@ -26,6 +26,8 @@
|
||||
android:id="@+id/homeworkRecycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="70dp"
|
||||
tools:listitem="@layout/item_homework" />
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
@ -105,6 +107,18 @@
|
||||
android:text="@string/all_retry" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/openAddHomeworkButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:text="@string/add_homework_title"
|
||||
android:tint="?colorOnSecondary"
|
||||
app:icon="@drawable/ic_all_add" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<io.github.wulkanowy.ui.widgets.MaterialLinearLayout
|
||||
@ -128,8 +142,8 @@
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:scaleType="fitStart"
|
||||
android:tint="?colorPrimary"
|
||||
app:srcCompat="@drawable/ic_chevron_left" />
|
||||
app:srcCompat="@drawable/ic_chevron_left"
|
||||
app:tint="?colorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homeworkNavDate"
|
||||
@ -152,7 +166,7 @@
|
||||
android:paddingRight="12dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:scaleType="fitEnd"
|
||||
android:tint="?colorPrimary"
|
||||
app:srcCompat="@drawable/ic_chevron_right" />
|
||||
app:srcCompat="@drawable/ic_chevron_right"
|
||||
app:tint="?colorPrimary" />
|
||||
</io.github.wulkanowy.ui.widgets.MaterialLinearLayout>
|
||||
</FrameLayout>
|
||||
|
@ -10,26 +10,37 @@
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/allDetailsHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/all_details"
|
||||
android:textSize="21sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/homework_dialog_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="5dp"
|
||||
app:srcCompat="@drawable/ic_menu_message_delete"
|
||||
app:tint="?colorPrimary"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/homework_dialog_full_screen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="5dp"
|
||||
app:srcCompat="@drawable/ic_fullscreen"
|
||||
app:tint="?colorOnBackground"
|
||||
@ -39,8 +50,8 @@
|
||||
android:id="@+id/homework_dialog_full_screen_exit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:layout_marginTop="24dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:padding="5dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/ic_fullscreen_exit"
|
||||
@ -153,13 +164,14 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="0dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:autoLink="web"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:paddingStart="0dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="@string/all_no_data"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="16sp"
|
||||
tools:maxLines="7"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -17,6 +17,7 @@
|
||||
<string name="license_title">Licenses</string>
|
||||
<string name="message_title">Messages</string>
|
||||
<string name="send_message_title">New message</string>
|
||||
<string name="add_homework_title">New homework</string>
|
||||
<string name="note_title">Notes and achievements</string>
|
||||
<string name="homework_title">Homework</string>
|
||||
<string name="account_title">Accounts manager</string>
|
||||
@ -57,7 +58,6 @@
|
||||
<string name="login_invalid_custom_email">Use the assigned login or email in @%1$s</string>
|
||||
<string name="login_invalid_symbol">Invalid symbol</string>
|
||||
<string name="login_incorrect_symbol">Student not found. Validate the symbol and the chosen variation of the UONET+ register</string>
|
||||
<string name="login_field_required">This field is required</string>
|
||||
<string name="login_duplicate_student">Selected student is already logged in</string>
|
||||
<string name="login_symbol_helper">The symbol can be found on the register page in <b>Uczeń</b> → <b>Dostęp Mobilny</b> → <b>Zarejestruj urządzenie mobilne</b>.\n\nMake sure that you have set the appropriate register variant in the <b>UONET+ register variant</b> field on the previous screen. Wulkanowy does not detect pre-school students at the moment</string>
|
||||
<string name="login_select_student">Select students to log in to the application</string>
|
||||
@ -316,6 +316,9 @@
|
||||
<string name="homework_no_items">No info about homework</string>
|
||||
<string name="homework_mark_as_done">Mark as done</string>
|
||||
<string name="homework_mark_as_undone">Mark as undone</string>
|
||||
<string name="homework_add">Add homework</string>
|
||||
<string name="homework_add_success">Homework added successfully</string>
|
||||
<string name="homework_delete_success">Homework deleted successfully</string>
|
||||
<string name="homework_attachments">Attachments</string>
|
||||
<plurals name="homework_notify_new_item_title">
|
||||
<item quantity="one">New homework</item>
|
||||
@ -592,6 +595,10 @@
|
||||
<string name="all_no">No</string>
|
||||
<string name="all_save">Save</string>
|
||||
<string name="all_title">Title</string>
|
||||
<string name="all_add">Add</string>
|
||||
<string name="all_copied">Copied</string>
|
||||
<string name="all_undo">Undo</string>
|
||||
<string name="all_change">Change</string>
|
||||
|
||||
|
||||
<!--Timetable Widget-->
|
||||
@ -697,12 +704,6 @@
|
||||
<string name="all_empty_color">No color</string>
|
||||
|
||||
|
||||
<!--Others-->
|
||||
<string name="all_copied">Copied</string>
|
||||
<string name="all_undo">Undo</string>
|
||||
<string name="all_change">Change</string>
|
||||
|
||||
|
||||
<!--Update helper-->
|
||||
<string name="update_download_started">Download of updates has started…</string>
|
||||
<string name="update_download_success">An update has just been downloaded.</string>
|
||||
@ -721,4 +722,5 @@
|
||||
<string name="error_unknown">An unexpected error occurred</string>
|
||||
<string name="error_feature_disabled">Feature disabled by your school</string>
|
||||
<string name="error_feature_not_available">Feature not available. Login in a mode other than Mobile API</string>
|
||||
<string name="error_field_required">This field is required</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user