add a dialog for setting the destination zip filename
This commit is contained in:
parent
48d0a1885e
commit
1ef349384d
|
@ -26,6 +26,7 @@ import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.filemanager.R
|
import com.simplemobiletools.filemanager.R
|
||||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.dialogs.CompressAsDialog
|
||||||
import com.simplemobiletools.filemanager.extensions.config
|
import com.simplemobiletools.filemanager.extensions.config
|
||||||
import kotlinx.android.synthetic.main.list_item.view.*
|
import kotlinx.android.synthetic.main.list_item.view.*
|
||||||
import java.io.*
|
import java.io.*
|
||||||
|
@ -211,10 +212,12 @@ class ItemsAdapter(val activity: SimpleActivity, var mItems: MutableList<FileDir
|
||||||
if (selectedPositions.isEmpty())
|
if (selectedPositions.isEmpty())
|
||||||
return
|
return
|
||||||
|
|
||||||
val firstFile = File(mItems[selectedPositions.first()].path)
|
val firstPath = mItems[selectedPositions.first()].path
|
||||||
activity.handleSAFDialog(firstFile) {
|
CompressAsDialog(activity, firstPath) {
|
||||||
val paths = selectedPositions.map { mItems[it].path }.toTypedArray()
|
activity.handleSAFDialog(File(firstPath)) {
|
||||||
compress(paths, "${firstFile.parentFile}/compressed.zip")
|
val paths = selectedPositions.map { mItems[it].path }.toTypedArray()
|
||||||
|
compress(paths, it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.simplemobiletools.filemanager.dialogs
|
||||||
|
|
||||||
|
import android.support.v7.app.AlertDialog
|
||||||
|
import android.view.WindowManager
|
||||||
|
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.filemanager.R
|
||||||
|
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||||
|
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class CompressAsDialog(val activity: SimpleActivity, val path: String, val callback: (destination: String) -> Unit) {
|
||||||
|
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
||||||
|
|
||||||
|
init {
|
||||||
|
val filename = path.getFilenameFromPath()
|
||||||
|
val indexOfDot = if (filename.contains('.') && File(path).isFile) filename.lastIndexOf(".") else filename.length
|
||||||
|
val baseFilename = filename.substring(0, indexOfDot)
|
||||||
|
view.file_name.setText(baseFilename)
|
||||||
|
|
||||||
|
AlertDialog.Builder(activity)
|
||||||
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.create().apply {
|
||||||
|
activity.setupDialogStuff(view, this, R.string.compress_as)
|
||||||
|
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||||
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||||
|
dismiss()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,8 +11,9 @@ import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: () -> Unit) {
|
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: () -> Unit) {
|
||||||
|
private val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null)
|
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/dialog_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
|
android:id="@+id/file_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/medium_margin"
|
||||||
|
android:layout_toLeftOf="@+id/file_extension"
|
||||||
|
android:inputType="textCapSentences"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textCursorDrawable="@null"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/file_extension"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBottom="@+id/file_name"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignTop="@+id/file_name"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text=".zip"
|
||||||
|
android:textSize="@dimen/normal_text_size"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Komprimovať</string>
|
<string name="compress">Komprimovať</string>
|
||||||
<string name="decompress">Dekomprimovať</string>
|
<string name="decompress">Dekomprimovať</string>
|
||||||
|
<string name="compress_as">Komprimovať ako</string>
|
||||||
<string name="compressing">Komprimuje sa…</string>
|
<string name="compressing">Komprimuje sa…</string>
|
||||||
<string name="decompressing">Dekomprimuje sa…</string>
|
<string name="decompressing">Dekomprimuje sa…</string>
|
||||||
<string name="compression_successful">Kompresia bola úspešná</string>
|
<string name="compression_successful">Kompresia bola úspešná</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Compression -->
|
<!-- Compression -->
|
||||||
<string name="compress">Compress</string>
|
<string name="compress">Compress</string>
|
||||||
<string name="decompress">Decompress</string>
|
<string name="decompress">Decompress</string>
|
||||||
|
<string name="compress_as">Compress as</string>
|
||||||
<string name="compressing">Compressing…</string>
|
<string name="compressing">Compressing…</string>
|
||||||
<string name="decompressing">Decompressing…</string>
|
<string name="decompressing">Decompressing…</string>
|
||||||
<string name="compression_successful">Compression successful</string>
|
<string name="compression_successful">Compression successful</string>
|
||||||
|
|
Loading…
Reference in New Issue