Commit 55c30347 authored by Jonas L.'s avatar Jonas L.

Refactoring

parent f6eae9e9
......@@ -21,20 +21,20 @@ class Application: Application() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val downloadChannel = NotificationChannel(
NotificationChannels.DOWNLOAD_PROGRESS,
getString(R.string.notification_channel_download_name),
NotificationManager.IMPORTANCE_DEFAULT
manager.createNotificationChannel(
NotificationChannel(
NotificationChannels.DOWNLOAD_PROGRESS,
getString(R.string.notification_channel_download_name),
NotificationManager.IMPORTANCE_DEFAULT
).apply {
description = getString(R.string.notification_channel_download_description)
setShowBadge(false)
lockscreenVisibility = Notification.VISIBILITY_PUBLIC
enableVibration(false)
enableLights(false)
setSound(null, null)
}
)
downloadChannel.description
downloadChannel.setShowBadge(false)
downloadChannel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
downloadChannel.enableVibration(false)
downloadChannel.enableLights(false)
downloadChannel.setSound(null, null)
manager.createNotificationChannel(downloadChannel)
}
}
}
\ No newline at end of file
}
......@@ -70,16 +70,11 @@ private fun readPackageSourceEntry(reader: JsonReader): PackageSourceEntry {
reader.beginObject()
while (reader.hasNext()) {
val name = reader.nextName()
if (name == "projectId") {
projectId = reader.nextString()
} else if (name == "projectUrl") {
projectUrl = reader.nextString()
} else if (name == "title") {
title = reader.nextString()
} else {
reader.skipValue()
when (reader.nextName()) {
"projectId" -> projectId = reader.nextString()
"projectUrl" -> projectUrl = reader.nextString()
"title" -> title = reader.nextString()
else -> reader.skipValue()
}
}
reader.endObject()
......
package de.determapp.android.util
object Validator {
private val idRegex = Regex("^[a-zA-Z0-9]+\$")
fun assertIdValid(id: String) {
if (!isIdValid(id)) {
throw IllegalStateException()
}
}
private fun isIdValid(id: String): Boolean {
return id.length == 16 && id.matches(Regex("^[a-zA-Z0-9]+\$"))
}
}
\ No newline at end of file
private fun isIdValid(id: String) = id.length == 16 && id.matches(idRegex)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment