From c8f8ec77a9b648929ce2e8d17a39f1b9ea8836b4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:35:24 +0000 Subject: [PATCH 01/10] Bump preference-ktx from 1.1.0 to 1.1.1 (#771) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 9e36346d..0a0089e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -139,7 +139,7 @@ dependencies { implementation "androidx.annotation:annotation:1.1.0" implementation "androidx.multidex:multidex:2.0.1" - implementation "androidx.preference:preference-ktx:1.1.0" + implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "androidx.viewpager:viewpager:1.0.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-beta01" From ee4a5e56a9aa9894ba7726fc9d19d19ea50e121d Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:37:38 +0000 Subject: [PATCH 02/10] Bump gradle from 3.6.2 to 3.6.3 (#772) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3facb045..40b2bab1 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.tools.build:gradle:3.6.2' + classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.google.gms:google-services:4.3.3' //noinspection GradleDependency https://github.com/firebase/firebase-android-sdk/issues/1276#issuecomment-592098283 classpath "io.fabric.tools:gradle:1.31.0" From 07307b9709a2cc74d20b55959e35ad6fbed891f6 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:59:02 +0000 Subject: [PATCH 03/10] Bump swiperefreshlayout from 1.1.0-beta01 to 1.1.0-rc01 (#770) --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 0a0089e1..ff7bcb34 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -142,7 +142,7 @@ dependencies { implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "androidx.viewpager:viewpager:1.0.0" - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-beta01" + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01" implementation "androidx.constraintlayout:constraintlayout:1.1.3" implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0" implementation "com.google.android.material:material:1.1.0" From 69be7ca412a837807b2df2cc780625a21226976b Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2020 21:01:41 +0000 Subject: [PATCH 04/10] Bump kotlin_version from 1.3.71 to 1.3.72 (#773) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 40b2bab1..706fb15b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.3.71' + ext.kotlin_version = '1.3.72' ext.about_libraries = '8.1.1' repositories { mavenCentral() From b19084cb579dce6a742364301bb40a290a80a30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sat, 18 Apr 2020 23:06:05 +0200 Subject: [PATCH 05/10] =?UTF-8?q?Fix=20visibility=20of=20dialog=20close=20?= =?UTF-8?q?button=20when=20homework=20content=20is=20l=E2=80=A6=20(#774)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/dialog_homework.xml | 12 ++++++------ .../main/res/layout/item_homework_dialog_details.xml | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/layout/dialog_homework.xml b/app/src/main/res/layout/dialog_homework.xml index daa07636..7c149d4b 100644 --- a/app/src/main/res/layout/dialog_homework.xml +++ b/app/src/main/res/layout/dialog_homework.xml @@ -9,14 +9,18 @@ + android:layout_height="wrap_content" + android:background="@drawable/ic_all_divider" + android:paddingHorizontal="10dp" + android:paddingVertical="5dp"> @@ -38,8 +40,6 @@ android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" - android:layout_marginEnd="10dp" - android:layout_marginBottom="10dp" android:text="@string/all_close" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> diff --git a/app/src/main/res/layout/item_homework_dialog_details.xml b/app/src/main/res/layout/item_homework_dialog_details.xml index 4b368c62..bfd246c8 100644 --- a/app/src/main/res/layout/item_homework_dialog_details.xml +++ b/app/src/main/res/layout/item_homework_dialog_details.xml @@ -1,4 +1,5 @@ + android:textSize="12sp" + tools:text="@tools:sample/lorem/random" /> From 4bd0459155e9f87596f4d9a88bc78962eb771f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sat, 18 Apr 2020 23:07:20 +0200 Subject: [PATCH 06/10] Don't log common errors to crashlytics (#775) --- .../github/wulkanowy/services/sync/SyncWorker.kt | 14 ++++++++------ .../grade/statistics/GradeStatisticsPresenter.kt | 4 ++-- .../modules/login/recover/LoginRecoverPresenter.kt | 4 ++-- .../modules/message/send/SendMessagePresenter.kt | 4 ++-- .../io/github/wulkanowy/utils/CrashlyticsUtils.kt | 12 +++++++++++- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt index 8a38fa55..126d856a 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/SyncWorker.kt @@ -1,7 +1,6 @@ package io.github.wulkanowy.services.sync import android.content.Context -import android.os.Build.VERSION_CODES.LOLLIPOP import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.BigTextStyle import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT @@ -17,9 +16,9 @@ import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository import io.github.wulkanowy.data.repositories.semester.SemesterRepository import io.github.wulkanowy.data.repositories.student.StudentRepository import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException import io.github.wulkanowy.services.sync.channels.DebugChannel import io.github.wulkanowy.services.sync.works.Work -import io.github.wulkanowy.utils.AppInfo import io.github.wulkanowy.utils.getCompatColor import io.reactivex.Completable import io.reactivex.Single @@ -33,8 +32,7 @@ class SyncWorker @AssistedInject constructor( private val semesterRepository: SemesterRepository, private val works: Set<@JvmSuppressWildcards Work>, private val preferencesRepository: PreferencesRepository, - private val notificationManager: NotificationManagerCompat, - private val appInfo: AppInfo + private val notificationManager: NotificationManagerCompat ) : RxWorker(appContext, workerParameters) { override fun createWork(): Single { @@ -47,6 +45,10 @@ class SyncWorker @AssistedInject constructor( .flatMapCompletable { semester -> Completable.mergeDelayError(works.map { work -> work.create(student, semester) + .onErrorResumeNext { + if (it is FeatureDisabledException || it is FeatureNotAvailableException) Completable.complete() + else Completable.error(it) + } .doOnSubscribe { Timber.i("${work::class.java.simpleName} is starting") } .doOnError { Timber.i("${work::class.java.simpleName} result: An exception occurred") } .doOnComplete { Timber.i("${work::class.java.simpleName} result: Success") } @@ -57,11 +59,11 @@ class SyncWorker @AssistedInject constructor( .onErrorReturn { Timber.e(it, "There was an error during synchronization") when { - it is FeatureDisabledException -> Result.success() inputData.getBoolean("one_time", false) -> { Result.failure(Data.Builder() .putString("error", it.toString()) - .build()) + .build() + ) } else -> Result.retry() } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt index 6323dbe1..90c4e38e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt @@ -133,7 +133,7 @@ class GradeStatisticsPresenter @Inject constructor( showSubjects(true) } }, { - Timber.e("Loading grade stats subjects result: An exception occurred") + Timber.i("Loading grade stats subjects result: An exception occurred") errorHandler.dispatch(it) }) ) @@ -179,7 +179,7 @@ class GradeStatisticsPresenter @Inject constructor( } analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh) }) { - Timber.e("Loading grade stats result: An exception occurred") + Timber.i("Loading grade stats result: An exception occurred") errorHandler.dispatch(it) }) } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt index b292ded5..9a21fb91 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/recover/LoginRecoverPresenter.kt @@ -70,7 +70,7 @@ class LoginRecoverPresenter @Inject constructor( .subscribe({ (resetUrl, siteKey) -> view?.loadReCaptcha(siteKey, resetUrl) }) { - Timber.e("Obtain captcha site key result: An exception occurred") + Timber.i("Obtain captcha site key result: An exception occurred") errorHandler.dispatch(it) }) } @@ -120,7 +120,7 @@ class LoginRecoverPresenter @Inject constructor( analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to true) }) { - Timber.e("Send recover request result: An exception occurred") + Timber.i("Send recover request result: An exception occurred") errorHandler.dispatch(it) analytics.logEvent("account_recover", "register" to host, "symbol" to symbol, "success" to false) }) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt index 385c12ff..aec79f9d 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessagePresenter.kt @@ -135,12 +135,12 @@ class SendMessagePresenter @Inject constructor( if (selectedRecipientChips.isNotEmpty()) setSelectedRecipients(selectedRecipientChips) showContent(true) } else { - Timber.e("Loading recipients result: Can't find the reporting unit") + Timber.i("Loading recipients result: Can't find the reporting unit") view?.showEmpty(true) } } }, { - Timber.e("Loading recipients result: An exception occurred") + Timber.i("Loading recipients result: An exception occurred") view?.showContent(true) errorHandler.dispatch(it) })) diff --git a/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt b/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt index 5c661f1a..ef269ec7 100644 --- a/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt +++ b/app/src/play/java/io/github/wulkanowy/utils/CrashlyticsUtils.kt @@ -7,6 +7,9 @@ import com.crashlytics.android.core.CrashlyticsCore import fr.bipi.tressence.crash.CrashlyticsLogExceptionTree import fr.bipi.tressence.crash.CrashlyticsLogTree import io.fabric.sdk.android.Fabric +import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException +import java.net.UnknownHostException fun initCrashlytics(context: Context, appInfo: AppInfo) { Fabric.with(Fabric.Builder(context) @@ -21,6 +24,13 @@ fun initCrashlytics(context: Context, appInfo: AppInfo) { .build()) } -class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE) +class CrashlyticsTree : CrashlyticsLogTree(Log.VERBOSE) { + + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + if (t is FeatureDisabledException || t is FeatureNotAvailableException || t is UnknownHostException) return + + super.log(priority, tag, message, t) + } +} class CrashlyticsExceptionTree : CrashlyticsLogExceptionTree() From 366ebc781d9f92bb85d40c862936e9bdfacb4267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 19 Apr 2020 23:20:55 +0200 Subject: [PATCH 07/10] Add error message and bug report button to error dialog (#778) --- .../github/wulkanowy/ui/base/ErrorDialog.kt | 45 ++++++++++++++-- .../github/wulkanowy/ui/base/ErrorHandler.kt | 24 ++------- .../wulkanowy/ui/modules/main/MainModule.kt | 7 ++- .../wulkanowy/utils/ResourcesExtension.kt | 20 +++++++ app/src/main/res/layout/dialog_error.xml | 52 ++++++++++++++++--- app/src/main/res/values-pl/strings.xml | 2 +- 6 files changed, 118 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/io/github/wulkanowy/utils/ResourcesExtension.kt diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt index 3255ea68..37418113 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorDialog.kt @@ -6,19 +6,32 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.HorizontalScrollView import android.widget.Toast import android.widget.Toast.LENGTH_LONG import androidx.core.content.getSystemService -import androidx.fragment.app.DialogFragment import io.github.wulkanowy.R +import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException +import io.github.wulkanowy.sdk.exception.ServiceUnavailableException +import io.github.wulkanowy.utils.AppInfo +import io.github.wulkanowy.utils.getString +import io.github.wulkanowy.utils.openEmailClient +import io.github.wulkanowy.utils.openInternetBrowser import kotlinx.android.synthetic.main.dialog_error.* import java.io.PrintWriter import java.io.StringWriter +import java.net.SocketTimeoutException +import java.net.UnknownHostException +import javax.inject.Inject -class ErrorDialog : DialogFragment() { +class ErrorDialog : BaseDialogFragment() { private lateinit var error: Throwable + @Inject + lateinit var appInfo: AppInfo + companion object { private const val ARGUMENT_KEY = "Data" @@ -49,6 +62,9 @@ class ErrorDialog : DialogFragment() { } errorDialogContent.text = stringWriter.toString() + with(errorDialogHorizontalScroll) { + post { fullScroll(HorizontalScrollView.FOCUS_LEFT) } + } errorDialogCopy.setOnClickListener { val clip = ClipData.newPlainText("wulkanowy", stringWriter.toString()) activity?.getSystemService()?.setPrimaryClip(clip) @@ -56,6 +72,29 @@ class ErrorDialog : DialogFragment() { Toast.makeText(context, R.string.all_copied, LENGTH_LONG).show() } errorDialogCancel.setOnClickListener { dismiss() } + errorDialogReport.setOnClickListener { openEmailClient(stringWriter.toString()) } + errorDialogMessage.text = resources.getString(error) + errorDialogReport.isEnabled = when (error) { + is UnknownHostException, + is SocketTimeoutException, + is ServiceUnavailableException, + is FeatureDisabledException, + is FeatureNotAvailableException -> false + else -> true + } + } + + private fun openEmailClient(content: String) { + requireContext().openEmailClient( + chooserTitle = getString(R.string.about_feedback), + email = "wulkanowyinc@gmail.com", + subject = "Zgłoszenie błędu", + body = requireContext().getString(R.string.about_feedback_template, + "${appInfo.systemManufacturer} ${appInfo.systemModel}", appInfo.systemVersion.toString(), appInfo.versionName + ) + "\n" + content, + onActivityNotFound = { + requireContext().openInternetBrowser("https://github.com/wulkanowy/wulkanowy/issues", ::showMessage) + } + ) } } - diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorHandler.kt b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorHandler.kt index 34dc3418..f746b36f 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/ErrorHandler.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/ErrorHandler.kt @@ -2,17 +2,11 @@ package io.github.wulkanowy.ui.base import android.content.res.Resources import com.chuckerteam.chucker.api.ChuckerCollector -import io.github.wulkanowy.R import io.github.wulkanowy.data.exceptions.NoCurrentStudentException import io.github.wulkanowy.sdk.exception.BadCredentialsException -import io.github.wulkanowy.sdk.exception.FeatureDisabledException -import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException -import io.github.wulkanowy.sdk.exception.NotLoggedInException -import io.github.wulkanowy.sdk.exception.ServiceUnavailableException +import io.github.wulkanowy.utils.getString import io.github.wulkanowy.utils.security.ScramblerException import timber.log.Timber -import java.net.SocketTimeoutException -import java.net.UnknownHostException import javax.inject.Inject open class ErrorHandler @Inject constructor(protected val resources: Resources, private val chuckerCollector: ChuckerCollector) { @@ -30,18 +24,10 @@ open class ErrorHandler @Inject constructor(protected val resources: Resources, } protected open fun proceed(error: Throwable) { - resources.run { - when (error) { - is UnknownHostException -> showErrorMessage(getString(R.string.error_no_internet), error) - is SocketTimeoutException -> showErrorMessage(getString(R.string.error_timeout), error) - is NotLoggedInException -> showErrorMessage(getString(R.string.error_login_failed), error) - is ServiceUnavailableException -> showErrorMessage(getString(R.string.error_service_unavailable), error) - is FeatureDisabledException -> showErrorMessage(getString(R.string.error_feature_disabled), error) - is ScramblerException, is BadCredentialsException -> onSessionExpired() - is NoCurrentStudentException -> onNoCurrentStudent() - is FeatureNotAvailableException -> showErrorMessage(getString(R.string.error_feature_not_available), error) - else -> showErrorMessage(getString(R.string.error_unknown), error) - } + when (error) { + is ScramblerException, is BadCredentialsException -> onSessionExpired() + is NoCurrentStudentException -> onNoCurrentStudent() + else -> showErrorMessage(resources.getString(error), error) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt index e87e260f..b533684d 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainModule.kt @@ -7,6 +7,7 @@ import dagger.Provides import dagger.android.ContributesAndroidInjector import io.github.wulkanowy.R import io.github.wulkanowy.di.scopes.PerFragment +import io.github.wulkanowy.ui.base.ErrorDialog import io.github.wulkanowy.ui.modules.about.AboutFragment import io.github.wulkanowy.ui.modules.about.contributor.ContributorFragment import io.github.wulkanowy.ui.modules.about.license.LicenseFragment @@ -115,6 +116,10 @@ abstract class MainModule { @ContributesAndroidInjector abstract fun bindAccountDialog(): AccountDialog + @PerFragment + @ContributesAndroidInjector + abstract fun bindErrorDialog(): ErrorDialog + @PerFragment @ContributesAndroidInjector(modules = [MobileDeviceModule::class]) abstract fun bindMobileDevices(): MobileDeviceFragment @@ -132,7 +137,7 @@ abstract class MainModule { abstract fun bindLogViewerFragment(): LogViewerFragment @PerFragment - @ContributesAndroidInjector() + @ContributesAndroidInjector abstract fun bindContributorFragment(): ContributorFragment @PerFragment diff --git a/app/src/main/java/io/github/wulkanowy/utils/ResourcesExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/ResourcesExtension.kt new file mode 100644 index 00000000..9744d374 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/utils/ResourcesExtension.kt @@ -0,0 +1,20 @@ +package io.github.wulkanowy.utils + +import android.content.res.Resources +import io.github.wulkanowy.R +import io.github.wulkanowy.sdk.exception.FeatureDisabledException +import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException +import io.github.wulkanowy.sdk.exception.NotLoggedInException +import io.github.wulkanowy.sdk.exception.ServiceUnavailableException +import java.net.SocketTimeoutException +import java.net.UnknownHostException + +fun Resources.getString(error: Throwable) = when (error) { + is UnknownHostException -> getString(R.string.error_no_internet) + is SocketTimeoutException -> getString(R.string.error_timeout) + is NotLoggedInException -> getString(R.string.error_login_failed) + is ServiceUnavailableException -> getString(R.string.error_service_unavailable) + is FeatureDisabledException -> getString(R.string.error_feature_disabled) + is FeatureNotAvailableException -> getString(R.string.error_feature_not_available) + else -> getString(R.string.error_unknown) +} diff --git a/app/src/main/res/layout/dialog_error.xml b/app/src/main/res/layout/dialog_error.xml index ec25f6a4..ac2c542a 100644 --- a/app/src/main/res/layout/dialog_error.xml +++ b/app/src/main/res/layout/dialog_error.xml @@ -1,26 +1,49 @@ - + + + + + android:overScrollMode="ifContentScrolls" + app:layout_constrainedHeight="true" + app:layout_constraintHeight_max="300dp" + app:layout_constraintHeight_min="200dp" + app:layout_constraintTop_toTopOf="parent"> - + + + + + - \ No newline at end of file + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 9cd65272..d179d9e4 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -421,5 +421,5 @@ Trwa przerwa techniczna dziennika UONET+. Spróbuj ponownie później Wystąpił nieoczekiwany błąd Funkcja wyłączona przez szkołę - Funkcja niedostępna. Zaloguj się w innym trybie niż Mobilne API + Funkcja niedostępna. Zaloguj się w trybie innym niż Mobilne API From 9b18e3669d5f07778fcc775d0d0736740c8683e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 19 Apr 2020 23:21:25 +0200 Subject: [PATCH 08/10] Fix crash after send message when activity is in background (#777) --- .../wulkanowy/ui/modules/message/send/SendMessageActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt index 7b15da71..232b05d7 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/message/send/SendMessageActivity.kt @@ -147,7 +147,7 @@ class SendMessageActivity : BaseActivity(), SendMessageVie } override fun popView() { - onBackPressed() + finish() } private fun setUpExtendedHitArea() { From 9c0e2dc5333a8cbaafe685d6ca161dd38fc28f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 19 Apr 2020 23:21:59 +0200 Subject: [PATCH 09/10] =?UTF-8?q?Refresh=20semesters=20if=20previous=20lis?= =?UTF-8?q?t=20was=20downloaded=20in=20different=20m=E2=80=A6=20(#776)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../semester/SemesterRepository.kt | 11 +-- .../data/repositories/student/StudentLocal.kt | 2 +- .../semester/SemesterRepositoryTest.kt | 70 ++++++++++++++----- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/semester/SemesterRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/semester/SemesterRepository.kt index dd702b3e..68946bee 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/semester/SemesterRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/semester/SemesterRepository.kt @@ -4,6 +4,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student +import io.github.wulkanowy.sdk.Sdk import io.github.wulkanowy.utils.getCurrentOrLast import io.github.wulkanowy.utils.isCurrent import io.github.wulkanowy.utils.uniqueSubtract @@ -20,10 +21,12 @@ class SemesterRepository @Inject constructor( ) { fun getSemesters(student: Student, forceRefresh: Boolean = false, refreshOnNoCurrent: Boolean = false): Single> { - return local.getSemesters(student).filter { !forceRefresh }.filter { - if (refreshOnNoCurrent) { - it.any { semester -> semester.isCurrent } - } else true + return local.getSemesters(student).filter { !forceRefresh }.filter { semesters -> + when { + Sdk.Mode.valueOf(student.loginMode) != Sdk.Mode.API -> semesters.firstOrNull { it.isCurrent }?.diaryId != 0 + refreshOnNoCurrent -> semesters.any { semester -> semester.isCurrent } + else -> true + } }.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { if (it) remote.getSemesters(student) diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt index c7a46e9d..06b9bb4a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt @@ -29,7 +29,7 @@ class StudentLocal @Inject constructor( fun getStudents(decryptPass: Boolean): Maybe> { return studentDb.loadAll() - .map { list -> list.map { it.apply { if (decryptPass) password = decrypt(password) } } } + .map { list -> list.map { it.apply { if (decryptPass && Sdk.Mode.valueOf(loginMode) != Sdk.Mode.API) password = decrypt(password) } } } .filter { it.isNotEmpty() } } diff --git a/app/src/test/java/io/github/wulkanowy/data/repositories/semester/SemesterRepositoryTest.kt b/app/src/test/java/io/github/wulkanowy/data/repositories/semester/SemesterRepositoryTest.kt index af872c57..58c94ab6 100644 --- a/app/src/test/java/io/github/wulkanowy/data/repositories/semester/SemesterRepositoryTest.kt +++ b/app/src/test/java/io/github/wulkanowy/data/repositories/semester/SemesterRepositoryTest.kt @@ -8,6 +8,7 @@ import io.github.wulkanowy.data.repositories.createSemesterEntity import io.reactivex.Maybe import io.reactivex.Single import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals import org.junit.Before import org.junit.Test import org.mockito.Mock @@ -37,13 +38,14 @@ class SemesterRepositoryTest { fun initTest() { MockitoAnnotations.initMocks(this) semesterRepository = SemesterRepository(semesterRemote, semesterLocal, settings) + doReturn("SCRAPPER").`when`(student).loginMode } @Test fun getSemesters_noSemesters() { val semesters = listOf( - createSemesterEntity(0, 0, now().minusMonths(6), now().minusMonths(3)), - createSemesterEntity(0, 0, now().minusMonths(3), now()) + createSemesterEntity(1, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(1, 2, now().minusMonths(3), now()) ) doReturn(Maybe.empty()).`when`(semesterLocal).getSemesters(student) @@ -55,11 +57,47 @@ class SemesterRepositoryTest { verify(semesterLocal).saveSemesters(semesters) } + @Test + fun getSemesters_invalidDiary_api() { + doReturn("API").`when`(student).loginMode + val badSemesters = listOf( + createSemesterEntity(0, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(0, 2, now().minusMonths(3), now()) + ) + + doReturn(Maybe.just(badSemesters)).`when`(semesterLocal).getSemesters(student) + + val items = semesterRepository.getSemesters(student).blockingGet() + assertEquals(2, items.size) + assertEquals(0, items[0].diaryId) + } + + @Test + fun getSemesters_invalidDiary_scrapper() { + doReturn("SCRAPPER").`when`(student).loginMode + val badSemesters = listOf( + createSemesterEntity(0, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(0, 2, now().minusMonths(3), now()) + ) + + val goodSemesters = listOf( + createSemesterEntity(1, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(1, 2, now().minusMonths(3), now()) + ) + + doReturn(Maybe.just(badSemesters), Maybe.just(badSemesters), Maybe.just(goodSemesters)).`when`(semesterLocal).getSemesters(student) + doReturn(Single.just(goodSemesters)).`when`(semesterRemote).getSemesters(student) + + val items = semesterRepository.getSemesters(student).blockingGet() + assertEquals(2, items.size) + assertNotEquals(0, items[0].diaryId) + } + @Test fun getSemesters_noCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now().minusMonths(12), now().minusMonths(6)), - createSemesterEntity(0, 0, now().minusMonths(6), now().minusMonths(1)) + createSemesterEntity(1, 1, now().minusMonths(12), now().minusMonths(6)), + createSemesterEntity(1, 2, now().minusMonths(6), now().minusMonths(1)) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) @@ -71,8 +109,8 @@ class SemesterRepositoryTest { @Test fun getSemesters_oneCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now().minusMonths(6), now().minusMonths(3)), - createSemesterEntity(0, 0, now().minusMonths(3), now()) + createSemesterEntity(1, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(1, 2, now().minusMonths(3), now()) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) @@ -84,8 +122,8 @@ class SemesterRepositoryTest { @Test fun getSemesters_doubleCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now(), now()), - createSemesterEntity(0, 0, now(), now()) + createSemesterEntity(1, 1, now(), now()), + createSemesterEntity(1, 2, now(), now()) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) @@ -97,8 +135,8 @@ class SemesterRepositoryTest { @Test fun getSemesters_noSemesters_refreshOnNoCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now().minusMonths(6), now().minusMonths(3)), - createSemesterEntity(0, 0, now().minusMonths(3), now()) + createSemesterEntity(1, 1, now().minusMonths(6), now().minusMonths(3)), + createSemesterEntity(1, 2, now().minusMonths(3), now()) ) doReturn(Maybe.empty()).`when`(semesterLocal).getSemesters(student) @@ -113,8 +151,8 @@ class SemesterRepositoryTest { @Test fun getSemesters_noCurrent_refreshOnNoCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now().minusMonths(12), now().minusMonths(6)), - createSemesterEntity(0, 0, now().minusMonths(6), now().minusMonths(1)) + createSemesterEntity(1, 1, now().minusMonths(12), now().minusMonths(6)), + createSemesterEntity(1, 2, now().minusMonths(6), now().minusMonths(1)) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) @@ -127,8 +165,8 @@ class SemesterRepositoryTest { @Test fun getSemesters_doubleCurrent_refreshOnNoCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now(), now()), - createSemesterEntity(0, 0, now(), now()) + createSemesterEntity(1, 1, now(), now()), + createSemesterEntity(1, 2, now(), now()) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) @@ -140,8 +178,8 @@ class SemesterRepositoryTest { @Test(expected = IllegalArgumentException::class) fun getCurrentSemester_doubleCurrent() { val semesters = listOf( - createSemesterEntity(0, 0, now(), now()), - createSemesterEntity(0, 0, now(), now()) + createSemesterEntity(1, 1, now(), now()), + createSemesterEntity(1, 1, now(), now()) ) doReturn(Maybe.just(semesters)).`when`(semesterLocal).getSemesters(student) From c1ffc2ae72c6f8d8fc4095ba191ae86d681c1389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Sun, 19 Apr 2020 23:37:29 +0200 Subject: [PATCH 10/10] Version 0.17.2 --- .travis.yml | 2 +- app/build.gradle | 6 +++--- app/src/main/play/release-notes/pl-PL/default.txt | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddd13916..0f6284a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ cache: branches: only: - develop - - 0.17.1 + - 0.17.2 android: licenses: diff --git a/app/build.gradle b/app/build.gradle index ff7bcb34..2480ff47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { testApplicationId "io.github.tests.wulkanowy" minSdkVersion 17 targetSdkVersion 29 - versionCode 55 - versionName "0.17.1" + versionCode 56 + versionName "0.17.2" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true @@ -128,7 +128,7 @@ configurations.all { } dependencies { - implementation "io.github.wulkanowy:sdk:0.17.1" + implementation "io.github.wulkanowy:sdk:0.17.2" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "androidx.core:core-ktx:1.2.0" diff --git a/app/src/main/play/release-notes/pl-PL/default.txt b/app/src/main/play/release-notes/pl-PL/default.txt index c2eca2bb..43be8682 100644 --- a/app/src/main/play/release-notes/pl-PL/default.txt +++ b/app/src/main/play/release-notes/pl-PL/default.txt @@ -1,9 +1,8 @@ -Wersja 0.17.1 +Wersja 0.17.2 -- naprawiliśmy problemy ze stabilnością w szczegółach zadania domowego i podglądzie wiadomości -- naprawiliśmy odświeżanie danych w określonych przypadkach -- naprawiliśmy odświeżanie listy urządzeń -- w trybie hybrydowym lista przedmiotów w zakładckach Klasa i Podsumowanie frekwencji powinna teraz zawierać tylko przedmioty ucznia -- na liście dzienników pokazują się teraz również te niestandardowe +- naprawiliśmy wyświetlanie przycisku oznaczania zadania domowego jako wykonanego +- naprawiliśmy rzadki błąd ze stabilnością przy wysyłaniu wiadomości +- naprawiliśmy błąd po logowaniu w domyślnym trybie, jeśli wcześniej użytkownik zalogowany był w trybie Mobilnego API +- ulepszyliśmy wygląd okienka ze szczegółami błędu Pełna lista zmian: https://github.com/wulkanowy/wulkanowy/releases