mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[Lab] Add option to full sync and clear profile.
This commit is contained in:
parent
a939d95ea3
commit
a5bb7d9c6e
@ -17,7 +17,8 @@ import kotlin.coroutines.CoroutineContext
|
|||||||
class ProfileRemoveDialog(
|
class ProfileRemoveDialog(
|
||||||
val activity: MainActivity,
|
val activity: MainActivity,
|
||||||
val profileId: Int,
|
val profileId: Int,
|
||||||
val profileName: String
|
val profileName: String,
|
||||||
|
val noProfileRemoval: Boolean = false
|
||||||
) : CoroutineScope {
|
) : CoroutineScope {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "ProfileRemoveDialog"
|
private const val TAG = "ProfileRemoveDialog"
|
||||||
@ -52,7 +53,6 @@ class ProfileRemoveDialog(
|
|||||||
app.db.attendanceDao().clear(profileId)
|
app.db.attendanceDao().clear(profileId)
|
||||||
app.db.attendanceTypeDao().clear(profileId)
|
app.db.attendanceTypeDao().clear(profileId)
|
||||||
app.db.classroomDao().clear(profileId)
|
app.db.classroomDao().clear(profileId)
|
||||||
app.db.configDao().clear(profileId)
|
|
||||||
app.db.endpointTimerDao().clear(profileId)
|
app.db.endpointTimerDao().clear(profileId)
|
||||||
app.db.eventDao().clear(profileId)
|
app.db.eventDao().clear(profileId)
|
||||||
app.db.eventTypeDao().clear(profileId)
|
app.db.eventTypeDao().clear(profileId)
|
||||||
@ -65,23 +65,27 @@ class ProfileRemoveDialog(
|
|||||||
app.db.messageRecipientDao().clear(profileId)
|
app.db.messageRecipientDao().clear(profileId)
|
||||||
app.db.noticeDao().clear(profileId)
|
app.db.noticeDao().clear(profileId)
|
||||||
app.db.noticeTypeDao().clear(profileId)
|
app.db.noticeTypeDao().clear(profileId)
|
||||||
app.db.noticeTypeDao().clear(profileId)
|
|
||||||
app.db.notificationDao().clear(profileId)
|
app.db.notificationDao().clear(profileId)
|
||||||
app.db.subjectDao().clear(profileId)
|
app.db.subjectDao().clear(profileId)
|
||||||
app.db.teacherAbsenceDao().clear(profileId)
|
app.db.teacherAbsenceDao().clear(profileId)
|
||||||
app.db.teacherAbsenceDao().clear(profileId)
|
|
||||||
app.db.teacherAbsenceTypeDao().clear(profileId)
|
app.db.teacherAbsenceTypeDao().clear(profileId)
|
||||||
app.db.teacherDao().clear(profileId)
|
app.db.teacherDao().clear(profileId)
|
||||||
app.db.teamDao().clear(profileId)
|
app.db.teamDao().clear(profileId)
|
||||||
app.db.timetableDao().clear(profileId)
|
app.db.timetableDao().clear(profileId)
|
||||||
|
|
||||||
|
app.db.metadataDao().deleteAll(profileId)
|
||||||
|
|
||||||
|
if (noProfileRemoval)
|
||||||
|
return@async
|
||||||
|
|
||||||
|
app.db.configDao().clear(profileId)
|
||||||
|
|
||||||
val loginStoreId = profileObject.loginStoreId
|
val loginStoreId = profileObject.loginStoreId
|
||||||
val profilesUsingLoginStore = app.db.profileDao().getIdsByLoginStoreIdNow(loginStoreId)
|
val profilesUsingLoginStore = app.db.profileDao().getIdsByLoginStoreIdNow(loginStoreId)
|
||||||
if (profilesUsingLoginStore.size == 1) {
|
if (profilesUsingLoginStore.size == 1) {
|
||||||
app.db.loginStoreDao().remove(loginStoreId)
|
app.db.loginStoreDao().remove(loginStoreId)
|
||||||
}
|
}
|
||||||
app.db.profileDao().remove(profileId)
|
app.db.profileDao().remove(profileId)
|
||||||
app.db.metadataDao().deleteAll(profileId)
|
|
||||||
|
|
||||||
if (App.profileId == profileId) {
|
if (App.profileId == profileId) {
|
||||||
app.profileLoadLast { }
|
app.profileLoadLast { }
|
||||||
|
@ -16,6 +16,7 @@ import kotlinx.coroutines.launch
|
|||||||
import pl.szczodrzynski.edziennik.*
|
import pl.szczodrzynski.edziennik.*
|
||||||
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
import pl.szczodrzynski.edziennik.data.db.entity.Event
|
||||||
import pl.szczodrzynski.edziennik.databinding.LabFragmentBinding
|
import pl.szczodrzynski.edziennik.databinding.LabFragmentBinding
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.settings.ProfileRemoveDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.modules.base.lazypager.LazyFragment
|
import pl.szczodrzynski.edziennik.ui.modules.base.lazypager.LazyFragment
|
||||||
import pl.szczodrzynski.edziennik.utils.TextInputDropDown
|
import pl.szczodrzynski.edziennik.utils.TextInputDropDown
|
||||||
import pl.szczodrzynski.fslogin.decode
|
import pl.szczodrzynski.fslogin.decode
|
||||||
@ -61,6 +62,15 @@ class LabPageFragment : LazyFragment(), CoroutineScope {
|
|||||||
app.db.teacherDao().query(SimpleSQLiteQuery("UPDATE teachers SET teacherSurname = \"\" WHERE profileId = ${App.profileId}"))
|
app.db.teacherDao().query(SimpleSQLiteQuery("UPDATE teachers SET teacherSurname = \"\" WHERE profileId = ${App.profileId}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
b.fullSync.onClick {
|
||||||
|
app.db.query(SimpleSQLiteQuery("UPDATE profiles SET empty = 1 WHERE profileId = ${App.profileId}"))
|
||||||
|
app.db.query(SimpleSQLiteQuery("DELETE FROM endpointTimers WHERE profileId = ${App.profileId}"))
|
||||||
|
}
|
||||||
|
|
||||||
|
b.clearProfile.onClick {
|
||||||
|
ProfileRemoveDialog(activity, App.profileId, "FAKE", noProfileRemoval = true)
|
||||||
|
}
|
||||||
|
|
||||||
b.removeHomework.onClick {
|
b.removeHomework.onClick {
|
||||||
app.db.eventDao().getRawNow("UPDATE events SET homeworkBody = NULL WHERE profileId = ${App.profileId}")
|
app.db.eventDao().getRawNow("UPDATE events SET homeworkBody = NULL WHERE profileId = ${App.profileId}")
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ public class SettingsNewFragment extends MaterialAboutFragment {
|
|||||||
.color(IconicsColor.colorInt(iconColor))
|
.color(IconicsColor.colorInt(iconColor))
|
||||||
)
|
)
|
||||||
.setOnClickAction(() -> {
|
.setOnClickAction(() -> {
|
||||||
new ProfileRemoveDialog(activity, app.getProfile().getId(), app.getProfile().getName());
|
new ProfileRemoveDialog(activity, app.getProfile().getId(), app.getProfile().getName(), false);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -45,6 +45,22 @@
|
|||||||
android:text="Set last 10 as unseen"
|
android:text="Set last 10 as unseen"
|
||||||
android:textAllCaps="false" />
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/fullSync"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="Full sync and empty profile"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/clearProfile"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:text="Clear all profile data"
|
||||||
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/rodo"
|
android:id="@+id/rodo"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -70,6 +86,7 @@
|
|||||||
android:id="@+id/unarchive"
|
android:id="@+id/unarchive"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
android:text="Unarchive this profile"
|
android:text="Unarchive this profile"
|
||||||
android:textAllCaps="false" />
|
android:textAllCaps="false" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user