diff --git a/app/src/main/java/github/zerorooot/nap511/MainActivity.kt b/app/src/main/java/github/zerorooot/nap511/MainActivity.kt index 4ac0597..262ffa7 100644 --- a/app/src/main/java/github/zerorooot/nap511/MainActivity.kt +++ b/app/src/main/java/github/zerorooot/nap511/MainActivity.kt @@ -1,7 +1,6 @@ package github.zerorooot.nap511 import android.annotation.SuppressLint -import android.app.Activity import android.app.AppOpsManager import android.content.Context import android.content.Intent @@ -14,7 +13,6 @@ import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.google.accompanist.systemuicontroller.rememberSystemUiController @@ -273,7 +271,7 @@ class MainActivity : ComponentActivity() { "selectToDown" -> fileViewModel.selectToDown() "cut" -> fileViewModel.cut() //具体实现在FileScreen#CreateDialogs()里 - "search" -> fileViewModel.isSearch = true + "search" -> fileViewModel.isOpenSearchDialog = true "delete" -> fileViewModel.deleteMultiple() "selectAll" -> fileViewModel.selectAll() "selectReverse" -> fileViewModel.selectReverse() diff --git a/app/src/main/java/github/zerorooot/nap511/activity/OfflineTaskActivity.kt b/app/src/main/java/github/zerorooot/nap511/activity/OfflineTaskActivity.kt index ffdc11f..8a4fc10 100644 --- a/app/src/main/java/github/zerorooot/nap511/activity/OfflineTaskActivity.kt +++ b/app/src/main/java/github/zerorooot/nap511/activity/OfflineTaskActivity.kt @@ -45,7 +45,15 @@ class OfflineTaskActivity : Activity() { if (intent.action == Intent.ACTION_VIEW || intent.action == Intent.ACTION_PROCESS_TEXT) { val urlList = (intent.dataString ?: run { intent.getStringExtra(Intent.EXTRA_PROCESS_TEXT) - } ?: run { "" }).split("\n").filter { i -> + } ?: run { "" }).split("\n").map { i -> + //支持复制无头磁力链接 + val a = i.replace(Regex("&dn=.*"), "") + if (a.length == 40 && Regex("^[a-z0-9A-Z]+\$").matches(a)) { + "magnet:?xt=urn:btih:$i" + } else { + i + } + }.filter { i -> i.startsWith("http", true) || i.startsWith( "ftp", true ) || i.startsWith("magnet", true) || i.startsWith("ed2k", true) diff --git a/app/src/main/java/github/zerorooot/nap511/screen/AlertDialog.kt b/app/src/main/java/github/zerorooot/nap511/screen/AlertDialog.kt index 1a2c1c8..4b7676f 100644 --- a/app/src/main/java/github/zerorooot/nap511/screen/AlertDialog.kt +++ b/app/src/main/java/github/zerorooot/nap511/screen/AlertDialog.kt @@ -1,8 +1,6 @@ package github.zerorooot.nap511.screen import android.app.Activity -import android.app.Application -import androidx.compose.animation.* import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.selection.selectable @@ -37,7 +35,6 @@ import github.zerorooot.nap511.viewmodel.FileViewModel import github.zerorooot.nap511.viewmodel.OfflineFileViewModel import github.zerorooot.nap511.viewmodel.RecycleViewModel import kotlinx.coroutines.delay -import kotlin.system.exitProcess @Composable fun CreateFolderDialog(fileViewModel: FileViewModel, enter: (String) -> Unit) { @@ -48,7 +45,7 @@ fun CreateFolderDialog(fileViewModel: FileViewModel, enter: (String) -> Unit) { @Composable fun SearchDialog(fileViewModel: FileViewModel, enter: (String) -> Unit) { - if (fileViewModel.isSearch) { + if (fileViewModel.isOpenSearchDialog) { BaseDialog("在当前目录下搜索", "关键字", enter = enter) } } diff --git a/app/src/main/java/github/zerorooot/nap511/screen/FileScreen.kt b/app/src/main/java/github/zerorooot/nap511/screen/FileScreen.kt index 228e140..e8da311 100644 --- a/app/src/main/java/github/zerorooot/nap511/screen/FileScreen.kt +++ b/app/src/main/java/github/zerorooot/nap511/screen/FileScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.togetherWith -import androidx.compose.animation.with import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Box @@ -370,7 +369,7 @@ fun CreateDialogs(fileViewModel: FileViewModel) { if (it != "") { fileViewModel.search(it) } - fileViewModel.isSearch = false + fileViewModel.isOpenSearchDialog = false } } diff --git a/app/src/main/java/github/zerorooot/nap511/viewmodel/FileViewModel.kt b/app/src/main/java/github/zerorooot/nap511/viewmodel/FileViewModel.kt index 6ca3e04..bf0e712 100644 --- a/app/src/main/java/github/zerorooot/nap511/viewmodel/FileViewModel.kt +++ b/app/src/main/java/github/zerorooot/nap511/viewmodel/FileViewModel.kt @@ -56,7 +56,7 @@ class FileViewModel(private val cookie: String, private val application: Applica var isOpenAria2Dialog by mutableStateOf(false) var selectIndex by mutableIntStateOf(0) - var isSearch by mutableStateOf(false) + var isOpenSearchDialog by mutableStateOf(false) //图片浏览相关 @@ -349,7 +349,7 @@ class FileViewModel(private val cookie: String, private val application: Applica isCutState = false return } - + isCutState = false viewModelScope.launch { val hashMapOf = hashMapOf() hashMapOf["pid"] = currentCid @@ -376,7 +376,6 @@ class FileViewModel(private val cookie: String, private val application: Applica } else { "移动失败~" } - isCutState = false Toast.makeText(application, message, Toast.LENGTH_SHORT).show() } } @@ -513,7 +512,7 @@ class FileViewModel(private val cookie: String, private val application: Applica setFileBeanProperty(files.fileBeanList) fileBeanList.clear() fileBeanList.addAll(files.fileBeanList) - appBarTitle = "搜索" + appBarTitle = "搜索-$searchKey" } }