mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-26 07:37:40 +00:00
Download to proper filename
This commit is contained in:
parent
971cd73fb3
commit
c3a89f589e
@ -7,6 +7,7 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
import com.topjohnwu.magisk.Const;
|
import com.topjohnwu.magisk.Const;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.magisk.utils.XStringKt;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -103,7 +104,7 @@ public class Repo extends BaseModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDownloadFilename() {
|
public String getDownloadFilename() {
|
||||||
return Utils.INSTANCE.getLegalFilename(getName() + "-" + getVersion() + ".zip");
|
return XStringKt.legalFilename(getName() + "-" + getVersion() + ".zip");
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IllegalRepoException extends Exception {
|
public class IllegalRepoException extends Exception {
|
||||||
|
@ -27,7 +27,7 @@ sealed class DownloadSubject : Parcelable {
|
|||||||
|
|
||||||
@IgnoredOnParcel
|
@IgnoredOnParcel
|
||||||
override val file by lazy {
|
override val file by lazy {
|
||||||
File(Config.downloadDirectory, "${module.name}-v${module.version}(${module.versionCode}).zip")
|
File(Config.downloadDirectory, module.downloadFilename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +70,6 @@ object Utils {
|
|||||||
return info.loadLabel(pm).toString()
|
return info.loadLabel(pm).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLegalFilename(filename: CharSequence): String {
|
|
||||||
return filename.toString().replace(" ", "_").replace("'", "").replace("\"", "")
|
|
||||||
.replace("$", "").replace("`", "").replace("*", "").replace("/", "_")
|
|
||||||
.replace("#", "").replace("@", "").replace("\\", "_")
|
|
||||||
}
|
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun loadModulesLeanback(): Map<String, OldModule> {
|
fun loadModulesLeanback(): Map<String, OldModule> {
|
||||||
val moduleMap = ValueSortedMap<String, OldModule>()
|
val moduleMap = ValueSortedMap<String, OldModule>()
|
||||||
|
@ -21,3 +21,7 @@ fun Int.res(vararg args: Any): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun String.trimEmptyToNull(): String? = if (isBlank()) null else this
|
fun String.trimEmptyToNull(): String? = if (isBlank()) null else this
|
||||||
|
|
||||||
|
fun String.legalFilename() = replace(" ", "_").replace("'", "").replace("\"", "")
|
||||||
|
.replace("$", "").replace("`", "").replace("*", "").replace("/", "_")
|
||||||
|
.replace("#", "").replace("@", "").replace("\\", "_")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user