This commit is contained in:
X1nto 2020-06-28 22:23:33 +04:00
parent 5bbc633890
commit 588dd1ba4c
8 changed files with 24 additions and 7 deletions

View File

@ -2,12 +2,14 @@ package com.vanced.manager.core
import android.app.Application
import com.downloader.PRDownloader
import com.vanced.manager.utils.NotificationHelper.createNotifChannel
class App: Application() {
override fun onCreate() {
super.onCreate()
PRDownloader.initialize(applicationContext)
createNotifChannel(this)
}
}

View File

@ -26,7 +26,7 @@ class MicrogDownloadService: Service() {
downloadMicrog()
} catch (e: Exception) {
when (e) {
is ExecutionException, is RuntimeException -> Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
is ExecutionException, is InterruptedException -> Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
else -> throw e
}
}

View File

@ -29,7 +29,7 @@ class VancedDownloadService: Service() {
downloadSplits()
} catch (e: Exception) {
when (e) {
is ExecutionException, is RuntimeException -> Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
is ExecutionException, is InterruptedException -> Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
else -> throw e
}

View File

@ -9,7 +9,6 @@ import android.view.ViewGroup
import android.widget.EditText
import androidx.fragment.app.DialogFragment
import androidx.preference.PreferenceManager
import com.dezlum.codelabs.getjson.GetJson
import com.google.android.material.button.MaterialButton
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools.getLatestVancedUrl
@ -33,9 +32,11 @@ class URLChangeFragment : DialogFragment() {
urlField.hint = prefs.getString("install_url", activity?.let { getLatestVancedUrl(it) })
view.findViewById<MaterialButton>(R.id.url_save).setOnClickListener {
prefs.edit().putString("install_url", urlField.text.toString()).apply()
dismiss()
}
view.findViewById<MaterialButton>(R.id.url_reset).setOnClickListener {
prefs.edit().putString("install_url", activity?.let { getLatestVancedUrl(it) }).apply()
dismiss()
}
}

View File

@ -52,7 +52,7 @@ object InternetTools {
fun getLatestVancedUrl(context: Context): String {
return if (GetJson().isConnected(context)) {
val latestVer = GetJson().AsJSONObject("https://x1nto.github.io/vanced.json").getAsJsonObject("version").asString
val latestVer = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json").get("version").asString
"https://vanced.app/api/v1/apks/$latestVer"
} else
"https://vanced.app/api/v1/apks/v15.05.54"

View File

@ -1,6 +1,7 @@
package com.vanced.manager.utils
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
@ -8,10 +9,22 @@ import com.vanced.manager.R
object NotificationHelper {
fun createNotifChannel(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notifChannel = NotificationChannel(
"69420",
context.getString(R.string.notif_channel_name),
NotificationManager.IMPORTANCE_DEFAULT
)
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(notifChannel)
}
}
fun displayDownloadNotif(channel: Int, maxVal: Int = 100, progress:Int = 0, filename: String, context: Context) {
val notifBuilder =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
Notification.Builder(context, channel.toString()).setChannelId(channel.toString())
Notification.Builder(context, channel.toString()).setChannelId("69420")
else
Notification.Builder(context).setPriority(Notification.PRIORITY_DEFAULT)

View File

@ -24,7 +24,7 @@
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:hintEnabled="true"
app:boxStrokeWidth="2dp"
@ -32,7 +32,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/url_input"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>

View File

@ -6,5 +6,6 @@
<string name="microg" translatable="false">MicroG</string>
<string name="root" translatable="false">root</string>
<string name="nonroot" translatable="false">nonroot</string>
<string name="notif_channel_name">App Downloads</string>
</resources>