forked from github/wulkanowy-mirror
Remove deprecations (#1170)
This commit is contained in:
parent
963caadced
commit
412057b512
@ -4,6 +4,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.fragment.app.FragmentPagerAdapter
|
import androidx.fragment.app.FragmentPagerAdapter
|
||||||
|
|
||||||
|
//TODO Use ViewPager2
|
||||||
class BaseFragmentPagerAdapter(private val fragmentManager: FragmentManager) :
|
class BaseFragmentPagerAdapter(private val fragmentManager: FragmentManager) :
|
||||||
FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||||
|
|
||||||
|
@ -42,10 +42,8 @@ class ErrorDialog : BaseDialogFragment<DialogErrorBinding>() {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val ARGUMENT_KEY = "Data"
|
private const val ARGUMENT_KEY = "Data"
|
||||||
|
|
||||||
fun newInstance(error: Throwable): ErrorDialog {
|
fun newInstance(error: Throwable) = ErrorDialog().apply {
|
||||||
return ErrorDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, error) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, error) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,12 +55,14 @@ class ErrorDialog : BaseDialogFragment<DialogErrorBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(
|
||||||
return DialogErrorBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogErrorBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val stringWriter = StringWriter().apply {
|
val stringWriter = StringWriter().apply {
|
||||||
error.printStackTrace(PrintWriter(this))
|
error.printStackTrace(PrintWriter(this))
|
||||||
|
@ -18,12 +18,11 @@ class AttendanceDialog : DialogFragment() {
|
|||||||
private lateinit var attendance: Attendance
|
private lateinit var attendance: Attendance
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(exam: Attendance): AttendanceDialog {
|
fun newInstance(exam: Attendance) = AttendanceDialog().apply {
|
||||||
return AttendanceDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,12 +34,14 @@ class AttendanceDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogAttendanceBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogAttendanceBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
attendanceDialogSubject.text = attendance.subject
|
attendanceDialogSubject.text = attendance.subject
|
||||||
|
@ -17,12 +17,11 @@ class ExamDialog : DialogFragment() {
|
|||||||
private lateinit var exam: Exam
|
private lateinit var exam: Exam
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(exam: Exam): ExamDialog {
|
fun newInstance(exam: Exam) = ExamDialog().apply {
|
||||||
return ExamDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,12 +33,14 @@ class ExamDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogExamBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogExamBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
examDialogSubjectValue.text = exam.subject
|
examDialogSubjectValue.text = exam.subject
|
||||||
|
@ -24,17 +24,18 @@ class GradeDetailsDialog : DialogFragment() {
|
|||||||
private lateinit var colorScheme: String
|
private lateinit var colorScheme: String
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
private const val COLOR_SCHEME_KEY = "Scheme"
|
private const val COLOR_SCHEME_KEY = "Scheme"
|
||||||
|
|
||||||
fun newInstance(grade: Grade, colorScheme: String): GradeDetailsDialog {
|
fun newInstance(grade: Grade, colorScheme: String) =
|
||||||
return GradeDetailsDialog().apply {
|
GradeDetailsDialog().apply {
|
||||||
arguments = Bundle().apply {
|
arguments = Bundle().apply {
|
||||||
putSerializable(ARGUMENT_KEY, grade)
|
putSerializable(ARGUMENT_KEY, grade)
|
||||||
putString(COLOR_SCHEME_KEY, colorScheme)
|
putString(COLOR_SCHEME_KEY, colorScheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -46,12 +47,14 @@ class GradeDetailsDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogGradeBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogGradeBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
gradeDialogSubject.text = grade.subject
|
gradeDialogSubject.text = grade.subject
|
||||||
|
@ -28,12 +28,11 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
|||||||
private lateinit var homework: Homework
|
private lateinit var homework: Homework
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(homework: Homework): HomeworkDetailsDialog {
|
fun newInstance(homework: Homework) = HomeworkDetailsDialog().apply {
|
||||||
return HomeworkDetailsDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, homework) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, homework) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,19 +44,22 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogHomeworkBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogHomeworkBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun initView() {
|
override fun initView() {
|
||||||
with(binding) {
|
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) }
|
homeworkDialogRead.setOnClickListener { presenter.toggleDone(homework) }
|
||||||
homeworkDialogClose.setOnClickListener { dismiss() }
|
homeworkDialogClose.setOnClickListener { dismiss() }
|
||||||
}
|
}
|
||||||
@ -87,7 +89,8 @@ class HomeworkDetailsDialog : BaseDialogFragment<DialogHomeworkBinding>(), Homew
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMarkAsDoneLabel(isDone: Boolean) {
|
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() {
|
override fun onDestroyView() {
|
||||||
|
@ -52,6 +52,8 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
|||||||
updateHelper.onResume(this)
|
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?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
updateHelper.onActivityResult(requestCode, resultCode)
|
updateHelper.onActivityResult(requestCode, resultCode)
|
||||||
@ -65,13 +67,15 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
|||||||
|
|
||||||
with(loginAdapter) {
|
with(loginAdapter) {
|
||||||
containerId = binding.loginViewpager.id
|
containerId = binding.loginViewpager.id
|
||||||
addFragments(listOf(
|
addFragments(
|
||||||
LoginFormFragment.newInstance(),
|
listOf(
|
||||||
LoginSymbolFragment.newInstance(),
|
LoginFormFragment.newInstance(),
|
||||||
LoginStudentSelectFragment.newInstance(),
|
LoginSymbolFragment.newInstance(),
|
||||||
LoginAdvancedFragment.newInstance(),
|
LoginStudentSelectFragment.newInstance(),
|
||||||
LoginRecoverFragment.newInstance()
|
LoginAdvancedFragment.newInstance(),
|
||||||
))
|
LoginRecoverFragment.newInstance()
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
with(binding.loginViewpager) {
|
with(binding.loginViewpager) {
|
||||||
@ -99,14 +103,20 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyInitSymbolFragment(loginData: Triple<String, String, String>) {
|
override fun notifyInitSymbolFragment(loginData: Triple<String, String, String>) {
|
||||||
(loginAdapter.getFragmentInstance(1) as? LoginSymbolFragment)?.onParentInitSymbolFragment(loginData)
|
(loginAdapter.getFragmentInstance(1) as? LoginSymbolFragment)?.onParentInitSymbolFragment(
|
||||||
|
loginData
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyInitStudentSelectFragment(studentsWithSemesters: List<StudentWithSemesters>) {
|
override fun notifyInitStudentSelectFragment(studentsWithSemesters: List<StudentWithSemesters>) {
|
||||||
(loginAdapter.getFragmentInstance(2) as? LoginStudentSelectFragment)?.onParentInitStudentSelectFragment(studentsWithSemesters)
|
(loginAdapter.getFragmentInstance(2) as? LoginStudentSelectFragment)
|
||||||
|
?.onParentInitStudentSelectFragment(studentsWithSemesters)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onFormFragmentAccountLogged(studentsWithSemesters: List<StudentWithSemesters>, loginData: Triple<String, String, String>) {
|
fun onFormFragmentAccountLogged(
|
||||||
|
studentsWithSemesters: List<StudentWithSemesters>,
|
||||||
|
loginData: Triple<String, String, String>
|
||||||
|
) {
|
||||||
presenter.onFormViewAccountLogged(studentsWithSemesters, loginData)
|
presenter.onFormViewAccountLogged(studentsWithSemesters, loginData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,11 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
initialize(startMenuIndex, savedInstanceState)
|
initialize(startMenuIndex, savedInstanceState)
|
||||||
pushFragment(moreMenuFragments[startMenuMoreIndex])
|
pushFragment(moreMenuFragments[startMenuMoreIndex])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (appInfo.systemVersion >= Build.VERSION_CODES.N_MR1) {
|
||||||
|
initShortcuts()
|
||||||
|
}
|
||||||
|
|
||||||
updateHelper.checkAndInstallUpdates(this)
|
updateHelper.checkAndInstallUpdates(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,11 +135,11 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
updateHelper.onResume(this)
|
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?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
updateHelper.onActivityResult(requestCode, resultCode)
|
updateHelper.onActivityResult(requestCode, resultCode)
|
||||||
if (appInfo.systemVersion >= Build.VERSION_CODES.N_MR1) initShortcuts()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
@RequiresApi(Build.VERSION_CODES.N_MR1)
|
||||||
@ -161,11 +166,6 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
|||||||
getString(R.string.timetable_title),
|
getString(R.string.timetable_title),
|
||||||
R.drawable.ic_shortcut_timetable,
|
R.drawable.ic_shortcut_timetable,
|
||||||
MainView.Section.TIMETABLE
|
MainView.Section.TIMETABLE
|
||||||
),
|
|
||||||
Triple(
|
|
||||||
getString(R.string.message_title),
|
|
||||||
R.drawable.ic_shortcut_message,
|
|
||||||
MainView.Section.MESSAGE
|
|
||||||
)
|
)
|
||||||
).forEach { (title, icon, enum) ->
|
).forEach { (title, icon, enum) ->
|
||||||
shortcutsList.add(
|
shortcutsList.add(
|
||||||
|
@ -20,13 +20,15 @@ import io.github.wulkanowy.ui.base.BaseDialogFragment
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class MobileDeviceTokenDialog : BaseDialogFragment<DialogMobileDeviceBinding>(), MobileDeviceTokenVIew {
|
class MobileDeviceTokenDialog : BaseDialogFragment<DialogMobileDeviceBinding>(),
|
||||||
|
MobileDeviceTokenVIew {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var presenter: MobileDeviceTokenPresenter
|
lateinit var presenter: MobileDeviceTokenPresenter
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun newInstance(): MobileDeviceTokenDialog = MobileDeviceTokenDialog()
|
|
||||||
|
fun newInstance() = MobileDeviceTokenDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
@ -34,12 +36,14 @@ class MobileDeviceTokenDialog : BaseDialogFragment<DialogMobileDeviceBinding>(),
|
|||||||
setStyle(STYLE_NO_TITLE, 0)
|
setStyle(STYLE_NO_TITLE, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogMobileDeviceBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogMobileDeviceBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,11 @@ class NoteDialog : DialogFragment() {
|
|||||||
private lateinit var note: Note
|
private lateinit var note: Note
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(exam: Note): NoteDialog {
|
fun newInstance(exam: Note) = NoteDialog().apply {
|
||||||
return NoteDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +38,15 @@ class NoteDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogNoteBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogNoteBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
noteDialogDate.text = note.date.toFormattedString()
|
noteDialogDate.text = note.date.toFormattedString()
|
||||||
@ -57,11 +58,19 @@ class NoteDialog : DialogFragment() {
|
|||||||
if (note.isPointsShow) {
|
if (note.isPointsShow) {
|
||||||
with(binding.noteDialogPoints) {
|
with(binding.noteDialogPoints) {
|
||||||
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
||||||
setTextColor(when (NoteCategory.getByValue(note.categoryType)) {
|
setTextColor(
|
||||||
NoteCategory.POSITIVE -> ContextCompat.getColor(requireContext(), R.color.note_positive)
|
when (NoteCategory.getByValue(note.categoryType)) {
|
||||||
NoteCategory.NEGATIVE -> ContextCompat.getColor(requireContext(), R.color.note_negative)
|
NoteCategory.POSITIVE -> ContextCompat.getColor(
|
||||||
else -> requireContext().getThemeAttrColor(android.R.attr.textColorPrimary)
|
requireContext(),
|
||||||
})
|
R.color.note_positive
|
||||||
|
)
|
||||||
|
NoteCategory.NEGATIVE -> ContextCompat.getColor(
|
||||||
|
requireContext(),
|
||||||
|
R.color.note_negative
|
||||||
|
)
|
||||||
|
else -> requireContext().getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.settings
|
|||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
@ -49,7 +50,10 @@ class SettingsFragment : PreferenceFragmentCompat(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
findPreference<Preference>(getString(R.string.pref_key_notifications_fix_issues))?.run {
|
findPreference<Preference>(getString(R.string.pref_key_notifications_fix_issues))?.run {
|
||||||
isVisible = AppKillerManager.isDeviceSupported() && AppKillerManager.isAnyActionAvailable(requireContext())
|
isVisible =
|
||||||
|
AppKillerManager.isDeviceSupported() && AppKillerManager.isAnyActionAvailable(
|
||||||
|
requireContext()
|
||||||
|
)
|
||||||
setOnPreferenceClickListener {
|
setOnPreferenceClickListener {
|
||||||
presenter.onFixSyncIssuesClicked()
|
presenter.onFixSyncIssuesClicked()
|
||||||
true
|
true
|
||||||
@ -57,14 +61,15 @@ class SettingsFragment : PreferenceFragmentCompat(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
presenter.onAttachView(this)
|
presenter.onAttachView(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.scheme_preferences, rootKey)
|
setPreferencesFromResource(R.xml.scheme_preferences, rootKey)
|
||||||
findPreference<Preference>(getString(R.string.pref_key_notification_debug))?.isVisible = appInfo.isDebug
|
findPreference<Preference>(getString(R.string.pref_key_notification_debug))?.isVisible =
|
||||||
|
appInfo.isDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||||
|
@ -24,12 +24,11 @@ class TimetableDialog : DialogFragment() {
|
|||||||
private lateinit var lesson: Timetable
|
private lateinit var lesson: Timetable
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(exam: Timetable): TimetableDialog {
|
fun newInstance(exam: Timetable) = TimetableDialog().apply {
|
||||||
return TimetableDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,12 +40,14 @@ class TimetableDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogTimetableBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogTimetableBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
with(lesson) {
|
with(lesson) {
|
||||||
setInfo(info, teacher, canceled, changes)
|
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) {
|
private fun setInfo(info: String, teacher: String, canceled: Boolean, changes: Boolean) {
|
||||||
with(binding) {
|
with(binding) {
|
||||||
when {
|
when {
|
||||||
info.isNotBlank() -> {
|
info.isNotBlank() -> {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
timetableDialogChangesTitle.setTextColor(
|
||||||
|
requireContext().getThemeAttrColor(
|
||||||
|
R.attr.colorPrimary
|
||||||
|
)
|
||||||
|
)
|
||||||
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
||||||
} else {
|
} else {
|
||||||
timetableDialogChangesTitle.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
timetableDialogChangesTitle.setTextColor(
|
||||||
|
requireContext().getThemeAttrColor(
|
||||||
|
R.attr.colorTimetableChange
|
||||||
|
)
|
||||||
|
)
|
||||||
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
timetableDialogChanges.setTextColor(requireContext().getThemeAttrColor(R.attr.colorTimetableChange))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +177,7 @@ class TimetableDialog : DialogFragment() {
|
|||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun setTime(start: LocalDateTime, end: LocalDateTime) {
|
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")}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package io.github.wulkanowy.ui.modules.timetable.completed
|
package io.github.wulkanowy.ui.modules.timetable.completed
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -17,12 +16,11 @@ class CompletedLessonDialog : DialogFragment() {
|
|||||||
private lateinit var completedLesson: CompletedLesson
|
private lateinit var completedLesson: CompletedLesson
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val ARGUMENT_KEY = "Item"
|
private const val ARGUMENT_KEY = "Item"
|
||||||
|
|
||||||
fun newInstance(exam: CompletedLesson): CompletedLessonDialog {
|
fun newInstance(exam: CompletedLesson) = CompletedLessonDialog().apply {
|
||||||
return CompletedLessonDialog().apply {
|
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
||||||
arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, exam) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,13 +32,14 @@ class CompletedLessonDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(
|
||||||
return DialogLessonCompletedBinding.inflate(inflater).apply { binding = this }.root
|
inflater: LayoutInflater,
|
||||||
}
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
) = DialogLessonCompletedBinding.inflate(inflater).apply { binding = this }.root
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
super.onViewCreated(view, savedInstanceState)
|
||||||
super.onActivityCreated(savedInstanceState)
|
|
||||||
|
|
||||||
with(binding) {
|
with(binding) {
|
||||||
completedLessonDialogSubject.text = completedLesson.subject
|
completedLessonDialogSubject.text = completedLesson.subject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user