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