small fixes
This commit is contained in:
parent
e9e90de48d
commit
847debf00d
11 changed files with 28 additions and 7 deletions
|
|
@ -116,7 +116,7 @@
|
|||
android:exported="true"
|
||||
android:label="@string/terminal"
|
||||
android:parentActivityName=".MainActivity"
|
||||
android:theme="@style/AppDefaultTheme">
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="ytdlnis.TerminalActivity" />
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ interface DownloadDao {
|
|||
@Query("SELECT * FROM downloads WHERE status='Active'")
|
||||
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>>
|
||||
|
||||
@Query("SELECT * FROM downloads WHERE status='Cancelled' ORDER BY id DESC")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ package com.deniscerri.ytdlnis.database.viewmodel
|
|||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.SharedPreferences
|
||||
import android.text.format.DateFormat
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
|
|
@ -22,7 +24,11 @@ import com.deniscerri.ytdlnis.work.DownloadWorker
|
|||
import com.google.gson.Gson
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.sql.Date
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class DownloadViewModel(application: Application) : AndroidViewModel(application) {
|
||||
private val repository : DownloadRepository
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class ConfigureDownloadBottomSheetDialog(private val resultItem: ResultItem, pri
|
|||
fragments.add(DownloadCommandFragment(resultItem, downloadItem))
|
||||
}else{
|
||||
(tabLayout.getChildAt(0) as? ViewGroup)?.getChildAt(2)?.isEnabled = false
|
||||
(tabLayout.getChildAt(0) as? ViewGroup)?.getChildAt(2)?.alpha = 0.3f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@ import android.annotation.SuppressLint
|
|||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
|
|
@ -38,6 +40,7 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
|
|
@ -150,6 +153,8 @@ class DownloadBottomSheetDialog(private val resultItem: ResultItem, private val
|
|||
item.downloadStartTime = it.timeInMillis
|
||||
runBlocking {
|
||||
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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import android.app.Dialog
|
|||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateFormat
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.Log
|
||||
import android.view.*
|
||||
|
|
@ -40,6 +41,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadItem>) : BottomSheetDialogFragment(), ConfigureMultipleDownloadsAdapter.OnItemClickListener, View.OnClickListener,
|
||||
|
|
@ -101,6 +103,9 @@ class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadI
|
|||
}
|
||||
runBlocking {
|
||||
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()
|
||||
}
|
||||
|
|
@ -244,8 +249,10 @@ class DownloadMultipleBottomSheetDialog(private var items: MutableList<DownloadI
|
|||
val resultItem = withContext(Dispatchers.IO){
|
||||
resultViewModel.getItemByURL(downloadItem!!.url)
|
||||
}
|
||||
val bottomSheet = ConfigureDownloadBottomSheetDialog(resultItem, downloadItem!!, this@DownloadMultipleBottomSheetDialog)
|
||||
bottomSheet.show(parentFragmentManager, "configureDownloadSingleSheet")
|
||||
if (parentFragmentManager.findFragmentByTag("configureDownloadSingleSheet") == null){
|
||||
val bottomSheet = ConfigureDownloadBottomSheetDialog(resultItem, downloadItem!!, this@DownloadMultipleBottomSheetDialog)
|
||||
bottomSheet.show(parentFragmentManager, "configureDownloadSingleSheet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
ok.text = content.resources.getString(R.string.update)
|
||||
ok.isEnabled = true
|
||||
content.endIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_delete_all)
|
||||
}else{
|
||||
ok.isEnabled = false
|
||||
content.endIconDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_clipboard)
|
||||
}
|
||||
|
||||
title.editText!!.addTextChangedListener(object : TextWatcher {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:liftOnScroll="false"
|
||||
app:liftOnScroll="true"
|
||||
android:background="@android:color/transparent"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:layout_width="match_parent"
|
||||
android:maxLines="4"
|
||||
android:maxLines="200"
|
||||
android:inputType="textMultiLine"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
<item name="android:windowContentOverlay">@null</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="AppTheme" parent="AppDefaultTheme" />
|
||||
|
||||
<style name="Toolbar" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
|
|
|
|||
Loading…
Reference in a new issue