Skip to content

Commit

Permalink
Fix compiler and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed May 3, 2024
1 parent 37bf5ec commit 8e546f7
Show file tree
Hide file tree
Showing 46 changed files with 218 additions and 185 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Add place directions
- Add share location button
- Add companion app warnings for the minority of places which require it
- Fix crashes during sync

## [0.7.2] - 2023-04-26

Expand Down
30 changes: 15 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java.net.URL
import java.net.URI

plugins {
alias(libs.plugins.android.application)
Expand All @@ -18,12 +18,12 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.DelicateCoroutinesApi"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
}
Expand Down Expand Up @@ -100,20 +100,20 @@ tasks.register("bundleData") {
val destDir = File(projectDir, "src/main/assets")
destDir.mkdirs()

val elementsSrc = URL("https://static.btcmap.org/api/v3/elements.json")
File(destDir, "elements.json").writeText(elementsSrc.readText())
val elementsSrc = URI("https://static.btcmap.org/api/v3/elements.json")
File(destDir, "elements.json").writeText(elementsSrc.toURL().readText())

val reportsSrc = URL("https://static.btcmap.org/api/v2/reports.json")
File(destDir, "reports.json").writeText(reportsSrc.readText())
val reportsSrc = URI("https://static.btcmap.org/api/v2/reports.json")
File(destDir, "reports.json").writeText(reportsSrc.toURL().readText())

val eventsSrc = URL("https://static.btcmap.org/api/v2/events.json")
File(destDir, "events.json").writeText(eventsSrc.readText())
val eventsSrc = URI("https://static.btcmap.org/api/v2/events.json")
File(destDir, "events.json").writeText(eventsSrc.toURL().readText())

val areasSrc = URL("https://static.btcmap.org/api/v2/areas.json")
File(destDir, "areas.json").writeText(areasSrc.readText())
val areasSrc = URI("https://static.btcmap.org/api/v2/areas.json")
File(destDir, "areas.json").writeText(areasSrc.toURL().readText())

val usersSrc = URL("https://static.btcmap.org/api/v2/users.json")
File(destDir, "users.json").writeText(usersSrc.readText())
val usersSrc = URI("https://static.btcmap.org/api/v2/users.json")
File(destDir, "users.json").writeText(usersSrc.toURL().readText())
}
}

Expand All @@ -124,6 +124,7 @@ dependencies {
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.preference.ktx)
implementation(libs.androidx.sqlite.ktx)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.androidx.constraintlayout)

implementation(libs.material)
Expand All @@ -137,7 +138,6 @@ dependencies {
implementation(libs.sqlite)
implementation(libs.coil.core)
implementation(libs.coil.svg)
implementation(libs.androidx.work.runtime.ktx)

testImplementation(libs.junit)
testImplementation(libs.json)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<application
android:name="app.App"
android:allowBackup="false"
android:dataExtractionRules="@xml/backup_rules"
android:fullBackupContent="false"
android:icon="@drawable/launcher"
android:label="@string/app_name"
android:supportsRtl="true"
Expand Down
119 changes: 51 additions & 68 deletions app/src/main/kotlin/element/ElementQueries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,17 @@ class ElementQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += Element(
id = cursor.getLong(0),
osmId = cursor.getString(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
osmJson = cursor.getJsonObject(4),
tags = cursor.getJsonObject(5),
updatedAt = cursor.getString(6)!!,
deletedAt = cursor.getStringOrNull(7),
add(
Element(
id = cursor.getLong(0),
osmId = cursor.getString(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
osmJson = cursor.getJsonObject(4),
tags = cursor.getJsonObject(5),
updatedAt = cursor.getString(6)!!,
deletedAt = cursor.getStringOrNull(7),
)
)
}
}
Expand All @@ -190,15 +192,17 @@ class ElementQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += Element(
id = cursor.getLong(0),
osmId = cursor.getString(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
osmJson = cursor.getJsonObject(4),
tags = cursor.getJsonObject(5),
updatedAt = cursor.getString(6)!!,
deletedAt = cursor.getStringOrNull(7),
add(
Element(
id = cursor.getLong(0),
osmId = cursor.getString(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
osmJson = cursor.getJsonObject(4),
tags = cursor.getJsonObject(5),
updatedAt = cursor.getString(6)!!,
deletedAt = cursor.getStringOrNull(7),
)
)
}
}
Expand Down Expand Up @@ -243,14 +247,16 @@ class ElementQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += ElementsCluster(
count = 1,
id = cursor.getLong(0),
lat = cursor.getDouble(1),
lon = cursor.getDouble(2),
iconId = cursor.getString(3),
boostExpires = cursor.getZonedDateTime(4),
requiresCompanionApp = (cursor.getStringOrNull(5) ?: "no") == "yes"
add(
ElementsCluster(
count = 1,
id = cursor.getLong(0),
lat = cursor.getDouble(1),
lon = cursor.getDouble(2),
iconId = cursor.getString(3),
boostExpires = cursor.getZonedDateTime(4),
requiresCompanionApp = (cursor.getStringOrNull(5) ?: "no") == "yes"
)
)
}
}
Expand Down Expand Up @@ -284,14 +290,16 @@ class ElementQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += ElementsCluster(
count = cursor.getLong(0),
id = cursor.getLong(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
iconId = cursor.getString(4),
boostExpires = cursor.getZonedDateTime(5),
requiresCompanionApp = (cursor.getStringOrNull(6) ?: "no") == "yes"
add(
ElementsCluster(
count = cursor.getLong(0),
id = cursor.getLong(1),
lat = cursor.getDouble(2),
lon = cursor.getDouble(3),
iconId = cursor.getString(4),
boostExpires = cursor.getZonedDateTime(5),
requiresCompanionApp = (cursor.getStringOrNull(6) ?: "no") == "yes"
)
)
}
}
Expand Down Expand Up @@ -332,43 +340,18 @@ class ElementQueries(private val db: SQLiteOpenHelper) {
),
)

buildList {
while (cursor.moveToNext()) {
this += AreaElement(
id = cursor.getLong(0),
lat = cursor.getDouble(1),
lon = cursor.getDouble(2),
icon = cursor.getString(3),
osmTags = cursor.getJsonObject(4),
issues = cursor.getJsonArray(5),
osmType = cursor.getString(6),
osmId = cursor.getLong(7),
)
}
}
}
}

suspend fun selectCategories(): List<ElementCategory> {
return withContext(Dispatchers.IO) {
val cursor = db.readableDatabase.query(
"""
SELECT
json_extract(tags, '$.category') AS category,
count(*) AS elements
FROM element
WHERE deleted_at = ''
GROUP BY category
ORDER BY category;
"""
)

buildList {
while (cursor.moveToNext()) {
add(
ElementCategory(
id = cursor.getString(0),
elements = cursor.getLong(1),
AreaElement(
id = cursor.getLong(0),
lat = cursor.getDouble(1),
lon = cursor.getDouble(2),
icon = cursor.getString(3),
osmTags = cursor.getJsonObject(4),
issues = cursor.getJsonArray(5),
osmType = cursor.getString(6),
osmId = cursor.getLong(7),
)
)
}
Expand Down
36 changes: 20 additions & 16 deletions app/src/main/kotlin/event/EventQueries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ class EventQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += EventListItem(
eventType = cursor.getString(0),
elementId = cursor.getLong(1),
osmId = cursor.getStringOrNull(2) ?: "",
elementName = cursor.getStringOrNull(3) ?: "",
eventDate = cursor.getZonedDateTime(4)!!,
userName = cursor.getString(5),
userTips = getLnUrl(cursor.getString(6)),
add(
EventListItem(
eventType = cursor.getString(0),
elementId = cursor.getLong(1),
osmId = cursor.getStringOrNull(2) ?: "",
elementName = cursor.getStringOrNull(3) ?: "",
eventDate = cursor.getZonedDateTime(4)!!,
userName = cursor.getString(5),
userTips = getLnUrl(cursor.getString(6)),
)
)
}
}
Expand Down Expand Up @@ -102,14 +104,16 @@ class EventQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += EventListItem(
eventType = cursor.getString(0),
elementId = cursor.getLong(1),
osmId = cursor.getStringOrNull(2) ?: "",
elementName = cursor.getStringOrNull(3) ?: "",
eventDate = cursor.getZonedDateTime(4)!!,
userName = "",
userTips = "",
add(
EventListItem(
eventType = cursor.getString(0),
elementId = cursor.getLong(1),
osmId = cursor.getStringOrNull(2) ?: "",
elementName = cursor.getStringOrNull(3) ?: "",
eventDate = cursor.getZonedDateTime(4)!!,
userName = "",
userTips = "",
)
)
}
}
Expand Down
16 changes: 9 additions & 7 deletions app/src/main/kotlin/reports/ReportQueries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ class ReportQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += Report(
areaId = cursor.getString(0),
date = cursor.getDate(1),
tags = cursor.getJsonObject(2),
createdAt = cursor.getZonedDateTime(3)!!,
updatedAt = cursor.getZonedDateTime(4)!!,
deletedAt = cursor.getZonedDateTime(5),
add(
Report(
areaId = cursor.getString(0),
date = cursor.getDate(1),
tags = cursor.getJsonObject(2),
createdAt = cursor.getZonedDateTime(3)!!,
updatedAt = cursor.getZonedDateTime(4)!!,
deletedAt = cursor.getZonedDateTime(5),
)
)
}
}
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/kotlin/user/UserQueries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ data class UserQueries(private val db: SQLiteOpenHelper) {

buildList {
while (cursor.moveToNext()) {
this += UserListItem(
id = cursor.getLong(0),
image = cursor.getHttpUrl(1),
name = cursor.getString(2),
tips = getLnUrl(cursor.getString(3)),
changes = cursor.getLong(4),
add(
UserListItem(
id = cursor.getLong(0),
image = cursor.getHttpUrl(1),
name = cursor.getString(2),
tips = getLnUrl(cursor.getString(3)),
changes = cursor.getLong(4),
)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_reports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Percentage of verified places"
android:text="@string/percentage_of_verified_places"
android:textAppearance="?attr/textAppearanceHeadline6" />

</LinearLayout>
Expand Down Expand Up @@ -165,7 +165,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Days since verified"
android:text="@string/days_since_verified"
android:textAppearance="?attr/textAppearanceHeadline6" />

</LinearLayout>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_area.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:baselineAligned="false"
android:gravity="center_vertical">
android:gravity="center_vertical"
tools:ignore="Overdraw">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/icon"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_area_element.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="1dp">
android:paddingTop="1dp"
tools:ignore="UseCompoundDrawables">

<ImageView
android:id="@+id/checkmark"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<string name="verify">Verify or Report</string>
<string name="atm">ATM</string>
<string name="checkmark_icon">Checkmark icon</string>
<string name="fetching_recent_changes">Fetching recent changes</string>
<string name="database">Database</string>
<string name="updated_s">Updated: %1$s</string>
<string name="database_is_empty">Database is empty</string>
Expand All @@ -45,7 +44,6 @@
<string name="category_cafe_plural">Cafes</string>
<string name="category_hotel">Hotel</string>
<string name="category_hotel_plural">Hotels</string>
<string name="category_other">Other</string>
<string name="category_other_plural">Other</string>
<string name="category_pub">Pub</string>
<string name="category_pub_plural">Pubs</string>
Expand All @@ -65,6 +63,8 @@
<string name="share">Share</string>
<string name="unknown">unknown</string>
<string name="companion_warning">You\'ll need a companion app (%1$s) in order to make a payment. This app doesn\'t require you to fill any personal data, to the best of our knowledge. Please let us know if it\'s not the case and we\'ll remove this place.</string>
<string name="percentage_of_verified_places">Percentage of verified places</string>
<string name="days_since_verified">Days since verified</string>
<plurals name="d_changes">
<item quantity="one">%d change</item>
<item quantity="other">%d changes</item>
Expand Down
Loading

0 comments on commit 8e546f7

Please sign in to comment.