mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-27 05:25:30 +01:00
Change equal to ==
This commit is contained in:
parent
68b0abfa91
commit
b6c1647476
@ -18,6 +18,7 @@ import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import com.google.android.material.badge.BadgeDrawable
|
||||
import com.google.android.material.badge.BadgeDrawable.BOTTOM_END
|
||||
@ -87,14 +88,14 @@ class AppUpdater : BroadcastReceiver() {
|
||||
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
||||
|
||||
var ftx1Index = 0
|
||||
while (ftx1Index < jsonBuilds.length() && !jsonBuilds.getJSONObject(ftx1Index).get("branch").equals(branch)) {
|
||||
while (ftx1Index < jsonBuilds.length() && jsonBuilds.getJSONObject(ftx1Index).get("branch") != branch) {
|
||||
ftx1Index++
|
||||
}
|
||||
if (ftx1Index >= jsonBuilds.length())
|
||||
ftx1Index = 0
|
||||
|
||||
val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id")
|
||||
if (!BuildConfig.GIT_HASH.equals(remoteBuildGitHash)) {
|
||||
if (BuildConfig.GIT_HASH != remoteBuildGitHash) {
|
||||
val id = jsonBuilds.getJSONObject(ftx1Index).get("id")
|
||||
val apkName = jsonBuilds.getJSONObject(ftx1Index).get("apkName")
|
||||
val uri = Uri.parse("$baseUrl/cache/${id}/${apkName}")
|
||||
@ -103,7 +104,7 @@ class AppUpdater : BroadcastReceiver() {
|
||||
builder.setTitle("New version ${jsonBuilds.getJSONObject(ftx1Index).get("runNumber")}")
|
||||
.setMessage(Html.fromHtml("<b>Changelog</b><p>${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}</p>", 0))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Update") { dialogInterface, it ->
|
||||
.setPositiveButton("Update") { dialogInterface, _ ->
|
||||
val receiver = AppUpdater()
|
||||
applicationContext.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||
receiver.downloadApk(applicationContext, uri)
|
||||
@ -115,7 +116,7 @@ class AppUpdater : BroadcastReceiver() {
|
||||
builder.setTitle("No updates available")
|
||||
.setMessage(Html.fromHtml("<b>Changelog</b><p>${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}</p>", 0))
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Close") { dialogInterface, it ->
|
||||
.setPositiveButton("Close") { dialogInterface, _ ->
|
||||
dialogInterface.dismiss()
|
||||
}.show()
|
||||
}
|
||||
@ -130,25 +131,25 @@ class AppUpdater : BroadcastReceiver() {
|
||||
@com.google.android.material.badge.ExperimentalBadgeUtils
|
||||
fun checkForUpdates2(context : Context, icon: ImageView) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val url = URL("$baseUrl/builds")
|
||||
val url = URL("$baseUrl/builds")
|
||||
try {
|
||||
val response = url.readText()
|
||||
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
||||
|
||||
var ftx1Index = 0
|
||||
while (ftx1Index < jsonBuilds.length() && !jsonBuilds.getJSONObject(ftx1Index).get("branch").equals(branch)) {
|
||||
while (ftx1Index < jsonBuilds.length() && jsonBuilds.getJSONObject(ftx1Index).get("branch") != branch) {
|
||||
ftx1Index++
|
||||
}
|
||||
if (ftx1Index >= jsonBuilds.length())
|
||||
ftx1Index = 0
|
||||
|
||||
val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id")
|
||||
if(!BuildConfig.GIT_HASH.equals(remoteBuildGitHash)){
|
||||
if(BuildConfig.GIT_HASH != remoteBuildGitHash){
|
||||
val badge = BadgeDrawable.create(context)
|
||||
badge.badgeGravity = BOTTOM_END
|
||||
badge.verticalOffset = 25
|
||||
badge.horizontalOffset = 25
|
||||
badge.backgroundColor = context.getResources().getColor(R.color.colorPrimary)
|
||||
badge.backgroundColor = ContextCompat.getColor(context, R.color.colorPrimary)
|
||||
BadgeUtils.attachBadgeDrawable(badge, icon)
|
||||
}
|
||||
} catch (e : IOException) {
|
||||
|
@ -151,7 +151,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Snackbar.make(this@MainActivity.findViewById(android.R.id.content), getString(R.string.logs_not_found), Snackbar.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
if (BuildConfig.FLAVOR.equals("edge")) {
|
||||
if (BuildConfig.FLAVOR == "edge") {
|
||||
binding.checkUpdatesIcon.visibility = View.GONE
|
||||
} else {
|
||||
AppUpdater.checkForUpdates2(context, binding.checkUpdatesIcon)
|
||||
|
Loading…
x
Reference in New Issue
Block a user