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