Skip to content

Commit f90e14a

Browse files
committed
update commons to 3.0.21
1 parent e2feab1 commit f90e14a

File tree

10 files changed

+85
-94
lines changed

10 files changed

+85
-94
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ext {
4646
}
4747

4848
dependencies {
49-
implementation 'com.simplemobiletools:commons:3.0.9'
49+
implementation 'com.simplemobiletools:commons:3.0.21'
5050

5151
implementation files('../libs/RootTools.jar')
5252

app/src/main/kotlin/com/simplemobiletools/filemanager/App.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package com.simplemobiletools.filemanager
22

33
import android.app.Application
44
import com.github.ajalt.reprint.core.Reprint
5+
import com.simplemobiletools.commons.extensions.checkUseEnglish
56
import com.simplemobiletools.filemanager.BuildConfig.USE_LEAK_CANARY
6-
import com.simplemobiletools.filemanager.extensions.config
77
import com.squareup.leakcanary.LeakCanary
8-
import java.util.*
98

109
class App : Application() {
1110
override fun onCreate() {
@@ -17,11 +16,7 @@ class App : Application() {
1716
LeakCanary.install(this)
1817
}
1918

20-
if (config.useEnglish) {
21-
val conf = resources.configuration
22-
conf.locale = Locale.ENGLISH
23-
resources.updateConfiguration(conf, resources.displayMetrics)
24-
}
19+
checkUseEnglish()
2520
Reprint.initialize(this)
2621
}
2722
}

app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ import java.util.*
2828
class MainActivity : SimpleActivity() {
2929
private val BACK_PRESS_TIMEOUT = 5000
3030
private var wasBackJustPressed = false
31-
3231
private var mStoredUseEnglish = false
3332

3433
private lateinit var fragment: ItemsFragment
3534

3635
override fun onCreate(savedInstanceState: Bundle?) {
3736
super.onCreate(savedInstanceState)
3837
setContentView(R.layout.activity_main)
39-
storeStoragePaths()
38+
appLaunched()
4039

4140
fragment = (fragment_holder as ItemsFragment).apply {
4241
isGetRingtonePicker = intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
@@ -47,6 +46,7 @@ class MainActivity : SimpleActivity() {
4746
if (savedInstanceState == null) {
4847
tryInitFileManager()
4948
}
49+
5050
checkWhatsNewDialog()
5151
checkIfRootAvailable()
5252
storeStateVariables()
@@ -230,14 +230,14 @@ class MainActivity : SimpleActivity() {
230230
}
231231

232232
private fun checkIfRootAvailable() {
233-
Thread({
233+
Thread {
234234
config.isRootAvailable = RootTools.isRootAvailable()
235235
if (config.isRootAvailable && config.enableRootAccess) {
236236
RootHelpers().askRootIFNeeded(this) {
237237
config.enableRootAccess = it
238238
}
239239
}
240-
}).start()
240+
}.start()
241241
}
242242

243243
fun pickedPath(path: String) {

app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
187187

188188
private fun copyRootItems(files: ArrayList<File>, destinationPath: String) {
189189
activity.toast(R.string.copying)
190-
Thread({
190+
Thread {
191191
var fileCnt = files.count()
192192
files.forEach {
193193
if (RootTools.copyFile(it.absolutePath, destinationPath, false, true)) {
@@ -205,7 +205,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
205205
listener?.refreshItems()
206206
finishActMode()
207207
}
208-
}).start()
208+
}.start()
209209
}
210210

211211
private fun compressSelection() {
@@ -217,7 +217,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
217217
activity.handleSAFDialog(File(firstPath)) {
218218
activity.toast(R.string.compressing)
219219
val paths = selectedPositions.map { fileDirItems[it].path }
220-
Thread({
220+
Thread {
221221
if (zipPaths(paths, it)) {
222222
activity.toast(R.string.compression_successful)
223223
activity.runOnUiThread {
@@ -227,7 +227,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
227227
} else {
228228
activity.toast(R.string.compressing_failed)
229229
}
230-
}).start()
230+
}.start()
231231
}
232232
}
233233
}
@@ -240,7 +240,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
240240
activity.handleSAFDialog(File(firstPath)) {
241241
activity.toast(R.string.decompressing)
242242
val paths = selectedPositions.map { fileDirItems[it].path }.filter { it.isZipFile() }
243-
Thread({
243+
Thread {
244244
if (unzipPaths(paths)) {
245245
activity.toast(R.string.decompression_successful)
246246
activity.runOnUiThread {
@@ -250,7 +250,7 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
250250
} else {
251251
activity.toast(R.string.decompressing_failed)
252252
}
253-
}).start()
253+
}.start()
254254
}
255255
}
256256

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/ChangeSortingDialog.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package com.simplemobiletools.filemanager.dialogs
22

33
import android.support.v7.app.AlertDialog
4-
import android.view.LayoutInflater
54
import com.simplemobiletools.commons.activities.BaseSimpleActivity
65
import com.simplemobiletools.commons.extensions.setupDialogStuff
76
import com.simplemobiletools.commons.helpers.*
87
import com.simplemobiletools.filemanager.R
9-
import com.simplemobiletools.filemanager.activities.SimpleActivity
108
import com.simplemobiletools.filemanager.extensions.config
119
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
1210

1311
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
1412
private var currSorting = 0
1513
private var config = activity.config
16-
private var view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_sorting, null)
14+
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
1715

1816
init {
1917
view.sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CompressAsDialog.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,26 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
3737
.setPositiveButton(R.string.ok, null)
3838
.setNegativeButton(R.string.cancel, null)
3939
.create().apply {
40-
activity.setupDialogStuff(view, this, R.string.compress_as)
41-
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
42-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
43-
val name = view.file_name.value
44-
when {
45-
name.isEmpty() -> activity.toast(R.string.empty_name)
46-
name.isAValidFilename() -> {
47-
val newFile = File(realPath, "$name.zip")
48-
if (newFile.exists()) {
49-
activity.toast(R.string.name_taken)
50-
return@OnClickListener
51-
}
40+
activity.setupDialogStuff(view, this, R.string.compress_as) {
41+
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
42+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
43+
val name = view.file_name.value
44+
when {
45+
name.isEmpty() -> activity.toast(R.string.empty_name)
46+
name.isAValidFilename() -> {
47+
val newFile = File(realPath, "$name.zip")
48+
if (newFile.exists()) {
49+
activity.toast(R.string.name_taken)
50+
return@OnClickListener
51+
}
5252

53-
dismiss()
54-
callback(newFile.absolutePath)
53+
dismiss()
54+
callback(newFile.absolutePath)
55+
}
56+
else -> activity.toast(R.string.invalid_name)
5557
}
56-
else -> activity.toast(R.string.invalid_name)
57-
}
58-
})
58+
})
59+
}
5960
}
6061
}
6162
}

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CreateNewItemDialog.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import android.view.WindowManager
66
import com.simplemobiletools.commons.activities.BaseSimpleActivity
77
import com.simplemobiletools.commons.extensions.*
88
import com.simplemobiletools.filemanager.R
9-
import com.simplemobiletools.filemanager.activities.SimpleActivity
109
import kotlinx.android.synthetic.main.dialog_create_new.view.*
1110
import java.io.File
1211
import java.io.IOException
@@ -19,32 +18,33 @@ class CreateNewItemDialog(val activity: BaseSimpleActivity, val path: String, va
1918
.setPositiveButton(R.string.ok, null)
2019
.setNegativeButton(R.string.cancel, null)
2120
.create().apply {
22-
activity.setupDialogStuff(view, this, R.string.create_new)
23-
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
24-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
25-
val name = view.item_name.value
26-
if (name.isEmpty()) {
27-
activity.toast(R.string.empty_name)
28-
} else if (name.isAValidFilename()) {
29-
val file = File(path, name)
30-
if (file.exists()) {
31-
activity.toast(R.string.name_taken)
32-
return@OnClickListener
33-
}
21+
activity.setupDialogStuff(view, this, R.string.create_new) {
22+
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
23+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
24+
val name = view.item_name.value
25+
if (name.isEmpty()) {
26+
activity.toast(R.string.empty_name)
27+
} else if (name.isAValidFilename()) {
28+
val file = File(path, name)
29+
if (file.exists()) {
30+
activity.toast(R.string.name_taken)
31+
return@OnClickListener
32+
}
3433

35-
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
36-
createDirectory(file, this) {
37-
callback(it)
34+
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
35+
createDirectory(file, this) {
36+
callback(it)
37+
}
38+
} else {
39+
createFile(file, this) {
40+
callback(it)
41+
}
3842
}
3943
} else {
40-
createFile(file, this) {
41-
callback(it)
42-
}
44+
activity.toast(R.string.invalid_name)
4345
}
44-
} else {
45-
activity.toast(R.string.invalid_name)
46-
}
47-
})
46+
})
47+
}
4848
}
4949
}
5050

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.simplemobiletools.filemanager.dialogs
22

33
import android.support.v7.app.AlertDialog
4-
import android.view.LayoutInflater
54
import android.view.WindowManager
65
import com.simplemobiletools.commons.activities.BaseSimpleActivity
76
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
87
import com.simplemobiletools.commons.dialogs.FilePickerDialog
98
import com.simplemobiletools.commons.extensions.*
109
import com.simplemobiletools.filemanager.R
11-
import com.simplemobiletools.filemanager.activities.SimpleActivity
1210
import kotlinx.android.synthetic.main.dialog_save_as.view.*
1311
import java.io.File
1412

@@ -20,7 +18,7 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
2018
}
2119

2220
var realPath = File(path).parent.trimEnd('/')
23-
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_save_as, null).apply {
21+
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
2422
save_as_path.text = activity.humanizePath(realPath)
2523

2624
val fullName = path.getFilenameFromPath()
@@ -47,38 +45,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, var path: String, val callb
4745
.setNegativeButton(R.string.cancel, null)
4846
.create().apply {
4947
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
50-
activity.setupDialogStuff(view, this, R.string.save_as)
51-
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
52-
val filename = view.save_as_name.value
53-
val extension = view.save_as_extension.value
48+
activity.setupDialogStuff(view, this, R.string.save_as) {
49+
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
50+
val filename = view.save_as_name.value
51+
val extension = view.save_as_extension.value
5452

55-
if (filename.isEmpty()) {
56-
activity.toast(R.string.filename_cannot_be_empty)
57-
return@setOnClickListener
58-
}
53+
if (filename.isEmpty()) {
54+
activity.toast(R.string.filename_cannot_be_empty)
55+
return@setOnClickListener
56+
}
5957

60-
if (extension.isEmpty()) {
61-
activity.toast(R.string.extension_cannot_be_empty)
62-
return@setOnClickListener
63-
}
58+
if (extension.isEmpty()) {
59+
activity.toast(R.string.extension_cannot_be_empty)
60+
return@setOnClickListener
61+
}
6462

65-
val newFile = File(realPath, "$filename.$extension")
66-
if (!newFile.name.isAValidFilename()) {
67-
activity.toast(R.string.filename_invalid_characters)
68-
return@setOnClickListener
69-
}
63+
val newFile = File(realPath, "$filename.$extension")
64+
if (!newFile.name.isAValidFilename()) {
65+
activity.toast(R.string.filename_invalid_characters)
66+
return@setOnClickListener
67+
}
7068

71-
if (newFile.exists()) {
72-
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
73-
ConfirmationDialog(activity, title) {
69+
if (newFile.exists()) {
70+
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
71+
ConfirmationDialog(activity, title) {
72+
callback(newFile.absolutePath)
73+
dismiss()
74+
}
75+
} else {
7476
callback(newFile.absolutePath)
7577
dismiss()
7678
}
77-
} else {
78-
callback(newFile.absolutePath)
79-
dismiss()
8079
}
81-
})
80+
}
8281
}
8382
}
8483
}

app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
5151
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
5252
super.onViewCreated(view, savedInstanceState)
5353
mView.apply {
54-
items_swipe_refresh.setOnRefreshListener({ refreshItems() })
54+
items_swipe_refresh.setOnRefreshListener { refreshItems() }
5555
items_fab.setOnClickListener { createNewItem() }
5656
breadcrumbs.listener = this@ItemsFragment
5757
}
@@ -160,13 +160,13 @@ class ItemsFragment : Fragment(), ItemsAdapter.ItemOperationsListener, Breadcrum
160160
private fun getRecyclerLayoutManager() = (mView.items_list.layoutManager as LinearLayoutManager)
161161

162162
private fun getItems(path: String, callback: (items: ArrayList<FileDirItem>) -> Unit) {
163-
Thread({
163+
Thread {
164164
if (!context!!.config.enableRootAccess || !context!!.isPathOnRoot(path)) {
165165
getRegularItemsOf(path, callback)
166166
} else {
167167
RootHelpers().getFiles(activity as SimpleActivity, path, callback)
168168
}
169-
}).start()
169+
}.start()
170170
}
171171

172172
private fun getRegularItemsOf(path: String, callback: (items: ArrayList<FileDirItem>) -> Unit) {

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<resources>
22

3-
<style name="AppTheme" parent="AppTheme.Base">
4-
5-
</style>
3+
<style name="AppTheme" parent="AppTheme.Base"/>
64

75
</resources>

0 commit comments

Comments
 (0)