Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
H
HookNotify
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
steve
HookNotify
Commits
93f3bd18
Commit
93f3bd18
authored
Feb 24, 2022
by
steve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除-先删除开发中的code 以免merge出现问题
parent
7a63e917
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
133 deletions
+0
-133
LogSaveUnit.kt
app/src/main/java/com/go/hookNotify/units/LogSaveUnit.kt
+0
-133
No files found.
app/src/main/java/com/go/hookNotify/units/LogSaveUnit.kt
View file @
93f3bd18
...
...
@@ -15,8 +15,6 @@ import java.util.*
object
LogSaveUnit
{
private
val
TAG
=
LogSaveUnit
::
class
.
simpleName
.
toString
()
fun
saveLogFile
(
documentPath
:
String
,
sContent
:
String
)
{
val
sdf
=
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
())
val
calendar
=
Calendar
.
getInstance
()
...
...
@@ -33,137 +31,6 @@ object LogSaveUnit {
save
(
destFile
,
sContent
)
}
// /**
// * android 版本 0..28(小於29)
// * 檢查文件是否存在
// */
// private fun checkFileLTAndroidQ(context: Context, saveFileName: String): String {
// var getSaveContent = ""
// val destFile = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), saveFileName)
// val uri: Uri?
// if (destFile.exists()) uri = Uri.parse("file://" + destFile.absoluteFile) else return ""
// try {
// val fileDescriptor = uri?.let { context.contentResolver.openFileDescriptor(it, "r", null) }
// val inputStream = FileInputStream(fileDescriptor?.fileDescriptor)
// getSaveContent = inputStreamToString(inputStream)
// } catch (e: FileNotFoundException) {
// e.printStackTrace()
// }
// return getSaveContent
// }
//
// /**
// * android 版本 29
// * 檢查文件是否存在
// */
// private fun checkFileAndroidQ(context: Context, saveFileName: String): String {
// val imageUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI
// val projection: Array<String> = arrayOf(MediaStore.Images.Media.DISPLAY_NAME, MediaStore.Images.Media._ID)
//
// //查詢
// val contentResolver = context.contentResolver
//
// //添加篩選條件
// val selection = "${MediaStore.Images.Media.DISPLAY_NAME}='$saveFileName'"
// val cursor = contentResolver.query(imageUri, projection, selection, null, null)
//
// var getSaveContent = ""
// if (cursor != null) {
// while (cursor.moveToNext()) {
// val fileIdIndex = cursor.getColumnIndex(MediaStore.Images.Media._ID)
// val thumbPath = MediaStore.Images.Media.EXTERNAL_CONTENT_URI.buildUpon().appendPath(cursor.getInt(fileIdIndex).toString()).build().toString()
// val fileUri = Uri.parse(thumbPath)
//
// try {
// val fileDescriptor = contentResolver.openAssetFileDescriptor(fileUri, "r", null)
// val inputStream = FileInputStream(fileDescriptor?.fileDescriptor)
// getSaveContent = inputStreamToString(inputStream)
// } catch (e: FileNotFoundException) {
// e.printStackTrace()
// }
//
// //只有在得到的唯一標示符
// if (!TextUtils.isEmpty(getSaveContent)) {
// break
// }
// }
// cursor.close()
// }
// return getSaveContent
// }
//
// /**
// * android 版本 大於 29
// * 檢查文件是否存在
// */
// @SuppressLint("Range")
// private fun checkFileGtAndroidQ(context: Context, saveFileName: String): String? {
// val cr = context.contentResolver
// val contentUri = MediaStore.Files.getContentUri("external")
// val projection: Array<String> = arrayOf(MediaStore.Files.FileColumns._ID, MediaStore.Files.FileColumns.DISPLAY_NAME)
// val selection = "${MediaStore.Files.FileColumns.MEDIA_TYPE}=${MediaStore.Files.FileColumns.MEDIA_TYPE_NONE}"
// val selectionArgs: Array<String>? = null
// val sortOrder = null
// val cursor = cr.query(contentUri, projection, selection, selectionArgs, sortOrder)
// var uri: Uri? = null
// val columnIndexID: Int
// if (cursor?.count == 0) {
// Log.d(TAG, "no file")
// return null
// } else {
// columnIndexID = cursor?.getColumnIndexOrThrow(MediaStore.Files.FileColumns._ID)!!
// while (cursor.moveToNext()) {
// val fileID = cursor.getLong(columnIndexID)
// val fileName = cursor.getString(cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME))
// if (fileName == saveFileName) {
// uri = Uri.withAppendedPath(contentUri, fileID.toString())
// break
// }
// }
// if (uri == null) {
// Log.d(TAG, "no uri")
// return null
// } else {
// return try {
// val fieldException = cr.openAssetFileDescriptor(uri, "r", null)
// val inputStream = FileInputStream(fieldException?.fileDescriptor)
// val sUUID = inputStreamToString(inputStream)
// inputStream.close()
// sUUID
// } catch (e: IOException) {
// Log.d(TAG, e.message.toString())
// null
// } finally {
// cursor.close()
// }
// }
// }
// }
// /**
// * 流 轉為 字符串
// * @param inputStream 流
// * @return 轉換完成的字符串
// */
// private fun inputStreamToString(inputStream: InputStream): String {
// val reader = BufferedReader(InputStreamReader(inputStream))
// val sb = StringBuilder()
// try {
// reader.use { r -> r.lineSequence().forEach { sb.append(it) } }
// } catch (e: IOException) {
// e.printStackTrace()
// } finally {
// try {
// inputStream.close()
// } catch (e: IOException) {
// e.printStackTrace()
// }
// }
// return sb.toString()
// }
private
fun
save
(
file
:
File
,
content
:
String
):
Boolean
{
if
(!
createFile
(
file
,
true
))
{
Log
.
e
(
"FileSaveUtil"
,
"create or delete file <\$file> failed."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment