From c4edf3c28e19066a9c4f20b8edb6c9e80ea00417 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 12 Nov 2016 12:12:05 +0100 Subject: [PATCH] replace a couple more extension functions --- app/src/main/java/com/simplemobiletools/gallery/Utils.kt | 8 ++------ .../gallery/dialogs/RenameDirectoryDialog.kt | 6 +----- .../gallery/dialogs/RenameFileDialog.kt | 6 +----- .../simplemobiletools/gallery/dialogs/SaveAsDialog.kt | 6 +++--- .../com/simplemobiletools/gallery/extensions/context.kt | 6 ------ .../com/simplemobiletools/gallery/extensions/editText.kt | 5 ----- .../com/simplemobiletools/gallery/extensions/string.kt | 9 --------- .../com/simplemobiletools/gallery/extensions/textView.kt | 5 ----- 8 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt delete mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/editText.kt delete mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/string.kt delete mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/textView.kt diff --git a/app/src/main/java/com/simplemobiletools/gallery/Utils.kt b/app/src/main/java/com/simplemobiletools/gallery/Utils.kt index 9bd33d178..3ee8b00fa 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/Utils.kt +++ b/app/src/main/java/com/simplemobiletools/gallery/Utils.kt @@ -14,11 +14,7 @@ import android.util.DisplayMetrics import android.util.TypedValue import android.view.* import android.webkit.MimeTypeMap -import com.simplemobiletools.filepicker.extensions.getFileDocument -import com.simplemobiletools.filepicker.extensions.hasStoragePermission -import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions -import com.simplemobiletools.filepicker.extensions.toast -import com.simplemobiletools.gallery.extensions.scanFile +import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.models.Medium import java.io.File @@ -149,6 +145,6 @@ class Utils { context.contentResolver.takePersistableUriPermission(treeUri, takeFlags) } - fun scanFiles(context: Context, paths: Array) = context.scanFile(paths) + fun scanFiles(context: Context, paths: Array) = context.rescanFiles(paths) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt index d2de737c0..036272dfa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameDirectoryDialog.kt @@ -3,14 +3,10 @@ package com.simplemobiletools.gallery.dialogs import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager -import com.simplemobiletools.filepicker.extensions.getFileDocument -import com.simplemobiletools.filepicker.extensions.humanizePath -import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions -import com.simplemobiletools.filepicker.extensions.toast +import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.Config import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity -import com.simplemobiletools.gallery.extensions.value import kotlinx.android.synthetic.main.rename_directory.view.* import java.io.File import java.util.* diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt index c0d4b5df3..a11553470 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/RenameFileDialog.kt @@ -4,14 +4,10 @@ import android.media.MediaScannerConnection import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager -import com.simplemobiletools.filepicker.extensions.getFileDocument -import com.simplemobiletools.filepicker.extensions.humanizePath -import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions -import com.simplemobiletools.filepicker.extensions.toast +import com.simplemobiletools.filepicker.extensions.* import com.simplemobiletools.gallery.Config import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.activities.SimpleActivity -import com.simplemobiletools.gallery.extensions.value import kotlinx.android.synthetic.main.rename_file.view.* import java.io.File diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt index e4af5d6f2..f397ffb42 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -5,10 +5,10 @@ import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.WindowManager import com.simplemobiletools.filepicker.extensions.getFilenameFromPath +import com.simplemobiletools.filepicker.extensions.isAValidFilename import com.simplemobiletools.filepicker.extensions.toast +import com.simplemobiletools.filepicker.extensions.value import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.extensions.isNameValid -import com.simplemobiletools.gallery.extensions.value import kotlinx.android.synthetic.main.rename_file.view.* class SaveAsDialog(val activity: Activity, val path: String, val listener: OnSaveAsListener) { @@ -34,7 +34,7 @@ class SaveAsDialog(val activity: Activity, val path: String, val listener: OnSav return@setOnClickListener } - if (!filename.isNameValid()) { + if (!filename.isAValidFilename()) { context.toast(R.string.filename_invalid_characters) return@setOnClickListener } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt deleted file mode 100644 index 33cdef78a..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import android.content.Context -import android.media.MediaScannerConnection - -fun Context.scanFile(paths: Array) = MediaScannerConnection.scanFile(this, paths, null, null) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/editText.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/editText.kt deleted file mode 100644 index 6bf3b3df9..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/editText.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import android.widget.EditText - -val EditText.value: String get() = this.text.toString().trim() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/string.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/string.kt deleted file mode 100644 index 3ad03ec42..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/string.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import java.util.regex.Pattern - -fun String.isNameValid(): Boolean { - val pattern = Pattern.compile("^[-_.A-Za-z0-9()#& ]+$") - val matcher = pattern.matcher(this) - return matcher.matches() -} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/textView.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/textView.kt deleted file mode 100644 index 7bcf1f833..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/textView.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import android.widget.TextView - -val TextView.value: String get() = text.toString().trim()