Skip to content

Commit

Permalink
Fix image url to string (#31)
Browse files Browse the repository at this point in the history
## Goal of the PR

The goal of the PR is to make ImageUrl.rawUrl visible again. It may be
usefull for integrators that use Room or other string based data
storage.

The rawUrl is was never really hidden has an integrator can create an
`ImageUrlDecorator` that return the rawUrl.

The decision is to revert previous modifications.
  • Loading branch information
StaehliJ authored Dec 6, 2023
1 parent f28db63 commit 10f8aba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ object Config {
const val minSdk = 21

const val major = 0
const val minor = 7
const val patch = 7
const val minor = 8
const val patch = 0
const val versionName = "$major.$minor.$patch"

const val maven_group = "ch.srg.data.provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import java.io.Serializable
@kotlinx.serialization.Serializable(with = ImageUrlSerializer::class)
data class ImageUrl(
/**
* Only for internal use!
* Only for internal use! Please use a Decorator!
*
* @return the undecorated url
*/
internal val rawUrl: String
val rawUrl: String
) : Serializable {

/**
Expand All @@ -35,4 +35,9 @@ data class ImageUrl(
fun decorated(decorator: ImageUrlDecorator, widthPixels: Int): String {
return decorator.decorate(rawUrl, widthPixels)
}

@Deprecated("Using toString is not recommended in this case.", replaceWith = ReplaceWith("rawUrl"))
override fun toString(): String {
return rawUrl
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ import android.os.Build
* License information is available from the LICENSE file.
*/
object UserAgentUtils {
private const val UNKNOWN_VERSION = "?"

fun createUserAgent(application: Context): String {
var version: String
var verCode: Int
try {
val pInfo = application.packageManager.getPackageInfo(application.packageName, 0)
version = pInfo.versionName
version = pInfo.versionName ?: UNKNOWN_VERSION
verCode = pInfo.versionCode
} catch (ignored: PackageManager.NameNotFoundException) {
version = "?"
version = UNKNOWN_VERSION
verCode = 0
}
return application.packageName + " " + version + "/" + verCode + " (" + Build.MODEL + ")"
Expand Down

0 comments on commit 10f8aba

Please sign in to comment.