updating the Copy dialog
This commit is contained in:
parent
067fa79ef6
commit
4ba982cdfa
|
@ -10,10 +10,7 @@ import android.support.v4.app.ActivityCompat
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.dialogs.StoragePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.getInternalStoragePath
|
||||
import com.simplemobiletools.commons.extensions.hasWriteStoragePermission
|
||||
import com.simplemobiletools.commons.extensions.storeStoragePaths
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
|
@ -48,6 +45,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
|
|||
storeStoragePaths()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateTextColors(main_screen)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
config.isFirstRun = false
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.filemanager.dialogs
|
|||
import android.support.v4.util.Pair
|
||||
import android.support.v7.app.AlertDialog
|
||||
import com.simplemobiletools.commons.asynctasks.CopyMoveTask
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
|
@ -18,20 +19,14 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
val view = activity.layoutInflater.inflate(R.layout.dialog_copy_item, null)
|
||||
val sourcePath = files[0].parent.trimEnd('/')
|
||||
var destinationPath = ""
|
||||
view.source.text = "${context.humanizePath(sourcePath)}/"
|
||||
|
||||
val config = context.config
|
||||
/*view.destination.setOnClickListener {
|
||||
FilePickerDialog(activity, destinationPath, false, config.showHidden, object : FilePickerDialog.OnFilePickerListener {
|
||||
override fun onFail(error: FilePickerDialog.FilePickerResult) {
|
||||
}
|
||||
|
||||
override fun onSuccess(pickedPath: String) {
|
||||
destinationPath = pickedPath
|
||||
view.destination.text = context.humanizePath(pickedPath)
|
||||
}
|
||||
})
|
||||
}*/
|
||||
view.destination.setOnClickListener {
|
||||
FilePickerDialog(activity, sourcePath, false, config.showHidden, true) {
|
||||
destinationPath = it
|
||||
view.destination.text = context.humanizePath(it)
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(context)
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
|
@ -44,7 +39,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (view.source.text.trimEnd('/') == destinationPath.trimEnd('/')) {
|
||||
if (sourcePath == destinationPath.trimEnd('/')) {
|
||||
context.toast(R.string.source_and_destination_same)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
@ -56,8 +51,7 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
}
|
||||
|
||||
if (files.size == 1) {
|
||||
val newFile = File(files[0].path)
|
||||
if (File(destinationPath, newFile.name).exists()) {
|
||||
if (File(destinationPath, files[0].name).exists()) {
|
||||
context.toast(R.string.name_taken)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
@ -74,6 +68,10 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
dismiss()
|
||||
} else {
|
||||
if (context.isPathOnSD(sourcePath) || context.isPathOnSD(destinationPath)) {
|
||||
if (activity.isShowingPermDialog(files[0])) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
context.toast(R.string.moving)
|
||||
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
|
||||
CopyMoveTask(context, true, config.treeUri, false, copyMoveListener).execute(pair)
|
||||
|
@ -89,14 +87,15 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
|
||||
context.scanFiles(updatedFiles) {
|
||||
activity.runOnUiThread {
|
||||
context.toast(R.string.moving_success)
|
||||
dismiss()
|
||||
copyMoveListener.copySucceeded(true, files.size * 2 == updatedFiles.size)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
view.destination.performClick()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
|
|||
|
||||
items_swipe_refresh.setOnRefreshListener({ fillItems() })
|
||||
items_fab.setOnClickListener { createNewItem() }
|
||||
context.updateTextColors(items_holder)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -59,6 +58,7 @@ class ItemsFragment : android.support.v4.app.Fragment(), ItemsAdapter.ItemOperat
|
|||
mShowHidden = !mShowHidden
|
||||
fillItems()
|
||||
}
|
||||
context.updateTextColors(items_holder)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
|
|
@ -9,23 +9,6 @@
|
|||
android:paddingRight="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/source_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/source"
|
||||
android:textSize="@dimen/smaller_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/source"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:text="source"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/destination_label"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -42,7 +25,7 @@
|
|||
android:paddingBottom="@dimen/small_margin"
|
||||
android:paddingRight="@dimen/small_margin"
|
||||
android:paddingTop="@dimen/small_margin"
|
||||
android:text="@string/select_destination"/>
|
||||
android:text="@string/click_select_destination"/>
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/dialog_radio_group"
|
||||
|
|
Loading…
Reference in New Issue