From 4ba982cdfacd089e97fa549d3a7f6bf995552e38 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 11 Mar 2017 23:03:52 +0100 Subject: [PATCH] updating the Copy dialog --- .../filemanager/activities/MainActivity.kt | 10 +++--- .../filemanager/dialogs/CopyDialog.kt | 33 +++++++++---------- .../filemanager/fragments/ItemsFragment.kt | 2 +- app/src/main/res/layout/dialog_copy_item.xml | 19 +---------- 4 files changed, 24 insertions(+), 40 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt index 4717ee83..d5b96ad2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt @@ -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 diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CopyDialog.kt index e143ee73..cf817332 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CopyDialog.kt @@ -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, 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, 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, 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, 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, File>(files, destinationDir) CopyMoveTask(context, true, config.treeUri, false, copyMoveListener).execute(pair) @@ -89,14 +87,15 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList, 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() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt index 5933a69f..9e07276e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/filemanager/fragments/ItemsFragment.kt @@ -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() { diff --git a/app/src/main/res/layout/dialog_copy_item.xml b/app/src/main/res/layout/dialog_copy_item.xml index 9ab3a8d2..2f67e7a6 100644 --- a/app/src/main/res/layout/dialog_copy_item.xml +++ b/app/src/main/res/layout/dialog_copy_item.xml @@ -9,23 +9,6 @@ android:paddingRight="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"> - - - - + android:text="@string/click_select_destination"/>