diff --git a/app/build.gradle b/app/build.gradle index dc94e81e3..4c0b8b22a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,7 +47,7 @@ ext { } 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.theartofdev.edmodo:android-image-cropper:2.4.0' implementation 'com.android.support:multidex:1.0.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 2cfd99759..b8d3cfc77 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -81,7 +81,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mIsGetAnyContentIntent || mIsSetWallpaperIntent removeTempFolder() - directories_refresh_layout.setOnRefreshListener({ getDirectories() }) + directories_refresh_layout.setOnRefreshListener { getDirectories() } mDirs = ArrayList() storeStateVariables() checkWhatsNewDialog() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt index 05a240577..b506b894f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/DeleteWithRememberDialog.kt @@ -1,23 +1,22 @@ package com.simplemobiletools.gallery.dialogs -import android.content.Context +import android.app.Activity import android.support.v7.app.AlertDialog -import android.view.LayoutInflater import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.gallery.R import kotlinx.android.synthetic.main.dialog_delete_with_remember.view.* -class DeleteWithRememberDialog(val context: Context, val callback: (remember: Boolean) -> Unit) { - var dialog: AlertDialog - val view = LayoutInflater.from(context).inflate(R.layout.dialog_delete_with_remember, null) +class DeleteWithRememberDialog(val activity: Activity, val callback: (remember: Boolean) -> Unit) { + private var dialog: AlertDialog + val view = activity.layoutInflater.inflate(R.layout.dialog_delete_with_remember, null)!! init { - val builder = AlertDialog.Builder(context) + val builder = AlertDialog.Builder(activity) .setPositiveButton(R.string.yes, { dialog, which -> dialogConfirmed() }) .setNegativeButton(R.string.no, null) dialog = builder.create().apply { - context.setupDialogStuff(view, this) + activity.setupDialogStuff(view, this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt index cc2e9432f..7486849d6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/ResizeDialog.kt @@ -74,19 +74,20 @@ class ResizeDialog(val activity: BaseSimpleActivity, val size: Point, val callba .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) { + 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() + } + } } } 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 4a401e289..8bd25c1ea 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SaveAsDialog.kt @@ -46,38 +46,39 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen .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) { + 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) { + 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() } - }) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt index e9dc60b49..5eda40879 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/SlideshowDialog.kt @@ -73,17 +73,18 @@ class SlideshowDialog(val activity: BaseSimpleActivity, val callback: () -> Unit .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) { + 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() + } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index f4b7f4b67..e6b0831d5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -119,7 +119,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mSurfaceView = mView.video_surface mSurfaceHolder = mSurfaceView!!.holder mSurfaceHolder!!.addCallback(this) - mSurfaceView!!.setOnClickListener({ toggleFullscreen() }) + mSurfaceView!!.setOnClickListener { toggleFullscreen() } mView.video_holder.setOnClickListener { toggleFullscreen() } mView.video_volume_controller.setOnTouchListener { v, event -> handleVolumeTouched(event) @@ -423,7 +423,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee setDataSource(context, Uri.parse(mediumPath)) setDisplay(mSurfaceHolder) setOnCompletionListener { videoCompleted() } - setOnVideoSizeChangedListener({ mediaPlayer, width, height -> setVideoSize() }) + setOnVideoSizeChangedListener { mediaPlayer, width, height -> setVideoSize() } setOnPreparedListener { videoPrepared(it) } setAudioStreamType(AudioManager.STREAM_MUSIC) prepare()