bug fixes
This commit is contained in:
parent
9574788ae8
commit
7eabba9c02
9 changed files with 69 additions and 47 deletions
|
|
@ -120,7 +120,7 @@ dependencies {
|
||||||
|
|
||||||
implementation "androidx.appcompat:appcompat:$appCompatVer"
|
implementation "androidx.appcompat:appcompat:$appCompatVer"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
|
||||||
implementation 'com.google.android.material:material:1.7.0'
|
implementation 'com.google.android.material:material:1.9.0-alpha02'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.core:core:1.9.0'
|
implementation 'androidx.core:core:1.9.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,16 @@ class DownloadLogsAdapter(onItemClickListener: OnItemClickListener, activity: Ac
|
||||||
val item = getItem(position)
|
val item = getItem(position)
|
||||||
val card = holder.item
|
val card = holder.item
|
||||||
|
|
||||||
card.findViewById<TextView>(R.id.title).text = item?.name
|
val title = card.findViewById<TextView>(R.id.title)
|
||||||
|
title.text = item?.name
|
||||||
|
|
||||||
card.findViewById<Button>(R.id.delete).setOnClickListener {
|
val delete = card.findViewById<Button>(R.id.delete)
|
||||||
|
|
||||||
|
delete.setOnClickListener {
|
||||||
onItemClickListener.onDeleteClick(item!!)
|
onItemClickListener.onDeleteClick(item!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
card.setOnClickListener {
|
title.setOnClickListener {
|
||||||
onItemClickListener.onItemClick(item!!)
|
onItemClickListener.onItemClick(item!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import kotlinx.coroutines.launch
|
||||||
class HistoryViewModel(application: Application) : AndroidViewModel(application) {
|
class HistoryViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
private val repository : HistoryRepository
|
private val repository : HistoryRepository
|
||||||
val sortOrder = MutableLiveData(HistorySort.DESC)
|
val sortOrder = MutableLiveData(HistorySort.DESC)
|
||||||
private val sortType = MutableLiveData(HistorySortType.DATE)
|
val sortType = MutableLiveData(HistorySortType.DATE)
|
||||||
private val websiteFilter = MutableLiveData("")
|
private val websiteFilter = MutableLiveData("")
|
||||||
private val queryFilter = MutableLiveData("")
|
private val queryFilter = MutableLiveData("")
|
||||||
private val formatFilter = MutableLiveData("")
|
private val formatFilter = MutableLiveData("")
|
||||||
|
|
|
||||||
|
|
@ -250,6 +250,12 @@ class HistoryFragment : Fragment(), HistoryAdapter.OnItemClickListener{
|
||||||
val author = sortSheet!!.findViewById<LinearLayout>(R.id.author)
|
val author = sortSheet!!.findViewById<LinearLayout>(R.id.author)
|
||||||
|
|
||||||
val sortOptions = listOf(date!!, title!!, author!!)
|
val sortOptions = listOf(date!!, title!!, author!!)
|
||||||
|
sortOptions.forEach { it.getChildAt(0).visibility = INVISIBLE }
|
||||||
|
when(historyViewModel.sortType.value!!) {
|
||||||
|
HistoryRepository.HistorySortType.DATE -> changeSortIcon(date, historyViewModel.sortOrder.value!!)
|
||||||
|
HistoryRepository.HistorySortType.TITLE -> changeSortIcon(title, historyViewModel.sortOrder.value!!)
|
||||||
|
HistoryRepository.HistorySortType.AUTHOR -> changeSortIcon(author, historyViewModel.sortOrder.value!!)
|
||||||
|
}
|
||||||
|
|
||||||
date.getChildAt(1).setOnClickListener {
|
date.getChildAt(1).setOnClickListener {
|
||||||
sortOptions.forEach { it.getChildAt(0).visibility = INVISIBLE }
|
sortOptions.forEach { it.getChildAt(0).visibility = INVISIBLE }
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class DownloadLogActivity : AppCompatActivity() {
|
||||||
private lateinit var content: TextView
|
private lateinit var content: TextView
|
||||||
private lateinit var contentScrollView : NestedScrollView
|
private lateinit var contentScrollView : NestedScrollView
|
||||||
private lateinit var topAppBar: MaterialToolbar
|
private lateinit var topAppBar: MaterialToolbar
|
||||||
|
private lateinit var observer: FileObserver
|
||||||
var context: Context? = null
|
var context: Context? = null
|
||||||
|
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
@ -26,19 +27,23 @@ class DownloadLogActivity : AppCompatActivity() {
|
||||||
context = baseContext
|
context = baseContext
|
||||||
|
|
||||||
topAppBar = findViewById(R.id.title)
|
topAppBar = findViewById(R.id.title)
|
||||||
topAppBar.setNavigationOnClickListener { onBackPressedDispatcher.onBackPressed() }
|
topAppBar.setNavigationOnClickListener {
|
||||||
|
onBackPressedDispatcher.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
content = findViewById(R.id.content)
|
content = findViewById(R.id.content)
|
||||||
contentScrollView = findViewById(R.id.content_scrollview)
|
contentScrollView = findViewById(R.id.content_scrollview)
|
||||||
|
|
||||||
val path = intent.getStringExtra("path")
|
val path = intent.getStringExtra("path")
|
||||||
if (path == null) onBackPressedDispatcher.onBackPressed()
|
if (path == null) {
|
||||||
|
onBackPressedDispatcher.onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
val file = File(path!!)
|
val file = File(path!!)
|
||||||
topAppBar.title = file.name
|
topAppBar.title = file.name
|
||||||
content.text = file.readText()
|
content.text = file.readText()
|
||||||
|
|
||||||
val observer: FileObserver = object : FileObserver(file, MODIFY) {
|
observer = object : FileObserver(file, MODIFY) {
|
||||||
override fun onEvent(event: Int, p: String?) {
|
override fun onEvent(event: Int, p: String?) {
|
||||||
runOnUiThread{
|
runOnUiThread{
|
||||||
content.text = File(path).readText()
|
content.text = File(path).readText()
|
||||||
|
|
@ -49,6 +54,11 @@ class DownloadLogActivity : AppCompatActivity() {
|
||||||
observer.startWatching();
|
observer.startWatching();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
observer.stopWatching()
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "DownloadLogActivity"
|
private const val TAG = "DownloadLogActivity"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,14 @@ class DownloadLogListActivity : AppCompatActivity(), DownloadLogsAdapter.OnItemC
|
||||||
private fun updateList(logFolder: File){
|
private fun updateList(logFolder: File){
|
||||||
fileList = mutableListOf()
|
fileList = mutableListOf()
|
||||||
fileList.addAll(logFolder.listFiles()!!)
|
fileList.addAll(logFolder.listFiles()!!)
|
||||||
if (fileList.isNotEmpty()) {
|
fileList.reverse()
|
||||||
fileList.reverse()
|
downloadLogAdapter.submitList(fileList.toList())
|
||||||
noResults.visibility = View.GONE
|
runOnUiThread{
|
||||||
downloadLogAdapter.submitList(fileList.toList())
|
if (fileList.isNotEmpty()) {
|
||||||
}else{
|
noResults.visibility = View.GONE
|
||||||
noResults.visibility = View.VISIBLE
|
}else{
|
||||||
|
noResults.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,12 @@ class DownloadWorker(
|
||||||
}
|
}
|
||||||
return Result.failure()
|
return Result.failure()
|
||||||
}else{
|
}else{
|
||||||
|
val logDownloads = sharedPreferences.getBoolean("log_downloads", false)
|
||||||
|
if (logDownloads){
|
||||||
|
val logFile = File(context.filesDir.absolutePath + """/logs/${downloadItem.id} - ${downloadItem.title}##${downloadItem.type}##${downloadItem.format.format_id}.log""")
|
||||||
|
logFile.appendText("${it.message}\n")
|
||||||
|
}
|
||||||
|
|
||||||
tempFileDir.delete()
|
tempFileDir.delete()
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
Toast.makeText(context, it.message, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, it.message, Toast.LENGTH_SHORT).show()
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,33 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/download_log_item_constraint"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
android:orientation="horizontal"
|
||||||
android:orientation="vertical"
|
android:padding="15dp"
|
||||||
android:padding="15dp">
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<TextView
|
||||||
android:id="@+id/download_log_item_constraint"
|
android:id="@+id/title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:layout_marginEnd="10dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/delete"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<Button
|
||||||
android:id="@+id/title"
|
android:id="@+id/delete"
|
||||||
android:layout_width="0dp"
|
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginEnd="10dp"
|
android:padding="15dp"
|
||||||
android:padding="10dp"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="18sp"
|
app:icon="@drawable/ic_delete_all"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/delete"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<Button
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/delete"
|
|
||||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:icon="@drawable/ic_delete_all"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
<Button
|
<Button
|
||||||
style="?attr/materialIconButtonStyle"
|
style="?attr/materialIconButtonStyle"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
|
android:scrollbars="none"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="0.01"
|
android:layout_weight="0.01"
|
||||||
app:icon="@drawable/ic_search"
|
app:icon="@drawable/ic_search"
|
||||||
|
|
@ -54,6 +55,7 @@
|
||||||
style="?attr/materialIconButtonStyle"
|
style="?attr/materialIconButtonStyle"
|
||||||
android:id="@+id/set_search_query_button"
|
android:id="@+id/set_search_query_button"
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
|
android:scrollbars="none"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:icon="@drawable/ic_arrow_up"
|
app:icon="@drawable/ic_arrow_up"
|
||||||
android:layout_weight="0.01"
|
android:layout_weight="0.01"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue