mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
use some helper functions for hiding/showing keyboard at dialogs
This commit is contained in:
parent
fc9c1a62a7
commit
39b4677887
6 changed files with 59 additions and 63 deletions
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.13.8'
|
||||
implementation 'com.simplemobiletools:commons:3.14.5'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||
implementation 'com.android.support:multidex:1.0.2'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
|
|
|
@ -22,9 +22,7 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
|||
val medium = media[position]
|
||||
val bundle = Bundle()
|
||||
bundle.putSerializable(MEDIUM, medium)
|
||||
val fragment: ViewPagerFragment
|
||||
|
||||
fragment = if (medium.isVideo()) {
|
||||
val fragment = if (medium.isVideo()) {
|
||||
VideoFragment()
|
||||
} else {
|
||||
PhotoFragment()
|
||||
|
@ -39,7 +37,7 @@ class MyPagerAdapter(val activity: ViewPagerActivity, fm: FragmentManager, val m
|
|||
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||||
val fragment = super.instantiateItem(container, position) as ViewPagerFragment
|
||||
fragments.put(position, fragment)
|
||||
fragments[position] = fragment
|
||||
return fragment
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@ import android.graphics.Point
|
|||
import android.support.v7.app.AlertDialog
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.WindowManager
|
||||
import android.widget.EditText
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.commons.extensions.showKeyboard
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.value
|
||||
import com.simplemobiletools.gallery.R
|
||||
|
@ -72,22 +72,22 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, R.string.resize_and_save) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val width = getViewValue(widthView)
|
||||
val height = getViewValue(heightView)
|
||||
if (width <= 0 || height <= 0) {
|
||||
activity.toast(R.string.invalid_values)
|
||||
return@setOnClickListener
|
||||
}
|
||||
activity.setupDialogStuff(view, this, R.string.resize_and_save) {
|
||||
showKeyboard(view.image_width)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val width = getViewValue(widthView)
|
||||
val height = getViewValue(heightView)
|
||||
if (width <= 0 || height <= 0) {
|
||||
activity.toast(R.string.invalid_values)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
|
||||
callback(newSize)
|
||||
dismiss()
|
||||
val newSize = Point(getViewValue(widthView), getViewValue(heightView))
|
||||
callback(newSize)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getViewValue(view: EditText): Int {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simplemobiletools.gallery.dialogs
|
||||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
|
@ -45,40 +44,40 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
|
||||
activity.setupDialogStuff(view, this, R.string.save_as) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.save_as_name.value
|
||||
val extension = view.save_as_extension.value
|
||||
activity.setupDialogStuff(view, this, R.string.save_as) {
|
||||
showKeyboard(view.save_as_name)
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
val filename = view.save_as_name.value
|
||||
val extension = view.save_as_extension.value
|
||||
|
||||
if (filename.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (filename.isEmpty()) {
|
||||
activity.toast(R.string.filename_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (extension.isEmpty()) {
|
||||
activity.toast(R.string.extension_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (extension.isEmpty()) {
|
||||
activity.toast(R.string.extension_cannot_be_empty)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
val newFile = File(realPath, "$filename.$extension")
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
return@setOnClickListener
|
||||
}
|
||||
val newFile = File(realPath, "$filename.$extension")
|
||||
if (!newFile.name.isAValidFilename()) {
|
||||
activity.toast(R.string.filename_invalid_characters)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
if (newFile.exists()) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
||||
ConfirmationDialog(activity, title) {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
if (newFile.exists()) {
|
||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
|
||||
ConfirmationDialog(activity, title) {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
} else {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
callback(newFile.absolutePath)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simplemobiletools.gallery.dialogs
|
|||
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.commons.extensions.hideKeyboard
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
|
@ -71,20 +70,20 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
|
|||
.setPositiveButton(R.string.ok, null)
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
|
||||
activity.setupDialogStuff(view, this) {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
|
||||
activity.toast(R.string.no_media_for_slideshow)
|
||||
return@setOnClickListener
|
||||
}
|
||||
activity.setupDialogStuff(view, this) {
|
||||
hideKeyboard()
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
|
||||
activity.toast(R.string.no_media_for_slideshow)
|
||||
return@setOnClickListener
|
||||
}
|
||||
|
||||
storeValues()
|
||||
callback()
|
||||
dismiss()
|
||||
storeValues()
|
||||
callback()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupValues() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.2.21'
|
||||
ext.kotlin_version = '1.2.30'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
|
Loading…
Reference in a new issue