again, some changes, mainly uniform text sizes where they matter, small bugfixes and some other things
This commit is contained in:
@@ -26,6 +26,7 @@ class AboutFragment : DialogFragment() {
|
||||
private var initialTouchY: Float = 0f
|
||||
private val swipeThreshold = 100
|
||||
private val swipeVelocityThreshold = 100
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -66,7 +67,7 @@ class AboutFragment : DialogFragment() {
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.windowAnimations = R.style.Theme_Solon_DialogAnimation
|
||||
dialog.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setCancelable(true)
|
||||
|
||||
@@ -27,11 +27,6 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalTime
|
||||
import android.util.Log
|
||||
import java.time.MonthDay
|
||||
import kotlin.math.floor
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
class CalWeekFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@@ -44,8 +39,9 @@ class CalWeekFragment : Fragment() {
|
||||
|
||||
val adapter = DayPagerAdapter(childFragmentManager, viewLifecycleOwner.lifecycle)
|
||||
|
||||
Vars.dayCounter = 0
|
||||
for (i in 0 until Vars.days.size) {
|
||||
adapter.addFragment(DayFragment(i))
|
||||
adapter.addFragment(DayFragment())
|
||||
}
|
||||
|
||||
viewPager.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||
@@ -81,7 +77,7 @@ class DayPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
|
||||
}
|
||||
}
|
||||
|
||||
class DayFragment(private val i: Int) : Fragment() {
|
||||
class DayFragment : Fragment() {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@@ -93,7 +89,8 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
val view = inflater.inflate(R.layout.fragment_day, container, false)
|
||||
|
||||
val dayLayout: LinearLayout = view.findViewById(R.id.layoutDayMain)
|
||||
Vars.dayMap[i]?.let { createDayView(it, dayLayout, resources) }
|
||||
Vars.dayMap[Vars.dayCounter]?.let { createDayView(it, dayLayout, resources) }
|
||||
Vars.dayCounter += 1
|
||||
|
||||
return view
|
||||
}
|
||||
@@ -256,7 +253,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
val nameDateTextView = TextView(requireContext())
|
||||
nameDateTextView.text = String.format("%s %s", day.name, day.date)
|
||||
nameDateTextView.setTypeface(customFont, Typeface.BOLD_ITALIC)
|
||||
nameDateTextView.textSize = 27f
|
||||
nameDateTextView.setAutoSizeTextTypeUniformWithConfiguration(75, 90, 1, 0)
|
||||
nameDateTextView.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
@@ -279,7 +276,6 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
prevSubj.free = false
|
||||
|
||||
for ((i, subj) in day.subjects.withIndex()) {
|
||||
Log.d("debug", "${subj.name} ${subj.substitute}")
|
||||
val subjectBackground = when (subj.substitute) {
|
||||
"0" -> if (subj.place != "Volno") {
|
||||
R.color.primary_transparent_bg
|
||||
@@ -338,6 +334,15 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
subjectLayout.gravity = Gravity.CENTER_VERTICAL
|
||||
subjectLayout.background = subjectDrawable
|
||||
|
||||
// height specifier
|
||||
val heightSpecifier = View(requireContext())
|
||||
heightSpecifier.layoutParams = LinearLayout.LayoutParams(
|
||||
0,
|
||||
160
|
||||
)
|
||||
|
||||
subjectLayout.addView(heightSpecifier)
|
||||
|
||||
val subjectNumberDrawable = GradientDrawable()
|
||||
subjectNumberDrawable.shape = GradientDrawable.RECTANGLE
|
||||
subjectNumberDrawable.cornerRadius = resources.getDimension(R.dimen.corner_radius)
|
||||
@@ -351,7 +356,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
val subjectNumberTextView = TextView(requireContext())
|
||||
subjectNumberTextView.typeface = customFont
|
||||
subjectNumberTextView.text = subj.number
|
||||
subjectNumberTextView.textSize = 30f
|
||||
subjectNumberTextView.setAutoSizeTextTypeUniformWithConfiguration(60, 80, 1, 0)
|
||||
subjectNumberTextView.setPadding(20, 20, 20, 20)
|
||||
subjectNumberTextView.gravity = Gravity.CENTER // Center text vertically
|
||||
subjectNumberTextView.setTextColor(
|
||||
@@ -380,36 +385,32 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
if (subj.name != "Volno") {
|
||||
subjectNameTextView.text = subj.name.uppercase()
|
||||
}
|
||||
subjectNameTextView.typeface = customFont
|
||||
subjectNameTextView.textSize = 27f
|
||||
subjectNameTextView.setTypeface(customFont, Typeface.BOLD)
|
||||
subjectNameTextView.setAutoSizeTextTypeUniformWithConfiguration(70, 85, 1, 0)
|
||||
subjectNameTextView.setPadding(60, 35, 0, 35)
|
||||
subjectNameTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||
subjectNameTextView.gravity = Gravity.CENTER_VERTICAL
|
||||
if (subj.name != "Volno") {
|
||||
subjectNameTextView.setTypeface(null, Typeface.BOLD)
|
||||
}
|
||||
subjectNameTextView.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
|
||||
if (subj.free) {
|
||||
subjectNameTextView.setPadding(260, 35, 10, 35)
|
||||
}
|
||||
subjectNameTextView.layoutParams = LinearLayout.LayoutParams(
|
||||
(2 * Util.getDisplayWidth(requireContext())) / 9,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
|
||||
subjectLayout.addView(subjectNameTextView)
|
||||
|
||||
val subjectPlaceTextView = TextView(requireContext())
|
||||
subjectPlaceTextView.typeface = customFont
|
||||
subjectPlaceTextView.text = subj.place
|
||||
subjectPlaceTextView.setPadding(20, 20, 20, 20)
|
||||
if (subj.free) {
|
||||
// italic
|
||||
subjectPlaceTextView.setTypeface(customFont, Typeface.ITALIC)
|
||||
}
|
||||
subjectPlaceTextView.textSize = 20f
|
||||
subjectPlaceTextView.setAutoSizeTextTypeUniformWithConfiguration(40, 60, 1, 0)
|
||||
subjectPlaceTextView.setAutoSizeTextTypeUniformWithConfiguration(55, 85, 1, 0)
|
||||
subjectPlaceTextView.gravity = Gravity.CENTER_VERTICAL
|
||||
subjectPlaceTextView.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
@@ -418,14 +419,6 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
)
|
||||
)
|
||||
|
||||
if (subj.free) {
|
||||
subjectPlaceTextView.layoutParams =
|
||||
LinearLayout.LayoutParams(
|
||||
230,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
}
|
||||
|
||||
if (subj.substitute != "2") {
|
||||
subjectLayout.addView(subjectPlaceTextView)
|
||||
}
|
||||
@@ -445,7 +438,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
val subjectTimeString = subj.start + "–" + subj.end
|
||||
subjectTimeTextView.typeface = customFont
|
||||
subjectTimeTextView.text = subjectTimeString
|
||||
subjectTimeTextView.textSize = 17f
|
||||
subjectTimeTextView.setAutoSizeTextTypeUniformWithConfiguration(55, 75, 1, 0)
|
||||
subjectTimeTextView.setPadding(10, 0, 20, 0)
|
||||
subjectTimeTextView.textAlignment = View.TEXT_ALIGNMENT_TEXT_END
|
||||
subjectTimeTextView.setTextColor(
|
||||
@@ -458,7 +451,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
val subjectTeacherTextView = TextView(requireContext())
|
||||
subjectTeacherTextView.text = subj.teacher
|
||||
subjectTeacherTextView.typeface = customFont
|
||||
subjectTeacherTextView.textSize = 11f
|
||||
subjectTeacherTextView.setAutoSizeTextTypeUniformWithConfiguration(30, 31, 1, 0)
|
||||
subjectTeacherTextView.setPadding(0, 0, 20, 10)
|
||||
subjectTeacherTextView.textAlignment = View.TEXT_ALIGNMENT_TEXT_END
|
||||
subjectTeacherTextView.setTextColor(
|
||||
@@ -508,15 +501,20 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
rootLayout.viewTreeObserver.removeOnPreDrawListener(this)
|
||||
|
||||
// Call your function or perform an action here
|
||||
if (subj.substitute != "2") {
|
||||
subjectPlaceTextView.setPadding(
|
||||
380 - frameLayout.width - subjectNameTextView.width,
|
||||
20,
|
||||
20,
|
||||
20
|
||||
if (subj.free) {
|
||||
subjectPlaceTextView.text = "Volno "
|
||||
}
|
||||
|
||||
nameDateTextView.layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
|
||||
if (subj.substitute == "2") {
|
||||
subjectNameTextView.layoutParams = LinearLayout.LayoutParams(
|
||||
subjectLayout.width,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
} else {
|
||||
subjectNameTextView.width = subjectLayout.width
|
||||
subjectNameTextView.setPadding(30, 35, 30, 35)
|
||||
subjectNameTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||
subjectNameTextView.gravity = Gravity.CENTER_VERTICAL
|
||||
@@ -576,7 +574,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
Vars.dayEndString = "Den končí v $endTime"
|
||||
dayEndTextView.text = Vars.dayEndString
|
||||
dayEndTextView.typeface = customFont
|
||||
dayEndTextView.textSize = 20f
|
||||
dayEndTextView.setAutoSizeTextTypeUniformWithConfiguration(55, 85, 1, 0)
|
||||
dayEndTextView.setPadding(0, 30, 0, 30)
|
||||
dayEndTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||
dayEndTextView.gravity = Gravity.CENTER
|
||||
@@ -618,7 +616,7 @@ class DayFragment(private val i: Int) : Fragment() {
|
||||
|
||||
val endParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
130
|
||||
)
|
||||
endParams.setMargins(
|
||||
resources.getDimensionPixelSize(R.dimen.cal_week_separator_height)/4,
|
||||
|
||||
@@ -38,6 +38,9 @@ class MainFragment : Fragment() {
|
||||
|
||||
private fun setup(view: View) {
|
||||
toolbar = view.findViewById(R.id.toolbar)
|
||||
toolbar.setAutoSizeTextTypeUniformWithConfiguration(60, 65, 1, 0)
|
||||
toolbar.ellipsize = null
|
||||
toolbar.setHorizontallyScrolling(false)
|
||||
|
||||
role = if (Parsing.userIsParent()) {
|
||||
" – Rodič"
|
||||
|
||||
@@ -28,7 +28,7 @@ import kotlin.math.abs
|
||||
|
||||
|
||||
// details for the marks of one subject
|
||||
class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx: Int?) : DialogFragment() {
|
||||
class MarkDetailsFragment : DialogFragment() {
|
||||
private lateinit var gestureDetector: GestureDetector
|
||||
private var initialTouchY: Float = 0f
|
||||
private val swipeThreshold = 100
|
||||
@@ -36,6 +36,7 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
|
||||
private lateinit var scrollView: ScrollView
|
||||
private var isScrollingToDismissEnabled = false
|
||||
private var isScrollingToTop = true
|
||||
private lateinit var dialog: Dialog
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -53,10 +54,6 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
|
||||
// get the root layout
|
||||
rootLayout = view.findViewById(R.id.one_mark_root)
|
||||
|
||||
if (idx == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
// set up gestures
|
||||
gestures(view)
|
||||
|
||||
@@ -131,9 +128,16 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
|
||||
// FL == FrameLayout
|
||||
// SV == ScrollView
|
||||
|
||||
val marks = MarksFragment.currentMarks
|
||||
val idx = MarksFragment.idx
|
||||
|
||||
if (idx !in 0 until marks.size) {
|
||||
return
|
||||
}
|
||||
|
||||
val font = context?.let { ResourcesCompat.getFont(it, R.font.roboto) }
|
||||
val gradeTV = TextView(requireContext())
|
||||
gradeTV.text = marks[idx!!].grade
|
||||
gradeTV.text = marks[idx].grade
|
||||
gradeTV.textSize = 60f
|
||||
gradeTV.setTypeface(font, Typeface.BOLD)
|
||||
gradeTV.background = Util.getAvgDrawable(requireContext(), marks[idx!!].grade)
|
||||
@@ -274,7 +278,7 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.windowAnimations = R.style.Theme_Solon_DialogAnimation
|
||||
dialog.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setCancelable(true)
|
||||
@@ -292,9 +296,9 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val deltaY = event.rawY - initialTouchY
|
||||
dialog?.window?.attributes?.y = deltaY.toInt()
|
||||
dialog?.window?.attributes?.windowAnimations = 0
|
||||
dialog?.show()
|
||||
dialog.window?.attributes?.y = deltaY.toInt()
|
||||
dialog.window?.attributes?.windowAnimations = 0
|
||||
dialog.show()
|
||||
|
||||
// Check if the dialog has been dragged beyond a threshold and dismiss if necessary
|
||||
if (deltaY > 200) {
|
||||
|
||||
@@ -14,6 +14,8 @@ import android.widget.Space
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.contains
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -23,6 +25,7 @@ class MarksFragment : Fragment() {
|
||||
private lateinit var inflater: LayoutInflater
|
||||
private var container: ViewGroup? = null
|
||||
private var savedInstanceState: Bundle? = null
|
||||
private val marksOneSubjectDialog: DialogFragment = MarksOneSubjectFragment()
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
@@ -52,7 +55,10 @@ class MarksFragment : Fragment() {
|
||||
val root = view.findViewById<LinearLayout>(R.id.no_mark_container)
|
||||
|
||||
for (subject in Vars.marks.keys) {
|
||||
root.addView(Vars.marks[subject]?.let { createMarkView(it) })
|
||||
val viewToAdd = Vars.marks[subject]?.let { createMarkView(it) } as View
|
||||
if (!root.contains(viewToAdd)) {
|
||||
root.addView(viewToAdd)
|
||||
}
|
||||
}
|
||||
|
||||
return view
|
||||
@@ -155,7 +161,7 @@ class MarksFragment : Fragment() {
|
||||
val subjectTextView = TextView(requireContext())
|
||||
subjectTextView.text = marks[0].subject.uppercase()
|
||||
subjectTextView.setPadding(20, 20, 20, 20)
|
||||
subjectTextView.textSize = 26f
|
||||
subjectTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
|
||||
subjectTextView.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
@@ -182,7 +188,7 @@ class MarksFragment : Fragment() {
|
||||
"-"
|
||||
}
|
||||
avgTextView.text = text
|
||||
avgTextView.textSize = 26f
|
||||
avgTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
|
||||
avgTextView.setPadding(20, 20, 20, 20)
|
||||
avgTextView.gravity = Gravity.CENTER // Center text vertically
|
||||
avgTextView.setTypeface(customFont, Typeface.NORMAL)
|
||||
@@ -244,7 +250,7 @@ class MarksFragment : Fragment() {
|
||||
}
|
||||
marksTextView.text = markString
|
||||
marksTextView.setPadding(20, 20, 20, 20)
|
||||
marksTextView.textSize = 23f
|
||||
marksTextView.setAutoSizeTextTypeUniformWithConfiguration(45, 65, 1, 0)
|
||||
marksTextView.setTextColor(
|
||||
ContextCompat.getColor(
|
||||
requireContext(),
|
||||
@@ -253,7 +259,7 @@ class MarksFragment : Fragment() {
|
||||
)
|
||||
marksTextView.layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
marksTextView.gravity = Gravity.CENTER
|
||||
marksTextView.ellipsize = null
|
||||
@@ -266,11 +272,19 @@ class MarksFragment : Fragment() {
|
||||
/* mark details will be a DialogFragment
|
||||
* and will slide up from the bottom
|
||||
*/
|
||||
MarksOneSubjectFragment(marks).show(requireFragmentManager(), "fragment_mark_details")
|
||||
currentMarks = marks
|
||||
if (marksOneSubjectDialog.dialog?.isShowing == false || marksOneSubjectDialog.dialog == null) {
|
||||
marksOneSubjectDialog.show(requireFragmentManager(), "fragment_mark_details")
|
||||
}
|
||||
}
|
||||
|
||||
return markRoot
|
||||
}
|
||||
|
||||
companion object {
|
||||
var currentMarks: MutableList<Mark> = mutableListOf()
|
||||
var idx: Int = 0
|
||||
}
|
||||
}
|
||||
|
||||
class Mark {
|
||||
|
||||
@@ -22,7 +22,7 @@ import androidx.fragment.app.DialogFragment
|
||||
|
||||
// details for the marks of one subject
|
||||
@Suppress("DEPRECATION")
|
||||
class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFragment() {
|
||||
class MarksOneSubjectFragment : DialogFragment() {
|
||||
private var initialTouchY: Float = 0f
|
||||
private lateinit var rootLayout: LinearLayout
|
||||
private lateinit var scrollView: ScrollView
|
||||
@@ -30,6 +30,8 @@ class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFrag
|
||||
private var isScrollingToDismissEnabled = false
|
||||
private var isScrollingToTop = true
|
||||
private lateinit var gestureDetector: GestureDetector
|
||||
private lateinit var dialog: Dialog
|
||||
private val markDetailsDialog: DialogFragment = MarkDetailsFragment()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -94,6 +96,8 @@ class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFrag
|
||||
// FL == FrameLayout
|
||||
// SV == ScrollView
|
||||
|
||||
val marks = MarksFragment.currentMarks
|
||||
|
||||
val customFont = context?.let { ResourcesCompat.getFont(it, R.font.roboto) }
|
||||
val bgColor = if (!marks.contains(Mark().none())) {
|
||||
Util.getAvgBgColor(requireContext(), Util.avg(marks))
|
||||
@@ -226,7 +230,7 @@ class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFrag
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog = super.onCreateDialog(savedInstanceState)
|
||||
dialog.window?.attributes?.windowAnimations = R.style.Theme_Solon_DialogAnimation
|
||||
dialog.window?.requestFeature(Window.FEATURE_NO_TITLE)
|
||||
dialog.setCancelable(true)
|
||||
@@ -243,9 +247,9 @@ class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFrag
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val deltaY = event.rawY - initialTouchY
|
||||
dialog?.window?.attributes?.y = deltaY.toInt()
|
||||
dialog?.window?.attributes?.windowAnimations = 0
|
||||
dialog?.show()
|
||||
dialog.window?.attributes?.y = deltaY.toInt()
|
||||
dialog.window?.attributes?.windowAnimations = 0
|
||||
dialog.show()
|
||||
|
||||
// Check if the dialog has been dragged beyond a threshold and dismiss if necessary
|
||||
if (deltaY > 200) {
|
||||
@@ -254,12 +258,19 @@ class MarksOneSubjectFragment(private val marks: MutableList<Mark>) : DialogFrag
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
if (dialog?.isShowing == true) {
|
||||
if (dialog.isShowing) {
|
||||
i?.let {
|
||||
MarkDetailsFragment(marks, i).show(
|
||||
requireFragmentManager(),
|
||||
"fragment_mark_details"
|
||||
)
|
||||
MarksFragment.idx = it
|
||||
if (
|
||||
it in 0 until MarksFragment.currentMarks.size &&
|
||||
markDetailsDialog.dialog?.isShowing == false ||
|
||||
markDetailsDialog.dialog == null
|
||||
) {
|
||||
markDetailsDialog.show(
|
||||
requireFragmentManager(),
|
||||
"fragment_mark_details"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
initialTouchY = 0f
|
||||
|
||||
@@ -2,15 +2,21 @@ package com.odweta.solon
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class MenuFragment : Fragment() {
|
||||
private lateinit var signOutDialog: Dialog
|
||||
private lateinit var signInDialog: DialogFragment
|
||||
private lateinit var aboutDialog: DialogFragment
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
@@ -33,32 +39,44 @@ class MenuFragment : Fragment() {
|
||||
// SettingsFragment().show(requireFragmentManager(), "fragment_settings")
|
||||
//}
|
||||
|
||||
signOut.setOnClickListener {
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context, R.style.Theme_Solon_AlertDialog)
|
||||
builder
|
||||
.setView(LayoutInflater.from(context).inflate(R.layout.alert_dialog_sign_out, null))
|
||||
.setPositiveButton("Ano") { dialog, _ ->
|
||||
Util.deleteFile(Vars.userDataFilePath)
|
||||
Util.deleteFile(Vars.timeTableFilePath)
|
||||
Util.deleteFile(Vars.marksFilePath)
|
||||
Util.deleteFile(Vars.accountDataFilePath)
|
||||
dialog.dismiss()
|
||||
exitProcess(0)
|
||||
}
|
||||
.setNegativeButton("Ne") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
// init dialogs
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(context, R.style.Theme_Solon_AlertDialog)
|
||||
builder
|
||||
.setView(LayoutInflater.from(context).inflate(R.layout.alert_dialog_sign_out, null))
|
||||
.setPositiveButton("Ano") { dialog, _ ->
|
||||
Util.deleteFile(Vars.userDataFilePath)
|
||||
Util.deleteFile(Vars.timeTableFilePath)
|
||||
Util.deleteFile(Vars.marksFilePath)
|
||||
Util.deleteFile(Vars.accountDataFilePath)
|
||||
dialog.dismiss()
|
||||
exitProcess(0)
|
||||
}
|
||||
.setNegativeButton("Ne") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
val dialog: AlertDialog = builder.create()
|
||||
dialog.show()
|
||||
signOutDialog = builder.create()
|
||||
|
||||
signInDialog = SignInFragment()
|
||||
|
||||
aboutDialog = AboutFragment()
|
||||
|
||||
signOut.setOnClickListener {
|
||||
if (!signOutDialog.isShowing) {
|
||||
signOutDialog.show()
|
||||
}
|
||||
}
|
||||
|
||||
signIn.setOnClickListener {
|
||||
SignInFragment().show(requireFragmentManager(), "fragment_sign_in")
|
||||
if (signInDialog.dialog?.isShowing == false || signInDialog.dialog == null) {
|
||||
signInDialog.show(requireFragmentManager(), "fragment_sign_in")
|
||||
}
|
||||
}
|
||||
|
||||
about.setOnClickListener {
|
||||
AboutFragment().show(requireFragmentManager(), "fragment_about")
|
||||
if (aboutDialog.dialog?.isShowing == false || aboutDialog.dialog == null) {
|
||||
aboutDialog.show(requireFragmentManager(), "fragment_about")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ class Vars {
|
||||
var height: Int = 0
|
||||
var internetAvail: Boolean = false
|
||||
|
||||
var dayCounter: Int = 0
|
||||
|
||||
var timeTableAvailOffline: Boolean = false
|
||||
var marksAvailOffline: Boolean = false
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
<TextView
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="70dp"
|
||||
android:layout_margin="20dp"
|
||||
android:background="@drawable/toolbar_background"
|
||||
android:fontFamily="@font/roboto"
|
||||
android:gravity="center"
|
||||
android:padding="15dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="25sp" />
|
||||
android:textSize="25sp"
|
||||
android:textColor="@color/white" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
|
||||
Reference in New Issue
Block a user