small fixes

This commit is contained in:
deniscerri 2023-03-22 12:56:57 +01:00
parent e9e90de48d
commit 847debf00d
No known key found for this signature in database
GPG key ID: 95C43D517D830350
11 changed files with 28 additions and 7 deletions

View file

@ -116,7 +116,7 @@
android:exported="true" android:exported="true"
android:label="@string/terminal" android:label="@string/terminal"
android:parentActivityName=".MainActivity" android:parentActivityName=".MainActivity"
android:theme="@style/AppDefaultTheme"> android:theme="@style/AppTheme">
<intent-filter> <intent-filter>
<action android:name="ytdlnis.TerminalActivity" /> <action android:name="ytdlnis.TerminalActivity" />

View file

@ -13,7 +13,7 @@ interface DownloadDao {
@Query("SELECT * FROM downloads WHERE status='Active'") @Query("SELECT * FROM downloads WHERE status='Active'")
fun getActiveDownloads() : LiveData<List<DownloadItem>> fun getActiveDownloads() : LiveData<List<DownloadItem>>
@Query("SELECT * FROM downloads WHERE status='Queued'") @Query("SELECT * FROM downloads WHERE status='Queued' ORDER BY downloadStartTime, id")
fun getQueuedDownloads() : LiveData<List<DownloadItem>> fun getQueuedDownloads() : LiveData<List<DownloadItem>>
@Query("SELECT * FROM downloads WHERE status='Cancelled' ORDER BY id DESC") @Query("SELECT * FROM downloads WHERE status='Cancelled' ORDER BY id DESC")

View file

@ -3,7 +3,9 @@ package com.deniscerri.ytdlnis.database.viewmodel
import android.app.Activity import android.app.Activity
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.text.format.DateFormat
import android.util.Log import android.util.Log
import android.widget.Toast
import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
@ -22,7 +24,11 @@ import com.deniscerri.ytdlnis.work.DownloadWorker
import com.google.gson.Gson import com.google.gson.Gson
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.sql.Date
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.collections.ArrayList
class DownloadViewModel(application: Application) : AndroidViewModel(application) { class DownloadViewModel(application: Application) : AndroidViewModel(application) {
private val repository : DownloadRepository private val repository : DownloadRepository

View file

@ -72,6 +72,7 @@ class ConfigureDownloadBottomSheetDialog(private val resultItem: ResultItem, pri
fragments.add(DownloadCommandFragment(resultItem, downloadItem)) fragments.add(DownloadCommandFragment(resultItem, downloadItem))
}else{ }else{
(tabLayout.getChildAt(0) as? ViewGroup)?.getChildAt(2)?.isEnabled = false (tabLayout.getChildAt(0) as? ViewGroup)?.getChildAt(2)?.isEnabled = false
(tabLayout.getChildAt(0) as? ViewGroup)?.getChildAt(2)?.alpha = 0.3f
} }
} }
} }

View file

@ -4,11 +4,13 @@ import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.content.DialogInterface import android.content.DialogInterface
import android.os.Bundle import android.os.Bundle
import android.text.format.DateFormat
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button import android.widget.Button
import android.widget.Toast
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -38,6 +40,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.io.File import java.io.File
import java.text.SimpleDateFormat
import java.util.* import java.util.*
@ -150,6 +153,8 @@ class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val
item.downloadStartTime = it.timeInMillis item.downloadStartTime = it.timeInMillis
runBlocking { runBlocking {
downloadViewModel.queueDownloads(listOf(item)) downloadViewModel.queueDownloads(listOf(item))
val date = SimpleDateFormat(DateFormat.getBestDateTimePattern(Locale.getDefault(), "ddMMMyyyy - HHmm"), Locale.getDefault()).format(item.downloadStartTime)
Toast.makeText(context, getString(R.string.download_rescheduled_to) + " " + date, Toast.LENGTH_LONG).show()
} }
dismiss() dismiss()
} }

View file

@ -6,6 +6,7 @@ import android.app.Dialog
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.format.DateFormat
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.util.Log import android.util.Log
import android.view.* import android.view.*
@ -40,6 +41,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.text.SimpleDateFormat
import java.util.* import java.util.*
class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadItem>) : BottomSheetDialogFragment(), ConfigureMultipleDownloadsAdapter.OnItemClickListener, View.OnClickListener, class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadItem>) : BottomSheetDialogFragment(), ConfigureMultipleDownloadsAdapter.OnItemClickListener, View.OnClickListener,
@ -101,6 +103,9 @@ class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadI
} }
runBlocking { runBlocking {
downloadViewModel.queueDownloads(items) downloadViewModel.queueDownloads(items)
val first = items.first()
val date = SimpleDateFormat(DateFormat.getBestDateTimePattern(Locale.getDefault(), "ddMMMyyyy - HHmm"), Locale.getDefault()).format(first.downloadStartTime)
Toast.makeText(context, getString(R.string.download_rescheduled_to) + " " + date, Toast.LENGTH_LONG).show()
} }
dismiss() dismiss()
} }
@ -244,8 +249,10 @@ class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadI
val resultItem = withContext(Dispatchers.IO){ val resultItem = withContext(Dispatchers.IO){
resultViewModel.getItemByURL(downloadItem!!.url) resultViewModel.getItemByURL(downloadItem!!.url)
} }
val bottomSheet = ConfigureDownloadBottomSheetDialog(resultItem, downloadItem!!, this@DownloadMultipleBottomSheetDialog) if (parentFragmentManager.findFragmentByTag("configureDownloadSingleSheet") == null){
bottomSheet.show(parentFragmentManager, "configureDownloadSingleSheet") val bottomSheet = ConfigureDownloadBottomSheetDialog(resultItem, downloadItem!!, this@DownloadMultipleBottomSheetDialog)
bottomSheet.show(parentFragmentManager, "configureDownloadSingleSheet")
}
} }
} }

View file

@ -79,8 +79,10 @@ class UiUtil(private val fileUtil: FileUtil) {
bottomSheet.findViewById<TextView>(R.id.bottom_sheet_subtitle)!!.text = content.resources.getString(R.string.update_template) bottomSheet.findViewById<TextView>(R.id.bottom_sheet_subtitle)!!.text = content.resources.getString(R.string.update_template)
ok.text = content.resources.getString(R.string.update) ok.text = content.resources.getString(R.string.update)
ok.isEnabled = true ok.isEnabled = true
content.endIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_delete_all)
}else{ }else{
ok.isEnabled = false ok.isEnabled = false
content.endIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_clipboard)
} }
title.editText!!.addTextChangedListener(object : TextWatcher { title.editText!!.addTextChangedListener(object : TextWatcher {

View file

@ -20,7 +20,7 @@
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:liftOnScroll="false" app:liftOnScroll="true"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">

View file

@ -25,6 +25,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="15dp" android:layout_marginEnd="15dp"
android:maxLines="2" android:maxLines="2"
android:ellipsize="end"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View file

@ -92,7 +92,7 @@
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:maxLines="4" android:maxLines="200"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>

View file

@ -17,7 +17,6 @@
<item name="android:windowContentOverlay">@null</item> <item name="android:windowContentOverlay">@null</item>
</style> </style>
<style name="AppTheme" parent="AppDefaultTheme" /> <style name="AppTheme" parent="AppDefaultTheme" />
<style name="Toolbar" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Toolbar" parent="Theme.Material3.DayNight.NoActionBar">