mirror of
https://github.com/CherretGit/zaprett-app.git
synced 2026-01-06 02:49:44 +05:00
fix crashes after Likchach42's PR
This commit is contained in:
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2025-07-08T13:21:50.180843436Z">
|
<DropdownSelection timestamp="2025-07-09T09:45:05.074315845Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=/home/white/.android/avd/Medium_Phone.avd" />
|
<DeviceId pluginId="LocalEmulator" identifier="path=/home/white/.android/avd/Pixel_8.avd" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import com.cherret.zaprett.utils.checkModuleInstallation
|
|||||||
import com.google.firebase.Firebase
|
import com.google.firebase.Firebase
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.google.firebase.analytics.analytics
|
import com.google.firebase.analytics.analytics
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
sealed class Screen(val route: String, @StringRes val nameResId: Int, val icon: ImageVector) {
|
sealed class Screen(val route: String, @StringRes val nameResId: Int, val icon: ImageVector) {
|
||||||
object home : Screen("home", R.string.title_home, Icons.Default.Home)
|
object home : Screen("home", R.string.title_home, Icons.Default.Home)
|
||||||
@@ -125,7 +126,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
message = stringResource(R.string.error_no_storage_message),
|
message = stringResource(R.string.error_no_storage_message),
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
|
||||||
val uri = Uri.fromParts("package", packageName, null)
|
val uri = Uri.fromParts("package", packageName, null)
|
||||||
intent.data = uri
|
intent.data = uri
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ private val client = OkHttpClient()
|
|||||||
private val json = Json { ignoreUnknownKeys = true }
|
private val json = Json { ignoreUnknownKeys = true }
|
||||||
|
|
||||||
fun getUpdate(callback: (UpdateInfo?) -> Unit) {
|
fun getUpdate(callback: (UpdateInfo?) -> Unit) {
|
||||||
val request = Request.Builder().url("https://raw.githubusercontent.com/CherretGit/zaprett-app/refs/heads/main/update.json").build()
|
//val request = Request.Builder().url("https://raw.githubusercontent.com/CherretGit/zaprett-app/refs/heads/main/update.json").build()
|
||||||
|
val request = Request.Builder().url("https://raw.githubusercontent.com/CherretGit/Test3/refs/heads/main/update.json").build() //test repo
|
||||||
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) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@@ -81,22 +82,7 @@ fun download(context: Context, url: String): Long {
|
|||||||
setTitle(fileName)
|
setTitle(fileName)
|
||||||
setDescription(fileName)
|
setDescription(fileName)
|
||||||
setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
|
||||||
val contentValues = ContentValues().apply {
|
|
||||||
put(MediaStore.Downloads.DISPLAY_NAME, fileName)
|
|
||||||
put(MediaStore.Downloads.RELATIVE_PATH, Environment.DIRECTORY_DOWNLOADS)
|
|
||||||
}
|
|
||||||
val uri = context.contentResolver.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues)
|
|
||||||
if (uri != null) {
|
|
||||||
setDestinationUri(uri)
|
|
||||||
} else {
|
|
||||||
Log.e("Updater", "Failed to create MediaStore URI")
|
|
||||||
return -1L
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
|
setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI or DownloadManager.Request.NETWORK_MOBILE)
|
||||||
}
|
}
|
||||||
return downloadManager.enqueue(request)
|
return downloadManager.enqueue(request)
|
||||||
|
|||||||
Reference in New Issue
Block a user