|
|
@ -27,6 +27,7 @@ import top.niunaijun.blackdex.util.LoadingUtil |
|
|
|
import top.niunaijun.blackdex.util.inflate |
|
|
|
import top.niunaijun.blackdex.util.inflate |
|
|
|
import top.niunaijun.blackdex.view.base.PermissionActivity |
|
|
|
import top.niunaijun.blackdex.view.base.PermissionActivity |
|
|
|
import top.niunaijun.blackdex.view.setting.SettingActivity |
|
|
|
import top.niunaijun.blackdex.view.setting.SettingActivity |
|
|
|
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MainActivity : PermissionActivity() { |
|
|
|
class MainActivity : PermissionActivity() { |
|
|
@ -39,6 +40,8 @@ class MainActivity : PermissionActivity() { |
|
|
|
|
|
|
|
|
|
|
|
private lateinit var loadingView: CatLoadingView |
|
|
|
private lateinit var loadingView: CatLoadingView |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var initialDir: File? = null |
|
|
|
|
|
|
|
|
|
|
|
private var appList: List<AppInfo> = ArrayList() |
|
|
|
private var appList: List<AppInfo> = ArrayList() |
|
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
@ -72,7 +75,9 @@ class MainActivity : PermissionActivity() { |
|
|
|
this.requestPermissionCallback = { |
|
|
|
this.requestPermissionCallback = { |
|
|
|
if (it) { |
|
|
|
if (it) { |
|
|
|
this.requestPermissionCallback = null |
|
|
|
this.requestPermissionCallback = null |
|
|
|
val initialDir = Environment.getExternalStorageDirectory() |
|
|
|
if (initialDir == null) { |
|
|
|
|
|
|
|
initialDir = Environment.getExternalStorageDirectory() |
|
|
|
|
|
|
|
} |
|
|
|
MaterialDialog(this).show { |
|
|
|
MaterialDialog(this).show { |
|
|
|
fileChooser( |
|
|
|
fileChooser( |
|
|
|
this@MainActivity, |
|
|
|
this@MainActivity, |
|
|
@ -80,9 +85,10 @@ class MainActivity : PermissionActivity() { |
|
|
|
filter = FileUtil::filterApk, |
|
|
|
filter = FileUtil::filterApk, |
|
|
|
) { _, file -> |
|
|
|
) { _, file -> |
|
|
|
viewModel.startDexDump(file.absolutePath) |
|
|
|
viewModel.startDexDump(file.absolutePath) |
|
|
|
|
|
|
|
this@MainActivity.initialDir = file.parentFile |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
negativeButton(res = R.string.cancel) |
|
|
|
negativeButton(R.string.cancel) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -117,35 +123,33 @@ class MainActivity : PermissionActivity() { |
|
|
|
showLoading() |
|
|
|
showLoading() |
|
|
|
} |
|
|
|
} |
|
|
|
DumpInfo.TIMEOUT -> { |
|
|
|
DumpInfo.TIMEOUT -> { |
|
|
|
loadingView.dismiss() |
|
|
|
hideLoading() |
|
|
|
MaterialDialog(this).show { |
|
|
|
MaterialDialog(this).show { |
|
|
|
title(res = R.string.unpack_fail) |
|
|
|
title(R.string.unpack_fail) |
|
|
|
message(res = R.string.jump_issue) |
|
|
|
message(R.string.jump_issue) |
|
|
|
negativeButton(res = R.string.github) { |
|
|
|
negativeButton(R.string.github) { |
|
|
|
negativeButton(text = "Github") { |
|
|
|
val intent = Intent( |
|
|
|
val intent = Intent( |
|
|
|
Intent.ACTION_VIEW, |
|
|
|
Intent.ACTION_VIEW, |
|
|
|
Uri.parse("https://github.com/CodingGay/BlackDex/issues") |
|
|
|
Uri.parse("https://github.com/CodingGay/BlackDex/issues") |
|
|
|
) |
|
|
|
) |
|
|
|
startActivity(intent) |
|
|
|
startActivity(intent) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
positiveButton(res = R.string.confirm) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
positiveButton(res = R.string.confirm) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
viewModel.dexDumpSuccess() |
|
|
|
viewModel.dexDumpSuccess() |
|
|
|
|
|
|
|
hideLoading() |
|
|
|
val title = if (it.state == DumpInfo.SUCCESS) { |
|
|
|
val title = if (it.state == DumpInfo.SUCCESS) { |
|
|
|
getString(R.string.unpack_success) |
|
|
|
R.string.unpack_success |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
getString(R.string.unpack_fail) |
|
|
|
R.string.unpack_fail |
|
|
|
} |
|
|
|
} |
|
|
|
loadingView.dismiss() |
|
|
|
|
|
|
|
MaterialDialog(this).show { |
|
|
|
MaterialDialog(this).show { |
|
|
|
title(text = title) |
|
|
|
title(title) |
|
|
|
message(text = it.msg) |
|
|
|
message(text = it.msg) |
|
|
|
positiveButton(res = R.string.confirm) |
|
|
|
positiveButton(R.string.confirm) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -212,6 +216,12 @@ class MainActivity : PermissionActivity() { |
|
|
|
LoadingUtil.showLoading(loadingView, supportFragmentManager) |
|
|
|
LoadingUtil.showLoading(loadingView, supportFragmentManager) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun hideLoading() { |
|
|
|
|
|
|
|
if (this::loadingView.isInitialized) { |
|
|
|
|
|
|
|
loadingView.dismiss() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun hideKeyboard() { |
|
|
|
private fun hideKeyboard() { |
|
|
|
val imm: InputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager |
|
|
|
val imm: InputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager |
|
|
|
window.peekDecorView()?.run { |
|
|
|
window.peekDecorView()?.run { |
|
|
|