mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
增加内置文件管理器,未完成
This commit is contained in:
parent
1b39e7068c
commit
a15aace1b4
@ -1,12 +1,19 @@
|
|||||||
package io.legado.app.ui.document
|
package io.legado.app.ui.document
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.ViewGroup
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.base.VMBaseActivity
|
import io.legado.app.base.VMBaseActivity
|
||||||
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
|
import io.legado.app.base.adapter.RecyclerAdapter
|
||||||
import io.legado.app.databinding.ActivityFileManageBinding
|
import io.legado.app.databinding.ActivityFileManageBinding
|
||||||
|
import io.legado.app.databinding.ItemFileBinding
|
||||||
|
import io.legado.app.lib.theme.backgroundColor
|
||||||
import io.legado.app.lib.theme.primaryTextColor
|
import io.legado.app.lib.theme.primaryTextColor
|
||||||
|
import io.legado.app.utils.FileDoc
|
||||||
import io.legado.app.utils.applyTint
|
import io.legado.app.utils.applyTint
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
|
|
||||||
@ -18,6 +25,9 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
private val searchView: SearchView by lazy {
|
private val searchView: SearchView by lazy {
|
||||||
binding.titleBar.findViewById(R.id.search_view)
|
binding.titleBar.findViewById(R.id.search_view)
|
||||||
}
|
}
|
||||||
|
private val adapter by lazy {
|
||||||
|
FileAdapter()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
initView()
|
initView()
|
||||||
@ -25,11 +35,14 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
|
binding.layTop.setBackgroundColor(backgroundColor)
|
||||||
|
binding.recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
|
binding.recyclerView.adapter = adapter
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initSearchView() {
|
private fun initSearchView() {
|
||||||
searchView.applyTint(primaryTextColor)
|
searchView.applyTint(primaryTextColor)
|
||||||
|
searchView.queryHint = getString(R.string.screen) + " • " + getString(R.string.file_manage)
|
||||||
searchView.onActionViewExpanded()
|
searchView.onActionViewExpanded()
|
||||||
searchView.isSubmitButtonEnabled = true
|
searchView.isSubmitButtonEnabled = true
|
||||||
searchView.clearFocus()
|
searchView.clearFocus()
|
||||||
@ -45,4 +58,28 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inner class FileAdapter : RecyclerAdapter<FileDoc, ItemFileBinding>(this@FileManageActivity) {
|
||||||
|
|
||||||
|
|
||||||
|
override fun getViewBinding(parent: ViewGroup): ItemFileBinding {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun registerListener(holder: ItemViewHolder, binding: ItemFileBinding) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun convert(
|
||||||
|
holder: ItemViewHolder,
|
||||||
|
binding: ItemFileBinding,
|
||||||
|
item: FileDoc,
|
||||||
|
payloads: MutableList<Any>
|
||||||
|
) {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import android.content.Context
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import io.legado.app.base.adapter.ItemViewHolder
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
import io.legado.app.base.adapter.RecyclerAdapter
|
import io.legado.app.base.adapter.RecyclerAdapter
|
||||||
import io.legado.app.databinding.ItemFileFilepickerBinding
|
import io.legado.app.databinding.ItemFilePickerBinding
|
||||||
import io.legado.app.help.config.AppConfig
|
import io.legado.app.help.config.AppConfig
|
||||||
import io.legado.app.lib.theme.getPrimaryDisabledTextColor
|
import io.legado.app.lib.theme.getPrimaryDisabledTextColor
|
||||||
import io.legado.app.lib.theme.getPrimaryTextColor
|
import io.legado.app.lib.theme.getPrimaryTextColor
|
||||||
@ -17,7 +17,7 @@ import java.io.File
|
|||||||
|
|
||||||
|
|
||||||
class FileAdapter(context: Context, val callBack: CallBack) :
|
class FileAdapter(context: Context, val callBack: CallBack) :
|
||||||
RecyclerAdapter<FileItem, ItemFileFilepickerBinding>(context) {
|
RecyclerAdapter<FileItem, ItemFilePickerBinding>(context) {
|
||||||
private var rootPath: String? = null
|
private var rootPath: String? = null
|
||||||
var currentPath: String? = null
|
var currentPath: String? = null
|
||||||
private set
|
private set
|
||||||
@ -84,13 +84,13 @@ class FileAdapter(context: Context, val callBack: CallBack) :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getViewBinding(parent: ViewGroup): ItemFileFilepickerBinding {
|
override fun getViewBinding(parent: ViewGroup): ItemFilePickerBinding {
|
||||||
return ItemFileFilepickerBinding.inflate(inflater, parent, false)
|
return ItemFilePickerBinding.inflate(inflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun convert(
|
override fun convert(
|
||||||
holder: ItemViewHolder,
|
holder: ItemViewHolder,
|
||||||
binding: ItemFileFilepickerBinding,
|
binding: ItemFilePickerBinding,
|
||||||
item: FileItem,
|
item: FileItem,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
@ -115,7 +115,7 @@ class FileAdapter(context: Context, val callBack: CallBack) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemFileFilepickerBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemFilePickerBinding) {
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
callBack.onFileClick(holder.layoutPosition)
|
callBack.onFileClick(holder.layoutPosition)
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import android.os.Environment
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import io.legado.app.base.adapter.ItemViewHolder
|
import io.legado.app.base.adapter.ItemViewHolder
|
||||||
import io.legado.app.base.adapter.RecyclerAdapter
|
import io.legado.app.base.adapter.RecyclerAdapter
|
||||||
import io.legado.app.databinding.ItemPathFilepickerBinding
|
import io.legado.app.databinding.ItemPathPickerBinding
|
||||||
import io.legado.app.ui.document.utils.FilePickerIcon
|
import io.legado.app.ui.document.utils.FilePickerIcon
|
||||||
import io.legado.app.utils.ConvertUtils
|
import io.legado.app.utils.ConvertUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
class PathAdapter(context: Context, val callBack: CallBack) :
|
class PathAdapter(context: Context, val callBack: CallBack) :
|
||||||
RecyclerAdapter<String, ItemPathFilepickerBinding>(context) {
|
RecyclerAdapter<String, ItemPathPickerBinding>(context) {
|
||||||
private val paths = LinkedList<String>()
|
private val paths = LinkedList<String>()
|
||||||
private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow())
|
private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow())
|
||||||
|
|
||||||
@ -43,13 +43,13 @@ class PathAdapter(context: Context, val callBack: CallBack) :
|
|||||||
setItems(paths)
|
setItems(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getViewBinding(parent: ViewGroup): ItemPathFilepickerBinding {
|
override fun getViewBinding(parent: ViewGroup): ItemPathPickerBinding {
|
||||||
return ItemPathFilepickerBinding.inflate(inflater, parent, false)
|
return ItemPathPickerBinding.inflate(inflater, parent, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun convert(
|
override fun convert(
|
||||||
holder: ItemViewHolder,
|
holder: ItemViewHolder,
|
||||||
binding: ItemPathFilepickerBinding,
|
binding: ItemPathPickerBinding,
|
||||||
item: String,
|
item: String,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
@ -59,7 +59,7 @@ class PathAdapter(context: Context, val callBack: CallBack) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun registerListener(holder: ItemViewHolder, binding: ItemPathFilepickerBinding) {
|
override fun registerListener(holder: ItemViewHolder, binding: ItemPathPickerBinding) {
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
callBack.onPathClick(holder.layoutPosition)
|
callBack.onPathClick(holder.layoutPosition)
|
||||||
}
|
}
|
||||||
|
22
app/src/main/res/layout/item_file_picker.xml
Normal file
22
app/src/main/res/layout/item_file_picker.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:padding="5dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/image_view"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -1087,4 +1087,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1090,4 +1090,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1090,4 +1090,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1087,4 +1087,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1089,4 +1089,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1089,4 +1089,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1090,4 +1090,5 @@
|
|||||||
<string name="privacy_policy">用户隐私与协议</string>
|
<string name="privacy_policy">用户隐私与协议</string>
|
||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
|
<string name="file_manage">文件管理</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user