Skip to content

Commit

Permalink
- refactor
Browse files Browse the repository at this point in the history
- Firefox Nightly: extract build date from resource files
  • Loading branch information
Tobi823 committed Oct 6, 2024
1 parent b00b6b3 commit b2eb7e2
Show file tree
Hide file tree
Showing 35 changed files with 203 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlinx.parcelize.Parcelize
@Keep
data class LatestVersion(
val downloadUrl: String,
val version: String,
val version: Version,
val publishDate: String?,
val exactFileSizeBytesOfDownload: Long?,
val fileHash: Sha256Hash?,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.marmaro.krt.ffupdater.app.entity

import android.os.Parcelable
import androidx.annotation.Keep
import kotlinx.parcelize.Parcelize
import java.time.LocalDate

/**
* buildDate is sometimes necessary to distinguish two different versions with the same version text (see Firefox Nightly).
* Normally this value could be set.
*/
@Parcelize
@Keep
data class Version(val versionText: String, val buildDate: LocalDate?) : Parcelable {
constructor(versionText: String) : this(versionText, null)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BETTER_THAN_GOOGLE_CHROME
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI.*
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -48,9 +49,10 @@ object Brave : AppBase() {
isSuitableAsset = { it.name == fileName },
requireReleaseDescription = false,
)
val version = result.tagName.replace("v", "")
return LatestVersion(
downloadUrl = result.url,
version = result.tagName.replace("v", ""),
version = Version(version),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BETTER_THAN_GOOGLE_CHROME
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -47,9 +48,10 @@ object BraveBeta : AppBase() {
isSuitableAsset = { it.name == fileName },
requireReleaseDescription = false,
)
val version = result.tagName.replace("v", "")
return LatestVersion(
downloadUrl = result.url,
version = result.tagName.replace("v", ""),
version = Version(version),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BETTER_THAN_GOOGLE_CHROME
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -47,9 +48,10 @@ object BraveNightly : AppBase() {
isSuitableAsset = { it.name == fileName },
requireReleaseDescription = false,
)
val version = result.tagName.replace("v", "")
return LatestVersion(
downloadUrl = result.url,
version = result.tagName.replace("v", ""),
version = Version(version),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.EOL
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.GOOD_PRIVACY_BROWSER
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -51,7 +52,7 @@ object Bromite : AppBase() {
)
return LatestVersion(
downloadUrl = result.url,
version = result.tagName,
version = Version(result.tagName),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.*
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -50,7 +51,7 @@ object BromiteSystemWebView : AppBase() {
)
return LatestVersion(
downloadUrl = result.url,
version = result.tagName,
version = Version(result.tagName),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BETTER_THAN_GOOGLE_CHROME
import de.marmaro.krt.ffupdater.app.entity.InstalledAppStatus
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -50,7 +51,7 @@ object Chromium : AppBase() {
val storageObject = findStorageObject(revision, platform)
return LatestVersion(
downloadUrl = storageObject.downloadUrl,
version = revision,
version = Version(revision),
publishDate = storageObject.timestamp,
exactFileSizeBytesOfDownload = storageObject.fileSizeBytes,
fileHash = null,
Expand Down Expand Up @@ -119,7 +120,7 @@ object Chromium : AppBase() {
@SuppressLint("ApplySharedPref")
override suspend fun appWasInstalledCallback(context: Context, available: InstalledAppStatus) {
PreferenceManager.getDefaultSharedPreferences(context).edit()
.putString(INSTALLED_VERSION_REVISION, available.latestVersion.version)
.putString(INSTALLED_VERSION_REVISION, available.latestVersion.version.versionText)
.putString(INSTALLED_VERSION_TIMESTAMP, available.latestVersion.publishDate)
.commit()
// this must be called last because the update is only recognized after setting the other values
Expand All @@ -132,7 +133,7 @@ object Chromium : AppBase() {
): Boolean {
try {
val preferences = PreferenceManager.getDefaultSharedPreferences(context)
if (preferences.getString(INSTALLED_VERSION_REVISION, "-1") != available.version) {
if (preferences.getString(INSTALLED_VERSION_REVISION, "-1") != available.version.versionText) {
return true
}
if (preferences.getString(INSTALLED_VERSION_TIMESTAMP, "") != available.publishDate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -47,7 +48,7 @@ object Cromite : AppBase() {
val version = tagNameWithoutPrefix.split("-")[0]
return LatestVersion(
downloadUrl = result.url,
version = version,
version = Version(version),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BETTER_THAN_GOOGLE_CHROME
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.github.GithubConsumer

Expand Down Expand Up @@ -45,7 +46,7 @@ object DuckDuckGoAndroid : AppBase() {
)
return LatestVersion(
downloadUrl = result.url,
version = result.tagName,
version = Version(result.tagName),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.OTHER
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.github.GithubConsumer

Expand Down Expand Up @@ -44,7 +45,7 @@ object FFUpdater : AppBase() {
)
return LatestVersion(
downloadUrl = result.url,
version = result.tagName,
version = Version(result.tagName),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.OTHER
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.github.GithubConsumer

Expand Down Expand Up @@ -42,7 +43,7 @@ object FairEmail : AppBase() {
)
return LatestVersion(
downloadUrl = result.url,
version = result.tagName,
version = Version(result.tagName),
publishDate = result.releaseDate,
exactFileSizeBytesOfDownload = result.fileSizeBytes,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.BASED_ON_FIREFOX
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.GOOD_PRIVACY_BROWSER
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.ABI
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
Expand Down Expand Up @@ -42,7 +43,7 @@ object FennecFdroid : AppBase() {
val result = FdroidConsumer.getLatestUpdate(packageName, getVersionAcceptor(), context)
return LatestVersion(
downloadUrl = result.downloadUrl,
version = result.versionName,
version = Version(result.versionName),
publishDate = result.createdAt,
exactFileSizeBytesOfDownload = null,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.FROM_MOZILLA
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.website.MozillaArchiveConsumer
Expand Down Expand Up @@ -44,7 +45,7 @@ object FirefoxBeta : AppBase() {
val dateTime = MozillaArchiveConsumer.findDateTimeFromPage(page)
return LatestVersion(
downloadUrl = downloadUrl,
version = version,
version = Version(version),
publishDate = dateTime.toString(),
exactFileSizeBytesOfDownload = null,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.FROM_MOZILLA
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.website.MozillaArchiveConsumer
Expand Down Expand Up @@ -43,7 +44,7 @@ object FirefoxFocus : AppBase() {
val dateTime = MozillaArchiveConsumer.findDateTimeFromPage(page)
return LatestVersion(
downloadUrl = downloadUrl,
version = version,
version = Version(version),
publishDate = dateTime.toString(),
exactFileSizeBytesOfDownload = null,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.FROM_MOZILLA
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.website.MozillaArchiveConsumer
Expand Down Expand Up @@ -44,7 +45,7 @@ object FirefoxFocusBeta : AppBase() {
val dateTime = MozillaArchiveConsumer.findDateTimeFromPage(page)
return LatestVersion(
downloadUrl = downloadUrl,
version = version,
version = Version(version),
publishDate = dateTime.toString(),
exactFileSizeBytesOfDownload = null,
fileHash = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.DisplayCategory.FROM_MOZILLA
import de.marmaro.krt.ffupdater.app.entity.LatestVersion
import de.marmaro.krt.ffupdater.app.entity.Version
import de.marmaro.krt.ffupdater.device.DeviceAbiExtractor
import de.marmaro.krt.ffupdater.network.exceptions.NetworkException
import de.marmaro.krt.ffupdater.network.website.MozillaArchiveConsumer
Expand Down Expand Up @@ -43,7 +44,7 @@ object FirefoxKlar : AppBase() {
val dateTime = MozillaArchiveConsumer.findDateTimeFromPage(page)
return LatestVersion(
downloadUrl = downloadUrl,
version = version,
version = Version(version),
publishDate = dateTime.toString(),
exactFileSizeBytesOfDownload = null,
fileHash = null,
Expand Down
Loading

0 comments on commit b2eb7e2

Please sign in to comment.