Update
This commit is contained in:
parent
3242c9f4a0
commit
f133a4446b
32 changed files with 260 additions and 459 deletions
|
@ -1,15 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
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
|
||||
android:allowBackup="true"
|
||||
|
@ -21,6 +12,11 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MyApplication"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".compose.SearchActivity"
|
||||
android:exported="false"
|
||||
android:label="@string/title_activity_search"
|
||||
android:theme="@style/Theme.MyApplication" />
|
||||
<activity
|
||||
android:name=".compose.RequirePermissionActivity"
|
||||
android:exported="true"
|
||||
|
@ -34,36 +30,27 @@
|
|||
<activity
|
||||
android:name=".compose.ViewFileActivity"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".main_page"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".store_page"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".document_page_search"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".document_page"
|
||||
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
|
||||
android:name=".picture_page"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".video_page"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".music_page"
|
||||
android:exported="false" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
|
@ -75,4 +62,15 @@
|
|||
android:resource="@xml/provider_paths" />
|
||||
</provider>
|
||||
</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>
|
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 |
|
@ -44,7 +44,8 @@ class RequirePermissionActivity : ComponentActivity() {
|
|||
window.statusBarColor = getColor(R.color.WhiteSmoke)
|
||||
setContent {
|
||||
Column(
|
||||
modifier = Modifier.statusBarsPadding()
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.fillMaxHeight(0.9f)
|
||||
.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
|
@ -72,7 +73,11 @@ class RequirePermissionActivity : ComponentActivity() {
|
|||
startActivity(intent)
|
||||
}
|
||||
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(
|
||||
activity, perm33, 101
|
||||
)
|
||||
|
@ -96,7 +101,6 @@ class RequirePermissionActivity : ComponentActivity() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -119,7 +123,11 @@ fun checkPermissions(context: Context): Boolean {
|
|||
return false
|
||||
}
|
||||
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 {
|
||||
if (context.checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.myapplication.compose.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ClipData
|
||||
import android.content.ClipDescription
|
||||
import android.content.Context
|
||||
|
@ -349,8 +350,7 @@ class FileColumn(val context: Context) {
|
|||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
,
|
||||
},
|
||||
dragAndDropCallBack = dragAndDropCallBack,
|
||||
onItemClick = onItemClick
|
||||
)
|
||||
|
@ -367,7 +367,7 @@ class FileColumn(val context: Context) {
|
|||
forceName: String? = null,
|
||||
forceParent: String? = null,
|
||||
update: (() -> Unit)? = null,
|
||||
dragAndDrop: Modifier = Modifier,
|
||||
@SuppressLint("ModifierParameter") dragAndDrop: Modifier = Modifier,
|
||||
dragAndDropCallBack: DragAndDropTarget? = null,
|
||||
onItemClick: ((String) -> Unit)? = null
|
||||
) {
|
||||
|
@ -443,7 +443,8 @@ class FileColumn(val context: Context) {
|
|||
.padding(vertical = 3.dp)
|
||||
.clickable {
|
||||
onItemClick?.invoke(file.path)
|
||||
}.then(
|
||||
}
|
||||
.then(
|
||||
if (dragAndDropCallBack != null) {
|
||||
Modifier.dragAndDropTarget(
|
||||
shouldStartDragAndDrop = { event ->
|
||||
|
@ -459,9 +460,7 @@ class FileColumn(val context: Context) {
|
|||
} else {
|
||||
Modifier
|
||||
}
|
||||
)
|
||||
|
||||
,
|
||||
),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Image(
|
||||
|
@ -509,9 +508,6 @@ class FileColumn(val context: Context) {
|
|||
if (f.isFile) {
|
||||
ClipHelper.getInstance(context).copy(f, context)
|
||||
}
|
||||
},
|
||||
onPaste = {
|
||||
|
||||
},
|
||||
onDelete = {
|
||||
AlertHelper.showDeleteAlert(context, file.path) {
|
||||
|
@ -533,9 +529,6 @@ class FileColumn(val context: Context) {
|
|||
if (f.isDirectory) {
|
||||
ClipHelper.getInstance(context).copyFolder(f.path)
|
||||
}
|
||||
},
|
||||
onPaste = {
|
||||
|
||||
},
|
||||
onDelete = {
|
||||
AlertHelper.showDeleteAlert(context, file.path) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package com.example.myapplication
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import android.widget.GridView
|
||||
|
@ -21,6 +21,7 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.core.view.WindowInsetsCompat.Type
|
||||
import com.example.myapplication.adapters.DocumentAdapter
|
||||
import com.example.myapplication.adapters.DocumentModel
|
||||
import com.example.myapplication.compose.SearchActivity
|
||||
import com.example.myapplication.fileSystem.CutHelper
|
||||
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.instance
|
||||
import com.example.myapplication.fileSystem.byTypeFileLister.DocumentLister.Companion.regex
|
||||
|
@ -71,9 +72,12 @@ class document_page : AppCompatActivity() {
|
|||
searchImageView.setOnClickListener { v: View? ->
|
||||
val intent =
|
||||
Intent(
|
||||
this@document_page,
|
||||
document_page_search::class.java
|
||||
this,
|
||||
SearchActivity::class.java
|
||||
)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("type", "document")
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent) // 跳转到搜索页面
|
||||
}
|
||||
|
||||
|
@ -93,7 +97,8 @@ class document_page : AppCompatActivity() {
|
|||
file
|
||||
)
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.setDataAndType(uri, when(file.extension){
|
||||
intent.setDataAndType(
|
||||
uri, when (file.extension) {
|
||||
"xls" -> "application/vnd.ms-excel"
|
||||
"xlsx" -> "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
"doc" -> "application/msword"
|
||||
|
@ -105,11 +110,14 @@ class document_page : AppCompatActivity() {
|
|||
"pdf" -> "application/pdf"
|
||||
|
||||
else -> "application/*"
|
||||
})
|
||||
}
|
||||
)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||
try { startActivity(intent) }
|
||||
catch (e: ActivityNotFoundException){
|
||||
Toast.makeText(baseContext,"没有安装可以打开此类型文件的应用",Toast.LENGTH_SHORT).show()
|
||||
try {
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(baseContext, "没有安装可以打开此类型文件的应用", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +141,7 @@ class document_page : AppCompatActivity() {
|
|||
}
|
||||
runOnUiThread {
|
||||
val adapter = DocumentAdapter(this@document_page, models)
|
||||
val grid = findViewById<GridView>(R.id.DocumentGrid)
|
||||
grid.setAdapter(adapter)
|
||||
documentGrid.setAdapter(adapter)
|
||||
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +211,12 @@ class document_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -222,7 +234,12 @@ class document_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -262,6 +279,7 @@ class document_page : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun loadingText(
|
||||
loadingTextView: TextView,
|
||||
defaultText: CharSequence,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import android.os.Environment
|
|||
import android.os.storage.StorageManager
|
||||
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 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()
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ import java.io.File
|
|||
class MusicLister : Lister() {
|
||||
companion object {
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,12 @@ package com.example.myapplication.fileSystem.byTypeFileLister
|
|||
|
||||
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) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.example.myapplication
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.AdapterView
|
||||
import android.widget.GridView
|
||||
|
@ -20,11 +20,10 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.core.view.WindowInsetsCompat.Type
|
||||
import com.example.myapplication.adapters.MusicAdapter
|
||||
import com.example.myapplication.adapters.MusicModel
|
||||
import com.example.myapplication.compose.SearchActivity
|
||||
import com.example.myapplication.fileSystem.CutHelper
|
||||
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.regex
|
||||
import com.example.myapplication.utils.AlertHelper
|
||||
import com.example.myapplication.utils.ClipHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -71,9 +70,12 @@ class music_page : AppCompatActivity() {
|
|||
searchImageView.setOnClickListener { v: View? ->
|
||||
val intent =
|
||||
Intent(
|
||||
this@music_page,
|
||||
music_page_search::class.java
|
||||
this,
|
||||
SearchActivity::class.java
|
||||
)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("type", "music")
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent) // 跳转到搜索页面
|
||||
}
|
||||
|
||||
|
@ -118,8 +120,7 @@ class music_page : AppCompatActivity() {
|
|||
}
|
||||
runOnUiThread {
|
||||
val adapter = MusicAdapter(this@music_page, models)
|
||||
val grid = findViewById<GridView>(R.id.MusicGrid)
|
||||
grid.setAdapter(adapter)
|
||||
musicGrid.setAdapter(adapter)
|
||||
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +190,12 @@ class music_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -207,7 +213,12 @@ class music_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -247,6 +258,7 @@ class music_page : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun loadingText(
|
||||
loadingTextView: TextView,
|
||||
defaultText: CharSequence,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.myapplication
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
@ -19,11 +20,10 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.core.view.WindowInsetsCompat.Type
|
||||
import com.example.myapplication.adapters.ImageAdapter
|
||||
import com.example.myapplication.adapters.ImageModel
|
||||
import com.example.myapplication.compose.SearchActivity
|
||||
import com.example.myapplication.fileSystem.CutHelper
|
||||
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.regex
|
||||
import com.example.myapplication.utils.AlertHelper
|
||||
import com.example.myapplication.utils.ClipHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -73,8 +73,11 @@ class picture_page : AppCompatActivity() {
|
|||
val intent =
|
||||
Intent(
|
||||
this@picture_page,
|
||||
picture_page_search::class.java
|
||||
SearchActivity::class.java
|
||||
)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("type", "image")
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent) // 跳转到搜索页面
|
||||
}
|
||||
|
||||
|
@ -119,8 +122,7 @@ class picture_page : AppCompatActivity() {
|
|||
}
|
||||
runOnUiThread {
|
||||
val adapter = ImageAdapter(this@picture_page, imageModels)
|
||||
val grid = findViewById<GridView>(R.id.PicturePageGrid)
|
||||
grid.setAdapter(adapter)
|
||||
pictureGrid.setAdapter(adapter)
|
||||
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +192,12 @@ class picture_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -208,7 +215,12 @@ class picture_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -248,6 +260,7 @@ class picture_page : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun loadingText(
|
||||
loadingTextView: TextView,
|
||||
defaultText: CharSequence,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -58,7 +58,8 @@ class store_page : AppCompatActivity() {
|
|||
val musicSizeString = WrappedFile.getSizeString(musicSize)
|
||||
val documentSize = DocumentLister.instance.getFullSize()
|
||||
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)
|
||||
runOnUiThread {
|
||||
findViewById<TextView>(R.id.pictureStorage).text = imageSizeString
|
||||
|
|
|
@ -59,7 +59,6 @@ class AlertHelper {
|
|||
fun showNoPasteAlert(
|
||||
context: Context,
|
||||
onCopy: () -> Unit,
|
||||
onPaste: () -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
onCut: () -> Unit,
|
||||
onInfo: () -> Unit
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.myapplication
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
|
@ -17,14 +18,11 @@ import androidx.core.content.FileProvider
|
|||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
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.VideoModel
|
||||
import com.example.myapplication.compose.SearchActivity
|
||||
import com.example.myapplication.fileSystem.CutHelper
|
||||
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.utils.AlertHelper
|
||||
import com.example.myapplication.utils.ClipHelper
|
||||
|
@ -73,9 +71,12 @@ class video_page : AppCompatActivity() {
|
|||
searchImageView.setOnClickListener { v: View? ->
|
||||
val intent =
|
||||
Intent(
|
||||
this@video_page,
|
||||
video_page_search::class.java
|
||||
this,
|
||||
SearchActivity::class.java
|
||||
)
|
||||
val bundle = Bundle()
|
||||
bundle.putString("type", "video")
|
||||
intent.putExtras(bundle)
|
||||
startActivity(intent) // 跳转到搜索页面
|
||||
}
|
||||
|
||||
|
@ -120,8 +121,7 @@ class video_page : AppCompatActivity() {
|
|||
}
|
||||
runOnUiThread {
|
||||
val adapter = VideoAdapter(this@video_page, videoModels)
|
||||
val grid = findViewById<GridView>(R.id.VideoGrid)
|
||||
grid.setAdapter(adapter)
|
||||
videoGrid.setAdapter(adapter)
|
||||
findViewById<TextView>(R.id.LoadingBlankText).visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,12 @@ class video_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -209,7 +214,12 @@ class video_page : AppCompatActivity() {
|
|||
runOnUiThread {
|
||||
loadingTextView.visibility = View.VISIBLE
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { loadingText(loadingTextView,loadingTextView.text) }
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
loadingText(
|
||||
loadingTextView,
|
||||
loadingTextView.text
|
||||
)
|
||||
}
|
||||
update {
|
||||
runOnUiThread {
|
||||
loadingTextView.visibility = View.GONE
|
||||
|
@ -249,6 +259,7 @@ class video_page : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun loadingText(
|
||||
loadingTextView: TextView,
|
||||
defaultText: CharSequence,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -127,4 +127,5 @@
|
|||
<string name="error_need_input_name">请输入名称</string>
|
||||
<string name="error_already_exist">已存在此文件(夹)</string>
|
||||
<string name="title_activity_view_file">ViewFileActivity</string>
|
||||
<string name="title_activity_search">SearchActivity</string>
|
||||
</resources>
|
Loading…
Reference in a new issue