mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
failure notif
This commit is contained in:
parent
ce516b12c1
commit
53f7a9fe17
@ -20,6 +20,19 @@
|
|||||||
"versionName": "0.2.2",
|
"versionName": "0.2.2",
|
||||||
"outputFile": "app-x86_64-release.apk"
|
"outputFile": "app-x86_64-release.apk"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "ONE_OF_MANY",
|
||||||
|
"filters": [
|
||||||
|
{
|
||||||
|
"filterType": "ABI",
|
||||||
|
"value": "x86"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attributes": [],
|
||||||
|
"versionCode": 4,
|
||||||
|
"versionName": "0.2.2",
|
||||||
|
"outputFile": "app-x86-release.apk"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "ONE_OF_MANY",
|
"type": "ONE_OF_MANY",
|
||||||
"filters": [
|
"filters": [
|
||||||
@ -45,19 +58,6 @@
|
|||||||
"versionCode": 4,
|
"versionCode": 4,
|
||||||
"versionName": "0.2.2",
|
"versionName": "0.2.2",
|
||||||
"outputFile": "app-arm64-v8a-release.apk"
|
"outputFile": "app-arm64-v8a-release.apk"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ONE_OF_MANY",
|
|
||||||
"filters": [
|
|
||||||
{
|
|
||||||
"filterType": "ABI",
|
|
||||||
"value": "x86"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"attributes": [],
|
|
||||||
"versionCode": 4,
|
|
||||||
"versionName": "0.2.2",
|
|
||||||
"outputFile": "app-x86-release.apk"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"elementType": "File"
|
"elementType": "File"
|
||||||
|
@ -12,6 +12,7 @@ import android.os.Environment
|
|||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import com.arthenica.ffmpegkit.FFmpegKit
|
import com.arthenica.ffmpegkit.FFmpegKit
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -193,7 +194,18 @@ class DownloadService : Service(){
|
|||||||
val folder_main = ".tmp"
|
val folder_main = ".tmp"
|
||||||
val f = File(path, folder_main)
|
val f = File(path, folder_main)
|
||||||
f.deleteRecursively()
|
f.deleteRecursively()
|
||||||
//Toast.makeText(this@DownloadService, R.string.dlcomplete, Toast.LENGTH_LONG).show()
|
if (returnCode.toString()!="0"){
|
||||||
|
var builder = NotificationCompat.Builder(this@DownloadService, "failed")
|
||||||
|
.setSmallIcon(R.drawable.ic_download)
|
||||||
|
.setContentTitle(resources.getString(R.string.downloadfailed))
|
||||||
|
.setContentText("failure")
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
|
createNotificationChannel()
|
||||||
|
with(NotificationManagerCompat.from(this@DownloadService)) {
|
||||||
|
// notificationId is a unique int for each notification that you must define
|
||||||
|
notify(69, builder.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
stopForeground(true)
|
stopForeground(true)
|
||||||
stopService(Intent(this@DownloadService,DownloadService::class.java))
|
stopService(Intent(this@DownloadService,DownloadService::class.java))
|
||||||
}, {
|
}, {
|
||||||
@ -214,7 +226,22 @@ class DownloadService : Service(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createNotificationChannel() {
|
||||||
|
// Create the NotificationChannel, but only on API 26+ because
|
||||||
|
// the NotificationChannel class is new and not in the support library
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
val name = "failed"
|
||||||
|
val descriptionText = "Download Failed"
|
||||||
|
val importance = NotificationManager.IMPORTANCE_DEFAULT
|
||||||
|
val channel = NotificationChannel("failed", name, importance).apply {
|
||||||
|
description = descriptionText
|
||||||
|
}
|
||||||
|
// Register the channel with the system
|
||||||
|
val notificationManager: NotificationManager =
|
||||||
|
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
notificationManager.createNotificationChannel(channel)
|
||||||
|
}
|
||||||
|
}
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
try {
|
try {
|
||||||
unregisterReceiver(onDownloadComplete)
|
unregisterReceiver(onDownloadComplete)
|
||||||
|
@ -26,4 +26,5 @@
|
|||||||
<string name="cannotDownload">Can\'t Download this stream!</string>
|
<string name="cannotDownload">Can\'t Download this stream!</string>
|
||||||
<string name="dlcomplete">Download is completed!</string>
|
<string name="dlcomplete">Download is completed!</string>
|
||||||
<string name="dlisinprogress">Another Download is already in progress please wait till it\'s finished!</string>
|
<string name="dlisinprogress">Another Download is already in progress please wait till it\'s finished!</string>
|
||||||
|
<string name="downloadfailed">Download Failed!</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user