..
This commit is contained in:
parent
604ae15055
commit
1451e6755f
12 changed files with 86 additions and 51 deletions
|
|
@ -96,13 +96,12 @@
|
|||
</activity>
|
||||
<activity
|
||||
android:name=".ui.more.terminal.TerminalActivity"
|
||||
android:configChanges="smallestScreenSize|layoutDirection|locale|orientation|screenSize"
|
||||
android:configChanges="smallestScreenSize|layoutDirection|orientation|screenSize"
|
||||
android:exported="true"
|
||||
android:label="@string/terminal"
|
||||
android:parentActivityName=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="ytdlnis.TerminalActivity" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
|
@ -110,6 +109,7 @@
|
|||
<activity-alias
|
||||
android:name=".terminalShareAlias"
|
||||
android:targetActivity=".ui.more.terminal.TerminalActivity"
|
||||
android:configChanges="smallestScreenSize|layoutDirection|orientation|screenSize"
|
||||
android:enabled="false"
|
||||
android:icon="@mipmap/terminal_icon"
|
||||
android:roundIcon="@mipmap/terminal_icon_round"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import androidx.core.widget.doAfterTextChanged
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
|
|
@ -634,7 +635,9 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, OnClickListene
|
|||
resultItem: ResultItem,
|
||||
type: DownloadViewModel.Type
|
||||
){
|
||||
if(findNavController().currentBackStack.value.firstOrNull {it.destination.id == R.id.downloadBottomSheetDialog} == null){
|
||||
if(findNavController().currentBackStack.value.firstOrNull {it.destination.id == R.id.downloadBottomSheetDialog} == null &&
|
||||
findNavController().currentDestination?.id == R.id.homeFragment
|
||||
){
|
||||
//show the fragment if its not in the backstack
|
||||
val bundle = Bundle()
|
||||
bundle.putParcelable("result", resultItem)
|
||||
|
|
|
|||
|
|
@ -54,16 +54,17 @@ class ActiveDownloadsFragment : Fragment(), ActiveDownloadAdapter.OnItemClickLis
|
|||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
fragmentView = inflater.inflate(R.layout.fragment_active, container, false)
|
||||
activity = getActivity()
|
||||
notificationUtil = NotificationUtil(requireContext())
|
||||
downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java]
|
||||
workManager = WorkManager.getInstance(requireContext())
|
||||
return fragmentView
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
activity = getActivity()
|
||||
notificationUtil = NotificationUtil(requireContext())
|
||||
downloadViewModel = ViewModelProvider(this)[DownloadViewModel::class.java]
|
||||
workManager = WorkManager.getInstance(requireContext())
|
||||
|
||||
activeDownloads =
|
||||
ActiveDownloadAdapter(
|
||||
this,
|
||||
|
|
@ -250,7 +251,7 @@ class ActiveDownloadsFragment : Fragment(), ActiveDownloadAdapter.OnItemClickLis
|
|||
}
|
||||
|
||||
override fun onOutputClick(item: DownloadItem) {
|
||||
if (item.logID != null) {
|
||||
if (item.logID != null && item.logID != 0L) {
|
||||
val bundle = Bundle()
|
||||
bundle.putLong("logID", item.logID!!)
|
||||
findNavController().navigate(
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package com.deniscerri.ytdlnis.ui.downloads
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.deniscerri.ytdlnis.ui.downloadcard.DownloadAudioFragment
|
||||
import com.deniscerri.ytdlnis.ui.downloadcard.DownloadCommandFragment
|
||||
import com.deniscerri.ytdlnis.ui.downloadcard.DownloadVideoFragment
|
||||
|
||||
class DownloadListFragmentAdapter (
|
||||
fragmentManager : FragmentManager,
|
||||
|
|
|
|||
|
|
@ -59,13 +59,6 @@ class GeneralSettingsFragment : BaseSettingsFragment() {
|
|||
locale = findPreference("locale")
|
||||
showTerminalShareIcon = findPreference("show_terminal")
|
||||
|
||||
val values = resources.getStringArray(R.array.language_values)
|
||||
val entries = mutableListOf<String>()
|
||||
values.forEach {
|
||||
entries.add(Locale(it).getDisplayName(Locale(it)))
|
||||
}
|
||||
language!!.entries = entries.toTypedArray()
|
||||
|
||||
if(language!!.value == null) language!!.value = Locale.getDefault().language
|
||||
|
||||
language!!.onPreferenceChangeListener =
|
||||
|
|
|
|||
|
|
@ -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<String>?
|
||||
filepath: List<String>?,
|
||||
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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -48,10 +48,7 @@
|
|||
android:name="com.deniscerri.ytdlnis.ui.more.MoreFragment"
|
||||
android:label="More"
|
||||
tools:layout="@layout/fragment_more" >
|
||||
<action
|
||||
android:id="@+id/action_moreFragment_to_terminalActivity"
|
||||
app:destination="@id/terminalActivity" />
|
||||
<action
|
||||
<action
|
||||
android:id="@+id/action_moreFragment_to_settingsActivity2"
|
||||
app:destination="@id/activitySettings" />
|
||||
<action
|
||||
|
|
@ -69,6 +66,9 @@
|
|||
<action
|
||||
android:id="@+id/action_moreFragment_to_settingsNav"
|
||||
app:destination="@id/settingsNav" />
|
||||
<action
|
||||
android:id="@+id/action_moreFragment_to_terminalActivity"
|
||||
app:destination="@id/terminalActivity" />
|
||||
</fragment>
|
||||
<activity
|
||||
android:id="@+id/terminalActivity"
|
||||
|
|
@ -89,7 +89,11 @@
|
|||
android:id="@+id/downloadQueueMainFragment"
|
||||
android:name="com.deniscerri.ytdlnis.ui.downloads.DownloadQueueMainFragment"
|
||||
tools:layout="@layout/fragment_download_queue_main_screen"
|
||||
android:label="DownloadQueueMainFragment" />
|
||||
android:label="DownloadQueueMainFragment" >
|
||||
<action
|
||||
android:id="@+id/action_downloadQueueMainFragment_to_downloadLogFragment"
|
||||
app:destination="@id/downloadLogFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/downloadLogListFragment"
|
||||
android:name="com.deniscerri.ytdlnis.ui.more.downloadLogs.DownloadLogListFragment"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<fragment
|
||||
android:id="@+id/terminalDownloadsListFragment"
|
||||
android:name="com.deniscerri.ytdlnis.ui.more.terminal.TerminalDownloadsListFragment"
|
||||
tools:layout="@layout/fragment_terminal_downloadList"
|
||||
tools:layout="@layout/fragment_terminal_download_list"
|
||||
android:label="TerminalDownloadsListFragment" >
|
||||
<action
|
||||
android:id="@+id/action_terminalDownloadsListFragment_to_terminalFragment2"
|
||||
|
|
|
|||
|
|
@ -102,6 +102,50 @@
|
|||
<item>music_offtopic</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="language_entries">
|
||||
<item>English</item>
|
||||
<item>العربية</item>
|
||||
<item>Azərbaycanca</item>
|
||||
<item>বাংলা</item>
|
||||
<item>বাংলা (India)</item>
|
||||
<item>Босански</item>
|
||||
<item>Deutsch</item>
|
||||
<item>Ἑλληνική</item>
|
||||
<item>Español</item>
|
||||
<item>فارسی</item>
|
||||
<item>Français</item>
|
||||
<item>हिन्दी</item>
|
||||
<item>Hrvatski</item>
|
||||
<item>Magyar</item>
|
||||
<item>Bahasa Indonesia</item>
|
||||
<item>Italiano</item>
|
||||
<item>日本語</item>
|
||||
<item>ꦧꦱꦗꦮ</item>
|
||||
<item>조선말</item>
|
||||
<item>latviešu</item>
|
||||
<item>بهاس ملايو</item>
|
||||
<item>Norsk Bokmål</item>
|
||||
<item>Norsk Nynorsk</item>
|
||||
<item>पंजाबी</item>
|
||||
<item>polski</item>
|
||||
<item>Português</item>
|
||||
<item>Português Brazil</item>
|
||||
<item>Русский</item>
|
||||
<item>Română</item>
|
||||
<item>Slovenčina</item>
|
||||
<item>Српски</item>
|
||||
<item>Shqip</item>
|
||||
<item>தமிழ்</item>
|
||||
<item>తెలుగు</item>
|
||||
<item>ภาษาไทย</item>
|
||||
<item>Türkçe</item>
|
||||
<item>தமிழ்</item>
|
||||
<item>Українська</item>
|
||||
<item>Tiếng Việt Nam</item>
|
||||
<item>中文</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="language_values">
|
||||
<item>en</item>
|
||||
<item>ar</item>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<PreferenceCategory android:title="@string/appearance">
|
||||
<ListPreference
|
||||
android:entries="@array/language_values"
|
||||
android:entries="@array/language_entries"
|
||||
android:entryValues="@array/language_values"
|
||||
android:defaultValue=""
|
||||
android:icon="@drawable/baseline_translate_24"
|
||||
|
|
|
|||
Loading…
Reference in a new issue