optimizations

This commit is contained in:
Odweta
2024-12-22 13:14:13 +01:00
parent fbc528b450
commit 49a28b0064
6 changed files with 0 additions and 98 deletions
@@ -1,6 +1,5 @@
package com.odweta.solon
import android.view.Window
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -11,11 +10,8 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.unit.dp
import com.odweta.solon.ui.theme.PastelYellow
import okhttp3.OkHttpClient
import org.json.JSONObject
import java.io.File
@@ -1,7 +1,6 @@
package com.odweta.solon
import android.content.Context
import android.util.Log
import androidx.compose.ui.graphics.Color
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -1,7 +1,6 @@
package com.odweta.solon
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
@@ -10,15 +9,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.core.view.WindowCompat
import com.odweta.solon.ui.theme.SolonTheme
import kotlin.math.sign
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -23,9 +23,6 @@ import androidx.compose.material.icons.filled.AutoAwesome
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -1,8 +1,6 @@
package com.odweta.solon
import android.util.Log
import androidx.compose.runtime.mutableStateOf
import com.odweta.solon.Util.Companion.getLectureId
import org.json.JSONObject
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
@@ -5,8 +5,6 @@ import android.content.pm.PackageManager
import android.net.ConnectivityManager
import android.net.NetworkCapabilities
import android.os.Build
import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.compose.runtime.mutableStateOf
import androidx.core.content.pm.PackageInfoCompat
import java.io.File
@@ -98,21 +96,6 @@ 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 avg(marks: MutableList<Mark>): String {
var sum = 0f
var len = 0
@@ -134,7 +117,6 @@ class Util {
}
return "${Math.round(sum / sum(weights) * 100f) / 100f}".replace(",", ".")
//return String.format("%.2f", (sum / sum(weights))).replace(',', '.')
}
private fun sum(nums: List<Float>): Float {
@@ -146,49 +128,6 @@ class Util {
return sum
}
/*fun getAvgBgColor(ctx: Context, avg: String): Color {
var color: Color = PastelOrangeTransparent
if (avg.toFloat() in 1f..<2f) {
color = PastelGreenTransparent
} else if (avg.toFloat() in 2f..<3f) {
color = PastelYellowTransparent
} else if (avg.toFloat() in 3f..<4f) {
color = PastelOrangeTransparent
} else if (avg.toFloat() in 4f..5f) {
color = PastelRedTransparent
}
return color
}
fun getAvgStrokeColor(ctx: Context, avg: String): Int {
var color: Int = R.color.pastel_orange
if (avg.toFloat() in 1f..<2f) {
color = R.color.pastel_green
} else if (avg.toFloat() in 2f..<3f) {
color = R.color.pastel_yellow
} else if (avg.toFloat() in 3f..<4f) {
color = R.color.pastel_orange
} else if (avg.toFloat() in 4f..5f) {
color = R.color.pastel_red
}
return ContextCompat.getColor(
ctx,
color
)
}
fun getAvgDrawable(ctx: Context, avg: String): Drawable {
val d = GradientDrawable()
d.setColor(getAvgBgColor(ctx, avg))
d.setStroke(10, getAvgStrokeColor(ctx, avg))
d.cornerRadius = 8f
return d
}*/
data class AppVersion(
val versionName: String,
val versionNumber: Long,
@@ -217,28 +156,6 @@ class Util {
}
}
fun stringToSettingsData(s: String): SettingsData {
val settings = s.split("\n")
val auxSettingsData = SettingsData()
val useSvobodaMode = settings[0].split("#")
val useAmoledMode = settings[1].split("#")
val showRefreshButton = settings[2].split("#")
auxSettingsData.useSvobodaMode.id = SettingsId.Svoboda
auxSettingsData.useSvobodaMode.name = useSvobodaMode[1]
auxSettingsData.useSvobodaMode.checked.value = useSvobodaMode[2].toBoolean()
auxSettingsData.useAmoledMode.id = SettingsId.Amoled
auxSettingsData.useAmoledMode.name = useAmoledMode[1]
auxSettingsData.useAmoledMode.checked.value = useAmoledMode[2].toBoolean()
auxSettingsData.showRefreshButton.id = SettingsId.RefreshButton
auxSettingsData.showRefreshButton.name = showRefreshButton[1]
auxSettingsData.showRefreshButton.checked.value = showRefreshButton[2].toBoolean()
return auxSettingsData
}
fun getLectureId(date: String, subjectIndex: Int): Int {
val concat = "$date[$subjectIndex]"
val bytes = concat.toByteArray()