mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
增加内置文件管理器,未完成
This commit is contained in:
parent
fdcc20dcd4
commit
56d02943ee
@ -95,13 +95,13 @@
|
|||||||
app:layout="@layout/view_preference_category">
|
app:layout="@layout/view_preference_category">
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="privacyPolicy"
|
android:key="crashLog"
|
||||||
android:title="@string/privacy_policy"
|
android:title="@string/crash_log"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="crashLog"
|
android:key="privacyPolicy"
|
||||||
android:title="@string/crash_log"
|
android:title="@string/privacy_policy"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
|
@ -18,6 +18,7 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
|
|||||||
import io.legado.app.utils.ConvertUtils
|
import io.legado.app.utils.ConvertUtils
|
||||||
import io.legado.app.utils.FileDoc
|
import io.legado.app.utils.FileDoc
|
||||||
import io.legado.app.utils.applyTint
|
import io.legado.app.utils.applyTint
|
||||||
|
import io.legado.app.utils.list
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
|
|
||||||
class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageViewModel>(),
|
class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageViewModel>(),
|
||||||
@ -38,6 +39,7 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
initView()
|
initView()
|
||||||
initSearchView()
|
initSearchView()
|
||||||
|
initData()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun initView() {
|
||||||
@ -66,15 +68,17 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initData() {
|
||||||
|
viewModel.rootDoc?.list()?.let {
|
||||||
|
fileAdapter.setItems(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onPathClick(position: Int) {
|
override fun onPathClick(position: Int) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class FileAdapter : RecyclerAdapter<FileDoc, ItemFileBinding>(this@FileManageActivity) {
|
inner class FileAdapter : RecyclerAdapter<FileDoc, ItemFileBinding>(this@FileManageActivity) {
|
||||||
private var rootPath: String? = null
|
|
||||||
var currentPath: String? = null
|
|
||||||
private set
|
|
||||||
private val homeIcon = ConvertUtils.toDrawable(FilePickerIcon.getHome())!!
|
|
||||||
private val upIcon = ConvertUtils.toDrawable(FilePickerIcon.getUpDir())!!
|
private val upIcon = ConvertUtils.toDrawable(FilePickerIcon.getUpDir())!!
|
||||||
private val folderIcon = ConvertUtils.toDrawable(FilePickerIcon.getFolder())!!
|
private val folderIcon = ConvertUtils.toDrawable(FilePickerIcon.getFolder())!!
|
||||||
private val fileIcon = ConvertUtils.toDrawable(FilePickerIcon.getFile())!!
|
private val fileIcon = ConvertUtils.toDrawable(FilePickerIcon.getFile())!!
|
||||||
@ -93,7 +97,14 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
item: FileDoc,
|
item: FileDoc,
|
||||||
payloads: MutableList<Any>
|
payloads: MutableList<Any>
|
||||||
) {
|
) {
|
||||||
binding.imageView
|
if (!item.isDir) {
|
||||||
|
binding.imageView.setImageDrawable(fileIcon)
|
||||||
|
} else if (holder.layoutPosition == 0 && viewModel.subDocs.isNotEmpty()) {
|
||||||
|
binding.imageView.setImageDrawable(upIcon)
|
||||||
|
} else {
|
||||||
|
binding.imageView.setImageDrawable(folderIcon)
|
||||||
|
}
|
||||||
|
binding.textView.text = item.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,13 @@ package io.legado.app.ui.document
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import io.legado.app.base.BaseViewModel
|
import io.legado.app.base.BaseViewModel
|
||||||
|
import io.legado.app.utils.FileDoc
|
||||||
|
|
||||||
class FileManageViewModel(application: Application) : BaseViewModel(application) {
|
class FileManageViewModel(application: Application) : BaseViewModel(application) {
|
||||||
|
|
||||||
|
val rootDoc = context.getExternalFilesDir(null)?.parentFile?.let {
|
||||||
|
FileDoc.fromFile(it)
|
||||||
|
}
|
||||||
|
val subDocs = arrayListOf<FileDoc>()
|
||||||
|
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ import io.legado.app.ui.book.toc.rule.TxtTocRuleActivity
|
|||||||
import io.legado.app.ui.config.ConfigActivity
|
import io.legado.app.ui.config.ConfigActivity
|
||||||
import io.legado.app.ui.config.ConfigTag
|
import io.legado.app.ui.config.ConfigTag
|
||||||
import io.legado.app.ui.dict.rule.DictRuleActivity
|
import io.legado.app.ui.dict.rule.DictRuleActivity
|
||||||
|
import io.legado.app.ui.document.FileManageActivity
|
||||||
import io.legado.app.ui.replace.ReplaceRuleActivity
|
import io.legado.app.ui.replace.ReplaceRuleActivity
|
||||||
import io.legado.app.ui.widget.dialog.TextDialog
|
import io.legado.app.ui.widget.dialog.TextDialog
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.*
|
||||||
@ -150,6 +151,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config) {
|
|||||||
"theme_setting" -> startActivity<ConfigActivity> {
|
"theme_setting" -> startActivity<ConfigActivity> {
|
||||||
putExtra("configTag", ConfigTag.THEME_CONFIG)
|
putExtra("configTag", ConfigTag.THEME_CONFIG)
|
||||||
}
|
}
|
||||||
|
"fileManage" -> startActivity<FileManageActivity>()
|
||||||
"readRecord" -> startActivity<ReadRecordActivity>()
|
"readRecord" -> startActivity<ReadRecordActivity>()
|
||||||
"donate" -> startActivity<DonateActivity>()
|
"donate" -> startActivity<DonateActivity>()
|
||||||
"about" -> startActivity<AboutActivity>()
|
"about" -> startActivity<AboutActivity>()
|
||||||
|
10
app/src/main/res/drawable/ic_folder_outline.xml
Normal file
10
app/src/main/res/drawable/ic_folder_outline.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector android:height="24dp"
|
||||||
|
android:tint="#000000"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:width="24dp"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M9.17,6l2,2H20v10H4V6h5.17M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z" />
|
||||||
|
</vector>
|
@ -1088,4 +1088,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1091,4 +1091,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1091,4 +1091,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1088,4 +1088,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1090,4 +1090,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1090,4 +1090,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1091,4 +1091,5 @@
|
|||||||
<string name="agree">同意</string>
|
<string name="agree">同意</string>
|
||||||
<string name="refuse">拒绝</string>
|
<string name="refuse">拒绝</string>
|
||||||
<string name="file_manage">文件管理</string>
|
<string name="file_manage">文件管理</string>
|
||||||
|
<string name="file_manage_summary">管理私有文件夹的文件</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -89,13 +89,13 @@
|
|||||||
app:layout="@layout/view_preference_category">
|
app:layout="@layout/view_preference_category">
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="privacyPolicy"
|
android:key="crashLog"
|
||||||
android:title="@string/privacy_policy"
|
android:title="@string/crash_log"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="crashLog"
|
android:key="privacyPolicy"
|
||||||
android:title="@string/crash_log"
|
android:title="@string/privacy_policy"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
|
@ -104,6 +104,13 @@
|
|||||||
android:icon="@drawable/ic_history"
|
android:icon="@drawable/ic_history"
|
||||||
app:iconSpaceReserved="false" />
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.prefs.Preference
|
||||||
|
android:key="fileManage"
|
||||||
|
android:title="@string/file_manage"
|
||||||
|
android:summary="@string/file_manage_summary"
|
||||||
|
android:icon="@drawable/ic_folder_outline"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
|
|
||||||
<io.legado.app.lib.prefs.Preference
|
<io.legado.app.lib.prefs.Preference
|
||||||
android:key="donate"
|
android:key="donate"
|
||||||
android:summary="@string/donate_summary"
|
android:summary="@string/donate_summary"
|
||||||
|
Loading…
Reference in New Issue
Block a user