diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a3ab7031..1de615b5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -96,13 +96,12 @@
-
@@ -110,6 +109,7 @@
()
- values.forEach {
- entries.add(Locale(it).getDisplayName(Locale(it)))
- }
- language!!.entries = entries.toTypedArray()
-
if(language!!.value == null) language!!.value = Locale.getDefault().language
language!!.onPreferenceChangeListener =
diff --git a/app/src/main/java/com/deniscerri/ytdlnis/util/NotificationUtil.kt b/app/src/main/java/com/deniscerri/ytdlnis/util/NotificationUtil.kt
index ebe59089..b64f3088 100644
--- a/app/src/main/java/com/deniscerri/ytdlnis/util/NotificationUtil.kt
+++ b/app/src/main/java/com/deniscerri/ytdlnis/util/NotificationUtil.kt
@@ -35,15 +35,7 @@ class NotificationUtil(var context: Context) {
private val commandDownloadNotificationBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, COMMAND_DOWNLOAD_SERVICE_CHANNEL_ID)
private val finishedDownloadNotificationBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, DOWNLOAD_FINISHED_CHANNEL_ID)
private val notificationManager: NotificationManager = context.getSystemService(NotificationManager::class.java)
- private val resources: Resources
- private var sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
-
- init {
- val confTmp = Configuration(context.resources.configuration)
- confTmp.setLocale(Locale(sharedPreferences.getString("app_language", "en")!!))
- val metrics = DisplayMetrics()
- resources = Resources(context.assets, metrics, confTmp)
- }
+ private val resources: Resources = context.resources
fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -199,16 +191,17 @@ class NotificationUtil(var context: Context) {
fun createDownloadFinished(
title: String?,
- filepath: List?
+ filepath: List?,
+ res: Resources
) {
val notificationBuilder = getBuilder(DOWNLOAD_FINISHED_CHANNEL_ID)
notificationBuilder
- .setContentTitle("${resources.getString(R.string.downloaded)} $title")
+ .setContentTitle("${res.getString(R.string.downloaded)} $title")
.setSmallIcon(R.drawable.ic_launcher_foreground_large)
.setLargeIcon(
BitmapFactory.decodeResource(
- resources,
+ res,
R.drawable.ic_launcher_foreground_large
)
)
@@ -259,8 +252,8 @@ class NotificationUtil(var context: Context) {
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
)
- notificationBuilder.addAction(0, resources.getString(R.string.Open_File), openNotificationPendingIntent)
- notificationBuilder.addAction(0, resources.getString(R.string.share), shareNotificationPendingIntent)
+ notificationBuilder.addAction(0, res.getString(R.string.Open_File), openNotificationPendingIntent)
+ notificationBuilder.addAction(0, res.getString(R.string.share), shareNotificationPendingIntent)
}catch (_: Exception){}
}
notificationManager.notify(DOWNLOAD_FINISHED_NOTIFICATION_ID, notificationBuilder.build())
@@ -269,9 +262,9 @@ class NotificationUtil(var context: Context) {
fun createDownloadErrored(title: String?,
error: String?,
logID: Long?,
- channel: String
+ res: Resources
) {
- val notificationBuilder = getBuilder(channel)
+ val notificationBuilder = getBuilder(DOWNLOAD_FINISHED_CHANNEL_ID)
val bundle = Bundle()
if (logID != null){
@@ -294,12 +287,12 @@ class NotificationUtil(var context: Context) {
.createPendingIntent()
notificationBuilder
- .setContentTitle("${resources.getString(R.string.failed_download)}: $title")
+ .setContentTitle("${res.getString(R.string.failed_download)}: $title")
.setContentText(error)
.setSmallIcon(R.drawable.ic_launcher_foreground_large)
.setLargeIcon(
BitmapFactory.decodeResource(
- resources,
+ res,
R.drawable.ic_launcher_foreground_large
)
)
@@ -309,7 +302,7 @@ class NotificationUtil(var context: Context) {
.clearActions()
if (logID != null){
notificationBuilder.setContentIntent(errorPendingIntent)
- notificationBuilder.addAction(0, resources.getString(R.string.logs), errorPendingIntent)
+ notificationBuilder.addAction(0, res.getString(R.string.logs), errorPendingIntent)
}
notificationManager.notify(DOWNLOAD_FINISHED_NOTIFICATION_ID, notificationBuilder.build())
}
diff --git a/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt b/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt
index 5a1e8639..3d6a290f 100644
--- a/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt
+++ b/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt
@@ -178,13 +178,6 @@ class UpdateUtil(var context: Context) {
val sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context)
if (updatingYTDL) {
- withContext(Dispatchers.Main){
- Toast.makeText(
- context,
- context.getString(R.string.ytdl_already_updating),
- Toast.LENGTH_LONG
- ).show()
- }
UpdateStatus.ALREADY_UP_TO_DATE
}
updatingYTDL = true
diff --git a/app/src/main/java/com/deniscerri/ytdlnis/work/DownloadWorker.kt b/app/src/main/java/com/deniscerri/ytdlnis/work/DownloadWorker.kt
index 7b15aa54..c01ef032 100644
--- a/app/src/main/java/com/deniscerri/ytdlnis/work/DownloadWorker.kt
+++ b/app/src/main/java/com/deniscerri/ytdlnis/work/DownloadWorker.kt
@@ -64,7 +64,7 @@ class DownloadWorker(
if (currentWork.count{it.state == WorkInfo.State.RUNNING} > 1) return Result.success()
val confTmp = Configuration(context.resources.configuration)
- val currLang = sharedPreferences.getString("app_language", "en")!!.split("-")
+ val currLang = sharedPreferences.getString("app_language", "")!!.ifEmpty { Locale.getDefault().language }.split("-")
confTmp.setLocale(if (currLang.size == 1) Locale(currLang[0]) else Locale(currLang[0], currLang[1]))
val metrics = DisplayMetrics()
val resources = Resources(context.assets, metrics, confTmp)
@@ -221,7 +221,7 @@ class DownloadWorker(
notificationUtil.cancelDownloadNotification(downloadItem.id.toInt())
notificationUtil.createDownloadFinished(
- downloadItem.title, if (finalPaths?.first().equals(context.getString(R.string.unfound_file))) null else finalPaths
+ downloadItem.title, if (finalPaths?.first().equals(context.getString(R.string.unfound_file))) null else finalPaths, resources
)
if (wasQuickDownloaded){
@@ -282,7 +282,7 @@ class DownloadWorker(
notificationUtil.createDownloadErrored(
downloadItem.title.ifEmpty { downloadItem.url }, it.message,
downloadItem.logID,
- NotificationUtil.DOWNLOAD_FINISHED_CHANNEL_ID
+ resources
)
setProgressAsync(workDataOf("progress" to 100, "output" to it.toString(), "id" to downloadItem.id))
diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml
index 428bc6bb..fef525e9 100644
--- a/app/src/main/res/navigation/nav_graph.xml
+++ b/app/src/main/res/navigation/nav_graph.xml
@@ -48,10 +48,7 @@
android:name="com.deniscerri.ytdlnis.ui.more.MoreFragment"
android:label="More"
tools:layout="@layout/fragment_more" >
-
-
+
+ android:label="DownloadQueueMainFragment" >
+
+
music_offtopic
+
+
+ - English
+ - العربية
+ - Azərbaycanca
+ - বাংলা
+ - বাংলা (India)
+ - Босански
+ - Deutsch
+ - Ἑλληνική
+ - Español
+ - فارسی
+ - Français
+ - हिन्दी
+ - Hrvatski
+ - Magyar
+ - Bahasa Indonesia
+ - Italiano
+ - 日本語
+ - ꦧꦱꦗꦮ
+ - 조선말
+ - latviešu
+ - بهاس ملايو
+ - Norsk Bokmål
+ - Norsk Nynorsk
+ - पंजाबी
+ - polski
+ - Português
+ - Português Brazil
+ - Русский
+ - Română
+ - Slovenčina
+ - Српски
+ - Shqip
+ - தமிழ்
+ - తెలుగు
+ - ภาษาไทย
+ - Türkçe
+ - தமிழ்
+ - Українська
+ - Tiếng Việt Nam
+ - 中文
+
+
- en
- ar
diff --git a/app/src/main/res/xml/general_preferences.xml b/app/src/main/res/xml/general_preferences.xml
index 94e17007..b71854ce 100644
--- a/app/src/main/res/xml/general_preferences.xml
+++ b/app/src/main/res/xml/general_preferences.xml
@@ -4,7 +4,7 @@