update commons to 3.0.21
This commit is contained in:
parent
e2feab1b9e
commit
f90e14ac0e
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.0.9'
|
||||
implementation 'com.simplemobiletools:commons:3.0.21'
|
||||
|
||||
implementation files('../libs/RootTools.jar')
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@ package com.simplemobiletools.filemanager
|
|||
|
||||
import android.app.Application
|
||||
import com.github.ajalt.reprint.core.Reprint
|
||||
import com.simplemobiletools.commons.extensions.checkUseEnglish
|
||||
import com.simplemobiletools.filemanager.BuildConfig.USE_LEAK_CANARY
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
import com.squareup.leakcanary.LeakCanary
|
||||
import java.util.*
|
||||
|
||||
class App : Application() {
|
||||
override fun onCreate() {
|
||||
|
@ -17,11 +16,7 @@ class App : Application() {
|
|||
LeakCanary.install(this)
|
||||
}
|
||||
|
||||
if (config.useEnglish) {
|
||||
val conf = resources.configuration
|
||||
conf.locale = Locale.ENGLISH
|
||||
resources.updateConfiguration(conf, resources.displayMetrics)
|
||||
}
|
||||
checkUseEnglish()
|
||||
Reprint.initialize(this)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.*
|
|||
class MainActivity : SimpleActivity() {
|
||||
private val BACK_PRESS_TIMEOUT = 5000
|
||||
private var wasBackJustPressed = false
|
||||
|
||||
private var mStoredUseEnglish = false
|
||||
|
||||
private lateinit var fragment: ItemsFragment
|
||||
|
@ -36,7 +35,7 @@ class MainActivity : SimpleActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
storeStoragePaths()
|
||||
appLaunched()
|
||||
|
||||
fragment = (fragment_holder as ItemsFragment).apply {
|
||||
isGetRingtonePicker = intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
||||
|
@ -47,6 +46,7 @@ class MainActivity : SimpleActivity() {
|
|||
if (savedInstanceState == null) {
|
||||
tryInitFileManager()
|
||||
}
|
||||
|
||||
checkWhatsNewDialog()
|
||||
checkIfRootAvailable()
|
||||
storeStateVariables()
|
||||
|
@ -230,14 +230,14 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun checkIfRootAvailable() {
|
||||
Thread({
|
||||
Thread {
|
||||
config.isRootAvailable = RootTools.isRootAvailable()
|
||||
if (config.isRootAvailable && config.enableRootAccess) {
|
||||
RootHelpers().askRootIFNeeded(this) {
|
||||
config.enableRootAccess = it
|
||||
}
|
||||
}
|
||||
}).start()
|
||||
}.start()
|
||||
}
|
||||
|
||||
fun pickedPath(path: String) {
|
||||
|
|
|
@ -187,7 +187,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
|
||||
private fun copyRootItems(files: ArrayList<File>, destinationPath: String) {
|
||||
activity.toast(R.string.copying)
|
||||
Thread({
|
||||
Thread {
|
||||
var fileCnt = files.count()
|
||||
files.forEach {
|
||||
if (RootTools.copyFile(it.absolutePath, destinationPath, false, true)) {
|
||||
|
@ -205,7 +205,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
}
|
||||
}).start()
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun compressSelection() {
|
||||
|
@ -217,7 +217,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
activity.handleSAFDialog(File(firstPath)) {
|
||||
activity.toast(R.string.compressing)
|
||||
val paths = selectedPositions.map { fileDirItems[it].path }
|
||||
Thread({
|
||||
Thread {
|
||||
if (zipPaths(paths, it)) {
|
||||
activity.toast(R.string.compression_successful)
|
||||
activity.runOnUiThread {
|
||||
|
@ -227,7 +227,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
} else {
|
||||
activity.toast(R.string.compressing_failed)
|
||||
}
|
||||
}).start()
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
activity.handleSAFDialog(File(firstPath)) {
|
||||
activity.toast(R.string.decompressing)
|
||||
val paths = selectedPositions.map { fileDirItems[it].path }.filter { it.isZipFile() }
|
||||
Thread({
|
||||
Thread {
|
||||
if (unzipPaths(paths)) {
|
||||
activity.toast(R.string.decompression_successful)
|
||||
activity.runOnUiThread {
|
||||
|
@ -250,7 +250,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
} else {
|
||||
activity.toast(R.string.decompressing_failed)
|
||||
}
|
||||
}).start()
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package com.simplemobiletools.filemanager.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import com.simplemobiletools.filemanager.extensions.config
|
||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
||||
|
||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
||||
private var currSorting = 0
|
||||
private var config = activity.config
|
||||
private var view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null)
|
||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
|
||||
|
||||
init {
|
||||
view.sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
||||
|
|
|
@ -37,25 +37,26 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.compress_as)
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||
val name = view.file_name.value
|
||||
when {
|
||||
name.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
name.isAValidFilename() -> {
|
||||
val newFile = File(realPath, "$name.zip")
|
||||
if (newFile.exists()) {
|
||||
activity.toast(R.string.name_taken)
|
||||
return@OnClickListener
|
||||
}
|
||||
activity.setupDialogStuff(view, this, R.string.compress_as) {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||
val name = view.file_name.value
|
||||
when {
|
||||
name.isEmpty() -> activity.toast(R.string.empty_name)
|
||||
name.isAValidFilename() -> {
|
||||
val newFile = File(realPath, "$name.zip")
|
||||
if (newFile.exists()) {
|
||||
activity.toast(R.string.name_taken)
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
dismiss()
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
callback(newFile.absolutePath)
|
||||
}
|
||||
else -> activity.toast(R.string.invalid_name)
|
||||
}
|
||||
else -> activity.toast(R.string.invalid_name)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.view.WindowManager
|
|||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import kotlinx.android.synthetic.main.dialog_create_new.view.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
@ -19,32 +18,33 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.create_new)
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||
val name = view.item_name.value
|
||||
if (name.isEmpty()) {
|
||||
activity.toast(R.string.empty_name)
|
||||
} else if (name.isAValidFilename()) {
|
||||
val file = File(path, name)
|
||||
if (file.exists()) {
|
||||
activity.toast(R.string.name_taken)
|
||||
return@OnClickListener
|
||||
}
|
||||
activity.setupDialogStuff(view, this, R.string.create_new) {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||
val name = view.item_name.value
|
||||
if (name.isEmpty()) {
|
||||
activity.toast(R.string.empty_name)
|
||||
} else if (name.isAValidFilename()) {
|
||||
val file = File(path, name)
|
||||
if (file.exists()) {
|
||||
activity.toast(R.string.name_taken)
|
||||
return@OnClickListener
|
||||
}
|
||||
|
||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
||||
createDirectory(file, this) {
|
||||
callback(it)
|
||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
||||
createDirectory(file, this) {
|
||||
callback(it)
|
||||
}
|
||||
} else {
|
||||
createFile(file, this) {
|
||||
callback(it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
createFile(file, this) {
|
||||
callback(it)
|
||||
}
|
||||
activity.toast(R.string.invalid_name)
|
||||
}
|
||||
} else {
|
||||
activity.toast(R.string.invalid_name)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package com.simplemobiletools.filemanager.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.LayoutInflater
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||
import java.io.File
|
||||
|
||||
|
@ -20,7 +18,7 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
|
|||
}
|
||||
|
||||
var realPath = File(path).parent.trimEnd('/')
|
||||
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
||||
save_as_path.text = activity.humanizePath(realPath)
|
||||
|
||||
val fullName = path.getFilenameFromPath()
|
||||
|
@ -47,38 +45,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
|
|||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, R.string.save_as)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||
val filename = view.save_as_name.value
|
||||
val extension = view.save_as_extension.value
|
||||
activity.setupDialogStuff(view, this, R.string.save_as) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.save_as_name.value
|
||||
val extension = view.save_as_extension.value
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (filename.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (extension.isEmpty()) {
|
||||
activity.toast(R.string.extension_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (extension.isEmpty()) {
|
||||
activity.toast(R.string.extension_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val newFile = File(realPath, "$filename.$extension")
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val newFile = File(realPath, "$filename.$extension")
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (newFile.exists()) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
||||
ConfirmationDialog(activity, title) {
|
||||
if (newFile.exists()) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
||||
ConfirmationDialog(activity, title) {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mView.apply {
|
||||
items_swipe_refresh.setOnRefreshListener({ refreshItems() })
|
||||
items_swipe_refresh.setOnRefreshListener { refreshItems() }
|
||||
items_fab.setOnClickListener { createNewItem() }
|
||||
breadcrumbs.listener = this@ItemsFragment
|
||||
}
|
||||
|
@ -160,13 +160,13 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
|
|||
private fun getRecyclerLayoutManager() = (mView.items_list.layoutManager as LinearLayoutManager)
|
||||
|
||||
private fun getItems(path: String, callback: (items: ArrayList<FileDirItem>) -> Unit) {
|
||||
Thread({
|
||||
Thread {
|
||||
if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
|
||||
getRegularItemsOf(path, callback)
|
||||
} else {
|
||||
RootHelpers().getFiles(activity as SimpleActivity, path, callback)
|
||||
}
|
||||
}).start()
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun getRegularItemsOf(path: String, callback: (items: ArrayList<FileDirItem>) -> Unit) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<resources>
|
||||
|
||||
<style name="AppTheme" parent="AppTheme.Base">
|
||||
|
||||
</style>
|
||||
<style name="AppTheme" parent="AppTheme.Base"/>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue