mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-02-05 08:46:28 +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 android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.ContextCompat.startActivity
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import com.google.android.material.badge.BadgeDrawable
|
import com.google.android.material.badge.BadgeDrawable
|
||||||
import com.google.android.material.badge.BadgeDrawable.BOTTOM_END
|
import com.google.android.material.badge.BadgeDrawable.BOTTOM_END
|
||||||
@ -87,14 +88,14 @@ class AppUpdater : BroadcastReceiver() {
|
|||||||
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
||||||
|
|
||||||
var ftx1Index = 0
|
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++
|
ftx1Index++
|
||||||
}
|
}
|
||||||
if (ftx1Index >= jsonBuilds.length())
|
if (ftx1Index >= jsonBuilds.length())
|
||||||
ftx1Index = 0
|
ftx1Index = 0
|
||||||
|
|
||||||
val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id")
|
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 id = jsonBuilds.getJSONObject(ftx1Index).get("id")
|
||||||
val apkName = jsonBuilds.getJSONObject(ftx1Index).get("apkName")
|
val apkName = jsonBuilds.getJSONObject(ftx1Index).get("apkName")
|
||||||
val uri = Uri.parse("$baseUrl/cache/${id}/${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")}")
|
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))
|
.setMessage(Html.fromHtml("<b>Changelog</b><p>${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}</p>", 0))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton("Update") { dialogInterface, it ->
|
.setPositiveButton("Update") { dialogInterface, _ ->
|
||||||
val receiver = AppUpdater()
|
val receiver = AppUpdater()
|
||||||
applicationContext.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
applicationContext.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||||
receiver.downloadApk(applicationContext, uri)
|
receiver.downloadApk(applicationContext, uri)
|
||||||
@ -115,7 +116,7 @@ class AppUpdater : BroadcastReceiver() {
|
|||||||
builder.setTitle("No updates available")
|
builder.setTitle("No updates available")
|
||||||
.setMessage(Html.fromHtml("<b>Changelog</b><p>${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}</p>", 0))
|
.setMessage(Html.fromHtml("<b>Changelog</b><p>${jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("message")}</p>", 0))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton("Close") { dialogInterface, it ->
|
.setPositiveButton("Close") { dialogInterface, _ ->
|
||||||
dialogInterface.dismiss()
|
dialogInterface.dismiss()
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
@ -130,25 +131,25 @@ class AppUpdater : BroadcastReceiver() {
|
|||||||
@com.google.android.material.badge.ExperimentalBadgeUtils
|
@com.google.android.material.badge.ExperimentalBadgeUtils
|
||||||
fun checkForUpdates2(context : Context, icon: ImageView) {
|
fun checkForUpdates2(context : Context, icon: ImageView) {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
val url = URL("$baseUrl/builds")
|
val url = URL("$baseUrl/builds")
|
||||||
try {
|
try {
|
||||||
val response = url.readText()
|
val response = url.readText()
|
||||||
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
val jsonBuilds = JSONTokener(response).nextValue() as JSONArray
|
||||||
|
|
||||||
var ftx1Index = 0
|
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++
|
ftx1Index++
|
||||||
}
|
}
|
||||||
if (ftx1Index >= jsonBuilds.length())
|
if (ftx1Index >= jsonBuilds.length())
|
||||||
ftx1Index = 0
|
ftx1Index = 0
|
||||||
|
|
||||||
val remoteBuildGitHash = jsonBuilds.getJSONObject(ftx1Index).getJSONObject("commit").getString("id")
|
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)
|
val badge = BadgeDrawable.create(context)
|
||||||
badge.badgeGravity = BOTTOM_END
|
badge.badgeGravity = BOTTOM_END
|
||||||
badge.verticalOffset = 25
|
badge.verticalOffset = 25
|
||||||
badge.horizontalOffset = 25
|
badge.horizontalOffset = 25
|
||||||
badge.backgroundColor = context.getResources().getColor(R.color.colorPrimary)
|
badge.backgroundColor = ContextCompat.getColor(context, R.color.colorPrimary)
|
||||||
BadgeUtils.attachBadgeDrawable(badge, icon)
|
BadgeUtils.attachBadgeDrawable(badge, icon)
|
||||||
}
|
}
|
||||||
} catch (e : IOException) {
|
} 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()
|
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
|
binding.checkUpdatesIcon.visibility = View.GONE
|
||||||
} else {
|
} else {
|
||||||
AppUpdater.checkForUpdates2(context, binding.checkUpdatesIcon)
|
AppUpdater.checkForUpdates2(context, binding.checkUpdatesIcon)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user