From 9b809790f90c269105add96e9fbacdbf3985f6f5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 8 Nov 2016 23:00:09 +0100 Subject: [PATCH] create the copy dialog at viewpageractivity --- .../gallery/activities/ViewPagerActivity.java | 23 ++++++++++++++++++- .../gallery/dialogs/CopyDialog.kt | 11 +++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java index d929c1b4b..c73c387d0 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/ViewPagerActivity.java @@ -23,6 +23,8 @@ import com.simplemobiletools.gallery.MyViewPager; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.adapters.MyPagerAdapter; +import com.simplemobiletools.gallery.asynctasks.CopyTask; +import com.simplemobiletools.gallery.dialogs.CopyDialog; import com.simplemobiletools.gallery.dialogs.RenameFileDialog; import com.simplemobiletools.gallery.fragments.ViewPagerFragment; import com.simplemobiletools.gallery.models.Medium; @@ -41,7 +43,7 @@ import butterknife.OnClick; public class ViewPagerActivity extends SimpleActivity implements ViewPager.OnPageChangeListener, View.OnSystemUiVisibilityChangeListener, ViewPager.OnTouchListener, - ViewPagerFragment.FragmentClickListener { + ViewPagerFragment.FragmentClickListener, CopyTask.CopyListener { @BindView(R.id.undo_delete) View mUndoBtn; @BindView(R.id.view_pager) MyViewPager mPager; @@ -185,7 +187,16 @@ public class ViewPagerActivity extends SimpleActivity } private void displayCopyDialog() { + final File file = getCurrentFile(); + final List files = new ArrayList<>(); + files.add(file); + new CopyDialog(this, files, this, new CopyDialog.OnCopyListener() { + @Override + public void onSuccess() { + + } + }); } private void openEditor() { @@ -491,4 +502,14 @@ public class ViewPagerActivity extends SimpleActivity super.onPause(); deleteFile(); } + + @Override + public void copySucceeded(@NotNull File destinationDir) { + + } + + @Override + public void copyFailed() { + + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt index fe73eb1fa..bbad09129 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt @@ -5,6 +5,8 @@ import android.support.v4.util.Pair import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager +import com.simplemobiletools.filepicker.extensions.getBasePath +import com.simplemobiletools.filepicker.extensions.getHumanReadablePath import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.Utils import com.simplemobiletools.gallery.asynctasks.CopyTask @@ -15,12 +17,17 @@ import kotlinx.android.synthetic.main.copy_item.view.* import java.io.File import java.util.* -class CopyDialog(val activity: Activity, val files: List, val path: String, val copyListener: CopyTask.CopyListener, val listener: OnCopyListener) { +class CopyDialog(val activity: Activity, val files: List, val copyListener: CopyTask.CopyListener, val listener: OnCopyListener) { init { val context = activity val view = LayoutInflater.from(context).inflate(R.layout.copy_item, null) - view.source.text = "${path.trimEnd('/')}/" + val path = files[0].parent.trimEnd('/') + + val basePath = path.getBasePath(context) + val humanPath = path.replaceFirst(basePath, activity.getHumanReadablePath(basePath)) + + view.source.text = humanPath view.destination.setOnClickListener {