diff --git a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt index 66901c2..ea0c967 100644 --- a/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt +++ b/app/src/main/java/com/dazuoye/filemanager/compose/ui/SearchFileColumn.kt @@ -3,6 +3,8 @@ package com.dazuoye.filemanager.compose.ui import android.content.Context import android.content.Intent import android.widget.Toast +import androidx.appcompat.app.AlertDialog +import androidx.appcompat.app.AlertDialog.Builder import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border @@ -331,13 +333,7 @@ class SearchFileColumn( IconButton( onClick = { - if (file.type == Type.FILE) { // 普通文件 - AlertHelper.showOnlyInfoNewAlert(context, - onInfo = { - AlertHelper.showFileInfoAlert(context, file.path) - } - ) - } + showFileInfoAlert(context,file.path) }, 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() + } } \ No newline at end of file diff --git a/app/src/main/java/com/dazuoye/filemanager/utils/AlertHelper.kt b/app/src/main/java/com/dazuoye/filemanager/utils/AlertHelper.kt index 90869b3..e552637 100644 --- a/app/src/main/java/com/dazuoye/filemanager/utils/AlertHelper.kt +++ b/app/src/main/java/com/dazuoye/filemanager/utils/AlertHelper.kt @@ -125,26 +125,6 @@ class AlertHelper { .show() } - fun showOnlyInfoNewAlert( - context: Context, - onInfo: () -> Unit, - ) { - val builder = Builder(context) - builder.setTitle(context.getString(R.string.select_action)) - .setItems( - arrayOf( - 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)?) { val builder = Builder(context) builder.setTitle(context.getString(R.string.confirm_to_delete))