mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
replace a couple more extension functions
This commit is contained in:
parent
bf94d8172c
commit
c4edf3c28e
8 changed files with 7 additions and 44 deletions
|
@ -14,11 +14,7 @@ import android.util.DisplayMetrics
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.webkit.MimeTypeMap
|
import android.webkit.MimeTypeMap
|
||||||
import com.simplemobiletools.filepicker.extensions.getFileDocument
|
import com.simplemobiletools.filepicker.extensions.*
|
||||||
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.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -149,6 +145,6 @@ class Utils {
|
||||||
context.contentResolver.takePersistableUriPermission(treeUri, takeFlags)
|
context.contentResolver.takePersistableUriPermission(treeUri, takeFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scanFiles(context: Context, paths: Array<String>) = context.scanFile(paths)
|
fun scanFiles(context: Context, paths: Array<String>) = context.rescanFiles(paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,10 @@ package com.simplemobiletools.gallery.dialogs
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.filepicker.extensions.getFileDocument
|
import com.simplemobiletools.filepicker.extensions.*
|
||||||
import com.simplemobiletools.filepicker.extensions.humanizePath
|
|
||||||
import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions
|
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
|
||||||
import com.simplemobiletools.gallery.Config
|
import com.simplemobiletools.gallery.Config
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.extensions.value
|
|
||||||
import kotlinx.android.synthetic.main.rename_directory.view.*
|
import kotlinx.android.synthetic.main.rename_directory.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
|
@ -4,14 +4,10 @@ import android.media.MediaScannerConnection
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.filepicker.extensions.getFileDocument
|
import com.simplemobiletools.filepicker.extensions.*
|
||||||
import com.simplemobiletools.filepicker.extensions.humanizePath
|
|
||||||
import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions
|
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
|
||||||
import com.simplemobiletools.gallery.Config
|
import com.simplemobiletools.gallery.Config
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.activities.SimpleActivity
|
import com.simplemobiletools.gallery.activities.SimpleActivity
|
||||||
import com.simplemobiletools.gallery.extensions.value
|
|
||||||
import kotlinx.android.synthetic.main.rename_file.view.*
|
import kotlinx.android.synthetic.main.rename_file.view.*
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ import android.support.v7.app.AlertDialog
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.simplemobiletools.filepicker.extensions.getFilenameFromPath
|
import com.simplemobiletools.filepicker.extensions.getFilenameFromPath
|
||||||
|
import com.simplemobiletools.filepicker.extensions.isAValidFilename
|
||||||
import com.simplemobiletools.filepicker.extensions.toast
|
import com.simplemobiletools.filepicker.extensions.toast
|
||||||
|
import com.simplemobiletools.filepicker.extensions.value
|
||||||
import com.simplemobiletools.gallery.R
|
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.*
|
import kotlinx.android.synthetic.main.rename_file.view.*
|
||||||
|
|
||||||
class SaveAsDialog(val activity: Activity, val path: String, val listener: OnSaveAsListener) {
|
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
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename.isNameValid()) {
|
if (!filename.isAValidFilename()) {
|
||||||
context.toast(R.string.filename_invalid_characters)
|
context.toast(R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
package com.simplemobiletools.gallery.extensions
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.media.MediaScannerConnection
|
|
||||||
|
|
||||||
fun Context.scanFile(paths: Array<String>) = MediaScannerConnection.scanFile(this, paths, null, null)
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.simplemobiletools.gallery.extensions
|
|
||||||
|
|
||||||
import android.widget.EditText
|
|
||||||
|
|
||||||
val EditText.value: String get() = this.text.toString().trim()
|
|
|
@ -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()
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.simplemobiletools.gallery.extensions
|
|
||||||
|
|
||||||
import android.widget.TextView
|
|
||||||
|
|
||||||
val TextView.value: String get() = text.toString().trim()
|
|
Loading…
Reference in a new issue