shrinkResources now enabled; debugSymbolLevel set to SYMBOL_TABLE; StwParser.kt now fetches news from the top of the website, if any are available; fixed a bug that would cut off shadows from the largest FAB in CanteenFragment.kt

This commit is contained in:
denizk0461
2023-05-09 11:34:31 +02:00
parent 603955b53b
commit b42118ed94
5 changed files with 41 additions and 11 deletions
+4 -3
View File
@@ -12,8 +12,8 @@ android {
applicationId "com.denizk0461.weserplaner" applicationId "com.denizk0461.weserplaner"
minSdk 24 minSdk 24
targetSdk 33 targetSdk 33
versionCode 3 versionCode 4
versionName "1.0.0" versionName "1.0.1"
resourceConfigurations += ["en", "de"] resourceConfigurations += ["en", "de"]
@@ -25,11 +25,12 @@ android {
buildTypes { buildTypes {
release { release {
minifyEnabled true minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug signingConfig signingConfigs.debug
ndk { ndk {
debugSymbolLevel 'FULL' debugSymbolLevel 'SYMBOL_TABLE'
} }
} }
} }
@@ -8,6 +8,7 @@ import kotlinx.coroutines.withContext
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.select.Elements import org.jsoup.select.Elements
import java.io.IOException
import kotlin.jvm.Throws import kotlin.jvm.Throws
/** /**
@@ -156,12 +157,22 @@ class StwParser(application: Application) {
// Trim off excess line breaks // Trim off excess line breaks
openingHours = openingHours.trim() openingHours = openingHours.trim()
// Fetch news displayed at the top of the page, if any are available
val news = try {
doc.getElementsByClass("field__items")[0]
.getElementsByTag("p")[0]
.text()
} catch (e: IOException) {
""
}
// Save the canteen to its list // Save the canteen to its list
canteens.add( canteens.add(
OfferCanteen( OfferCanteen(
canteenId, canteenId,
doc.getElementsByClass("pane-title")[1].text(), doc.getElementsByClass("pane-title")[1].text(),
openingHours, openingHours,
news,
) )
) )
@@ -4,6 +4,8 @@ import android.content.Context
import androidx.room.Database import androidx.room.Database
import androidx.room.Room import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.denizk0461.weserplaner.model.* import com.denizk0461.weserplaner.model.*
/** /**
@@ -17,7 +19,7 @@ import com.denizk0461.weserplaner.model.*
OfferCategory::class, OfferCategory::class,
OfferItem::class, OfferItem::class,
], ],
version = 19, version = 20,
) )
abstract class AppDatabase : RoomDatabase() { abstract class AppDatabase : RoomDatabase() {
@@ -43,15 +45,29 @@ abstract class AppDatabase : RoomDatabase() {
*/ */
if (instance == null) { if (instance == null) {
synchronized(AppDatabase::class) { synchronized(AppDatabase::class) {
instance = Room.databaseBuilder( instance = Room
.databaseBuilder(
context.applicationContext, context.applicationContext,
AppDatabase::class.java, AppDatabase::class.java,
"event_db" "event_db",
).fallbackToDestructiveMigration().build() ).addMigrations(migrationAddNewsToOfferCanteen_19_20)
.fallbackToDestructiveMigration()
.build()
} }
} }
// Instance can never be null at this point // Instance can never be null at this point
return instance!! return instance!!
} }
// - migrations - //
/**
* Adds the column 'news' to the data object [OfferCanteen].
*/
private val migrationAddNewsToOfferCanteen_19_20 = object : Migration(19, 20) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE offer_canteen ADD COLUMN news TEXT NOT NULL DEFAULT ''")
}
}
} }
} }
@@ -9,6 +9,7 @@ import androidx.room.PrimaryKey
* @param id primary key that uniquely identifies the item * @param id primary key that uniquely identifies the item
* @param canteen name of the canteen * @param canteen name of the canteen
* @param openingHours opening hours of the canteen * @param openingHours opening hours of the canteen
* @param news news about the canteen
*/ */
@Entity( @Entity(
tableName = "offer_canteen", tableName = "offer_canteen",
@@ -17,4 +18,5 @@ data class OfferCanteen(
@PrimaryKey val id: Int, @PrimaryKey val id: Int,
val canteen: String, val canteen: String,
val openingHours: String, val openingHours: String,
val news: String,
) )
+2 -2
View File
@@ -212,8 +212,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginBottom="@dimen/fab_margin"
app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior"> app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior">
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
@@ -246,6 +244,8 @@
app:srcCompat="@drawable/refresh" app:srcCompat="@drawable/refresh"
android:contentDescription="@string/canteen_fab_refresh_content_desc" android:contentDescription="@string/canteen_fab_refresh_content_desc"
android:tooltipText="@string/canteen_fab_refresh_content_desc" android:tooltipText="@string/canteen_fab_refresh_content_desc"
android:layout_marginHorizontal="@dimen/fab_margin"
android:layout_marginBottom="@dimen/fab_margin"
tools:ignore="UnusedAttribute"/> tools:ignore="UnusedAttribute"/>
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>