diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragmentPagerAdapter.kt b/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragmentPagerAdapter.kt index 5f8bf4178..bd735535d 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragmentPagerAdapter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/BaseFragmentPagerAdapter.kt @@ -4,6 +4,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter +//TODO Use ViewPager2 class BaseFragmentPagerAdapter(private val fragmentManager: FragmentManager) : FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt index f76614e1e..4ce977709 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt @@ -42,10 +42,8 @@ class ErrorDialog : BaseDialogFragment() { companion object { private const val ARGUMENT_KEY = "Data" - fun newInstance(error: Throwable): ErrorDialog { - return ErrorDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, error) } - } + fun newInstance(error: Throwable) = ErrorDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, error) } } } @@ -57,12 +55,14 @@ class ErrorDialog : BaseDialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - return DialogErrorBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogErrorBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) val stringWriter = StringWriter().apply { error.printStackTrace(PrintWriter(this)) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt index d5e2fe122..8b6526cdc 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/AttendanceDialog.kt @@ -18,12 +18,11 @@ class AttendanceDialog : DialogFragment() { private lateinit var attendance: Attendance companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(exam: Attendance): AttendanceDialog { - return AttendanceDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } - } + fun newInstance(exam: Attendance) = AttendanceDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } } } @@ -35,12 +34,14 @@ class AttendanceDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogAttendanceBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogAttendanceBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(binding) { attendanceDialogSubject.text = attendance.subject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamDialog.kt index c1a6f1f0d..3f815a2cb 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamDialog.kt @@ -17,12 +17,11 @@ class ExamDialog : DialogFragment() { private lateinit var exam: Exam companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(exam: Exam): ExamDialog { - return ExamDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } - } + fun newInstance(exam: Exam) = ExamDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } } } @@ -34,12 +33,14 @@ class ExamDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogExamBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogExamBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(binding) { examDialogSubjectValue.text = exam.subject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt index 698aff3ea..286194464 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt @@ -24,17 +24,18 @@ class GradeDetailsDialog : DialogFragment() { private lateinit var colorScheme: String companion object { + private const val ARGUMENT_KEY = "Item" + private const val COLOR_SCHEME_KEY = "Scheme" - fun newInstance(grade: Grade, colorScheme: String): GradeDetailsDialog { - return GradeDetailsDialog().apply { + fun newInstance(grade: Grade, colorScheme: String) = + GradeDetailsDialog().apply { arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, grade) putString(COLOR_SCHEME_KEY, colorScheme) } } - } } override fun onCreate(savedInstanceState: Bundle?) { @@ -46,12 +47,14 @@ class GradeDetailsDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogGradeBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogGradeBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(binding) { gradeDialogSubject.text = grade.subject diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt index aecaa394d..93045a481 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/details/HomeworkDetailsDialog.kt @@ -28,12 +28,11 @@ class HomeworkDetailsDialog : BaseDialogFragment(), Homew private lateinit var homework: Homework companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(homework: Homework): HomeworkDetailsDialog { - return HomeworkDetailsDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, homework) } - } + fun newInstance(homework: Homework) = HomeworkDetailsDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, homework) } } } @@ -45,19 +44,22 @@ class HomeworkDetailsDialog : BaseDialogFragment(), Homew } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogHomeworkBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogHomeworkBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) presenter.onAttachView(this) } @SuppressLint("SetTextI18n") override fun initView() { with(binding) { - homeworkDialogRead.text = view?.context?.getString(if (homework.isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done) + homeworkDialogRead.text = + view?.context?.getString(if (homework.isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done) homeworkDialogRead.setOnClickListener { presenter.toggleDone(homework) } homeworkDialogClose.setOnClickListener { dismiss() } } @@ -87,7 +89,8 @@ class HomeworkDetailsDialog : BaseDialogFragment(), Homew } 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) + binding.homeworkDialogRead.text = + view?.context?.getString(if (isDone) R.string.homework_mark_as_undone else R.string.homework_mark_as_done) } override fun onDestroyView() { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt index aff1c84ca..8d96a498f 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/LoginActivity.kt @@ -52,6 +52,8 @@ class LoginActivity : BaseActivity(), Logi updateHelper.onResume(this) } + //https://developer.android.com/guide/playcore/in-app-updates#status_callback + @Suppress("DEPRECATION") override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) updateHelper.onActivityResult(requestCode, resultCode) @@ -65,13 +67,15 @@ class LoginActivity : BaseActivity(), Logi with(loginAdapter) { containerId = binding.loginViewpager.id - addFragments(listOf( - LoginFormFragment.newInstance(), - LoginSymbolFragment.newInstance(), - LoginStudentSelectFragment.newInstance(), - LoginAdvancedFragment.newInstance(), - LoginRecoverFragment.newInstance() - )) + addFragments( + listOf( + LoginFormFragment.newInstance(), + LoginSymbolFragment.newInstance(), + LoginStudentSelectFragment.newInstance(), + LoginAdvancedFragment.newInstance(), + LoginRecoverFragment.newInstance() + ) + ) } with(binding.loginViewpager) { @@ -99,14 +103,20 @@ class LoginActivity : BaseActivity(), Logi } override fun notifyInitSymbolFragment(loginData: Triple) { - (loginAdapter.getFragmentInstance(1) as? LoginSymbolFragment)?.onParentInitSymbolFragment(loginData) + (loginAdapter.getFragmentInstance(1) as? LoginSymbolFragment)?.onParentInitSymbolFragment( + loginData + ) } override fun notifyInitStudentSelectFragment(studentsWithSemesters: List) { - (loginAdapter.getFragmentInstance(2) as? LoginStudentSelectFragment)?.onParentInitStudentSelectFragment(studentsWithSemesters) + (loginAdapter.getFragmentInstance(2) as? LoginStudentSelectFragment) + ?.onParentInitStudentSelectFragment(studentsWithSemesters) } - fun onFormFragmentAccountLogged(studentsWithSemesters: List, loginData: Triple) { + fun onFormFragmentAccountLogged( + studentsWithSemesters: List, + loginData: Triple + ) { presenter.onFormViewAccountLogged(studentsWithSemesters, loginData) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index da3863f4c..5585ac27c 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -122,6 +122,11 @@ class MainActivity : BaseActivity(), MainVie initialize(startMenuIndex, savedInstanceState) pushFragment(moreMenuFragments[startMenuMoreIndex]) } + + if (appInfo.systemVersion >= Build.VERSION_CODES.N_MR1) { + initShortcuts() + } + updateHelper.checkAndInstallUpdates(this) } @@ -130,11 +135,11 @@ class MainActivity : BaseActivity(), MainVie updateHelper.onResume(this) } - @SuppressLint("NewApi") + //https://developer.android.com/guide/playcore/in-app-updates#status_callback + @Suppress("DEPRECATION") override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) updateHelper.onActivityResult(requestCode, resultCode) - if (appInfo.systemVersion >= Build.VERSION_CODES.N_MR1) initShortcuts() } @RequiresApi(Build.VERSION_CODES.N_MR1) @@ -161,11 +166,6 @@ class MainActivity : BaseActivity(), MainVie getString(R.string.timetable_title), R.drawable.ic_shortcut_timetable, MainView.Section.TIMETABLE - ), - Triple( - getString(R.string.message_title), - R.drawable.ic_shortcut_message, - MainView.Section.MESSAGE ) ).forEach { (title, icon, enum) -> shortcutsList.add( diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt index 48150d8de..6357c495a 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/mobiledevice/token/MobileDeviceTokenDialog.kt @@ -20,13 +20,15 @@ import io.github.wulkanowy.ui.base.BaseDialogFragment import javax.inject.Inject @AndroidEntryPoint -class MobileDeviceTokenDialog : BaseDialogFragment(), MobileDeviceTokenVIew { +class MobileDeviceTokenDialog : BaseDialogFragment(), + MobileDeviceTokenVIew { @Inject lateinit var presenter: MobileDeviceTokenPresenter companion object { - fun newInstance(): MobileDeviceTokenDialog = MobileDeviceTokenDialog() + + fun newInstance() = MobileDeviceTokenDialog() } override fun onCreate(savedInstanceState: Bundle?) { @@ -34,12 +36,14 @@ class MobileDeviceTokenDialog : BaseDialogFragment(), setStyle(STYLE_NO_TITLE, 0) } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogMobileDeviceBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogMobileDeviceBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) presenter.onAttachView(this) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteDialog.kt index e016fe0b9..4cb1cda02 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/note/NoteDialog.kt @@ -22,12 +22,11 @@ class NoteDialog : DialogFragment() { private lateinit var note: Note companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(exam: Note): NoteDialog { - return NoteDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } - } + fun newInstance(exam: Note) = NoteDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } } } @@ -39,13 +38,15 @@ class NoteDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogNoteBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogNoteBinding.inflate(inflater).apply { binding = this }.root @SuppressLint("SetTextI18n") - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(binding) { noteDialogDate.text = note.date.toFormattedString() @@ -57,11 +58,19 @@ class NoteDialog : DialogFragment() { if (note.isPointsShow) { with(binding.noteDialogPoints) { text = "${if (note.points > 0) "+" else ""}${note.points}" - setTextColor(when (NoteCategory.getByValue(note.categoryType)) { - NoteCategory.POSITIVE -> ContextCompat.getColor(requireContext(), R.color.note_positive) - NoteCategory.NEGATIVE -> ContextCompat.getColor(requireContext(), R.color.note_negative) - else -> requireContext().getThemeAttrColor(android.R.attr.textColorPrimary) - }) + setTextColor( + when (NoteCategory.getByValue(note.categoryType)) { + NoteCategory.POSITIVE -> ContextCompat.getColor( + requireContext(), + R.color.note_positive + ) + NoteCategory.NEGATIVE -> ContextCompat.getColor( + requireContext(), + R.color.note_negative + ) + else -> requireContext().getThemeAttrColor(android.R.attr.textColorPrimary) + } + ) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt index ad4692b96..e02f3b8d8 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/settings/SettingsFragment.kt @@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.settings import android.content.SharedPreferences import android.os.Bundle +import android.view.View import androidx.appcompat.app.AlertDialog import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat @@ -49,7 +50,10 @@ class SettingsFragment : PreferenceFragmentCompat(), } } findPreference(getString(R.string.pref_key_notifications_fix_issues))?.run { - isVisible = AppKillerManager.isDeviceSupported() && AppKillerManager.isAnyActionAvailable(requireContext()) + isVisible = + AppKillerManager.isDeviceSupported() && AppKillerManager.isAnyActionAvailable( + requireContext() + ) setOnPreferenceClickListener { presenter.onFixSyncIssuesClicked() true @@ -57,14 +61,15 @@ class SettingsFragment : PreferenceFragmentCompat(), } } - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) presenter.onAttachView(this) } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.scheme_preferences, rootKey) - findPreference(getString(R.string.pref_key_notification_debug))?.isVisible = appInfo.isDebug + findPreference(getString(R.string.pref_key_notification_debug))?.isVisible = + appInfo.isDebug } override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableDialog.kt index f7d5b1ed9..7744515d9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/TimetableDialog.kt @@ -24,12 +24,11 @@ class TimetableDialog : DialogFragment() { private lateinit var lesson: Timetable companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(exam: Timetable): TimetableDialog { - return TimetableDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } - } + fun newInstance(exam: Timetable) = TimetableDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } } } @@ -41,12 +40,14 @@ class TimetableDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogTimetableBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogTimetableBinding.inflate(inflater).apply { binding = this }.root - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(lesson) { setInfo(info, teacher, canceled, changes) @@ -76,15 +77,24 @@ class TimetableDialog : DialogFragment() { } } + @SuppressLint("DefaultLocale") private fun setInfo(info: String, teacher: String, canceled: Boolean, changes: Boolean) { with(binding) { when { info.isNotBlank() -> { if (canceled) { - timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary)) + timetableDialogChangesTitle.setTextColor( + requireContext().getThemeAttrColor( + R.attr.colorPrimary + ) + ) timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary)) } else { - timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange)) + timetableDialogChangesTitle.setTextColor( + requireContext().getThemeAttrColor( + R.attr.colorTimetableChange + ) + ) timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange)) } @@ -167,6 +177,7 @@ class TimetableDialog : DialogFragment() { @SuppressLint("SetTextI18n") private fun setTime(start: LocalDateTime, end: LocalDateTime) { - binding.timetableDialogTime.text = "${start.toFormattedString("HH:mm")} - ${end.toFormattedString("HH:mm")}" + binding.timetableDialogTime.text = + "${start.toFormattedString("HH:mm")} - ${end.toFormattedString("HH:mm")}" } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonDialog.kt index 56ea16cfa..258fc59df 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetable/completed/CompletedLessonDialog.kt @@ -1,6 +1,5 @@ package io.github.wulkanowy.ui.modules.timetable.completed -import android.annotation.SuppressLint import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -17,12 +16,11 @@ class CompletedLessonDialog : DialogFragment() { private lateinit var completedLesson: CompletedLesson companion object { + private const val ARGUMENT_KEY = "Item" - fun newInstance(exam: CompletedLesson): CompletedLessonDialog { - return CompletedLessonDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } - } + fun newInstance(exam: CompletedLesson) = CompletedLessonDialog().apply { + arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) } } } @@ -34,13 +32,14 @@ class CompletedLessonDialog : DialogFragment() { } } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return DialogLessonCompletedBinding.inflate(inflater).apply { binding = this }.root - } + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ) = DialogLessonCompletedBinding.inflate(inflater).apply { binding = this }.root - @SuppressLint("SetTextI18n") - override fun onActivityCreated(savedInstanceState: Bundle?) { - super.onActivityCreated(savedInstanceState) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) with(binding) { completedLessonDialogSubject.text = completedLesson.subject