fixed app crash, added an easter egg

This commit is contained in:
Odweta
2024-10-16 22:19:36 +02:00
parent a046e5a000
commit d9c296f80e
14 changed files with 66 additions and 22 deletions
@@ -21,6 +21,8 @@ import android.widget.Space
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.marginLeft
import androidx.core.view.setMargins
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
@@ -251,6 +253,7 @@ class DayFragment : Fragment() {
handler.removeCallbacksAndMessages(null)
}
@SuppressLint("UseCompatLoadingForDrawables")
private fun createDayView(day: Day, rootLayout: LinearLayout, resources: Resources) {
val customFont = context?.let { ResourcesCompat.getFont(it, R.font.roboto) }
@@ -435,10 +438,25 @@ class DayFragment : Fragment() {
namePlaceLL.addView(subjectPlaceTextView)
}
namePlaceLL.setPadding(30, 15, 0, 15)
namePlaceLL.setPadding(30, 15, 20, 15)
subjectLayout.addView(namePlaceLL)
if (subj.teacher == "Jindřich Svoboda") {
val img = ImageView(requireContext())
img.setImageDrawable(resources.getDrawable(R.drawable.spock))
val frameLayout2 = FrameLayout(requireContext())
val layoutParams2 = LinearLayout.LayoutParams(
100,
120,
)
frameLayout2.foregroundGravity = Gravity.CENTER
frameLayout2.layoutParams = layoutParams2
frameLayout2.addView(img)
subjectLayout.addView(frameLayout2)
}
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
@@ -125,7 +125,7 @@ class MarksFragment : Fragment() {
LinearLayout.LayoutParams.WRAP_CONTENT
)
params.setMargins(20, 0, 20, 0)
params.height = 210
params.height = 160
markRoot.layoutParams = params
markRoot.gravity = Gravity.CENTER_VERTICAL
@@ -159,8 +159,9 @@ class MarksFragment : Fragment() {
val subjectTextView = TextView(requireContext())
subjectTextView.text = marks[0].subject.uppercase()
subjectTextView.setPadding(20, 20, 20, 20)
subjectTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
//subjectTextView.setPadding(20, 20, 20, 20)
//subjectTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
subjectTextView.textSize = resources.getDimension(R.dimen.text_size_subject_number) / resources.displayMetrics.scaledDensity
subjectTextView.setTextColor(
ContextCompat.getColor(
requireContext(),
@@ -172,7 +173,7 @@ class MarksFragment : Fragment() {
val fl2 = FrameLayout(requireContext())
fl2.layoutParams = LinearLayout.LayoutParams(
210,
160,
FrameLayout.LayoutParams.MATCH_PARENT,
)
fl2.addView(subjectTextView)
@@ -187,8 +188,9 @@ class MarksFragment : Fragment() {
"-"
}
avgTextView.text = text
avgTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
avgTextView.setPadding(20, 20, 20, 20)
//avgTextView.setPadding(20, 20, 20, 20)
//avgTextView.setAutoSizeTextTypeUniformWithConfiguration(65, 85, 1, 0)
avgTextView.textSize = resources.getDimension(R.dimen.text_size_subject_number) / resources.displayMetrics.scaledDensity
avgTextView.gravity = Gravity.CENTER // Center text vertically
avgTextView.setTypeface(customFont, Typeface.NORMAL)
avgTextView.setTextColor(
@@ -200,7 +202,7 @@ class MarksFragment : Fragment() {
val frameLayout = FrameLayout(requireContext())
frameLayout.layoutParams = LinearLayout.LayoutParams(
210,
160,
FrameLayout.LayoutParams.MATCH_PARENT,
)
frameLayout.addView(avgTextView)
@@ -249,7 +251,8 @@ class MarksFragment : Fragment() {
}
marksTextView.text = markString
marksTextView.setPadding(20, 20, 20, 20)
marksTextView.setAutoSizeTextTypeUniformWithConfiguration(45, 65, 1, 0)
//marksTextView.setAutoSizeTextTypeUniformWithConfiguration(45, 65, 1, 0)
marksTextView.textSize = resources.getDimension(R.dimen.text_size_mark) / resources.displayMetrics.scaledDensity
marksTextView.setTextColor(
ContextCompat.getColor(
requireContext(),
@@ -124,7 +124,8 @@ class MarksOneSubjectFragment : DialogFragment() {
// e.g. average in that subject, hours per week maybe idk
val subjectDetailsLL = LinearLayout(requireContext())
subjectDetailsLL.orientation = LinearLayout.HORIZONTAL
subjectDetailsLL.setPadding(20, 20, 20, 20)
subjectDetailsLL.gravity = Gravity.CENTER_VERTICAL
subjectDetailsLL.setPadding(40, 40, 40, 40)
subjectDetailsLL.background = bg
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
@@ -141,9 +142,7 @@ class MarksOneSubjectFragment : DialogFragment() {
val wholeNameTV = TextView(requireContext())
// index by the abbrev and get the name (if null just fallback to the abbrev)
wholeNameTV.text = Vars.subjectNameMap[marks[0].subject] ?: marks[0].subject
wholeNameTV.textSize = 28f
wholeNameTV.gravity = Gravity.CENTER
wholeNameTV.setPadding(20, 30, 10, 30)
wholeNameTV.gravity = Gravity.CENTER_VERTICAL
wholeNameTV.setTypeface(customFont, Typeface.BOLD)
wholeNameTV.setTextColor(
ContextCompat.getColor(
@@ -162,9 +161,13 @@ class MarksOneSubjectFragment : DialogFragment() {
avgTV.textAlignment = View.TEXT_ALIGNMENT_TEXT_END
avgTV.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
LinearLayout.LayoutParams.WRAP_CONTENT
)
avgTV.setPadding(30, 30, 30, 30)
if (wholeNameTV.text.length < 15) {
wholeNameTV.textSize = 28f
} else {
wholeNameTV.textSize = 24f
}
avgTV.setTextColor(
ContextCompat.getColor(
requireContext(),
@@ -145,7 +145,8 @@ class Util {
var sum = 0f
var len = 0
for (mark in marks) {
val marksCopy = marks.toList()
for (mark in marksCopy) {
len += 1
if (mark.grade !in "0123456789") {
marks.remove(mark)
Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

@@ -10,6 +10,7 @@
<dimen name="text_size_subject_teacher">15sp</dimen>
<dimen name="text_size_day_end">28sp</dimen>
<dimen name="text_size_toolbar">26sp</dimen>
<dimen name="text_size_mark">26sp</dimen>
<dimen name="design_bottom_navigation_text_size" tools:override="true">15sp</dimen>
<dimen name="design_bottom_navigation_active_text_size" tools:override="true">15sp</dimen>
</resources>