mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-03 23:58:55 +01:00 
			
		
		
		
	Tweak the app updater logic and add FOSS build support (#1843)
This commit is contained in:
		@@ -25,7 +25,7 @@ class GetApplicationRelease(
 | 
			
		||||
            return Result.NoNewUpdate
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        val release = service.latest(arguments.repository)
 | 
			
		||||
        val release = service.latest(arguments) ?: return Result.NoNewUpdate
 | 
			
		||||
 | 
			
		||||
        lastChecked.set(now.toEpochMilli())
 | 
			
		||||
 | 
			
		||||
@@ -73,6 +73,7 @@ class GetApplicationRelease(
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    data class Arguments(
 | 
			
		||||
        val isFoss: Boolean,
 | 
			
		||||
        val isPreview: Boolean,
 | 
			
		||||
        val commitCount: Int,
 | 
			
		||||
        val versionName: String,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
package tachiyomi.domain.release.model
 | 
			
		||||
 | 
			
		||||
import android.os.Build
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Contains information about the latest release.
 | 
			
		||||
 */
 | 
			
		||||
@@ -9,27 +7,5 @@ data class Release(
 | 
			
		||||
    val version: String,
 | 
			
		||||
    val info: String,
 | 
			
		||||
    val releaseLink: String,
 | 
			
		||||
    private val assets: List<String>,
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get download link of latest release from the assets.
 | 
			
		||||
     * @return download link of latest release.
 | 
			
		||||
     */
 | 
			
		||||
    fun getDownloadLink(): String {
 | 
			
		||||
        val apkVariant = when (Build.SUPPORTED_ABIS[0]) {
 | 
			
		||||
            "arm64-v8a" -> "-arm64-v8a"
 | 
			
		||||
            "armeabi-v7a" -> "-armeabi-v7a"
 | 
			
		||||
            "x86" -> "-x86"
 | 
			
		||||
            "x86_64" -> "-x86_64"
 | 
			
		||||
            else -> ""
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return assets.find { it.contains("mihon$apkVariant-") } ?: assets[0]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Assets class containing download url.
 | 
			
		||||
     */
 | 
			
		||||
    data class Assets(val downloadLink: String)
 | 
			
		||||
}
 | 
			
		||||
    val downloadLink: String,
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,9 @@
 | 
			
		||||
package tachiyomi.domain.release.service
 | 
			
		||||
 | 
			
		||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
 | 
			
		||||
import tachiyomi.domain.release.model.Release
 | 
			
		||||
 | 
			
		||||
interface ReleaseService {
 | 
			
		||||
 | 
			
		||||
    suspend fun latest(repository: String): Release
 | 
			
		||||
    suspend fun latest(arguments: GetApplicationRelease.Arguments): Release?
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user