update Commons with some dialog crashfixes

This commit is contained in:
tibbi 2017-12-01 11:04:26 +01:00
parent 84fee84349
commit 9fbbd902e8
7 changed files with 59 additions and 57 deletions

View file

@ -47,7 +47,7 @@ ext {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:3.0.13' implementation 'com.simplemobiletools:commons:3.0.16'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0' implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.8.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
implementation 'com.android.support:multidex:1.0.2' implementation 'com.android.support:multidex:1.0.2'

View file

@ -81,7 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mIsGetAnyContentIntent || mIsSetWallpaperIntent mIsGetAnyContentIntent || mIsSetWallpaperIntent
removeTempFolder() removeTempFolder()
directories_refresh_layout.setOnRefreshListener({ getDirectories() }) directories_refresh_layout.setOnRefreshListener { getDirectories() }
mDirs = ArrayList() mDirs = ArrayList()
storeStateVariables() storeStateVariables()
checkWhatsNewDialog() checkWhatsNewDialog()

View file

@ -1,23 +1,22 @@
package com.simplemobiletools.gallery.dialogs package com.simplemobiletools.gallery.dialogs
import android.content.Context import android.app.Activity
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.*
class DeleteWithRememberDialog(val context: Context, val callback: (remember: Boolean) -> Unit) { class DeleteWithRememberDialog(val activity: Activity, val callback: (remember: Boolean) -> Unit) {
var dialog: AlertDialog private var dialog: AlertDialog
val view = LayoutInflater.from(context).inflate(R.layout.dialog_delete_with_remember, null) val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!!
init { init {
val builder = AlertDialog.Builder(context) val builder = AlertDialog.Builder(activity)
.setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() }) .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() })
.setNegativeButton(R.string.no, null) .setNegativeButton(R.string.no, null)
dialog = builder.create().apply { dialog = builder.create().apply {
context.setupDialogStuff(view, this) activity.setupDialogStuff(view, this)
} }
} }

View file

@ -74,19 +74,20 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.resize_and_save) activity.setupDialogStuff(view, this, R.string.resize_and_save) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val width = getViewValue(widthView) val width = getViewValue(widthView)
val height = getViewValue(heightView) val height = getViewValue(heightView)
if (width <= 0 || height <= 0) { if (width <= 0 || height <= 0) {
activity.toast(R.string.invalid_values) activity.toast(R.string.invalid_values)
return@setOnClickListener return@setOnClickListener
} }
val newSize = Point(getViewValue(widthView), getViewValue(heightView)) val newSize = Point(getViewValue(widthView), getViewValue(heightView))
callback(newSize) callback(newSize)
dismiss() dismiss()
}) }
}
} }
} }

View file

@ -46,38 +46,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
activity.setupDialogStuff(view, this, R.string.save_as) activity.setupDialogStuff(view, this, R.string.save_as) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.save_as_name.value val filename = view.save_as_name.value
val extension = view.save_as_extension.value val extension = view.save_as_extension.value
if (filename.isEmpty()) { if (filename.isEmpty()) {
activity.toast(R.string.filename_cannot_be_empty) activity.toast(R.string.filename_cannot_be_empty)
return@setOnClickListener return@setOnClickListener
} }
if (extension.isEmpty()) { if (extension.isEmpty()) {
activity.toast(R.string.extension_cannot_be_empty) activity.toast(R.string.extension_cannot_be_empty)
return@setOnClickListener return@setOnClickListener
} }
val newFile = File(realPath, "$filename.$extension") val newFile = File(realPath, "$filename.$extension")
if (!newFile.name.isAValidFilename()) { if (!newFile.name.isAValidFilename()) {
activity.toast(R.string.filename_invalid_characters) activity.toast(R.string.filename_invalid_characters)
return@setOnClickListener return@setOnClickListener
} }
if (newFile.exists()) { if (newFile.exists()) {
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name) val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFile.name)
ConfirmationDialog(activity, title) { ConfirmationDialog(activity, title) {
callback(newFile.absolutePath)
dismiss()
}
} else {
callback(newFile.absolutePath) callback(newFile.absolutePath)
dismiss() dismiss()
} }
} else {
callback(newFile.absolutePath)
dismiss()
} }
}) }
} }
} }
} }

View file

@ -73,17 +73,18 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.create().apply { .create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
activity.setupDialogStuff(view, this) activity.setupDialogStuff(view, this) {
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({ getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) { if (!view.include_photos.isChecked && !view.include_videos.isChecked && !view.include_gifs.isChecked) {
activity.toast(R.string.no_media_for_slideshow) activity.toast(R.string.no_media_for_slideshow)
return@setOnClickListener return@setOnClickListener
} }
storeValues() storeValues()
callback() callback()
dismiss() dismiss()
}) }
}
} }
} }

View file

@ -119,7 +119,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
mSurfaceView = mView.video_surface mSurfaceView = mView.video_surface
mSurfaceHolder = mSurfaceView!!.holder mSurfaceHolder = mSurfaceView!!.holder
mSurfaceHolder!!.addCallback(this) mSurfaceHolder!!.addCallback(this)
mSurfaceView!!.setOnClickListener({ toggleFullscreen() }) mSurfaceView!!.setOnClickListener { toggleFullscreen() }
mView.video_holder.setOnClickListener { toggleFullscreen() } mView.video_holder.setOnClickListener { toggleFullscreen() }
mView.video_volume_controller.setOnTouchListener { v, event -> mView.video_volume_controller.setOnTouchListener { v, event ->
handleVolumeTouched(event) handleVolumeTouched(event)
@ -423,7 +423,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
setDataSource(context, Uri.parse(mediumPath)) setDataSource(context, Uri.parse(mediumPath))
setDisplay(mSurfaceHolder) setDisplay(mSurfaceHolder)
setOnCompletionListener { videoCompleted() } setOnCompletionListener { videoCompleted() }
setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) setOnVideoSizeChangedListener { mediaPlayer, width, height -> setVideoSize() }
setOnPreparedListener { videoPrepared(it) } setOnPreparedListener { videoPrepared(it) }
setAudioStreamType(AudioManager.STREAM_MUSIC) setAudioStreamType(AudioManager.STREAM_MUSIC)
prepare() prepare()