Skip to content

Commit

Permalink
target android 14
Browse files Browse the repository at this point in the history
(cherry picked from commit c3d2b36)
  • Loading branch information
crackededed committed Sep 11, 2023
1 parent 391657a commit a8920ee
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ android {
}
}
namespace = "com.github.andreyasadchy.xtra"
compileSdk = 33
compileSdk = 34

defaultConfig {
applicationId = "com.github.andreyasadchy.xtra"
minSdk = 16
targetSdk = 33
targetSdk = 34
versionCode = 121
versionName = "2.24.3"
versionName = "2.25.0"
resourceConfigurations += listOf("ar", "de", "en", "es", "fr", "in", "ja", "pt-rBR", "ru", "tr")
}

Expand Down
9 changes: 8 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />

<application
android:name=".XtraApp"
Expand All @@ -21,7 +23,7 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/DarkTheme"
tools:targetApi="tiramisu">
tools:ignore="UnusedAttribute">
<activity
android:name=".ui.main.MainActivity"
android:launchMode="singleTask"
Expand Down Expand Up @@ -66,6 +68,11 @@
android:value="true" />
</service>

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="dataSync"
tools:node="merge" />

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.andreyasadchy.xtra.ui.download

import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -74,7 +75,7 @@ class ClipDownloadDialog : BaseDownloadDialog() {
cancel.setOnClickListener { dismiss() }
download.setOnClickListener {
val quality = spinner.selectedItem.toString()
viewModel.download(qualities.getValue(quality), downloadPath, quality, requireContext().prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false))
viewModel.download(qualities.getValue(quality), downloadPath, quality, Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE || requireContext().prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false))
dismiss()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
import android.os.Build
import androidx.core.app.NotificationCompat
import androidx.hilt.work.HiltWorker
Expand Down Expand Up @@ -122,7 +123,11 @@ class DownloadWorker @AssistedInject constructor(@Assisted context: Context, @As
}, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) PendingIntent.FLAG_IMMUTABLE else PendingIntent.FLAG_UPDATE_CURRENT))
addAction(android.R.drawable.ic_delete, applicationContext.getString(R.string.stop), WorkManager.getInstance(applicationContext).createCancelPendingIntent(id))
}.build()
return ForegroundInfo(offlineVideo.id, notification)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ForegroundInfo(offlineVideo.id, notification, FOREGROUND_SERVICE_TYPE_DATA_SYNC)
} else {
ForegroundInfo(offlineVideo.id, notification)
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.andreyasadchy.xtra.ui.download

import android.os.Build
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
Expand Down Expand Up @@ -143,7 +144,7 @@ class VideoDownloadDialog : BaseDownloadDialog() {
fun startDownload() {
val quality = spinner.selectedItem.toString()
val url = videoInfo.qualities.getValue(quality)
viewModel.download(url, downloadPath, quality, fromIndex, toIndex, requireContext().prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false))
viewModel.download(url, downloadPath, quality, fromIndex, toIndex, Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE || requireContext().prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false))
dismiss()
}
startDownload()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.andreyasadchy.xtra.ui.saved.downloads

import android.graphics.Color
import android.os.Build
import android.text.format.DateUtils
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -180,7 +181,7 @@ class DownloadsAdapter(
options.setOnClickListener { it ->
PopupMenu(context, it).apply {
inflate(R.menu.offline_item)
if (context.prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false) && item.status != OfflineVideo.STATUS_DOWNLOADED) {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE || context.prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false)) && item.status != OfflineVideo.STATUS_DOWNLOADED) {
menu.findItem(R.id.stopDownload).isVisible = true
menu.findItem(R.id.resumeDownload).isVisible = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.andreyasadchy.xtra.ui.saved.downloads

import android.content.Context
import android.os.Build
import androidx.lifecycle.ViewModel
import androidx.work.WorkManager
import com.github.andreyasadchy.xtra.model.offline.OfflineVideo
Expand Down Expand Up @@ -28,7 +29,7 @@ class DownloadsViewModel @Inject internal constructor(
fun delete(context: Context, video: OfflineVideo) {
repository.deleteVideo(context, video)
GlobalScope.launch {
val useWorkManager = context.prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false)
val useWorkManager = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE || context.prefs().getBoolean(C.DEBUG_WORKMANAGER_DOWNLOADS, false)
if (video.status == OfflineVideo.STATUS_DOWNLOADED || useWorkManager) {
if (useWorkManager) {
WorkManager.getInstance(context).cancelUniqueWork(video.id.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ class SettingsActivity : AppCompatActivity() {
IntegrityDialog.show(childFragmentManager)
true
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
findPreference<SwitchPreferenceCompat>(C.DEBUG_WORKMANAGER_DOWNLOADS)?.isVisible = false
}
}

override fun onSaveInstanceState(outState: Bundle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fun ViewPager2.reduceDragSensitivity() {
}

class TextWithCanvas(context: Context, attrs: AttributeSet) : AppCompatTextView(context, attrs) {
override fun draw(canvas: Canvas?) {
override fun draw(canvas: Canvas) {
for (i in 0..6) {
super.draw(canvas)
}
Expand Down
26 changes: 13 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
[versions]
android-gradle-plugin = "8.1.0"
android-gradle-plugin = "8.1.1"
apollo = "3.8.2"
appcompat = "1.7.0-alpha02"
checker-qual = "3.36.0"
appcompat = "1.7.0-alpha03"
checker-qual = "3.38.0"
coil = "2.4.0"
constraintlayout = "2.1.4"
core = "1.10.1"
core = "1.12.0"
coroutines = "1.7.3"
draglistview = "1.7.3"
fetch = "3.1.6"
flexbox = "3.0.0"
fragment = "1.6.1"
glide = "4.15.1"
glide = "4.16.0"
glide-webpdecoder = "2.3.4.15.1"
hilt = "2.47"
hilt = "2.48"
hilt-extension-compiler = "1.0.0"
hilt-work = "1.0.0"
kotlin = "1.9.0"
lifecycle = "2.6.1"
lifecycle = "2.6.2"
material = "1.9.0"
media3 = "1.1.0"
navigation = "2.6.0"
media3 = "1.1.1"
navigation = "2.7.2"
okhttp = "5.0.0-alpha.11"
open-m3u8 = "0.2.6"
paging = "3.2.0"
preference = "1.2.0"
paging = "3.2.1"
preference = "1.2.1"
request-inspector-webview = "1.0.3"
retrofit = "2.9.0"
room = "2.6.0-alpha01"
room = "2.6.0-beta01"
swiperefreshlayout = "1.1.0"
webkit = "1.7.0"
webkit = "1.8.0"
work = "2.8.1"

[libraries]
Expand Down

0 comments on commit a8920ee

Please sign in to comment.