bug squashes

pull/144/head v1.6.2
deniscerri 3 years ago
parent a8ffbf5053
commit 4178c778bc
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -21,6 +21,7 @@ import android.widget.CheckBox
import android.widget.FrameLayout
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.ActivityCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.forEach
@ -187,8 +188,9 @@ class MainActivity : BaseActivity() {
fun hideBottomNavigation(){
if(navigationView is NavigationBarView){
if (navigationView is BottomNavigationView){
findViewById<FragmentContainerView>(R.id.frame_layout).updateLayoutParams {
this.height = LayoutParams.MATCH_PARENT
findViewById<FragmentContainerView>(R.id.frame_layout).updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomToTop = ConstraintLayout.LayoutParams.UNSET
bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID
}
navigationView.animate()?.translationY(navigationView.height.toFloat())?.setDuration(300)?.withEndAction {
navigationView.visibility = View.GONE
@ -207,8 +209,9 @@ class MainActivity : BaseActivity() {
fun showBottomNavigation(){
if(navigationView is NavigationBarView){
if (navigationView is BottomNavigationView){
findViewById<FragmentContainerView>(R.id.frame_layout).updateLayoutParams {
this.height = 0
findViewById<FragmentContainerView>(R.id.frame_layout).updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomToTop = R.id.bottomNavigationView
bottomToBottom = ConstraintLayout.LayoutParams.UNSET
}
navigationView.animate()?.translationY(0F)?.setDuration(300)?.withEndAction {
navigationView.visibility = View.VISIBLE

@ -22,6 +22,7 @@ import androidx.appcompat.view.ActionMode
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
@ -95,10 +96,15 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
override fun onActionButtonClick(itemID: Long) {
val item = items.find { it.id == itemID } ?: return
val file = fileUtil.getLogFile(requireContext(), item)
val intent = Intent(requireContext(), DownloadLogFragment::class.java)
intent.putExtra("logpath", file.absolutePath)
startActivity(intent)
val logFile = fileUtil.getLogFile(requireContext(), item)
if (logFile.exists()) {
val bundle = Bundle()
bundle.putString("logpath", logFile.absolutePath)
findNavController().navigate(
R.id.downloadLogFragment,
bundle
)
}
}
override fun onCardClick(itemID: Long) {

@ -292,7 +292,11 @@ class InfoUtil(private val context: Context) {
try {
val id = obj.getString("videoId")
val title = obj.getString("title").toString()
title.replace("&#39;s", "'")
title.replace("&amp", "&")
val author = obj.getString("author").toString()
author.replace("&#39;s", "'")
author.replace("&amp", "&")
if (author.isBlank()) throw Exception()

@ -147,6 +147,24 @@ class NotificationUtil(var context: Context) {
notificationManager.notify(DOWNLOAD_RESUME_NOTIFICATION_ID, notificationBuilder.build())
}
fun createUpdatingItemNotification(channel: String){
val notificationBuilder = getBuilder(channel)
notificationBuilder
.setContentTitle(context.getString(R.string.updating_download_data))
.setSmallIcon(android.R.drawable.stat_sys_download)
.setLargeIcon(
BitmapFactory.decodeResource(
context.resources,
android.R.drawable.stat_sys_download
)
)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.clearActions()
notificationManager.notify(DOWNLOAD_UPDATING_NOTIFICATION_ID, notificationBuilder.build())
}
fun createDownloadFinished(title: String?,
filepath: String?,
channel: String
@ -271,6 +289,7 @@ class NotificationUtil(var context: Context) {
const val DOWNLOAD_FINISHED_CHANNEL_ID = "3"
const val DOWNLOAD_FINISHED_NOTIFICATION_ID = 3
const val DOWNLOAD_RESUME_NOTIFICATION_ID = 4
const val DOWNLOAD_UPDATING_NOTIFICATION_ID = 5
private const val PROGRESS_MAX = 100
private const val PROGRESS_CURR = 0
}

@ -66,10 +66,15 @@ class DownloadWorker(
runBlocking{
repository.setDownloadStatus(downloadItem, DownloadRepository.Status.Active)
}
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
CoroutineScope(Dispatchers.IO).launch {
//update item if its incomplete
updateDownloadItem(downloadItem, infoUtil, dao, resultDao)
if (sharedPreferences.getBoolean("log_downloads", false)){
updateDownloadItem(downloadItem, infoUtil, dao, resultDao, true, notificationUtil)
}else{
CoroutineScope(Dispatchers.IO).launch {
//update item if its incomplete
updateDownloadItem(downloadItem, infoUtil, dao, resultDao, false, notificationUtil)
}
}
val intent = Intent(context, MainActivity::class.java)
@ -88,7 +93,6 @@ class DownloadWorker(
tempFileDir.delete()
tempFileDir.mkdirs()
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val aria2 = sharedPreferences.getBoolean("aria2", false)
if (aria2) {
request.addOption("--downloader", "libaria2c.so")
@ -153,6 +157,11 @@ class DownloadWorker(
request.addOption("--cookies", cookiesFile.absolutePath)
}
val proxy = sharedPreferences.getString("proxy", "")
if (proxy!!.isNotBlank()){
request.addOption("--proxy", proxy)
}
val keepCache = sharedPreferences.getBoolean("keep_cache", false)
if(keepCache){
request.addOption("--part")
@ -333,7 +342,7 @@ class DownloadWorker(
NotificationUtil.DOWNLOAD_FINISHED_CHANNEL_ID
)
if (updateDownloadItem(downloadItem, infoUtil, dao, resultDao)){
if (updateDownloadItem(downloadItem, infoUtil, dao, resultDao, false, notificationUtil)){
runCatching {
setProgressAsync(workDataOf("progress" to 100, "output" to "Creating Result Items", "id" to downloadItem.id, "log" to false))
runBlocking {
@ -390,10 +399,10 @@ class DownloadWorker(
return Result.success()
}
private fun updateDownloadItem(downloadItem: DownloadItem, infoUtil: InfoUtil, dao: DownloadDao, resultDao: ResultDao) : Boolean {
private fun updateDownloadItem(downloadItem: DownloadItem, infoUtil: InfoUtil, dao: DownloadDao, resultDao: ResultDao, logDownloads: Boolean, notificationUtil: NotificationUtil) : Boolean {
var wasQuickDownloaded = false
if (downloadItem.title.isEmpty() || downloadItem.author.isEmpty() || downloadItem.thumb.isEmpty()){
if (logDownloads) notificationUtil.createUpdatingItemNotification(NotificationUtil.DOWNLOAD_SERVICE_CHANNEL_ID)
runCatching {
setProgressAsync(workDataOf("progress" to 0, "output" to context.getString(R.string.updating_download_data), "id" to downloadItem.id, "log" to false))
val info = infoUtil.getMissingInfo(downloadItem.url)
@ -407,6 +416,7 @@ class DownloadWorker(
dao.update(downloadItem)
}
}
if (logDownloads) notificationUtil.cancelDownloadNotification(NotificationUtil.DOWNLOAD_UPDATING_NOTIFICATION_ID)
}
return wasQuickDownloaded
}

Loading…
Cancel
Save