From 31f5fdbde16942dba4f0bdada3ad3482dd3bab0e Mon Sep 17 00:00:00 2001 From: Kordian Bruck Date: Fri, 22 Jan 2021 19:33:33 +0100 Subject: [PATCH] Fix logic in topnewscard, update couple of deps. --- app/build.gradle | 16 ++++++++-------- .../component/ui/news/TopNewsCard.kt | 4 +--- .../component/ui/news/TopNewsStore.kt | 2 +- .../component/ui/overview/card/Card.kt | 12 +++++++----- build.gradle | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 405c122c8e..a73ecef893 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -104,25 +104,25 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.4' // Android arch components - implementation 'androidx.room:room-rxjava2:2.3.0-alpha03' - implementation 'androidx.room:room-runtime:2.3.0-alpha03' + implementation 'androidx.room:room-rxjava2:2.3.0-alpha04' + implementation 'androidx.room:room-runtime:2.3.0-alpha04' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'android.arch.lifecycle:reactivestreams:1.1.1' implementation 'android.arch.work:work-runtime-ktx:1.0.1' implementation 'androidx.appcompat:appcompat:1.2.0' kapt 'androidx.lifecycle:lifecycle-compiler:2.2.0' - kapt 'androidx.room:room-compiler:2.3.0-alpha03' + kapt 'androidx.room:room-compiler:2.3.0-alpha04' // Play services implementation 'com.google.android.gms:play-services-base:17.5.0' implementation 'com.google.android.gms:play-services-location:17.1.0' // Firebase - implementation 'com.google.firebase:firebase-core:18.0.0' - implementation 'com.google.firebase:firebase-messaging:21.0.0' - implementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.2' - implementation 'com.google.firebase:firebase-analytics-ktx:18.0.0' + implementation 'com.google.firebase:firebase-core:18.0.1' + implementation 'com.google.firebase:firebase-messaging:21.0.1' + implementation 'com.google.firebase:firebase-crashlytics-ktx:17.3.0' + implementation 'com.google.firebase:firebase-analytics-ktx:18.0.1' // Helpers implementation 'com.google.code.gson:gson:2.8.6' @@ -182,7 +182,7 @@ dependencies { testImplementation 'junit:junit:4.13' testImplementation 'org.mockito:mockito-core:3.5.11' testImplementation 'org.assertj:assertj-core:3.17.1' - testImplementation 'androidx.room:room-testing:2.3.0-alpha03' + testImplementation 'androidx.room:room-testing:2.3.0-alpha04' testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" testImplementation 'com.android.support.test:rules:1.0.2' diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsCard.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsCard.kt index d7cf582597..3a578688ff 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsCard.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsCard.kt @@ -71,9 +71,7 @@ class TopNewsCard(context: Context) : Card(CardManager.CARD_TOP_NEWS, context, " } override fun shouldShow(prefs: SharedPreferences): Boolean { - return if (newsAlert == null) { - false - } else topNewsStore.isEnabled() && newsAlert.shouldDisplay + return newsAlert != null && topNewsStore.isEnabled() && newsAlert.shouldDisplay } public override fun discard(editor: SharedPreferences.Editor) { diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsStore.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsStore.kt index 681574ce27..55b9a7a72b 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsStore.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/news/TopNewsStore.kt @@ -62,7 +62,7 @@ class RealTopNewsStore @Inject constructor( } val displayUntil = sharedPrefs.getString(Const.NEWS_ALERT_SHOW_UNTIL, "")!! - val until: DateTime = DateTimeUtils.parseIsoDateWithMillis(displayUntil)!! + val until: DateTime? = DateTimeUtils.parseIsoDateWithMillis(displayUntil) if (until == null || until.isBeforeNow) { return null } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/Card.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/Card.kt index 1fba9c128d..cfedfe10ae 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/Card.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/overview/card/Card.kt @@ -4,6 +4,7 @@ import android.content.Context import android.content.SharedPreferences import android.content.SharedPreferences.Editor import android.preference.PreferenceManager +import android.util.Log import androidx.recyclerview.widget.DiffUtil import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.component.other.navigation.NavDestination @@ -18,9 +19,9 @@ import de.tum.`in`.tumcampusapp.utils.Utils * @param settingsPrefix Preference key prefix used for all preferences belonging to that card */ abstract class Card( - val cardType: Int, - protected var context: Context, - val settingsPrefix: String = "" + val cardType: Int, + protected var context: Context, + val settingsPrefix: String = "" ) : Comparable { // Settings for showing this card on start page or as notification @@ -111,6 +112,7 @@ abstract class Card( e.putBoolean(settingsPrefix + "_start", false) e.putBoolean(settingsPrefix + "_phone", false) e.apply() + Utils.log("Hiding card: $settingsPrefix") } override fun compareTo(other: Card): Int { @@ -125,8 +127,8 @@ abstract class Card( protected abstract fun discard(editor: Editor) class DiffCallback( - private val oldList: List, - private val newList: List + private val oldList: List, + private val newList: List ) : DiffUtil.Callback() { override fun getOldListSize() = oldList.size diff --git a/build.gradle b/build.gradle index 722037d44c..da00c1c9eb 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.4.10' + ext.kotlin_version = '1.4.21' repositories { google() jcenter() @@ -9,13 +9,13 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:4.1.1' classpath 'com.google.gms:google-services:4.3.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'org.jlleitschuh.gradle:ktlint-gradle:8.2.0' - classpath "com.github.ben-manes:gradle-versions-plugin:0.33.0" + classpath "com.github.ben-manes:gradle-versions-plugin:0.36.0" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.13.1" - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1' } }