优化
This commit is contained in:
@@ -5,12 +5,14 @@ import android.os.Bundle
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
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.ItemViewHolder
|
||||||
import io.legado.app.base.adapter.RecyclerAdapter
|
import io.legado.app.base.adapter.RecyclerAdapter
|
||||||
|
import io.legado.app.constant.AppConst
|
||||||
import io.legado.app.databinding.ActivityFileManageBinding
|
import io.legado.app.databinding.ActivityFileManageBinding
|
||||||
import io.legado.app.databinding.ItemFileBinding
|
import io.legado.app.databinding.ItemFileBinding
|
||||||
import io.legado.app.databinding.ItemPathPickerBinding
|
import io.legado.app.databinding.ItemPathPickerBinding
|
||||||
@@ -19,6 +21,7 @@ import io.legado.app.ui.document.utils.FilePickerIcon
|
|||||||
import io.legado.app.ui.widget.recycler.VerticalDivider
|
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.applyTint
|
import io.legado.app.utils.applyTint
|
||||||
|
import io.legado.app.utils.openFileUri
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -141,6 +144,14 @@ class FileManageActivity : VMBaseActivity<ActivityFileManageBinding, FileManageV
|
|||||||
viewModel.subDocs.add(item)
|
viewModel.subDocs.add(item)
|
||||||
pathAdapter.setItems(viewModel.subDocs)
|
pathAdapter.setItems(viewModel.subDocs)
|
||||||
viewModel.upFiles(item)
|
viewModel.upFiles(item)
|
||||||
|
} else {
|
||||||
|
openFileUri(
|
||||||
|
FileProvider.getUriForFile(
|
||||||
|
this@FileManageActivity,
|
||||||
|
AppConst.authority,
|
||||||
|
item
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class SelectActionBar @JvmOverloads constructor(
|
|||||||
.inflate(LayoutInflater.from(context), this, true)
|
.inflate(LayoutInflater.from(context), this, true)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
if (!isInEditMode) {
|
||||||
setBackgroundColor(context.bottomBackground)
|
setBackgroundColor(context.bottomBackground)
|
||||||
elevation = context.elevation
|
elevation = context.elevation
|
||||||
binding.cbSelectedAll.setTextColor(primaryTextColor)
|
binding.cbSelectedAll.setTextColor(primaryTextColor)
|
||||||
@@ -46,6 +47,7 @@ class SelectActionBar @JvmOverloads constructor(
|
|||||||
binding.btnSelectActionMain.setOnClickListener { callBack?.onClickSelectBarMainAction() }
|
binding.btnSelectActionMain.setOnClickListener { callBack?.onClickSelectBarMainAction() }
|
||||||
binding.ivMenuMore.setOnClickListener { selMenu?.show() }
|
binding.ivMenuMore.setOnClickListener { selMenu?.show() }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setMainActionText(text: String) = binding.run {
|
fun setMainActionText(text: String) = binding.run {
|
||||||
btnSelectActionMain.text = text
|
btnSelectActionMain.text = text
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ fun Context.openUrl(url: String) {
|
|||||||
startActivity(IntentHelp.getBrowserIntent(url))
|
startActivity(IntentHelp.getBrowserIntent(url))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toastOnUi(e.localizedMessage ?: "open url error")
|
toastOnUi(e.localizedMessage ?: "open url error")
|
||||||
|
e.printOnDebug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,6 +313,7 @@ fun Context.openUrl(uri: Uri) {
|
|||||||
startActivity(IntentHelp.getBrowserIntent(uri))
|
startActivity(IntentHelp.getBrowserIntent(uri))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toastOnUi(e.localizedMessage ?: "open url error")
|
toastOnUi(e.localizedMessage ?: "open url error")
|
||||||
|
e.printOnDebug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,6 +330,7 @@ fun Context.openFileUri(uri: Uri, type: String? = null) {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
toastOnUi(e.stackTraceStr)
|
toastOnUi(e.stackTraceStr)
|
||||||
|
e.printOnDebug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,21 +7,25 @@ import java.io.File
|
|||||||
@Keep
|
@Keep
|
||||||
object IntentType {
|
object IntentType {
|
||||||
|
|
||||||
fun from(uri: Uri): String? {
|
fun from(uri: Uri): String {
|
||||||
return from(uri.toString())
|
return from(uri.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun from(file: File): String? {
|
fun from(file: File): String {
|
||||||
return from(file.absolutePath)
|
return from(file.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun from(path: String?): String? {
|
fun from(path: String?): String {
|
||||||
return when (path?.substringAfterLast(".")?.lowercase()) {
|
val suffix = path
|
||||||
|
?.substringAfterLast(File.separator)
|
||||||
|
?.substringAfterLast(".", "")
|
||||||
|
?.lowercase()
|
||||||
|
return when (suffix) {
|
||||||
"m4a", "mp3", "mid", "xmf", "ogg", "wav" -> "video/*"
|
"m4a", "mp3", "mid", "xmf", "ogg", "wav" -> "video/*"
|
||||||
"3gp", "mp4" -> "audio/*"
|
"3gp", "mp4" -> "audio/*"
|
||||||
"jpg", "gif", "png", "jpeg", "bmp" -> "image/*"
|
"jpg", "gif", "png", "jpeg", "bmp" -> "image/*"
|
||||||
"txt", "json" -> "text/plain"
|
"", "txt", "json", "log" -> "text/plain"
|
||||||
else -> appIntentType?.from(path)
|
else -> appIntentType?.from(path) ?: "*/*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:contentInsetStartWithNavigation="0dp"
|
app:contentInsetRight="24dp"
|
||||||
app:contentLayout="@layout/view_search" />
|
app:contentLayout="@layout/view_search" />
|
||||||
|
|
||||||
<!--path-->
|
<!--path-->
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
app:layout_constraintBottom_toTopOf="@id/select_action_bar"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/rv_path">
|
app:layout_constraintTop_toBottomOf="@id/rv_path">
|
||||||
|
|
||||||
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
|
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
|
||||||
@@ -50,10 +50,4 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<io.legado.app.ui.widget.SelectActionBar
|
|
||||||
android:id="@+id/select_action_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user