Skip to content

Commit 4ba982c

Browse files
committed
updating the Copy dialog
1 parent 067fa79 commit 4ba982c

File tree

4 files changed

+24
-40
lines changed

4 files changed

+24
-40
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ import android.support.v4.app.ActivityCompat
1010
import android.view.Menu
1111
import android.view.MenuItem
1212
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
13-
import com.simplemobiletools.commons.extensions.getInternalStoragePath
14-
import com.simplemobiletools.commons.extensions.hasWriteStoragePermission
15-
import com.simplemobiletools.commons.extensions.storeStoragePaths
16-
import com.simplemobiletools.commons.extensions.toast
13+
import com.simplemobiletools.commons.extensions.*
1714
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
1815
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
1916
import com.simplemobiletools.commons.models.FileDirItem
@@ -48,6 +45,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
4845
storeStoragePaths()
4946
}
5047

48+
override fun onResume() {
49+
super.onResume()
50+
updateTextColors(main_screen)
51+
}
52+
5153
override fun onDestroy() {
5254
super.onDestroy()
5355
config.isFirstRun = false

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.dialogs
33
import android.support.v4.util.Pair
44
import android.support.v7.app.AlertDialog
55
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
6+
import com.simplemobiletools.commons.dialogs.FilePickerDialog
67
import com.simplemobiletools.commons.extensions.*
78
import com.simplemobiletools.filemanager.R
89
import com.simplemobiletools.filemanager.activities.SimpleActivity
@@ -18,20 +19,14 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
1819
val view = activity.layoutInflater.inflate(R.layout.dialog_copy_item, null)
1920
val sourcePath = files[0].parent.trimEnd('/')
2021
var destinationPath = ""
21-
view.source.text = "${context.humanizePath(sourcePath)}/"
2222

2323
val config = context.config
24-
/*view.destination.setOnClickListener {
25-
FilePickerDialog(activity, destinationPath, false, config.showHidden, object : FilePickerDialog.OnFilePickerListener {
26-
override fun onFail(error: FilePickerDialog.FilePickerResult) {
27-
}
28-
29-
override fun onSuccess(pickedPath: String) {
30-
destinationPath = pickedPath
31-
view.destination.text = context.humanizePath(pickedPath)
32-
}
33-
})
34-
}*/
24+
view.destination.setOnClickListener {
25+
FilePickerDialog(activity, sourcePath, false, config.showHidden, true) {
26+
destinationPath = it
27+
view.destination.text = context.humanizePath(it)
28+
}
29+
}
3530

3631
AlertDialog.Builder(context)
3732
.setPositiveButton(R.string.ok, null)
@@ -44,7 +39,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
4439
return@setOnClickListener
4540
}
4641

47-
if (view.source.text.trimEnd('/') == destinationPath.trimEnd('/')) {
42+
if (sourcePath == destinationPath.trimEnd('/')) {
4843
context.toast(R.string.source_and_destination_same)
4944
return@setOnClickListener
5045
}
@@ -56,8 +51,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
5651
}
5752

5853
if (files.size == 1) {
59-
val newFile = File(files[0].path)
60-
if (File(destinationPath, newFile.name).exists()) {
54+
if (File(destinationPath, files[0].name).exists()) {
6155
context.toast(R.string.name_taken)
6256
return@setOnClickListener
6357
}
@@ -74,6 +68,10 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
7468
dismiss()
7569
} else {
7670
if (context.isPathOnSD(sourcePath) || context.isPathOnSD(destinationPath)) {
71+
if (activity.isShowingPermDialog(files[0])) {
72+
return@setOnClickListener
73+
}
74+
7775
context.toast(R.string.moving)
7876
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
7977
CopyMoveTask(context, true, config.treeUri, false, copyMoveListener).execute(pair)
@@ -89,14 +87,15 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
8987

9088
context.scanFiles(updatedFiles) {
9189
activity.runOnUiThread {
92-
context.toast(R.string.moving_success)
93-
dismiss()
9490
copyMoveListener.copySucceeded(true, files.size * 2 == updatedFiles.size)
91+
dismiss()
9592
}
9693
}
9794
}
9895
}
9996
})
10097
}
98+
99+
view.destination.performClick()
101100
}
102101
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
5050

5151
items_swipe_refresh.setOnRefreshListener({ fillItems() })
5252
items_fab.setOnClickListener { createNewItem() }
53-
context.updateTextColors(items_holder)
5453
}
5554

5655
override fun onResume() {
@@ -59,6 +58,7 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
5958
mShowHidden = !mShowHidden
6059
fillItems()
6160
}
61+
context.updateTextColors(items_holder)
6262
}
6363

6464
override fun onPause() {

app/src/main/res/layout/dialog_copy_item.xml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@
99
android:paddingRight="@dimen/activity_margin"
1010
android:paddingTop="@dimen/activity_margin">
1111

12-
<com.simplemobiletools.commons.views.MyTextView
13-
android:id="@+id/source_label"
14-
android:layout_width="wrap_content"
15-
android:layout_height="wrap_content"
16-
android:text="@string/source"
17-
android:textSize="@dimen/smaller_text_size"/>
18-
19-
<com.simplemobiletools.commons.views.MyTextView
20-
android:id="@+id/source"
21-
android:layout_width="match_parent"
22-
android:layout_height="wrap_content"
23-
android:layout_marginBottom="@dimen/activity_margin"
24-
android:layout_marginLeft="@dimen/activity_margin"
25-
android:paddingRight="@dimen/small_margin"
26-
android:paddingTop="@dimen/small_margin"
27-
android:text="source"/>
28-
2912
<com.simplemobiletools.commons.views.MyTextView
3013
android:id="@+id/destination_label"
3114
android:layout_width="wrap_content"
@@ -42,7 +25,7 @@
4225
android:paddingBottom="@dimen/small_margin"
4326
android:paddingRight="@dimen/small_margin"
4427
android:paddingTop="@dimen/small_margin"
45-
android:text="@string/select_destination"/>
28+
android:text="@string/click_select_destination"/>
4629

4730
<RadioGroup
4831
android:id="@+id/dialog_radio_group"

0 commit comments

Comments
 (0)