fix: file info in search
This commit is contained in:
parent
e73dea21a9
commit
1ceb0f669b
2 changed files with 26 additions and 27 deletions
|
@ -3,6 +3,8 @@ package com.dazuoye.filemanager.compose.ui
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AlertDialog.Builder
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
|
@ -331,13 +333,7 @@ class SearchFileColumn(
|
||||||
|
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
if (file.type == Type.FILE) { // 普通文件
|
showFileInfoAlert(context,file.path)
|
||||||
AlertHelper.showOnlyInfoNewAlert(context,
|
|
||||||
onInfo = {
|
|
||||||
AlertHelper.showFileInfoAlert(context, file.path)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(horizontal = 10.dp)
|
modifier = Modifier.padding(horizontal = 10.dp)
|
||||||
) {
|
) {
|
||||||
|
@ -348,4 +344,27 @@ class SearchFileColumn(
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
fun showFileInfoAlert(context: Context, file: String) {
|
||||||
|
val f = File(file)
|
||||||
|
if (!f.exists()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val wrappedFile = WrappedFile(f)
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
builder.setTitle(context.getString(R.string.file_info))
|
||||||
|
.setMessage(
|
||||||
|
context.getString(
|
||||||
|
R.string.file_info_text,
|
||||||
|
wrappedFile.name,
|
||||||
|
wrappedFile.path,
|
||||||
|
wrappedFile.getSizeString(),
|
||||||
|
wrappedFile.getModifiedTimeString(context)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setNegativeButton(context.getString(R.string.okay)) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -125,26 +125,6 @@ class AlertHelper {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showOnlyInfoNewAlert(
|
|
||||||
context: Context,
|
|
||||||
onInfo: () -> Unit,
|
|
||||||
) {
|
|
||||||
val builder = Builder(context)
|
|
||||||
builder.setTitle(context.getString(R.string.select_action))
|
|
||||||
.setItems(
|
|
||||||
arrayOf<CharSequence>(
|
|
||||||
context.getString(R.string.action_info)
|
|
||||||
)
|
|
||||||
) { _: DialogInterface?, which: Int ->
|
|
||||||
when (which) {
|
|
||||||
1 -> onInfo()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.setNegativeButton(context.getString(R.string.action_cancel))
|
|
||||||
{ dialog: DialogInterface, which: Int -> dialog.dismiss() }
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showDeleteAlert(context: Context, file: String, onConfirm: (() -> Unit)?) {
|
fun showDeleteAlert(context: Context, file: String, onConfirm: (() -> Unit)?) {
|
||||||
val builder = Builder(context)
|
val builder = Builder(context)
|
||||||
builder.setTitle(context.getString(R.string.confirm_to_delete))
|
builder.setTitle(context.getString(R.string.confirm_to_delete))
|
||||||
|
|
Loading…
Reference in a new issue