bugfixes
@@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetDropDown">
|
<component name="deploymentTargetDropDown">
|
||||||
<value>
|
<value>
|
||||||
<entry key="app">
|
<entry key="Run">
|
||||||
<State />
|
<State />
|
||||||
</entry>
|
</entry>
|
||||||
</value>
|
</value>
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.odweta.solen"
|
namespace = "com.odweta.solon"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.odweta.solen"
|
applicationId = "com.odweta.solon"
|
||||||
minSdk = 28
|
minSdk = 28
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0"
|
versionName = "0.5"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 21 KiB |
@@ -1,24 +0,0 @@
|
|||||||
package com.odweta.solen
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
|
|
||||||
class MainFragment : Fragment() {
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View? {
|
|
||||||
return inflater.inflate(R.layout.activity_main, container, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
MainActivity.setListener(requireContext())
|
|
||||||
MainActivity.callSetupMain(view, savedInstanceState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Paint
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
@@ -18,7 +17,6 @@ import android.view.ViewGroup
|
|||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -20,12 +20,6 @@ class Account(val username: String, val password: String, private val error: Int
|
|||||||
return Account("", "", 1)
|
return Account("", "", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearAccountFile() {
|
|
||||||
val file = File(Vars.fileDir, Vars.accountDataFilePath)
|
|
||||||
file.delete()
|
|
||||||
file.createNewFile()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun haveSaved(): Boolean {
|
fun haveSaved(): Boolean {
|
||||||
/* check if a file exists
|
/* check if a file exists
|
||||||
* no -> create it and return false
|
* no -> create it and return false
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
@@ -7,7 +7,6 @@ import android.graphics.drawable.GradientDrawable
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -24,15 +23,8 @@ import androidx.core.content.res.ResourcesCompat
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||||
import androidx.viewpager2.widget.ViewPager2
|
import androidx.viewpager2.widget.ViewPager2
|
||||||
import kotlinx.coroutines.coroutineScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.time.DayOfWeek
|
|
||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.LocalTime
|
import java.time.LocalTime
|
||||||
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
|
|
||||||
class Dialogs {
|
class Dialogs {
|
||||||
class LanguageChange(context: Context) : AlertDialog(context) {
|
class LanguageChange(context: Context) : AlertDialog(context) {
|
||||||
@@ -1,34 +1,23 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.FrameLayout
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.transition.AutoTransition
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
interface MainActivityListener {
|
interface MainActivityListener {
|
||||||
fun setupMain(view: View, savedInstanceState: Bundle?)
|
|
||||||
fun onSignIn(view: View, wantDelete: Boolean, dialog: Dialog?)
|
fun onSignIn(view: View, wantDelete: Boolean, dialog: Dialog?)
|
||||||
|
|
||||||
|
fun launchPhase1()
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity(), MainActivityListener {
|
class MainActivity : AppCompatActivity(), MainActivityListener {
|
||||||
@@ -36,10 +25,6 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
private var toastShowing: Boolean = false
|
private var toastShowing: Boolean = false
|
||||||
private var toastShown: Boolean = false
|
private var toastShown: Boolean = false
|
||||||
private var toast2Shown: Boolean = false
|
private var toast2Shown: Boolean = false
|
||||||
private var done: Boolean = false
|
|
||||||
private var role: String = " - Student"
|
|
||||||
private lateinit var navbar: BottomNavigationView
|
|
||||||
private lateinit var toolbar: TextView
|
|
||||||
|
|
||||||
// @section COMPANION
|
// @section COMPANION
|
||||||
companion object {
|
companion object {
|
||||||
@@ -51,14 +36,14 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun callSetupMain(view: View, savedInstanceState: Bundle?) {
|
|
||||||
intfc?.setupMain(view, savedInstanceState)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun callOnSignIn(view: View, wantDelete: Boolean, dialog: Dialog?) {
|
fun callOnSignIn(view: View, wantDelete: Boolean, dialog: Dialog?) {
|
||||||
intfc?.onSignIn(view, wantDelete, dialog)
|
intfc?.onSignIn(view, wantDelete, dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun callLaunchPhase1() {
|
||||||
|
intfc?.launchPhase1()
|
||||||
|
}
|
||||||
|
|
||||||
fun quit(context: Context) {
|
fun quit(context: Context) {
|
||||||
// Create an Intent to launch the home screen
|
// Create an Intent to launch the home screen
|
||||||
val homeIntent = Intent(Intent.ACTION_MAIN)
|
val homeIntent = Intent(Intent.ACTION_MAIN)
|
||||||
@@ -91,86 +76,6 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupMain(view: View, savedInstanceState: Bundle?) {
|
|
||||||
toolbar = view.findViewById(R.id.toolbar)
|
|
||||||
|
|
||||||
if (
|
|
||||||
Util.fileToString(Vars.userDataFilePath) != "" &&
|
|
||||||
JSONObject(Util.fileToString(Vars.userDataFilePath)).has("fullName")
|
|
||||||
) {
|
|
||||||
toolbar.text =
|
|
||||||
JSONObject(Util.fileToString(Vars.userDataFilePath)).getString("fullName") +
|
|
||||||
role
|
|
||||||
} else {
|
|
||||||
toolbar.text = "Přihlašte se, prosím."
|
|
||||||
}
|
|
||||||
|
|
||||||
navbar = findViewById(R.id.bottomNav)
|
|
||||||
|
|
||||||
var frag = supportFragmentManager.findFragmentById(R.id.fragmentContainer)
|
|
||||||
|
|
||||||
if (!Vars.resetNav) {
|
|
||||||
if (frag == null || frag is CalWeekFragment) {
|
|
||||||
frag = CalWeekFragment()
|
|
||||||
navbar.selectedItemId = R.id.nav_timetable
|
|
||||||
}
|
|
||||||
if (frag is MarksFragment) {
|
|
||||||
frag = MarksFragment()
|
|
||||||
navbar.selectedItemId = R.id.nav_marks
|
|
||||||
}
|
|
||||||
if (frag is MenuFragment) {
|
|
||||||
frag = MenuFragment()
|
|
||||||
navbar.selectedItemId = R.id.nav_menu
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
frag = CalWeekFragment()
|
|
||||||
navbar.selectedItemId = R.id.nav_timetable
|
|
||||||
Vars.resetNav = false
|
|
||||||
}
|
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.replace(R.id.fragmentContainer, frag)
|
|
||||||
.commit()
|
|
||||||
|
|
||||||
navbar.setOnItemSelectedListener {
|
|
||||||
val ft = supportFragmentManager.beginTransaction()
|
|
||||||
|
|
||||||
when (it.itemId) {
|
|
||||||
R.id.nav_timetable -> {
|
|
||||||
ft.setCustomAnimations(
|
|
||||||
R.anim.slide_up,
|
|
||||||
R.anim.slide_down,
|
|
||||||
)
|
|
||||||
ft.replace(R.id.fragmentContainer, CalWeekFragment())
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.nav_marks -> {
|
|
||||||
ft.setCustomAnimations(
|
|
||||||
R.anim.slide_up,
|
|
||||||
R.anim.slide_down,
|
|
||||||
)
|
|
||||||
ft.replace(R.id.fragmentContainer, MarksFragment())
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.nav_menu -> {
|
|
||||||
ft.setCustomAnimations(
|
|
||||||
R.anim.slide_up,
|
|
||||||
R.anim.slide_down,
|
|
||||||
)
|
|
||||||
ft.replace(R.id.fragmentContainer, MenuFragment())
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> return@setOnItemSelectedListener false
|
|
||||||
}
|
|
||||||
|
|
||||||
ft.commit()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
setOnInternetAvailListener()
|
|
||||||
done = true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -219,14 +124,13 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
btn.text = "Přihlásit se"
|
btn.text = "Přihlásit se"
|
||||||
}
|
}
|
||||||
|
|
||||||
Account.save(acc)
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val valid = Account.isValid(acc)
|
val valid = Account.isValid(acc)
|
||||||
|
|
||||||
checked = true
|
checked = true
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
Account.save(acc)
|
||||||
if (!wantDelete) {
|
if (!wantDelete) {
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
}
|
}
|
||||||
@@ -244,58 +148,6 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setOnInternetAvailListener() {
|
|
||||||
lifecycleScope.launch {
|
|
||||||
while (true) {
|
|
||||||
if (Util.internetAvail(applicationContext) && !Vars.internetAvail) {
|
|
||||||
Vars.internetAvail = Util.internetAvail(applicationContext)
|
|
||||||
withContext(Dispatchers.Main) {
|
|
||||||
fetchNewData()
|
|
||||||
}
|
|
||||||
} else if (!Vars.internetAvail) {
|
|
||||||
Vars.internetAvail = Util.internetAvail(applicationContext)
|
|
||||||
toolbar.text = "Bez připojení k internetu."
|
|
||||||
} else {
|
|
||||||
Vars.internetAvail = Util.internetAvail(applicationContext)
|
|
||||||
}
|
|
||||||
delay(1000) // Check for internet availability every second
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fetchNewData() {
|
|
||||||
lifecycleScope.launch {
|
|
||||||
done = false
|
|
||||||
while (!done) {
|
|
||||||
toolbar.text = "Načítání nových dat"
|
|
||||||
delay(300)
|
|
||||||
toolbar.text = "Načítání nových dat."
|
|
||||||
delay(300)
|
|
||||||
toolbar.text = "Načítání nových dat.."
|
|
||||||
delay(300)
|
|
||||||
toolbar.text = "Načítání nových dat..."
|
|
||||||
delay(300)
|
|
||||||
}
|
|
||||||
|
|
||||||
role = if (Parsing.userIsParent()) {
|
|
||||||
" - Rodič"
|
|
||||||
} else {
|
|
||||||
" - Student"
|
|
||||||
}
|
|
||||||
|
|
||||||
toolbar.text =
|
|
||||||
JSONObject(Util.fileToString(Vars.userDataFilePath)).getString("fullName") +
|
|
||||||
role
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
|
||||||
launchPhase1()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @section LAUNCH
|
// @section LAUNCH
|
||||||
private fun launch() {
|
private fun launch() {
|
||||||
@@ -321,7 +173,7 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchPhase1() {
|
override fun launchPhase1() {
|
||||||
val toast: Toast = Toast.makeText(
|
val toast: Toast = Toast.makeText(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
"Nelze načíst data, zkuste se připojit k internetu.",
|
"Nelze načíst data, zkuste se připojit k internetu.",
|
||||||
@@ -369,18 +221,12 @@ class MainActivity : AppCompatActivity(), MainActivityListener {
|
|||||||
week = Parsing.parseTimeTableJSON(timeTableJSON)
|
week = Parsing.parseTimeTableJSON(timeTableJSON)
|
||||||
|
|
||||||
// fetch and parse marks
|
// fetch and parse marks
|
||||||
lifecycleScope.launch {
|
|
||||||
Vars.marksJSON = """{"message": "Zatím žádné známky, zkuste aktualizovat data."}"""
|
|
||||||
|
|
||||||
Vars.marksJSON = Network.getMarksJSON()
|
Vars.marksJSON = Network.getMarksJSON()
|
||||||
|
|
||||||
//Log.d("MARKS_JSON", JSONObject(Vars.marksJSON).getJSONArray("subjects").toString())
|
|
||||||
|
|
||||||
Vars.marksAvailOffline =
|
Vars.marksAvailOffline =
|
||||||
Util.saveStringToFile(Vars.marksFilePath, Vars.marksJSON)
|
Util.saveStringToFile(Vars.marksFilePath, Vars.marksJSON)
|
||||||
|
|
||||||
Vars.marks = Parsing.parseMarksJSON(Vars.marksJSON)
|
Vars.marks = Parsing.parseMarksJSON(Vars.marksJSON)
|
||||||
}
|
|
||||||
|
|
||||||
// continue to launch phase 2
|
// continue to launch phase 2
|
||||||
launchPhase2()
|
launchPhase2()
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
package com.odweta.solon
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
import org.json.JSONObject
|
||||||
|
|
||||||
|
class MainFragment : Fragment() {
|
||||||
|
private var done: Boolean = false
|
||||||
|
private var role: String = " - Student"
|
||||||
|
private lateinit var navbar: BottomNavigationView
|
||||||
|
private lateinit var toolbar: TextView
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
return inflater.inflate(R.layout.activity_main, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
MainActivity.setListener(requireContext())
|
||||||
|
setup(view)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setup(view: View) {
|
||||||
|
toolbar = view.findViewById(R.id.toolbar)
|
||||||
|
|
||||||
|
if (
|
||||||
|
Util.fileToString(Vars.userDataFilePath) != "" &&
|
||||||
|
JSONObject(Util.fileToString(Vars.userDataFilePath)).has("fullName")
|
||||||
|
) {
|
||||||
|
toolbar.text =
|
||||||
|
JSONObject(Util.fileToString(Vars.userDataFilePath)).getString("fullName") +
|
||||||
|
role
|
||||||
|
} else {
|
||||||
|
toolbar.text = "Přihlašte se, prosím."
|
||||||
|
}
|
||||||
|
|
||||||
|
navbar = view.findViewById(R.id.bottomNav)
|
||||||
|
|
||||||
|
var frag = requireFragmentManager().findFragmentById(R.id.fragmentContainer)
|
||||||
|
|
||||||
|
if (!Vars.resetNav) {
|
||||||
|
if (frag == null || frag is CalWeekFragment) {
|
||||||
|
frag = CalWeekFragment()
|
||||||
|
navbar.selectedItemId = R.id.nav_timetable
|
||||||
|
}
|
||||||
|
if (frag is MarksFragment) {
|
||||||
|
frag = MarksFragment()
|
||||||
|
navbar.selectedItemId = R.id.nav_marks
|
||||||
|
}
|
||||||
|
if (frag is MenuFragment) {
|
||||||
|
frag = MenuFragment()
|
||||||
|
navbar.selectedItemId = R.id.nav_menu
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
frag = CalWeekFragment()
|
||||||
|
navbar.selectedItemId = R.id.nav_timetable
|
||||||
|
Vars.resetNav = false
|
||||||
|
}
|
||||||
|
|
||||||
|
requireFragmentManager().beginTransaction()
|
||||||
|
.replace(R.id.fragmentContainer, frag)
|
||||||
|
.commit()
|
||||||
|
|
||||||
|
navbar.setOnItemSelectedListener {
|
||||||
|
val ft = requireFragmentManager().beginTransaction()
|
||||||
|
|
||||||
|
when (it.itemId) {
|
||||||
|
R.id.nav_timetable -> {
|
||||||
|
ft.setCustomAnimations(
|
||||||
|
R.anim.slide_up,
|
||||||
|
R.anim.slide_down,
|
||||||
|
)
|
||||||
|
ft.replace(R.id.fragmentContainer, CalWeekFragment())
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.nav_marks -> {
|
||||||
|
ft.setCustomAnimations(
|
||||||
|
R.anim.slide_up,
|
||||||
|
R.anim.slide_down,
|
||||||
|
)
|
||||||
|
ft.replace(R.id.fragmentContainer, MarksFragment())
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.nav_menu -> {
|
||||||
|
ft.setCustomAnimations(
|
||||||
|
R.anim.slide_up,
|
||||||
|
R.anim.slide_down,
|
||||||
|
)
|
||||||
|
ft.replace(R.id.fragmentContainer, MenuFragment())
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> return@setOnItemSelectedListener false
|
||||||
|
}
|
||||||
|
|
||||||
|
ft.commit()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
setOnInternetAvailListener()
|
||||||
|
done = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setOnInternetAvailListener() {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
while (true) {
|
||||||
|
if (Util.internetAvail(requireContext()) && !Vars.internetAvail) {
|
||||||
|
Vars.internetAvail = Util.internetAvail(requireContext())
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
fetchNewData()
|
||||||
|
}
|
||||||
|
} else if (!Vars.internetAvail) {
|
||||||
|
Vars.internetAvail = Util.internetAvail(requireContext())
|
||||||
|
toolbar.text = "Bez připojení k internetu."
|
||||||
|
} else {
|
||||||
|
Vars.internetAvail = Util.internetAvail(requireContext())
|
||||||
|
}
|
||||||
|
delay(1000) // Check for internet availability every second
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fetchNewData() {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
done = false
|
||||||
|
while (!done) {
|
||||||
|
toolbar.text = "Načítání nových dat"
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat."
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat.."
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat..."
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat.."
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat."
|
||||||
|
delay(300)
|
||||||
|
toolbar.text = "Načítání nových dat"
|
||||||
|
delay(300)
|
||||||
|
}
|
||||||
|
|
||||||
|
role = if (Parsing.userIsParent()) {
|
||||||
|
" - Rodič"
|
||||||
|
} else {
|
||||||
|
" - Student"
|
||||||
|
}
|
||||||
|
|
||||||
|
toolbar.text =
|
||||||
|
JSONObject(Util.fileToString(Vars.userDataFilePath)).getString("fullName") +
|
||||||
|
role
|
||||||
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
MainActivity.callLaunchPhase1()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
@@ -25,10 +25,6 @@ class MarksFragment : Fragment() {
|
|||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View? {
|
): View? {
|
||||||
val view = inflater.inflate(R.layout.activity_marks, container, false)
|
|
||||||
|
|
||||||
val root = view.findViewById<LinearLayout>(R.id.root)
|
|
||||||
|
|
||||||
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.marksAvailOffline = Util.saveStringToFile(Vars.marksFilePath, Vars.marksJSON)
|
||||||
@@ -41,6 +37,24 @@ class MarksFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
Vars.marks.keys.contains("-") &&
|
||||||
|
Vars.marks.keys.size == 1
|
||||||
|
) {
|
||||||
|
val view = inflater.inflate(R.layout.activity_no_marks, container, false)
|
||||||
|
|
||||||
|
val root = view.findViewById<LinearLayout>(R.id.no_mark_container)
|
||||||
|
|
||||||
|
for (subject in Vars.marks.keys) {
|
||||||
|
root.addView(Vars.marks[subject]?.let { createMarkView(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
return view
|
||||||
|
} else {
|
||||||
|
val view = inflater.inflate(R.layout.activity_marks, container, false)
|
||||||
|
|
||||||
|
val root = view.findViewById<LinearLayout>(R.id.root)
|
||||||
|
|
||||||
root.addView(createSpace())
|
root.addView(createSpace())
|
||||||
for (subject in Vars.marks.keys) {
|
for (subject in Vars.marks.keys) {
|
||||||
root.addView(Vars.marks[subject]?.let { createMarkView(it) })
|
root.addView(Vars.marks[subject]?.let { createMarkView(it) })
|
||||||
@@ -49,6 +63,7 @@ class MarksFragment : Fragment() {
|
|||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun createSpace(): Space {
|
private fun createSpace(): Space {
|
||||||
val space = Space(requireContext())
|
val space = Space(requireContext())
|
||||||
@@ -155,6 +170,25 @@ class MarksFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
markRoot.background = markDrawable
|
markRoot.background = markDrawable
|
||||||
|
|
||||||
|
if (marks[0].subject == "Zatím žádné známky.") {
|
||||||
|
markRoot.gravity = Gravity.CENTER
|
||||||
|
val tv = TextView(requireContext())
|
||||||
|
tv.text = "Zatím žádné známky."
|
||||||
|
tv.textSize = 30f
|
||||||
|
tv.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
requireContext(),
|
||||||
|
R.color.white
|
||||||
|
)
|
||||||
|
)
|
||||||
|
tv.gravity = Gravity.CENTER
|
||||||
|
tv.setTypeface(customFont, Typeface.BOLD)
|
||||||
|
|
||||||
|
markRoot.addView(tv)
|
||||||
|
|
||||||
|
return markRoot
|
||||||
|
}
|
||||||
|
|
||||||
val avgDrawable = GradientDrawable()
|
val avgDrawable = GradientDrawable()
|
||||||
avgDrawable.shape = GradientDrawable.RECTANGLE
|
avgDrawable.shape = GradientDrawable.RECTANGLE
|
||||||
avgDrawable.cornerRadius = resources.getDimension(R.dimen.corner_radius)
|
avgDrawable.cornerRadius = resources.getDimension(R.dimen.corner_radius)
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.app.Dialog
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.DialogFragment
|
|
||||||
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.view.Window
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ImageView
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
@@ -239,7 +238,9 @@ class Parsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun parseMarksJSON(jsonString: String): MutableMap<String, MutableList<Mark>> {
|
fun parseMarksJSON(jsonString: String): MutableMap<String, MutableList<Mark>> {
|
||||||
if (!JSONObject(jsonString).has("marks")) {
|
// no marks
|
||||||
|
val json = JSONObject(jsonString)
|
||||||
|
if (json.has("marks") && json.getJSONArray("marks").length() == 0) {
|
||||||
val noMarks = mutableMapOf<String, MutableList<Mark>>()
|
val noMarks = mutableMapOf<String, MutableList<Mark>>()
|
||||||
val list = mutableListOf<Mark>()
|
val list = mutableListOf<Mark>()
|
||||||
list.add(Mark().none())
|
list.add(Mark().none())
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.GestureDetector.SimpleOnGestureListener
|
import android.view.GestureDetector.SimpleOnGestureListener
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
@@ -12,14 +11,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.LinearLayout
|
|
||||||
import android.widget.ScrollView
|
import android.widget.ScrollView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
class SettingsFragment : DialogFragment() {
|
class SettingsFragment : DialogFragment() {
|
||||||
private lateinit var scrollView: ScrollView
|
private lateinit var scrollView: ScrollView
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.Gravity
|
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import android.view.WindowManager
|
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
class SignInFragment : DialogFragment() {
|
class SignInFragment : DialogFragment() {
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
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 android.widget.ImageView
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
|
|
||||||
class SignInMainFragment : Fragment() {
|
class SignInMainFragment : Fragment() {
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
@@ -6,7 +6,6 @@ import android.net.ConnectivityManager
|
|||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import org.json.JSONObject
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.odweta.solen
|
package com.odweta.solon
|
||||||
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black"
|
||||||
|
android:id="@+id/no_mark_root">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/no_mark_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:foregroundGravity="center" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@mipmap/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 810 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#000000</color>
|
||||||
|
</resources>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
<string name="app_name">Solen</string>
|
<string name="app_name">Solon</string>
|
||||||
|
|
||||||
<string name="menu_cal_week">Calendar for this week</string>
|
<string name="menu_cal_week">Calendar for this week</string>
|
||||||
<string name="kolaonline_enhanced">ŠkolaOnLine Enhanced</string>
|
<string name="kolaonline_enhanced">ŠkolaOnLine Enhanced</string>
|
||||||
|
|||||||