mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 12:56:45 -06:00
[API] Fix archiving compatibility for older app versions.
This commit is contained in:
parent
6c6bc89f57
commit
a02033d0f3
@ -617,6 +617,16 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
swipeRefreshLayout.isRefreshing = false
|
swipeRefreshLayout.isRefreshing = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (app.profile.shouldArchive()) {
|
||||||
|
MaterialAlertDialogBuilder(this)
|
||||||
|
.setTitle(R.string.profile_archiving_title)
|
||||||
|
.setMessage(
|
||||||
|
R.string.profile_archiving_format,
|
||||||
|
app.profile.dateYearEnd.formattedString
|
||||||
|
)
|
||||||
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
if (app.profile.isBeforeYear()) {
|
if (app.profile.isBeforeYear()) {
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(R.string.profile_year_not_started_title)
|
.setTitle(R.string.profile_year_not_started_title)
|
||||||
@ -629,21 +639,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
|||||||
swipeRefreshLayout.isRefreshing = false
|
swipeRefreshLayout.isRefreshing = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// vulcan hotfix
|
|
||||||
if (app.profile.dateYearEnd.month > 6) {
|
|
||||||
app.profile.dateYearEnd.month = 6
|
|
||||||
app.profile.dateYearEnd.day = 30
|
|
||||||
}
|
|
||||||
if (app.profile.shouldArchive()) {
|
|
||||||
MaterialAlertDialogBuilder(this)
|
|
||||||
.setTitle(R.string.profile_archiving_title)
|
|
||||||
.setMessage(
|
|
||||||
R.string.profile_archiving_format,
|
|
||||||
app.profile.dateYearEnd.formattedString
|
|
||||||
)
|
|
||||||
.setPositiveButton(R.string.ok, null)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
swipeRefreshLayout.isRefreshing = true
|
swipeRefreshLayout.isRefreshing = true
|
||||||
Toast.makeText(this, fragmentToSyncName(navTargetId), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, fragmentToSyncName(navTargetId), Toast.LENGTH_SHORT).show()
|
||||||
val fragmentParam = when (navTargetId) {
|
val fragmentParam = when (navTargetId) {
|
||||||
|
@ -73,11 +73,6 @@ open class EdziennikTask(override val profileId: Int, val request: Any) : IApiTa
|
|||||||
|
|
||||||
internal fun run(app: App, taskCallback: EdziennikCallback) {
|
internal fun run(app: App, taskCallback: EdziennikCallback) {
|
||||||
profile?.let { profile ->
|
profile?.let { profile ->
|
||||||
// vulcan hotfix
|
|
||||||
if (profile.dateYearEnd.month > 6) {
|
|
||||||
profile.dateYearEnd.month = 6
|
|
||||||
profile.dateYearEnd.day = 30
|
|
||||||
}
|
|
||||||
if (profile.archived) {
|
if (profile.archived) {
|
||||||
d(TAG, "The profile $profileId is archived")
|
d(TAG, "The profile $profileId is archived")
|
||||||
taskCallback.onError(ApiError(TAG, ERROR_PROFILE_ARCHIVED))
|
taskCallback.onError(ApiError(TAG, ERROR_PROFILE_ARCHIVED))
|
||||||
|
@ -91,7 +91,21 @@ open class Profile(
|
|||||||
@delegate:Ignore
|
@delegate:Ignore
|
||||||
val currentSemester by lazy { dateToSemester(Date.getToday()) }
|
val currentSemester by lazy { dateToSemester(Date.getToday()) }
|
||||||
|
|
||||||
fun shouldArchive() = Date.getToday() >= dateYearEnd && Date.getToday().year > studentSchoolYearStart
|
fun shouldArchive(): Boolean {
|
||||||
|
// vulcan hotfix
|
||||||
|
if (dateYearEnd.month > 6) {
|
||||||
|
dateYearEnd.month = 6
|
||||||
|
dateYearEnd.day = 30
|
||||||
|
}
|
||||||
|
// fix for when versions <4.3 synced 2020/2021 year dates to older profiles during 2020 Jun-Aug
|
||||||
|
if (dateSemester1Start.year > studentSchoolYearStart) {
|
||||||
|
val diff = dateSemester1Start.year - studentSchoolYearStart
|
||||||
|
dateSemester1Start.year -= diff
|
||||||
|
dateSemester2Start.year -= diff
|
||||||
|
dateYearEnd.year -= diff
|
||||||
|
}
|
||||||
|
return Date.getToday() >= dateYearEnd && Date.getToday().year > studentSchoolYearStart
|
||||||
|
}
|
||||||
fun isBeforeYear() = Date.getToday() < dateSemester1Start
|
fun isBeforeYear() = Date.getToday() < dateSemester1Start
|
||||||
|
|
||||||
var disabledNotifications: List<Long>? = null
|
var disabledNotifications: List<Long>? = null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user