visual bugfixes, textsize things, yes

This commit is contained in:
Odweta
2024-02-27 20:27:00 +01:00
parent d79b3a179f
commit 58e412af3c
8 changed files with 48 additions and 59 deletions
+1 -14
View File
@@ -3,20 +3,7 @@
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<value> <value>
<entry key="app"> <entry key="app">
<State> <State />
<targetSelectedWithDropDown>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="$USER_HOME$/.var/app/com.google.AndroidStudio/config/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2024-02-21T21:45:22.107764718Z" />
</State>
</entry> </entry>
</value> </value>
</component> </component>
@@ -27,6 +27,7 @@ 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 java.time.MonthDay
import kotlin.math.floor import kotlin.math.floor
import kotlin.time.Duration.Companion.days import kotlin.time.Duration.Companion.days
@@ -278,6 +279,7 @@ 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
@@ -370,7 +372,7 @@ class DayFragment(private val i: Int) : Fragment() {
frameLayout.addView(subjectNumberTextView) frameLayout.addView(subjectNumberTextView)
if (day.subjects[0].substitute != "2") { if (subj.substitute != "2") {
subjectLayout.addView(frameLayout) subjectLayout.addView(frameLayout)
} }
@@ -380,7 +382,7 @@ class DayFragment(private val i: Int) : Fragment() {
} }
subjectNameTextView.typeface = customFont subjectNameTextView.typeface = customFont
subjectNameTextView.textSize = 27f subjectNameTextView.textSize = 27f
subjectNameTextView.setPadding(60, 35, 20, 35) subjectNameTextView.setPadding(60, 35, 0, 35)
subjectNameTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER subjectNameTextView.textAlignment = View.TEXT_ALIGNMENT_CENTER
subjectNameTextView.gravity = Gravity.CENTER_VERTICAL subjectNameTextView.gravity = Gravity.CENTER_VERTICAL
if (subj.name != "Volno") { if (subj.name != "Volno") {
@@ -394,7 +396,7 @@ class DayFragment(private val i: Int) : Fragment() {
) )
if (subj.free) { if (subj.free) {
subjectNameTextView.setPadding(260, 35, 20, 35) subjectNameTextView.setPadding(260, 35, 10, 35)
} }
subjectLayout.addView(subjectNameTextView) subjectLayout.addView(subjectNameTextView)
@@ -403,10 +405,11 @@ class DayFragment(private val i: Int) : Fragment() {
subjectPlaceTextView.typeface = customFont subjectPlaceTextView.typeface = customFont
subjectPlaceTextView.text = subj.place subjectPlaceTextView.text = subj.place
if (subj.free) { if (subj.free) {
// underline // italic
subjectPlaceTextView.setTypeface(customFont, Typeface.ITALIC) subjectPlaceTextView.setTypeface(customFont, Typeface.ITALIC)
} }
subjectPlaceTextView.textSize = 22f subjectPlaceTextView.textSize = 20f
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,12 +421,12 @@ class DayFragment(private val i: Int) : Fragment() {
if (subj.free) { if (subj.free) {
subjectPlaceTextView.layoutParams = subjectPlaceTextView.layoutParams =
LinearLayout.LayoutParams( LinearLayout.LayoutParams(
220, 230,
LinearLayout.LayoutParams.MATCH_PARENT LinearLayout.LayoutParams.MATCH_PARENT
) )
} }
if (day.subjects[0].substitute != "2") { if (subj.substitute != "2") {
subjectLayout.addView(subjectPlaceTextView) subjectLayout.addView(subjectPlaceTextView)
} }
@@ -442,7 +445,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 = 20f subjectTimeTextView.textSize = 17f
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(
@@ -455,7 +458,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 = 12f subjectTeacherTextView.textSize = 11f
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(
@@ -472,7 +475,7 @@ class DayFragment(private val i: Int) : Fragment() {
} }
timeTeacherLayout.setPadding(0, 0, 10, 0) timeTeacherLayout.setPadding(0, 0, 10, 0)
if (day.subjects[0].substitute != "2") { if (subj.substitute != "2") {
subjectLayout.addView(timeTeacherLayout) subjectLayout.addView(timeTeacherLayout)
} }
@@ -505,9 +508,9 @@ 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 (day.subjects[0].substitute != "2") { if (subj.substitute != "2") {
subjectPlaceTextView.setPadding( subjectPlaceTextView.setPadding(
400 - frameLayout.width - subjectNameTextView.width, 380 - frameLayout.width - subjectNameTextView.width,
20, 20,
20, 20,
20 20
@@ -625,11 +628,9 @@ class DayFragment(private val i: Int) : Fragment() {
) )
dayEndTextView.layoutParams = endParams dayEndTextView.layoutParams = endParams
if (day.subjects[0].substitute != "2") { dayLayout.addView(dayEndSeparator)
dayLayout.addView(dayEndSeparator) dayLayout.addView(dayEndTextView)
dayLayout.addView(dayEndTextView) dayLayout.addView(dayEndSeparator2)
dayLayout.addView(dayEndSeparator2)
}
scrollView.addView(dayLayout) scrollView.addView(dayLayout)
@@ -321,15 +321,17 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
// Fragment Transition // Fragment Transition
private fun ft(container: Int, frag: Fragment, animIn: Int, animOut: Int) { private fun ft(container: Int, frag: Fragment, animIn: Int, animOut: Int) {
val ft = supportFragmentManager.beginTransaction() if (Util.isAppInForeground(applicationContext, packageName)) {
val ft = supportFragmentManager.beginTransaction()
ft.setCustomAnimations( ft.setCustomAnimations(
animIn, animIn,
animOut animOut
) )
ft.replace(container, frag) ft.replace(container, frag)
ft.commit() ft.commit()
}
} }
} }
@@ -150,7 +150,7 @@ class MainFragment : Fragment() {
private fun fetchNewData() { private fun fetchNewData() {
lifecycleScope.launch { lifecycleScope.launch {
done = false done = false
while (!done) { while (!done || !Util.internetAvail(requireContext())) {
toolbar.text = String.format("%s", "Načítání nových dat") toolbar.text = String.format("%s", "Načítání nových dat")
delay(300) delay(300)
toolbar.text = String.format("%s", "Načítání nových dat.") toolbar.text = String.format("%s", "Načítání nových dat.")
@@ -148,7 +148,7 @@ class MarkDetailsFragment(private val marks: MutableList<Mark>, private var idx:
gradeTV.setTextColor(ContextCompat.getColor(requireContext(), R.color.white)) gradeTV.setTextColor(ContextCompat.getColor(requireContext(), R.color.white))
val subjectDesc = makeTV("Předmět:", Typeface.BOLD, Util.getDisplayWidth(requireContext())/3) val subjectDesc = makeTV("Předmět:", Typeface.BOLD, Util.getDisplayWidth(requireContext())/2)
val subjectTV = makeTV(Vars.subjectNameMap[marks[idx!!].subject] ?: marks[idx!!].subject, Typeface.NORMAL, 22f) val subjectTV = makeTV(Vars.subjectNameMap[marks[idx!!].subject] ?: marks[idx!!].subject, Typeface.NORMAL, 22f)
val descDesc = makeTV("Popis:", Typeface.BOLD, Util.getDisplayWidth(requireContext())/3) val descDesc = makeTV("Popis:", Typeface.BOLD, Util.getDisplayWidth(requireContext())/3)
@@ -34,7 +34,6 @@ class MarksFragment : Fragment() {
if (Vars.marksAvailOffline && !Util.fileIsEmpty(Vars.marksFilePath)) { if (Vars.marksAvailOffline && !Util.fileIsEmpty(Vars.marksFilePath)) {
Vars.marksJSON = Util.fileToString(Vars.marksFilePath) Vars.marksJSON = Util.fileToString(Vars.marksFilePath)
Vars.marksAvailOffline = Util.saveStringToFile(Vars.marksFilePath, Vars.marksJSON)
Vars.marks = Parsing.parseMarksJSON(Vars.marksJSON) Vars.marks = Parsing.parseMarksJSON(Vars.marksJSON)
} else { } else {
lifecycleScope.launch { lifecycleScope.launch {
@@ -156,7 +155,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 = 30f subjectTextView.textSize = 26f
subjectTextView.setTextColor( subjectTextView.setTextColor(
ContextCompat.getColor( ContextCompat.getColor(
requireContext(), requireContext(),
@@ -183,7 +182,7 @@ class MarksFragment : Fragment() {
"-" "-"
} }
avgTextView.text = text avgTextView.text = text
avgTextView.textSize = 30f avgTextView.textSize = 26f
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)
@@ -5,6 +5,7 @@ import android.animation.AnimatorInflater
import android.animation.AnimatorListenerAdapter import android.animation.AnimatorListenerAdapter
import android.animation.ArgbEvaluator import android.animation.ArgbEvaluator
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.app.ActivityManager
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Resources import android.content.res.Resources
@@ -123,6 +124,19 @@ class Util {
} }
} }
fun isAppInForeground(context: Context, packageName: String): Boolean {
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val runningAppProcesses = activityManager.runningAppProcesses ?: return false
for (processInfo in runningAppProcesses) {
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND &&
processInfo.processName == packageName) {
return true
}
}
return false
}
fun pixelsToDp(pixels: Int, resources: Resources): Int { fun pixelsToDp(pixels: Int, resources: Resources): Int {
return (pixels * resources.displayMetrics.density).toInt() return (pixels * resources.displayMetrics.density).toInt()
} }
@@ -110,30 +110,16 @@
app:layout_constraintTop_toBottomOf="@+id/textView" app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.3" /> app:layout_constraintVertical_bias="0.3" />
<ImageView
android:id="@+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="61dp"
android:contentDescription="@string/gitlab_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.303"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@mipmap/gitlab_logo_foreground" />
<TextView <TextView
android:id="@+id/sourceCode" android:id="@+id/sourceCode"
style="@style/LinkText" style="@style/LinkText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="96dp"
android:layout_marginBottom="100dp"
android:text="@string/source_code" android:text="@string/source_code"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textSize="20sp" android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@+id/imageView7" /> app:layout_constraintTop_toBottomOf="@+id/textView" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>