This commit is contained in:
Kagura 2024-10-10 13:01:51 +08:00
parent 3242c9f4a0
commit f133a4446b
32 changed files with 260 additions and 459 deletions

View file

@ -1,15 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -21,6 +12,11 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MyApplication" android:theme="@style/Theme.MyApplication"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".compose.SearchActivity"
android:exported="false"
android:label="@string/title_activity_search"
android:theme="@style/Theme.MyApplication" />
<activity <activity
android:name=".compose.RequirePermissionActivity" android:name=".compose.RequirePermissionActivity"
android:exported="true" android:exported="true"
@ -34,36 +30,27 @@
<activity <activity
android:name=".compose.ViewFileActivity" android:name=".compose.ViewFileActivity"
android:exported="false" /> android:exported="false" />
<activity
android:name=".main_page"
android:exported="false" />
<activity <activity
android:name=".store_page" android:name=".store_page"
android:exported="false" /> android:exported="false" />
<activity
android:name=".document_page_search"
android:exported="false" />
<activity <activity
android:name=".document_page" android:name=".document_page"
android:exported="false" /> android:exported="false" />
<activity
android:name=".music_page_search"
android:exported="false" />
<activity
android:name=".music_page"
android:exported="false" />
<activity
android:name=".video_page_search"
android:exported="false" />
<activity
android:name=".picture_page_search"
android:exported="false" />
<activity
android:name=".main_page"
android:exported="false" />
<activity <activity
android:name=".picture_page" android:name=".picture_page"
android:exported="false" /> android:exported="false" />
<activity <activity
android:name=".video_page" android:name=".video_page"
android:exported="false" /> android:exported="false" />
<activity
android:name=".music_page"
android:exported="false" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
@ -75,4 +62,15 @@
android:resource="@xml/provider_paths" /> android:resource="@xml/provider_paths" />
</provider> </provider>
</application> </application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest> </manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View file

@ -44,7 +44,8 @@ class RequirePermissionActivity : ComponentActivity() {
window.statusBarColor = getColor(R.color.WhiteSmoke) window.statusBarColor = getColor(R.color.WhiteSmoke)
setContent { setContent {
Column( Column(
modifier = Modifier.statusBarsPadding() modifier = Modifier
.statusBarsPadding()
.fillMaxHeight(0.9f) .fillMaxHeight(0.9f)
.fillMaxWidth(), .fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
@ -72,7 +73,11 @@ class RequirePermissionActivity : ComponentActivity() {
startActivity(intent) startActivity(intent)
} }
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
val perm33 = arrayOf(permission.READ_MEDIA_AUDIO,permission.READ_MEDIA_VIDEO,permission.READ_MEDIA_IMAGES) val perm33 = arrayOf(
permission.READ_MEDIA_AUDIO,
permission.READ_MEDIA_VIDEO,
permission.READ_MEDIA_IMAGES
)
ActivityCompat.requestPermissions( ActivityCompat.requestPermissions(
activity, perm33, 101 activity, perm33, 101
) )
@ -96,7 +101,6 @@ class RequirePermissionActivity : ComponentActivity() {
} }
} }
} }
} }
override fun onResume() { override fun onResume() {
@ -119,7 +123,11 @@ fun checkPermissions(context: Context): Boolean {
return false return false
} }
if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
val perm33 = arrayOf(permission.READ_MEDIA_AUDIO,permission.READ_MEDIA_VIDEO,permission.READ_MEDIA_IMAGES) val perm33 = arrayOf(
permission.READ_MEDIA_AUDIO,
permission.READ_MEDIA_VIDEO,
permission.READ_MEDIA_IMAGES
)
perm33.forEach { perm33.forEach {
if (context.checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED) { if (context.checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED) {
return false return false

View file

@ -0,0 +1,29 @@
package com.example.myapplication.compose
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister
import com.example.myapplication.fileSystem.byTypeFileLister.ImageLister
import com.example.myapplication.fileSystem.byTypeFileLister.MusicLister
import com.example.myapplication.fileSystem.byTypeFileLister.VideoLister
class SearchActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val type = intent.extras?.getString("type")
val searchTypeRegex: Regex? = when (type) {
"music" -> MusicLister.regex
"image" -> ImageLister.regex
"video" -> VideoLister.regex
"document" -> DocumentLister.regex
else -> null
}
enableEdgeToEdge()
setContent {
}
}
}

View file

@ -1,5 +1,6 @@
package com.example.myapplication.compose.ui package com.example.myapplication.compose.ui
import android.annotation.SuppressLint
import android.content.ClipData import android.content.ClipData
import android.content.ClipDescription import android.content.ClipDescription
import android.content.Context import android.content.Context
@ -349,8 +350,7 @@ class FileColumn(val context: Context) {
) )
) )
}) })
} },
,
dragAndDropCallBack = dragAndDropCallBack, dragAndDropCallBack = dragAndDropCallBack,
onItemClick = onItemClick onItemClick = onItemClick
) )
@ -367,7 +367,7 @@ class FileColumn(val context: Context) {
forceName: String? = null, forceName: String? = null,
forceParent: String? = null, forceParent: String? = null,
update: (() -> Unit)? = null, update: (() -> Unit)? = null,
dragAndDrop: Modifier = Modifier, @SuppressLint("ModifierParameter") dragAndDrop: Modifier = Modifier,
dragAndDropCallBack: DragAndDropTarget? = null, dragAndDropCallBack: DragAndDropTarget? = null,
onItemClick: ((String) -> Unit)? = null onItemClick: ((String) -> Unit)? = null
) { ) {
@ -443,7 +443,8 @@ class FileColumn(val context: Context) {
.padding(vertical = 3.dp) .padding(vertical = 3.dp)
.clickable { .clickable {
onItemClick?.invoke(file.path) onItemClick?.invoke(file.path)
}.then( }
.then(
if (dragAndDropCallBack != null) { if (dragAndDropCallBack != null) {
Modifier.dragAndDropTarget( Modifier.dragAndDropTarget(
shouldStartDragAndDrop = { event -> shouldStartDragAndDrop = { event ->
@ -459,9 +460,7 @@ class FileColumn(val context: Context) {
} else { } else {
Modifier Modifier
} }
) ),
,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Image( Image(
@ -509,9 +508,6 @@ class FileColumn(val context: Context) {
if (f.isFile) { if (f.isFile) {
ClipHelper.getInstance(context).copy(f, context) ClipHelper.getInstance(context).copy(f, context)
} }
},
onPaste = {
}, },
onDelete = { onDelete = {
AlertHelper.showDeleteAlert(context, file.path) { AlertHelper.showDeleteAlert(context, file.path) {
@ -533,9 +529,6 @@ class FileColumn(val context: Context) {
if (f.isDirectory) { if (f.isDirectory) {
ClipHelper.getInstance(context).copyFolder(f.path) ClipHelper.getInstance(context).copyFolder(f.path)
} }
},
onPaste = {
}, },
onDelete = { onDelete = {
AlertHelper.showDeleteAlert(context, file.path) { AlertHelper.showDeleteAlert(context, file.path) {

View file

@ -1,11 +1,11 @@
package com.example.myapplication package com.example.myapplication
import android.annotation.SuppressLint
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.util.Log
import android.view.View import android.view.View
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.GridView import android.widget.GridView
@ -21,6 +21,7 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type import androidx.core.view.WindowInsetsCompat.Type
import com.example.myapplication.adapters.DocumentAdapter import com.example.myapplication.adapters.DocumentAdapter
import com.example.myapplication.adapters.DocumentModel import com.example.myapplication.adapters.DocumentModel
import com.example.myapplication.compose.SearchActivity
import com.example.myapplication.fileSystem.CutHelper import com.example.myapplication.fileSystem.CutHelper
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.instance import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.instance
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.regex import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.regex
@ -71,9 +72,12 @@ class document_page : AppCompatActivity() {
searchImageView.setOnClickListener { v: View? -> searchImageView.setOnClickListener { v: View? ->
val intent = val intent =
Intent( Intent(
this@document_page, this,
document_page_search::class.java SearchActivity::class.java
) )
val bundle = Bundle()
bundle.putString("type", "document")
intent.putExtras(bundle)
startActivity(intent) // 跳转到搜索页面 startActivity(intent) // 跳转到搜索页面
} }
@ -93,7 +97,8 @@ class document_page : AppCompatActivity() {
file file
) )
val intent = Intent(Intent.ACTION_VIEW) val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(uri, when(file.extension){ intent.setDataAndType(
uri, when (file.extension) {
"xls" -> "application/vnd.ms-excel" "xls" -> "application/vnd.ms-excel"
"xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
"doc" -> "application/msword" "doc" -> "application/msword"
@ -105,11 +110,14 @@ class document_page : AppCompatActivity() {
"pdf" -> "application/pdf" "pdf" -> "application/pdf"
else -> "application/*" else -> "application/*"
}) }
)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
try { startActivity(intent) } try {
catch (e: ActivityNotFoundException){ startActivity(intent)
Toast.makeText(baseContext,"没有安装可以打开此类型文件的应用",Toast.LENGTH_SHORT).show() } catch (e: ActivityNotFoundException) {
Toast.makeText(baseContext, "没有安装可以打开此类型文件的应用", Toast.LENGTH_SHORT)
.show()
} }
} }
} }
@ -133,8 +141,7 @@ class document_page : AppCompatActivity() {
} }
runOnUiThread { runOnUiThread {
val adapter = DocumentAdapter(this@document_page, models) val adapter = DocumentAdapter(this@document_page, models)
val grid = findViewById<GridView>(R.id.DocumentGrid) documentGrid.setAdapter(adapter)
grid.setAdapter(adapter)
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
} }
} }
@ -204,7 +211,12 @@ class document_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -222,7 +234,12 @@ class document_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -262,6 +279,7 @@ class document_page : AppCompatActivity() {
} }
} }
@SuppressLint("SetTextI18n")
private fun loadingText( private fun loadingText(
loadingTextView: TextView, loadingTextView: TextView,
defaultText: CharSequence, defaultText: CharSequence,

View file

@ -1,44 +0,0 @@
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SearchView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
public class document_page_search extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.document_page_search);
// 设置左箭头的点击事件返回上一级页面
ImageView leftArrowImageView = findViewById(R.id.leftArrowImageView);
leftArrowImageView.setOnClickListener(v -> {
Intent intent = new Intent(document_page_search.this, document_page.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
});
SearchView searchView = findViewById(R.id.searchDocument); // 确保使用正确的 ID
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// 处理搜索提交
Toast.makeText(document_page_search.this, "搜索: " + query, Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// 处理搜索文本变化
// 可以在这里添加过滤逻辑
return false;
}
});
}
}

View file

@ -6,7 +6,7 @@ import android.os.Environment
import android.os.storage.StorageManager import android.os.storage.StorageManager
import java.io.IOException import java.io.IOException
class SystemStorageInfo(private val context: Context) { class SystemStorageInfo(context: Context) {
private val storageManager = context.getSystemService(Context.STORAGE_SERVICE) as StorageManager private val storageManager = context.getSystemService(Context.STORAGE_SERVICE) as StorageManager
private val storageStatsManager = private val storageStatsManager =
context.getSystemService(Context.STORAGE_STATS_SERVICE) as StorageStatsManager context.getSystemService(Context.STORAGE_STATS_SERVICE) as StorageStatsManager
@ -34,6 +34,7 @@ class SystemStorageInfo(private val context: Context) {
} }
} }
fun getUsedPercentage(): Int = 100 - Math.round(freeStorage.toDouble() * 100 / totalStorage.toDouble()).toInt() fun getUsedPercentage(): Int =
100 - Math.round(freeStorage.toDouble() * 100 / totalStorage.toDouble()).toInt()
} }

View file

@ -10,7 +10,8 @@ import java.io.File
class MusicLister : Lister() { class MusicLister : Lister() {
companion object { companion object {
val instance by lazy { MusicLister() } val instance by lazy { MusicLister() }
val directories = listOf("Recordings", "Download", "Audiobooks", "Music", "Podcasts", "Ringtones") val directories =
listOf("Recordings", "Download", "Audiobooks", "Music", "Podcasts", "Ringtones")
val regex = "\\.(mp3|ogg|aac|wav)".toRegex() val regex = "\\.(mp3|ogg|aac|wav)".toRegex()
} }

View file

@ -2,7 +2,12 @@ package com.example.myapplication.fileSystem.byTypeFileLister
import java.io.File import java.io.File
fun Lister.walkDir(directory: File,list: MutableList<String>,pattern: Regex ,ignoreDotFile: Boolean = true){ fun Lister.walkDir(
directory: File,
list: MutableList<String>,
pattern: Regex,
ignoreDotFile: Boolean = true
) {
if (!directory.exists() || !directory.isDirectory) { if (!directory.exists() || !directory.isDirectory) {
return return
} }

View file

@ -1,10 +1,10 @@
package com.example.myapplication package com.example.myapplication
import android.annotation.SuppressLint
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.util.Log
import android.view.View import android.view.View
import android.widget.AdapterView import android.widget.AdapterView
import android.widget.GridView import android.widget.GridView
@ -20,11 +20,10 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type import androidx.core.view.WindowInsetsCompat.Type
import com.example.myapplication.adapters.MusicAdapter import com.example.myapplication.adapters.MusicAdapter
import com.example.myapplication.adapters.MusicModel import com.example.myapplication.adapters.MusicModel
import com.example.myapplication.compose.SearchActivity
import com.example.myapplication.fileSystem.CutHelper import com.example.myapplication.fileSystem.CutHelper
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion
import com.example.myapplication.fileSystem.byTypeFileLister.MusicLister.Companion.instance import com.example.myapplication.fileSystem.byTypeFileLister.MusicLister.Companion.instance
import com.example.myapplication.fileSystem.byTypeFileLister.MusicLister.Companion.regex
import com.example.myapplication.utils.AlertHelper import com.example.myapplication.utils.AlertHelper
import com.example.myapplication.utils.ClipHelper import com.example.myapplication.utils.ClipHelper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -71,9 +70,12 @@ class music_page : AppCompatActivity() {
searchImageView.setOnClickListener { v: View? -> searchImageView.setOnClickListener { v: View? ->
val intent = val intent =
Intent( Intent(
this@music_page, this,
music_page_search::class.java SearchActivity::class.java
) )
val bundle = Bundle()
bundle.putString("type", "music")
intent.putExtras(bundle)
startActivity(intent) // 跳转到搜索页面 startActivity(intent) // 跳转到搜索页面
} }
@ -118,8 +120,7 @@ class music_page : AppCompatActivity() {
} }
runOnUiThread { runOnUiThread {
val adapter = MusicAdapter(this@music_page, models) val adapter = MusicAdapter(this@music_page, models)
val grid = findViewById<GridView>(R.id.MusicGrid) musicGrid.setAdapter(adapter)
grid.setAdapter(adapter)
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
} }
} }
@ -189,7 +190,12 @@ class music_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -207,7 +213,12 @@ class music_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -247,6 +258,7 @@ class music_page : AppCompatActivity() {
} }
} }
@SuppressLint("SetTextI18n")
private fun loadingText( private fun loadingText(
loadingTextView: TextView, loadingTextView: TextView,
defaultText: CharSequence, defaultText: CharSequence,

View file

@ -1,43 +0,0 @@
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SearchView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
public class music_page_search extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.music_page_search);
// 设置左箭头的点击事件返回上一级页面
ImageView leftArrowImageView = findViewById(R.id.leftArrowImageView);
leftArrowImageView.setOnClickListener(v -> {
Intent intent = new Intent(music_page_search.this, music_page.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
});
SearchView searchView = findViewById(R.id.searchMusic); // 确保使用正确的 ID
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// 处理搜索提交
Toast.makeText(music_page_search.this, "搜索: " + query, Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// 处理搜索文本变化
// 可以在这里添加过滤逻辑
return false;
}
});
}
}

View file

@ -1,5 +1,6 @@
package com.example.myapplication package com.example.myapplication
import android.annotation.SuppressLint
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -19,11 +20,10 @@ import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type import androidx.core.view.WindowInsetsCompat.Type
import com.example.myapplication.adapters.ImageAdapter import com.example.myapplication.adapters.ImageAdapter
import com.example.myapplication.adapters.ImageModel import com.example.myapplication.adapters.ImageModel
import com.example.myapplication.compose.SearchActivity
import com.example.myapplication.fileSystem.CutHelper import com.example.myapplication.fileSystem.CutHelper
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion
import com.example.myapplication.fileSystem.byTypeFileLister.ImageLister.Companion.instance import com.example.myapplication.fileSystem.byTypeFileLister.ImageLister.Companion.instance
import com.example.myapplication.fileSystem.byTypeFileLister.ImageLister.Companion.regex
import com.example.myapplication.utils.AlertHelper import com.example.myapplication.utils.AlertHelper
import com.example.myapplication.utils.ClipHelper import com.example.myapplication.utils.ClipHelper
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -73,8 +73,11 @@ class picture_page : AppCompatActivity() {
val intent = val intent =
Intent( Intent(
this@picture_page, this@picture_page,
picture_page_search::class.java SearchActivity::class.java
) )
val bundle = Bundle()
bundle.putString("type", "image")
intent.putExtras(bundle)
startActivity(intent) // 跳转到搜索页面 startActivity(intent) // 跳转到搜索页面
} }
@ -119,8 +122,7 @@ class picture_page : AppCompatActivity() {
} }
runOnUiThread { runOnUiThread {
val adapter = ImageAdapter(this@picture_page, imageModels) val adapter = ImageAdapter(this@picture_page, imageModels)
val grid = findViewById<GridView>(R.id.PicturePageGrid) pictureGrid.setAdapter(adapter)
grid.setAdapter(adapter)
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
} }
} }
@ -190,7 +192,12 @@ class picture_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -208,7 +215,12 @@ class picture_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -248,6 +260,7 @@ class picture_page : AppCompatActivity() {
} }
} }
@SuppressLint("SetTextI18n")
private fun loadingText( private fun loadingText(
loadingTextView: TextView, loadingTextView: TextView,
defaultText: CharSequence, defaultText: CharSequence,

View file

@ -1,43 +0,0 @@
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SearchView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
public class picture_page_search extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.picture_page_search);
// 设置左箭头的点击事件返回上一级页面
ImageView leftArrowImageView = findViewById(R.id.leftArrowImageView);
leftArrowImageView.setOnClickListener(v -> {
Intent intent = new Intent(picture_page_search.this, picture_page.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
});
SearchView searchView = findViewById(R.id.searchPicture); // 确保使用正确的 ID
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// 处理搜索提交
Toast.makeText(picture_page_search.this, "搜索: " + query, Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// 处理搜索文本变化
// 可以在这里添加过滤逻辑
return false;
}
});
}
}

View file

@ -58,7 +58,8 @@ class store_page : AppCompatActivity() {
val musicSizeString = WrappedFile.getSizeString(musicSize) val musicSizeString = WrappedFile.getSizeString(musicSize)
val documentSize = DocumentLister.instance.getFullSize() val documentSize = DocumentLister.instance.getFullSize()
val documentSizeString = WrappedFile.getSizeString(documentSize) val documentSizeString = WrappedFile.getSizeString(documentSize)
val otherSize = systemStorageInfo.getTotalStorageSize() - systemStorageInfo.getFreeStorageSize() - imageSize - musicSize - documentSize val otherSize =
systemStorageInfo.getTotalStorageSize() - systemStorageInfo.getFreeStorageSize() - imageSize - musicSize - documentSize
val otherSizeString = WrappedFile.getSizeString(otherSize) val otherSizeString = WrappedFile.getSizeString(otherSize)
runOnUiThread { runOnUiThread {
findViewById<TextView>(R.id.pictureStorage).text = imageSizeString findViewById<TextView>(R.id.pictureStorage).text = imageSizeString

View file

@ -59,7 +59,6 @@ class AlertHelper {
fun showNoPasteAlert( fun showNoPasteAlert(
context: Context, context: Context,
onCopy: () -> Unit, onCopy: () -> Unit,
onPaste: () -> Unit,
onDelete: () -> Unit, onDelete: () -> Unit,
onCut: () -> Unit, onCut: () -> Unit,
onInfo: () -> Unit onInfo: () -> Unit

View file

@ -1,5 +1,6 @@
package com.example.myapplication package com.example.myapplication
import android.annotation.SuppressLint
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
@ -17,14 +18,11 @@ import androidx.core.content.FileProvider
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type import androidx.core.view.WindowInsetsCompat.Type
import com.example.myapplication.adapters.ImageAdapter
import com.example.myapplication.adapters.ImageModel
import com.example.myapplication.adapters.VideoAdapter import com.example.myapplication.adapters.VideoAdapter
import com.example.myapplication.adapters.VideoModel import com.example.myapplication.adapters.VideoModel
import com.example.myapplication.compose.SearchActivity
import com.example.myapplication.fileSystem.CutHelper import com.example.myapplication.fileSystem.CutHelper
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion
import com.example.myapplication.fileSystem.byTypeFileLister.VideoLister.Companion.regex
import com.example.myapplication.fileSystem.byTypeFileLister.VideoLister.Companion.instance import com.example.myapplication.fileSystem.byTypeFileLister.VideoLister.Companion.instance
import com.example.myapplication.utils.AlertHelper import com.example.myapplication.utils.AlertHelper
import com.example.myapplication.utils.ClipHelper import com.example.myapplication.utils.ClipHelper
@ -73,9 +71,12 @@ class video_page : AppCompatActivity() {
searchImageView.setOnClickListener { v: View? -> searchImageView.setOnClickListener { v: View? ->
val intent = val intent =
Intent( Intent(
this@video_page, this,
video_page_search::class.java SearchActivity::class.java
) )
val bundle = Bundle()
bundle.putString("type", "video")
intent.putExtras(bundle)
startActivity(intent) // 跳转到搜索页面 startActivity(intent) // 跳转到搜索页面
} }
@ -120,8 +121,7 @@ class video_page : AppCompatActivity() {
} }
runOnUiThread { runOnUiThread {
val adapter = VideoAdapter(this@video_page, videoModels) val adapter = VideoAdapter(this@video_page, videoModels)
val grid = findViewById<GridView>(R.id.VideoGrid) videoGrid.setAdapter(adapter)
grid.setAdapter(adapter)
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
} }
} }
@ -191,7 +191,12 @@ class video_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -209,7 +214,12 @@ class video_page : AppCompatActivity() {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.VISIBLE loadingTextView.visibility = View.VISIBLE
} }
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) } CoroutineScope(Dispatchers.IO).launch {
loadingText(
loadingTextView,
loadingTextView.text
)
}
update { update {
runOnUiThread { runOnUiThread {
loadingTextView.visibility = View.GONE loadingTextView.visibility = View.GONE
@ -249,6 +259,7 @@ class video_page : AppCompatActivity() {
} }
} }
@SuppressLint("SetTextI18n")
private fun loadingText( private fun loadingText(
loadingTextView: TextView, loadingTextView: TextView,
defaultText: CharSequence, defaultText: CharSequence,

View file

@ -1,43 +0,0 @@
package com.example.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.SearchView;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
public class video_page_search extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.video_page_search);
// 设置左箭头的点击事件返回上一级页面
ImageView leftArrowImageView = findViewById(R.id.leftArrowImageView);
leftArrowImageView.setOnClickListener(v -> {
Intent intent = new Intent(video_page_search.this, video_page.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
});
SearchView searchView = findViewById(R.id.searchVideo); // 确保使用正确的 ID
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
// 处理搜索提交
Toast.makeText(video_page_search.this, "搜索: " + query, Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// 处理搜索文本变化
// 可以在这里添加过滤逻辑
return false;
}
});
}
}

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="@+id/leftArrowImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="left_arrow"
android:layout_marginTop="45dp"
android:src="@drawable/ic_left_arrow" />
<SearchView
android:id="@+id/searchDocument"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="20dp"
android:background="@drawable/search_border"
android:iconifiedByDefault="false"
android:padding="10dp"
android:queryHint="搜索文件"
android:textColor="@color/black" />
</LinearLayout>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="@+id/leftArrowImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="left_arrow"
android:layout_marginTop="45dp"
android:src="@drawable/ic_left_arrow" />
<SearchView
android:id="@+id/searchMusic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="20dp"
android:background="@drawable/search_border"
android:iconifiedByDefault="false"
android:padding="10dp"
android:queryHint="搜索音乐"
android:textColor="@color/black" />
</LinearLayout>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="@+id/leftArrowImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="left_arrow"
android:layout_marginTop="45dp"
android:src="@drawable/ic_left_arrow" />
<SearchView
android:id="@+id/searchPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="20dp"
android:background="@drawable/search_border"
android:iconifiedByDefault="false"
android:padding="10dp"
android:queryHint="搜索图片"
android:textColor="@color/black" />
</LinearLayout>

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">
<ImageView
android:id="@+id/leftArrowImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="left_arrow"
android:layout_marginTop="45dp"
android:src="@drawable/ic_left_arrow" />
<SearchView
android:id="@+id/searchVideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:layout_marginStart="20dp"
android:background="@drawable/search_border"
android:iconifiedByDefault="false"
android:padding="10dp"
android:queryHint="搜索视频"
android:textColor="@color/black" />
</LinearLayout>

View file

@ -127,4 +127,5 @@
<string name="error_need_input_name">请输入名称</string> <string name="error_need_input_name">请输入名称</string>
<string name="error_already_exist">已存在此文件(夹)</string> <string name="error_already_exist">已存在此文件(夹)</string>
<string name="title_activity_view_file">ViewFileActivity</string> <string name="title_activity_view_file">ViewFileActivity</string>
<string name="title_activity_search">SearchActivity</string>
</resources> </resources>