mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 14:36:47 -06:00
Merge branch 'release/1.6.3'
This commit is contained in:
commit
775b5122ef
@ -22,8 +22,8 @@ android {
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 31
|
||||
versionCode 106
|
||||
versionName "1.6.2"
|
||||
versionCode 107
|
||||
versionName "1.6.3"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
resValue "string", "app_name", "Wulkanowy"
|
||||
@ -174,7 +174,7 @@ ext {
|
||||
room = "2.4.2"
|
||||
chucker = "3.5.2"
|
||||
mockk = "1.12.2"
|
||||
coroutines = "1.6.0"
|
||||
coroutines = "1.6.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -233,7 +233,7 @@ dependencies {
|
||||
implementation 'me.xdrop:fuzzywuzzy:1.4.0'
|
||||
implementation 'com.fredporciuncula:flow-preferences:1.6.0'
|
||||
|
||||
playImplementation platform('com.google.firebase:firebase-bom:29.3.0')
|
||||
playImplementation platform('com.google.firebase:firebase-bom:29.3.1')
|
||||
playImplementation 'com.google.firebase:firebase-analytics-ktx'
|
||||
playImplementation 'com.google.firebase:firebase-messaging:'
|
||||
playImplementation 'com.google.firebase:firebase-crashlytics:'
|
||||
@ -241,8 +241,8 @@ dependencies {
|
||||
playImplementation 'com.google.android.play:core-ktx:1.8.1'
|
||||
playImplementation 'com.google.android.gms:play-services-ads:20.6.0'
|
||||
|
||||
hmsImplementation 'com.huawei.hms:hianalytics:6.4.1.301'
|
||||
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.6.5.200'
|
||||
hmsImplementation 'com.huawei.hms:hianalytics:6.4.1.302'
|
||||
hmsImplementation 'com.huawei.agconnect:agconnect-crash:1.6.5.300'
|
||||
|
||||
releaseImplementation "com.github.ChuckerTeam.Chucker:library-no-op:$chucker"
|
||||
|
||||
|
@ -15,79 +15,41 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class ShortcutsHelper @Inject constructor(@ApplicationContext private val context: Context) {
|
||||
|
||||
// Destination cannot be used here as shortcuts
|
||||
// require their intents to only use primitive types (see PersistableBundle.isValidType).
|
||||
|
||||
private val destinations = mapOf(
|
||||
"grade" to Destination.Grade,
|
||||
"attendance" to Destination.Attendance,
|
||||
"exam" to Destination.Exam,
|
||||
"timetable" to Destination.Timetable()
|
||||
)
|
||||
|
||||
init {
|
||||
initializeShortcuts()
|
||||
}
|
||||
|
||||
fun getDestination(intent: Intent) =
|
||||
destinations[intent.getStringExtra(EXTRA_SHORTCUT_DESTINATION_ID)]
|
||||
|
||||
private fun initializeShortcuts() {
|
||||
fun initializeShortcuts() {
|
||||
val shortcutsInfo = listOf(
|
||||
ShortcutInfoCompat.Builder(context, "grade_shortcut")
|
||||
.setShortLabel(context.getString(R.string.grade_title))
|
||||
.setLongLabel(context.getString(R.string.grade_title))
|
||||
.setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_grade))
|
||||
.setIntent(SplashActivity.getStartIntent(context)
|
||||
.apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "grade")
|
||||
}
|
||||
)
|
||||
.setIntent(SplashActivity.getStartIntent(context, Destination.Grade)
|
||||
.apply { action = Intent.ACTION_VIEW })
|
||||
.build(),
|
||||
|
||||
ShortcutInfoCompat.Builder(context, "attendance_shortcut")
|
||||
.setShortLabel(context.getString(R.string.attendance_title))
|
||||
.setLongLabel(context.getString(R.string.attendance_title))
|
||||
.setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_attendance))
|
||||
.setIntent(SplashActivity.getStartIntent(context)
|
||||
.apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "attendance")
|
||||
}
|
||||
)
|
||||
.setIntent(SplashActivity.getStartIntent(context, Destination.Attendance)
|
||||
.apply { action = Intent.ACTION_VIEW })
|
||||
.build(),
|
||||
|
||||
ShortcutInfoCompat.Builder(context, "exam_shortcut")
|
||||
.setShortLabel(context.getString(R.string.exam_title))
|
||||
.setLongLabel(context.getString(R.string.exam_title))
|
||||
.setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_exam))
|
||||
.setIntent(SplashActivity.getStartIntent(context)
|
||||
.apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "exam")
|
||||
}
|
||||
)
|
||||
.setIntent(SplashActivity.getStartIntent(context, Destination.Exam)
|
||||
.apply { action = Intent.ACTION_VIEW })
|
||||
.build(),
|
||||
|
||||
ShortcutInfoCompat.Builder(context, "timetable_shortcut")
|
||||
.setShortLabel(context.getString(R.string.timetable_title))
|
||||
.setLongLabel(context.getString(R.string.timetable_title))
|
||||
.setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_timetable))
|
||||
.setIntent(SplashActivity.getStartIntent(context)
|
||||
.apply {
|
||||
action = Intent.ACTION_VIEW
|
||||
putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "timetable")
|
||||
}
|
||||
)
|
||||
.setIntent(SplashActivity.getStartIntent(context, Destination.Timetable())
|
||||
.apply { action = Intent.ACTION_VIEW })
|
||||
.build()
|
||||
)
|
||||
|
||||
shortcutsInfo.forEach { ShortcutManagerCompat.pushDynamicShortcut(context, it) }
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
private const val EXTRA_SHORTCUT_DESTINATION_ID = "shortcut_destination_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.github.wulkanowy.ui.modules
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.fragment.app.Fragment
|
||||
import io.github.wulkanowy.data.serializers.LocalDateSerializer
|
||||
import io.github.wulkanowy.ui.modules.attendance.AttendanceFragment
|
||||
@ -16,12 +15,11 @@ import io.github.wulkanowy.ui.modules.note.NoteFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.school.SchoolFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolannouncement.SchoolAnnouncementFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.TimetableFragment
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.time.LocalDate
|
||||
|
||||
@Serializable
|
||||
sealed class Destination : Parcelable {
|
||||
sealed class Destination {
|
||||
|
||||
/*
|
||||
Type in children classes have to be as getter to avoid null in enums
|
||||
@ -47,35 +45,30 @@ sealed class Destination : Parcelable {
|
||||
MESSAGE(Message);
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Dashboard : Destination() {
|
||||
override val destinationType get() = Type.DASHBOARD
|
||||
override val destinationFragment get() = DashboardFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Grade : Destination() {
|
||||
override val destinationType get() = Type.GRADE
|
||||
override val destinationFragment get() = GradeFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Attendance : Destination() {
|
||||
override val destinationType get() = Type.ATTENDANCE
|
||||
override val destinationFragment get() = AttendanceFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Exam : Destination() {
|
||||
override val destinationType get() = Type.EXAM
|
||||
override val destinationFragment get() = ExamFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
data class Timetable(
|
||||
@Serializable(with = LocalDateSerializer::class)
|
||||
@ -85,56 +78,48 @@ sealed class Destination : Parcelable {
|
||||
override val destinationFragment get() = TimetableFragment.newInstance(date)
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Homework : Destination() {
|
||||
override val destinationType get() = Type.HOMEWORK
|
||||
override val destinationFragment get() = HomeworkFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Note : Destination() {
|
||||
override val destinationType get() = Type.NOTE
|
||||
override val destinationFragment get() = NoteFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Conference : Destination() {
|
||||
override val destinationType get() = Type.CONFERENCE
|
||||
override val destinationFragment get() = ConferenceFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object SchoolAnnouncement : Destination() {
|
||||
override val destinationType get() = Type.SCHOOL_ANNOUNCEMENT
|
||||
override val destinationFragment get() = SchoolAnnouncementFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object School : Destination() {
|
||||
override val destinationType get() = Type.SCHOOL
|
||||
override val destinationFragment get() = SchoolFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object LuckyNumber : Destination() {
|
||||
override val destinationType get() = Type.LUCKY_NUMBER
|
||||
override val destinationFragment get() = LuckyNumberFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object More : Destination() {
|
||||
override val destinationType get() = Type.MORE
|
||||
override val destinationFragment get() = MoreFragment.newInstance()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Serializable
|
||||
object Message : Destination() {
|
||||
override val destinationType get() = Type.MESSAGE
|
||||
|
@ -9,6 +9,7 @@ import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.text.parseAsHtml
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.core.view.updateMarginsRelative
|
||||
@ -563,7 +564,7 @@ class DashboardAdapter @Inject constructor() : RecyclerView.Adapter<RecyclerView
|
||||
) {
|
||||
with(binding.dashboardLessonsItemDayHeader) {
|
||||
isVisible = header != null
|
||||
text = header?.content
|
||||
text = header?.content?.parseAsHtml()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.modules.Destination
|
||||
import io.github.wulkanowy.ui.modules.account.accountquick.AccountQuickDialog
|
||||
import io.github.wulkanowy.utils.*
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -55,13 +57,13 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
|
||||
companion object {
|
||||
|
||||
private const val EXTRA_START_DESTINATION = "start_destination"
|
||||
private const val EXTRA_START_DESTINATION = "start_destination_json"
|
||||
|
||||
fun getStartIntent(
|
||||
context: Context,
|
||||
destination: Destination? = null,
|
||||
) = Intent(context, MainActivity::class.java).apply {
|
||||
putExtra(EXTRA_START_DESTINATION, destination)
|
||||
destination?.let { putExtra(EXTRA_START_DESTINATION, Json.encodeToString(it)) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,9 +72,8 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
override val currentStackSize get() = navController.currentStack?.size
|
||||
|
||||
override val currentViewTitle
|
||||
get() = (navController.currentFrag as? MainView.TitledView)?.titleStringId?.let {
|
||||
getString(it)
|
||||
}
|
||||
get() = (navController.currentFrag as? MainView.TitledView)?.titleStringId
|
||||
?.let { getString(it) }
|
||||
|
||||
override val currentViewSubtitle get() = (navController.currentFrag as? MainView.TitledView)?.subtitleString
|
||||
|
||||
@ -86,7 +87,7 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
|
||||
messageContainer = binding.mainMessageContainer
|
||||
updateHelper.messageContainer = binding.mainFragmentContainer
|
||||
|
||||
val destination = (intent.getParcelableExtra(EXTRA_START_DESTINATION) as Destination?)
|
||||
val destination = intent.getStringExtra(EXTRA_START_DESTINATION)
|
||||
?.takeIf { savedInstanceState == null }
|
||||
|
||||
presenter.onAttachView(this, destination)
|
||||
|
@ -19,6 +19,8 @@ import io.github.wulkanowy.ui.modules.message.MessageView
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersView
|
||||
import io.github.wulkanowy.ui.modules.studentinfo.StudentInfoView
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import timber.log.Timber
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
@ -30,6 +32,7 @@ class MainPresenter @Inject constructor(
|
||||
private val prefRepository: PreferencesRepository,
|
||||
private val syncManager: SyncManager,
|
||||
private val analytics: AnalyticsHelper,
|
||||
private val json: Json
|
||||
) : BasePresenter<MainView>(errorHandler, studentRepository) {
|
||||
|
||||
private var studentsWitSemesters: List<StudentWithSemesters>? = null
|
||||
@ -51,9 +54,11 @@ class MainPresenter @Inject constructor(
|
||||
else -> 4
|
||||
}
|
||||
|
||||
fun onAttachView(view: MainView, initDestination: Destination?) {
|
||||
fun onAttachView(view: MainView, initDestinationJson: String?) {
|
||||
super.onAttachView(view)
|
||||
|
||||
val initDestination: Destination? = initDestinationJson?.let { json.decodeFromString(it) }
|
||||
|
||||
val startMenuIndex = initDestination.startMenuIndex
|
||||
val destinations = rootDestinationTypeList.map {
|
||||
if (it == initDestination?.destinationType) initDestination else it.defaultDestination
|
||||
|
@ -15,6 +15,8 @@ import io.github.wulkanowy.ui.modules.Destination
|
||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import javax.inject.Inject
|
||||
|
||||
@SuppressLint("CustomSplashScreen")
|
||||
@ -29,13 +31,13 @@ class SplashActivity : BaseActivity<SplashPresenter, ViewBinding>(), SplashView
|
||||
|
||||
companion object {
|
||||
|
||||
private const val EXTRA_START_DESTINATION = "start_destination"
|
||||
private const val EXTRA_START_DESTINATION = "start_destination_json"
|
||||
|
||||
private const val EXTRA_EXTERNAL_URL = "external_url"
|
||||
|
||||
fun getStartIntent(context: Context, destination: Destination? = null) =
|
||||
Intent(context, SplashActivity::class.java).apply {
|
||||
putExtra(EXTRA_START_DESTINATION, destination)
|
||||
destination?.let { putExtra(EXTRA_START_DESTINATION, Json.encodeToString(it)) }
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
}
|
||||
}
|
||||
@ -43,12 +45,12 @@ class SplashActivity : BaseActivity<SplashPresenter, ViewBinding>(), SplashView
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
installSplashScreen().setKeepOnScreenCondition { true }
|
||||
shortcutsHelper.initializeShortcuts()
|
||||
|
||||
val externalLink = intent?.getStringExtra(EXTRA_EXTERNAL_URL)
|
||||
val startDestination = intent?.getParcelableExtra(EXTRA_START_DESTINATION) as Destination?
|
||||
?: shortcutsHelper.getDestination(intent)
|
||||
val startDestinationJson = intent?.getStringExtra(EXTRA_START_DESTINATION)
|
||||
|
||||
presenter.onAttachView(this, externalLink, startDestination)
|
||||
presenter.onAttachView(this, externalLink, startDestinationJson)
|
||||
}
|
||||
|
||||
override fun openLoginView() {
|
||||
|
@ -5,16 +5,21 @@ import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.ui.modules.Destination
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import javax.inject.Inject
|
||||
|
||||
class SplashPresenter @Inject constructor(
|
||||
errorHandler: ErrorHandler,
|
||||
studentRepository: StudentRepository,
|
||||
private val json: Json
|
||||
) : BasePresenter<SplashView>(errorHandler, studentRepository) {
|
||||
|
||||
fun onAttachView(view: SplashView, externalUrl: String?, startDestination: Destination?) {
|
||||
fun onAttachView(view: SplashView, externalUrl: String?, startDestinationJson: String?) {
|
||||
super.onAttachView(view)
|
||||
|
||||
val startDestination: Destination? = startDestinationJson?.let { json.decodeFromString(it) }
|
||||
|
||||
if (!externalUrl.isNullOrBlank()) {
|
||||
view.openExternalUrlAndFinish(externalUrl)
|
||||
return
|
||||
|
@ -1,4 +1,4 @@
|
||||
Wersja 1.6.2
|
||||
Wersja 1.6.3
|
||||
|
||||
- dodaliśmy możliwość usuwania wielu wiadomości jednocześnie
|
||||
- dodaliśmy opcję szybkiego dodawania sprawdzianów do kalendarza
|
||||
|
@ -5,13 +5,9 @@ import io.github.wulkanowy.data.repositories.StudentRepository
|
||||
import io.github.wulkanowy.services.sync.SyncManager
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.AnalyticsHelper
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.Runs
|
||||
import io.mockk.clearMocks
|
||||
import io.mockk.every
|
||||
import io.mockk.*
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.just
|
||||
import io.mockk.verify
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@ -43,8 +39,14 @@ class MainPresenterTest {
|
||||
clearMocks(mainView)
|
||||
|
||||
every { mainView.initView(any(), any()) } just Runs
|
||||
presenter =
|
||||
MainPresenter(errorHandler, studentRepository, prefRepository, syncManager, analytics)
|
||||
presenter = MainPresenter(
|
||||
errorHandler = errorHandler,
|
||||
studentRepository = studentRepository,
|
||||
prefRepository = prefRepository,
|
||||
syncManager = syncManager,
|
||||
analytics = analytics,
|
||||
json = Json
|
||||
)
|
||||
presenter.onAttachView(mainView, null)
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import io.mockk.MockKAnnotations
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.verify
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@ -30,7 +31,7 @@ class SplashPresenterTest {
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this)
|
||||
presenter = SplashPresenter(errorHandler, studentRepository)
|
||||
presenter = SplashPresenter(errorHandler, studentRepository, Json)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -13,10 +13,10 @@ buildscript {
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
||||
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
|
||||
classpath 'com.google.gms:google-services:4.3.10'
|
||||
classpath 'com.huawei.agconnect:agcp:1.6.5.200'
|
||||
classpath 'com.huawei.agconnect:agcp:1.6.5.300'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
|
||||
classpath "com.github.triplet.gradle:play-publisher:3.6.0"
|
||||
classpath "ru.cian:huawei-publish-gradle-plugin:1.3.3"
|
||||
|
Loading…
x
Reference in New Issue
Block a user