forked from github/wulkanowy-mirror
Merge branch 'release/0.25.1'
This commit is contained in:
commit
e0c802bf67
@ -18,8 +18,8 @@ android {
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 30
|
||||
versionCode 82
|
||||
versionName "0.25.0"
|
||||
versionCode 83
|
||||
versionName "0.25.1"
|
||||
multiDexEnabled true
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
@ -142,7 +142,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:0.25.0"
|
||||
implementation "io.github.wulkanowy:sdk:0.25.1"
|
||||
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
||||
|
||||
|
2142
app/schemas/io.github.wulkanowy.data.db.AppDatabase/33.json
Normal file
2142
app/schemas/io.github.wulkanowy.data.db.AppDatabase/33.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -34,5 +34,9 @@
|
||||
{
|
||||
"displayName": "Mateusz Idziejczak",
|
||||
"githubUsername": "Luncenok"
|
||||
},
|
||||
{
|
||||
"displayName": "MRmlik12",
|
||||
"githubUsername": "MRmlik12"
|
||||
}
|
||||
]
|
||||
|
@ -86,7 +86,11 @@ class WulkanowyApp : Application(), Configuration.Provider {
|
||||
|
||||
private fun fixWebViewLocale() {
|
||||
//https://stackoverflow.com/questions/40398528/android-webview-language-changes-abruptly-on-android-7-0-and-above
|
||||
WebView(this).destroy()
|
||||
try {
|
||||
WebView(this).destroy()
|
||||
} catch (e: Exception) {
|
||||
//Ignore exceptions
|
||||
}
|
||||
}
|
||||
|
||||
override fun getWorkManagerConfiguration() = Configuration.Builder()
|
||||
|
@ -84,6 +84,7 @@ import io.github.wulkanowy.data.db.migrations.Migration3
|
||||
import io.github.wulkanowy.data.db.migrations.Migration30
|
||||
import io.github.wulkanowy.data.db.migrations.Migration31
|
||||
import io.github.wulkanowy.data.db.migrations.Migration32
|
||||
import io.github.wulkanowy.data.db.migrations.Migration33
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
import io.github.wulkanowy.data.db.migrations.Migration5
|
||||
import io.github.wulkanowy.data.db.migrations.Migration6
|
||||
@ -129,7 +130,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 32
|
||||
const val VERSION_SCHEMA = 33
|
||||
|
||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider): Array<Migration> {
|
||||
return arrayOf(
|
||||
@ -163,7 +164,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration29(),
|
||||
Migration30(),
|
||||
Migration31(),
|
||||
Migration32()
|
||||
Migration32(),
|
||||
Migration33()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -59,10 +59,10 @@ data class StudentInfo(
|
||||
val email: String,
|
||||
|
||||
@Embedded(prefix = "first_guardian_")
|
||||
val firstGuardian: StudentGuardian,
|
||||
val firstGuardian: StudentGuardian?,
|
||||
|
||||
@Embedded(prefix = "second_guardian_")
|
||||
val secondGuardian: StudentGuardian
|
||||
val secondGuardian: StudentGuardian?
|
||||
|
||||
) : Serializable {
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration33 : Migration(32, 33) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("DROP TABLE IF EXISTS StudentInfo")
|
||||
|
||||
database.execSQL(
|
||||
"""CREATE TABLE IF NOT EXISTS StudentInfo (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
student_id INTEGER NOT NULL,
|
||||
full_name TEXT NOT NULL,
|
||||
first_name TEXT NOT NULL,
|
||||
second_name TEXT NOT NULL,
|
||||
surname TEXT NOT NULL,
|
||||
birth_date INTEGER NOT NULL,
|
||||
birth_place TEXT NOT NULL,
|
||||
gender TEXT NOT NULL,
|
||||
has_polish_citizenship INTEGER NOT NULL,
|
||||
family_name TEXT NOT NULL,
|
||||
parents_names TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
registered_address TEXT NOT NULL,
|
||||
correspondence_address TEXT NOT NULL,
|
||||
phone_number TEXT NOT NULL,
|
||||
cell_phone_number TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
first_guardian_full_name TEXT,
|
||||
first_guardian_kinship TEXT,
|
||||
first_guardian_address TEXT,
|
||||
first_guardian_phones TEXT,
|
||||
first_guardian_email TEXT,
|
||||
second_guardian_full_name TEXT,
|
||||
second_guardian_kinship TEXT,
|
||||
second_guardian_address TEXT,
|
||||
second_guardian_phones TEXT,
|
||||
second_guardian_email TEXT)
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ fun SdkStudentInfo.mapToEntity(semester: Semester) = StudentInfo(
|
||||
phoneNumber = phoneNumber,
|
||||
cellPhoneNumber = phoneNumber,
|
||||
email = email,
|
||||
firstGuardian = guardians[0].mapToEntity(),
|
||||
secondGuardian = guardians[1].mapToEntity()
|
||||
firstGuardian = guardianFirst?.mapToEntity(),
|
||||
secondGuardian = guardianSecond?.mapToEntity()
|
||||
)
|
||||
|
||||
fun SdkStudentGuardian.mapToEntity() = StudentGuardian(
|
||||
|
@ -5,14 +5,21 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import io.github.wulkanowy.data.db.entities.Grade
|
||||
import io.github.wulkanowy.data.db.entities.GradeSummary
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.databinding.ItemGradeSummaryBinding
|
||||
import io.github.wulkanowy.databinding.ScrollableHeaderGradeSummaryBinding
|
||||
import io.github.wulkanowy.sdk.Sdk
|
||||
import io.github.wulkanowy.utils.calcAverage
|
||||
import io.github.wulkanowy.utils.changeModifier
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
class GradeSummaryAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
class GradeSummaryAdapter @Inject constructor(
|
||||
private val preferencesRepository: PreferencesRepository
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
private enum class ViewType(val id: Int) {
|
||||
HEADER(1),
|
||||
@ -49,7 +56,7 @@ class GradeSummaryAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerV
|
||||
if (items.isEmpty()) return
|
||||
|
||||
with(binding) {
|
||||
gradeSummaryScrollableHeaderFinal.text = formatAverage(items.calcAverage())
|
||||
gradeSummaryScrollableHeaderFinal.text = formatAverage(items.calcAverage(preferencesRepository.gradePlusModifier, preferencesRepository.gradeMinusModifier))
|
||||
gradeSummaryScrollableHeaderCalculated.text = formatAverage(items
|
||||
.filter { value -> value.average != 0.0 }
|
||||
.map { values -> values.average }
|
||||
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.StudentGuardian
|
||||
import io.github.wulkanowy.data.db.entities.StudentInfo
|
||||
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
||||
import io.github.wulkanowy.data.enums.Gender
|
||||
@ -75,7 +76,11 @@ class StudentInfoFragment :
|
||||
with(binding) {
|
||||
studentInfoSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
studentInfoSwipe.setColorSchemeColors(requireContext().getThemeAttrColor(R.attr.colorPrimary))
|
||||
studentInfoSwipe.setProgressBackgroundColorSchemeColor(requireContext().getThemeAttrColor(R.attr.colorSwipeRefresh))
|
||||
studentInfoSwipe.setProgressBackgroundColorSchemeColor(
|
||||
requireContext().getThemeAttrColor(
|
||||
R.attr.colorSwipeRefresh
|
||||
)
|
||||
)
|
||||
studentInfoErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
studentInfoErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
@ -135,11 +140,14 @@ class StudentInfoFragment :
|
||||
@SuppressLint("DefaultLocale")
|
||||
override fun showFamilyTypeData(studentInfo: StudentInfo) {
|
||||
updateData(
|
||||
listOf(
|
||||
studentInfo.firstGuardian.kinship.capitalize() to studentInfo.firstGuardian.fullName,
|
||||
studentInfo.secondGuardian.kinship.capitalize() to studentInfo.secondGuardian.fullName
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
listOfNotNull(
|
||||
studentInfo.firstGuardian?.let { it.kinship.capitalize() to it.fullName },
|
||||
studentInfo.secondGuardian?.let { it.kinship.capitalize() to it.fullName },
|
||||
).map { (title, value) ->
|
||||
val updatedValue = value.ifBlank { getString(R.string.all_no_data) }
|
||||
val updatedTitle = title.ifBlank { getString(R.string.all_no_data) }
|
||||
|
||||
updatedTitle to updatedValue
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -156,28 +164,28 @@ class StudentInfoFragment :
|
||||
)
|
||||
}
|
||||
|
||||
override fun showFirstGuardianTypeData(studentInfo: StudentInfo) {
|
||||
override fun showFirstGuardianTypeData(studentGuardian: StudentGuardian) {
|
||||
updateData(
|
||||
listOf(
|
||||
getString(R.string.student_info_full_name) to studentInfo.firstGuardian.fullName,
|
||||
getString(R.string.student_info_kinship) to studentInfo.firstGuardian.kinship,
|
||||
getString(R.string.student_info_guardian_address) to studentInfo.firstGuardian.address,
|
||||
getString(R.string.student_info_phones) to studentInfo.firstGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentInfo.firstGuardian.email
|
||||
getString(R.string.student_info_full_name) to studentGuardian.fullName,
|
||||
getString(R.string.student_info_kinship) to studentGuardian.kinship,
|
||||
getString(R.string.student_info_guardian_address) to studentGuardian.address,
|
||||
getString(R.string.student_info_phones) to studentGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentGuardian.email
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun showSecondGuardianTypeData(studentInfo: StudentInfo) {
|
||||
override fun showSecondGuardianTypeData(studentGuardian: StudentGuardian) {
|
||||
updateData(
|
||||
listOf(
|
||||
getString(R.string.student_info_full_name) to studentInfo.secondGuardian.fullName,
|
||||
getString(R.string.student_info_kinship) to studentInfo.secondGuardian.kinship,
|
||||
getString(R.string.student_info_guardian_address) to studentInfo.secondGuardian.address,
|
||||
getString(R.string.student_info_phones) to studentInfo.secondGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentInfo.secondGuardian.email
|
||||
getString(R.string.student_info_full_name) to studentGuardian.fullName,
|
||||
getString(R.string.student_info_kinship) to studentGuardian.kinship,
|
||||
getString(R.string.student_info_guardian_address) to studentGuardian.address,
|
||||
getString(R.string.student_info_phones) to studentGuardian.phones,
|
||||
getString(R.string.student_info_email) to studentGuardian.email
|
||||
).map {
|
||||
if (it.second.isBlank()) it.copy(second = getString(R.string.all_no_data)) else it
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class StudentInfoPresenter @Inject constructor(
|
||||
when (it.status) {
|
||||
Status.LOADING -> Timber.i("Loading student info $infoType started")
|
||||
Status.SUCCESS -> {
|
||||
if (it.data != null) {
|
||||
if (it.data != null && !(infoType == StudentInfoView.Type.FAMILY && it.data.firstGuardian == null && it.data.secondGuardian == null)) {
|
||||
Timber.i("Loading student info $infoType result: Success")
|
||||
showCorrectData(it.data)
|
||||
view?.run {
|
||||
@ -94,7 +94,7 @@ class StudentInfoPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_item", "type" to "student_info")
|
||||
} else {
|
||||
Timber.i("Loading student info $infoType result: No school info found")
|
||||
Timber.i("Loading student info $infoType result: No student or family info found")
|
||||
view?.run {
|
||||
showContent(!isViewEmpty)
|
||||
showEmpty(isViewEmpty)
|
||||
@ -122,8 +122,8 @@ class StudentInfoPresenter @Inject constructor(
|
||||
StudentInfoView.Type.CONTACT -> view?.showContactTypeData(studentInfo)
|
||||
StudentInfoView.Type.ADDRESS -> view?.showAddressTypeData(studentInfo)
|
||||
StudentInfoView.Type.FAMILY -> view?.showFamilyTypeData(studentInfo)
|
||||
StudentInfoView.Type.SECOND_GUARDIAN -> view?.showSecondGuardianTypeData(studentInfo)
|
||||
StudentInfoView.Type.FIRST_GUARDIAN -> view?.showFirstGuardianTypeData(studentInfo)
|
||||
StudentInfoView.Type.SECOND_GUARDIAN -> view?.showSecondGuardianTypeData(studentInfo.secondGuardian!!)
|
||||
StudentInfoView.Type.FIRST_GUARDIAN -> view?.showFirstGuardianTypeData(studentInfo.firstGuardian!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.wulkanowy.ui.modules.studentinfo
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.StudentGuardian
|
||||
import io.github.wulkanowy.data.db.entities.StudentInfo
|
||||
import io.github.wulkanowy.data.db.entities.StudentWithSemesters
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
@ -24,9 +25,9 @@ interface StudentInfoView : BaseView {
|
||||
|
||||
fun showFamilyTypeData(studentInfo: StudentInfo)
|
||||
|
||||
fun showFirstGuardianTypeData(studentInfo: StudentInfo)
|
||||
fun showFirstGuardianTypeData(studentGuardian: StudentGuardian)
|
||||
|
||||
fun showSecondGuardianTypeData(studentInfo: StudentInfo)
|
||||
fun showSecondGuardianTypeData(studentGuardian: StudentGuardian)
|
||||
|
||||
fun openStudentInfoView(infoType: Type, studentWithSemesters: StudentWithSemesters)
|
||||
|
||||
|
@ -16,10 +16,20 @@ fun List<Grade>.calcAverage(): Double {
|
||||
}
|
||||
|
||||
@JvmName("calcSummaryAverage")
|
||||
fun List<GradeSummary>.calcAverage() = asSequence()
|
||||
fun List<GradeSummary>.calcAverage(plusModifier: Double, minusModifier: Double) = asSequence()
|
||||
.mapNotNull {
|
||||
if (it.finalGrade.matches("[0-6]".toRegex())) {
|
||||
it.finalGrade.toDouble()
|
||||
if (it.finalGrade.matches("[0-6][+-]?".toRegex())) {
|
||||
when {
|
||||
it.finalGrade.endsWith('+') -> {
|
||||
it.finalGrade.removeSuffix("+").toDouble() + plusModifier
|
||||
}
|
||||
it.finalGrade.endsWith('-') -> {
|
||||
it.finalGrade.removeSuffix("-").toDouble() - minusModifier
|
||||
}
|
||||
else -> {
|
||||
it.finalGrade.toDouble()
|
||||
}
|
||||
}
|
||||
} else null
|
||||
}
|
||||
.average()
|
||||
|
@ -1,6 +1,7 @@
|
||||
Wersja 0.25.0
|
||||
Wersja 0.25.1
|
||||
- naprawiliśmy przełączanie semestrów przy przełączaniu uczniów
|
||||
- naprawiliśmy błąd przy odświeżaniu ocen gdy włączony był inny niż domyślny tryb liczenia średniej
|
||||
- do średniej końcowej wliczają się teraz również oceny z plusami i minusami
|
||||
- dodaliśmy menadżer kont, gdzie można podejrzeć informacje o uczniu oraz zmienić pseudonim
|
||||
- zmieniliśmy ikonę planu lekcji oraz kolor animacji odświeżania w ciemnym motywie
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
android:padding="10dp"
|
||||
android:visibility="gone"
|
||||
tools:ignore="UseCompoundDrawables"
|
||||
tools:visibility="gone">
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
|
@ -393,7 +393,7 @@
|
||||
|
||||
|
||||
<!--Student info-->
|
||||
<string name="student_info_empty">No info about student</string>
|
||||
<string name="student_info_empty">No info about student or student family</string>
|
||||
<string name="student_info_first_name">Name</string>
|
||||
<string name="student_info_second_name">Second name</string>
|
||||
<string name="student_info_gender">Gender</string>
|
||||
|
@ -33,12 +33,13 @@ class GradeExtensionTest {
|
||||
|
||||
@Test
|
||||
fun calcSummaryAverage() {
|
||||
assertEquals(2.5, listOf(
|
||||
createGradeSummary("5"),
|
||||
createGradeSummary("-5"),
|
||||
assertEquals(3.5, listOf(
|
||||
createGradeSummary("4"),
|
||||
createGradeSummary("5+"),
|
||||
createGradeSummary("5-"),
|
||||
createGradeSummary("test"),
|
||||
createGradeSummary("0")
|
||||
).calcAverage(), 0.005)
|
||||
).calcAverage(0.5, 0.5), 0.005)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user