1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 08:19:09 -05:00

Merge branch 'hotfix/1.9.2'

This commit is contained in:
Mikołaj Pich 2023-03-08 21:28:57 +01:00
commit c4672b8de9
19 changed files with 2580 additions and 33 deletions

View File

@ -23,8 +23,8 @@ android {
testApplicationId "io.github.tests.wulkanowy" testApplicationId "io.github.tests.wulkanowy"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 33 targetSdkVersion 33
versionCode 120 versionCode 121
versionName "1.9.1" versionName "1.9.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "app_name", "Wulkanowy" resValue "string", "app_name", "Wulkanowy"
@ -186,7 +186,7 @@ ext {
} }
dependencies { dependencies {
implementation "io.github.wulkanowy:sdk:1.9.1" implementation "io.github.wulkanowy:sdk:1.9.2"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.8'
@ -246,6 +246,7 @@ dependencies {
playImplementation 'com.google.firebase:firebase-analytics-ktx' playImplementation 'com.google.firebase:firebase-analytics-ktx'
playImplementation 'com.google.firebase:firebase-messaging:' playImplementation 'com.google.firebase:firebase-messaging:'
playImplementation 'com.google.firebase:firebase-crashlytics:' playImplementation 'com.google.firebase:firebase-crashlytics:'
playImplementation 'com.google.firebase:firebase-config-ktx'
playImplementation 'com.google.android.play:core:1.10.3' playImplementation 'com.google.android.play:core:1.10.3'
playImplementation 'com.google.android.play:core-ktx:1.8.1' playImplementation 'com.google.android.play:core-ktx:1.8.1'
playImplementation 'com.google.android.gms:play-services-ads:21.4.0' playImplementation 'com.google.android.gms:play-services-ads:21.4.0'

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
package io.github.wulkanowy.utils
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class RemoteConfigHelper @Inject constructor() : BaseRemoteConfigHelper()

View File

@ -0,0 +1,7 @@
package io.github.wulkanowy.utils
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class RemoteConfigHelper @Inject constructor() : BaseRemoteConfigHelper()

View File

@ -34,11 +34,15 @@ class WulkanowyApp : Application(), Configuration.Provider {
@Inject @Inject
lateinit var adsHelper: AdsHelper lateinit var adsHelper: AdsHelper
@Inject
lateinit var remoteConfigHelper: RemoteConfigHelper
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
initializeAppLanguage() initializeAppLanguage()
themeManager.applyDefaultTheme() themeManager.applyDefaultTheme()
adsHelper.initialize() adsHelper.initialize()
remoteConfigHelper.initialize()
initLogging() initLogging()
} }

View File

@ -19,6 +19,7 @@ import io.github.wulkanowy.data.db.SharedPrefProvider
import io.github.wulkanowy.data.repositories.PreferencesRepository import io.github.wulkanowy.data.repositories.PreferencesRepository
import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.sdk.Sdk
import io.github.wulkanowy.utils.AppInfo import io.github.wulkanowy.utils.AppInfo
import io.github.wulkanowy.utils.RemoteConfigHelper
import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType import okhttp3.MediaType.Companion.toMediaType
@ -36,10 +37,11 @@ internal class DataModule {
@Singleton @Singleton
@Provides @Provides
fun provideSdk(chuckerInterceptor: ChuckerInterceptor) = fun provideSdk(chuckerInterceptor: ChuckerInterceptor, remoteConfig: RemoteConfigHelper) =
Sdk().apply { Sdk().apply {
androidVersion = android.os.Build.VERSION.RELEASE androidVersion = android.os.Build.VERSION.RELEASE
buildTag = android.os.Build.MODEL buildTag = android.os.Build.MODEL
userAgentTemplate = remoteConfig.userAgentTemplate
setSimpleHttpLogger { Timber.d(it) } setSimpleHttpLogger { Timber.d(it) }
// for debug only // for debug only

View File

@ -48,6 +48,7 @@ import javax.inject.Singleton
AutoMigration(from = 46, to = 47), AutoMigration(from = 46, to = 47),
AutoMigration(from = 47, to = 48), AutoMigration(from = 47, to = 48),
AutoMigration(from = 51, to = 52), AutoMigration(from = 51, to = 52),
AutoMigration(from = 54, to = 55, spec = Migration55::class),
], ],
version = AppDatabase.VERSION_SCHEMA, version = AppDatabase.VERSION_SCHEMA,
exportSchema = true exportSchema = true
@ -56,7 +57,7 @@ import javax.inject.Singleton
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {
companion object { companion object {
const val VERSION_SCHEMA = 54 const val VERSION_SCHEMA = 55
fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf( fun getMigrations(sharedPrefProvider: SharedPrefProvider, appInfo: AppInfo) = arrayOf(
Migration2(), Migration2(),

View File

@ -2,16 +2,14 @@ package io.github.wulkanowy.data.db.entities
import androidx.room.ColumnInfo import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey
import java.io.Serializable import java.io.Serializable
@Entity(tableName = "MessageAttachments") @Entity(
tableName = "MessageAttachments",
primaryKeys = ["message_global_key", "url", "filename"],
)
data class MessageAttachment( data class MessageAttachment(
@PrimaryKey
@ColumnInfo(name = "real_id")
val realId: Int,
@ColumnInfo(name = "message_global_key") @ColumnInfo(name = "message_global_key")
val messageGlobalKey: String, val messageGlobalKey: String,

View File

@ -0,0 +1,17 @@
package io.github.wulkanowy.data.db.migrations
import androidx.room.DeleteColumn
import androidx.room.migration.AutoMigrationSpec
import androidx.sqlite.db.SupportSQLiteDatabase
@DeleteColumn(
tableName = "MessageAttachments",
columnName = "real_id",
)
class Migration55 : AutoMigrationSpec {
override fun onPostMigrate(db: SupportSQLiteDatabase) {
db.execSQL("DELETE FROM Messages")
db.execSQL("DELETE FROM MessageAttachments")
}
}

View File

@ -40,7 +40,6 @@ fun List<SdkMessage>.mapToEntities(
fun List<SdkMessageAttachment>.mapToEntities(messageGlobalKey: String) = map { fun List<SdkMessageAttachment>.mapToEntities(messageGlobalKey: String) = map {
MessageAttachment( MessageAttachment(
messageGlobalKey = messageGlobalKey, messageGlobalKey = messageGlobalKey,
realId = it.url.hashCode(),
url = it.url, url = it.url,
filename = it.filename filename = it.filename
) )

View File

@ -103,7 +103,10 @@ class MessageRepository @Inject constructor(
messagesDb.loadMessageWithAttachment(message.messageGlobalKey) messagesDb.loadMessageWithAttachment(message.messageGlobalKey)
}, },
fetch = { fetch = {
sdk.init(student).getMessageDetails(it!!.message.messageGlobalKey, markAsRead) sdk.init(student).getMessageDetails(
messageKey = it!!.message.messageGlobalKey,
markAsRead = message.unread && markAsRead,
)
}, },
saveFetchResult = { old, new -> saveFetchResult = { old, new ->
checkNotNull(old) { "Fetched message no longer exist!" } checkNotNull(old) { "Fetched message no longer exist!" }

View File

@ -12,6 +12,7 @@ import io.github.wulkanowy.data.pojos.RegisterUser
import io.github.wulkanowy.data.repositories.StudentRepository import io.github.wulkanowy.data.repositories.StudentRepository
import io.github.wulkanowy.data.resourceFlow import io.github.wulkanowy.data.resourceFlow
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
import io.github.wulkanowy.services.sync.SyncManager import io.github.wulkanowy.services.sync.SyncManager
import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.modules.login.LoginData import io.github.wulkanowy.ui.modules.login.LoginData
@ -158,7 +159,7 @@ class LoginStudentSelectPresenter @Inject constructor(
isNotEmptySymbolsExist: Boolean, isNotEmptySymbolsExist: Boolean,
) = buildList { ) = buildList {
val filteredEmptySymbols = emptySymbols.filter { val filteredEmptySymbols = emptySymbols.filter {
it.error !is AccountPermissionException it.error !is InvalidSymbolException
}.ifEmpty { emptySymbols.takeIf { !isNotEmptySymbolsExist }.orEmpty() } }.ifEmpty { emptySymbols.takeIf { !isNotEmptySymbolsExist }.orEmpty() }
if (filteredEmptySymbols.isNotEmpty() && isNotEmptySymbolsExist) { if (filteredEmptySymbols.isNotEmpty() && isNotEmptySymbolsExist) {
@ -281,7 +282,7 @@ class LoginStudentSelectPresenter @Inject constructor(
private fun onEmailClick() { private fun onEmailClick() {
view?.openEmail(lastError?.message.ifNullOrBlank { view?.openEmail(lastError?.message.ifNullOrBlank {
loginData.baseUrl + "/" + loginData.symbol + "\n" + registerUser.symbols.filterNot { loginData.baseUrl + "/" + loginData.symbol + "\n" + registerUser.symbols.filterNot {
it.error is AccountPermissionException && it.symbol != loginData.symbol (it.error is AccountPermissionException || it.error is InvalidSymbolException) && it.symbol != loginData.symbol
}.joinToString(";\n") { symbol -> }.joinToString(";\n") { symbol ->
buildString { buildString {
append(" -") append(" -")
@ -297,7 +298,9 @@ class LoginStudentSelectPresenter @Inject constructor(
} }
}) })
} }
} } + "\nPozostałe: " + registerUser.symbols.filter {
it.error is AccountPermissionException || it.error is InvalidSymbolException
}.joinToString(", ") { it.symbol }
}) })
} }

View File

@ -93,6 +93,13 @@ class LoginSymbolFragment :
} }
} }
override fun setErrorSymbolInvalid() {
with(binding.loginSymbolNameLayout) {
requestFocus()
error = getString(R.string.login_invalid_symbol)
}
}
override fun setErrorSymbolRequire() { override fun setErrorSymbolRequire() {
setErrorSymbol(getString(R.string.error_field_required)) setErrorSymbol(getString(R.string.error_field_required))
} }

View File

@ -7,6 +7,7 @@ import io.github.wulkanowy.data.pojos.RegisterUser
import io.github.wulkanowy.data.repositories.StudentRepository import io.github.wulkanowy.data.repositories.StudentRepository
import io.github.wulkanowy.data.resourceFlow import io.github.wulkanowy.data.resourceFlow
import io.github.wulkanowy.sdk.scrapper.getNormalizedSymbol import io.github.wulkanowy.sdk.scrapper.getNormalizedSymbol
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.modules.login.LoginData import io.github.wulkanowy.ui.modules.login.LoginData
import io.github.wulkanowy.ui.modules.login.LoginErrorHandler import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
@ -61,11 +62,11 @@ class LoginSymbolPresenter @Inject constructor(
email = loginData.login, email = loginData.login,
password = loginData.password, password = loginData.password,
scrapperBaseUrl = loginData.baseUrl, scrapperBaseUrl = loginData.baseUrl,
symbol = view?.symbolValue.orEmpty(), symbol = loginData.symbol.orEmpty(),
) )
}.onEach { }.onEach { user ->
registerUser = it.dataOrNull registerUser = user.dataOrNull
when (it) { when (user) {
is Resource.Loading -> view?.run { is Resource.Loading -> view?.run {
Timber.i("Login with symbol started") Timber.i("Login with symbol started")
hideSoftKeyboard() hideSoftKeyboard()
@ -73,7 +74,7 @@ class LoginSymbolPresenter @Inject constructor(
showContent(false) showContent(false)
} }
is Resource.Success -> { is Resource.Success -> {
when (it.data.symbols.size) { when (user.data.symbols.size) {
0 -> { 0 -> {
Timber.i("Login with symbol result: Empty student list") Timber.i("Login with symbol result: Empty student list")
view?.run { view?.run {
@ -82,8 +83,19 @@ class LoginSymbolPresenter @Inject constructor(
} }
} }
else -> { else -> {
Timber.i("Login with symbol result: Success") val enteredSymbolDetails = user.data.symbols
view?.navigateToStudentSelect(loginData, requireNotNull(it.data)) .firstOrNull()
?.takeIf { it.symbol == loginData.symbol }
if (enteredSymbolDetails?.error is InvalidSymbolException) {
view?.run {
setErrorSymbolInvalid()
showContact(true)
}
} else {
Timber.i("Login with symbol result: Success")
view?.navigateToStudentSelect(loginData, requireNotNull(user.data))
}
} }
} }
analytics.logEvent( analytics.logEvent(
@ -102,10 +114,10 @@ class LoginSymbolPresenter @Inject constructor(
"students" to -1, "students" to -1,
"scrapperBaseUrl" to loginData.baseUrl, "scrapperBaseUrl" to loginData.baseUrl,
"symbol" to view?.symbolValue, "symbol" to view?.symbolValue,
"error" to it.error.message.ifNullOrBlank { "No message" } "error" to user.error.message.ifNullOrBlank { "No message" }
) )
loginErrorHandler.dispatch(it.error) loginErrorHandler.dispatch(user.error)
lastError = it.error lastError = user.error
view?.showContact(true) view?.showContact(true)
} }
} }

View File

@ -16,6 +16,8 @@ interface LoginSymbolView : BaseView {
fun setErrorSymbolIncorrect() fun setErrorSymbolIncorrect()
fun setErrorSymbolInvalid()
fun setErrorSymbolRequire() fun setErrorSymbolRequire()
fun setErrorSymbol(message: String) fun setErrorSymbol(message: String)

View File

@ -0,0 +1,9 @@
package io.github.wulkanowy.utils
abstract class BaseRemoteConfigHelper {
open fun initialize() = Unit
open val userAgentTemplate: String
get() = RemoteConfigDefaults.USER_AGENT_TEMPLATE.value as String
}

View File

@ -0,0 +1,8 @@
package io.github.wulkanowy.utils
enum class RemoteConfigDefaults(val value: Any) {
USER_AGENT_TEMPLATE(""),
;
val key get() = name.lowercase()
}

View File

@ -1,10 +1,7 @@
Wersja 1.9.1 Wersja 1.9.2
- dodaliśmy obsługę Androida 13 (w tym ikona aplikacji obsługująca Material You) - naprawiliśmy oznaczanie wiadomości jako odczytanych (problem dotyczył głównie kont rodziców z wieloma dziećmi w tej samej szkole)
- przerobiliśmy ekran wyboru ucznia przy pierwszym logowaniu - naprawiliśmy zapisywanie załączników do wiadomości w sytuacji, gdy ten sam załącznik był dodany do więcej niż jednej wiadomości
- naprawiliśmy usuwanie wiadomości w niektórych przypadkach - usprawniliśmy ekran z wyborem uczniów i wpisywaniem symbolu przy pierwszym logowaniu
- naprawiliśmy błąd występujący przy resecie hasła
- naprawiliśmy literówkę w tytule domyślnej treści wiadomości usprawiedliwiania
- naprawiliśmy nazwę aplikacji przy ustawionym w telefonie jezyku francuskim
Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases

View File

@ -0,0 +1,35 @@
package io.github.wulkanowy.utils
import android.content.Context
import com.google.firebase.FirebaseApp
import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class RemoteConfigHelper @Inject constructor(
@ApplicationContext private val context: Context,
private val appInfo: AppInfo,
) : BaseRemoteConfigHelper() {
override fun initialize() {
FirebaseApp.initializeApp(context)
Firebase.remoteConfig.setConfigSettingsAsync(remoteConfigSettings {
fetchTimeoutInSeconds = 3
if (appInfo.isDebug) {
minimumFetchIntervalInSeconds = 0
}
})
Firebase.remoteConfig.setDefaultsAsync(RemoteConfigDefaults.values().associate {
it.key to it.value
})
Firebase.remoteConfig.fetchAndActivate()
}
override val userAgentTemplate: String
get() = Firebase.remoteConfig.getString(RemoteConfigDefaults.USER_AGENT_TEMPLATE.key)
}