-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for latestTestVersion (#10)
- Loading branch information
1 parent
e444dd7
commit f492307
Showing
10 changed files
with
172 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
versioncheckkotlin/src/main/java/com/steamclock/versioncheckkotlin/VersionCheckConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
package com.steamclock.versioncheckkotlin | ||
|
||
import com.steamclock.versioncheckkotlin.interfaces.DefaultVersionDataConverter | ||
import com.steamclock.versioncheckkotlin.interfaces.NetworkURLFetcher | ||
import com.steamclock.versioncheckkotlin.interfaces.URLFetcher | ||
import com.steamclock.versioncheckkotlin.interfaces.VersionDataConverter | ||
import com.steamclock.versioncheckkotlin.interfaces.* | ||
|
||
data class VersionCheckConfig( | ||
val appVersionName: String, | ||
val appVersionCode: Int, | ||
val url: String, | ||
val urlFetcher: URLFetcher = NetworkURLFetcher, | ||
val versionDataConverter: VersionDataConverter = DefaultVersionDataConverter | ||
val versionDataConverter: VersionDataConverter = DefaultVersionDataConverter, | ||
val packageDetails: PackageDetails? = null | ||
) |
25 changes: 25 additions & 0 deletions
25
...ncheckkotlin/src/main/java/com/steamclock/versioncheckkotlin/interfaces/PackageDetails.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.steamclock.versioncheckkotlin.interfaces | ||
|
||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
|
||
interface PackageDetails { | ||
fun wasSideLoaded(): Boolean | ||
} | ||
|
||
@Suppress("DEPRECATION") | ||
class DefaultPackageDetails(private val pm: PackageManager, private val name: String): PackageDetails { | ||
override fun wasSideLoaded(): Boolean { | ||
return try { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { | ||
val info = pm.getInstallSourceInfo(name) | ||
info.installingPackageName == null | ||
} else { | ||
val installer = pm.getInstallerPackageName(name) | ||
installer == null | ||
} | ||
} catch (e: Exception) { | ||
false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...oncheckkotlin/src/test/java/com/steamclock/versioncheckkotlin/utils/MockPackageDetails.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.steamclock.versioncheckkotlin.utils | ||
|
||
import com.steamclock.versioncheckkotlin.interfaces.PackageDetails | ||
|
||
object MockPackageDetails { | ||
object WasSideLoaded: PackageDetails { | ||
override fun wasSideLoaded() = true | ||
} | ||
|
||
object WasNotSideLoaded: PackageDetails { | ||
override fun wasSideLoaded() = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters