mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 05:23:00 +00:00
test 3
This commit is contained in:
parent
3c6ff26e83
commit
6d24a08075
5 changed files with 19 additions and 4 deletions
|
@ -5,6 +5,7 @@ import android.app.Service
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
|
@ -28,7 +29,7 @@ class MicrogDownloadService: Service() {
|
||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
registerReceiver(receiver, null)
|
registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||||
downloadMicrog()
|
downloadMicrog()
|
||||||
stopSelf()
|
stopSelf()
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.Service
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
@ -31,6 +32,7 @@ class VancedDownloadService: Service() {
|
||||||
private var apkType: String = "arch"
|
private var apkType: String = "arch"
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
|
registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||||
downloadSplits()
|
downloadSplits()
|
||||||
stopSelf()
|
stopSelf()
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
|
|
|
@ -31,7 +31,12 @@ class URLChangeFragment : DialogFragment() {
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||||
urlField.hint = prefs.getString("install_url", baseUrl)
|
urlField.hint = prefs.getString("install_url", baseUrl)
|
||||||
view.findViewById<MaterialButton>(R.id.url_save).setOnClickListener {
|
view.findViewById<MaterialButton>(R.id.url_save).setOnClickListener {
|
||||||
prefs.edit().putString("install_url", urlField.text.toString()).apply()
|
if (urlField.text.endsWith("/"))
|
||||||
|
prefs.edit().putString("install_url", urlField.text.removeSuffix("/").toString()).apply()
|
||||||
|
|
||||||
|
if (!urlField.text.startsWith("https://"))
|
||||||
|
prefs.edit().putString("install_url", "https://${urlField.text}").apply()
|
||||||
|
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
view.findViewById<MaterialButton>(R.id.url_reset).setOnClickListener {
|
view.findViewById<MaterialButton>(R.id.url_reset).setOnClickListener {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.DOWNLOAD_SERVICE
|
import android.content.Context.DOWNLOAD_SERVICE
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -45,7 +46,7 @@ class UpdateCheckFragment : DialogFragment() {
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
activity?.registerReceiver(receiver, null)
|
activity?.registerReceiver(receiver, IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE))
|
||||||
checkUpdates()
|
checkUpdates()
|
||||||
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
||||||
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
||||||
|
|
|
@ -46,15 +46,17 @@ object InternetTools {
|
||||||
client.newCall(request).enqueue(object : Callback {
|
client.newCall(request).enqueue(object : Callback {
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
toReturn = 0
|
toReturn = 0
|
||||||
|
returnVal(toReturn)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResponse(call: Call, response: Response) {
|
override fun onResponse(call: Call, response: Response) {
|
||||||
toReturn = JSONObject(response.body?.string()!!).getInt(obj)
|
toReturn = JSONObject(response.body?.string()!!).getInt(obj)
|
||||||
|
returnVal(toReturn)
|
||||||
Log.d("VMResponse", toReturn.toString())
|
Log.d("VMResponse", toReturn.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Log.d("VMResponse", toReturn.toString())
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +82,10 @@ object InternetTools {
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun returnVal(value: Any): Any {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
fun isUpdateAvailable(): Boolean {
|
fun isUpdateAvailable(): Boolean {
|
||||||
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
|
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
|
||||||
val remoteVersion = checkUrl.get("versionCode").asInt
|
val remoteVersion = checkUrl.get("versionCode").asInt
|
||||||
|
|
Loading…
Reference in a new issue