diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index d96a77c50..8d3532271 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -145,7 +145,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return } - uri = intent.data + uri = intent.data!! if (uri.scheme != "file" && uri.scheme != "content") { toast(R.string.unknown_file_location) finish() @@ -153,9 +153,9 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { - val realPath = intent.extras.getString(REAL_FILE_PATH) + val realPath = intent.extras!!.getString(REAL_FILE_PATH) uri = when { - isPathOnOTG(realPath) -> uri + isPathOnOTG(realPath!!) -> uri realPath.startsWith("file:/") -> Uri.parse(realPath) else -> Uri.fromFile(File(realPath)) } @@ -305,7 +305,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener try { if (isNougatPlus()) { inputStream = contentResolver.openInputStream(uri) - oldExif = ExifInterface(inputStream) + oldExif = ExifInterface(inputStream!!) } } catch (e: Exception) { } finally { @@ -317,7 +317,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } else if (editor_draw_canvas.isVisible()) { val bitmap = editor_draw_canvas.getBitmap() if (saveUri.scheme == "file") { - SaveAsDialog(this, saveUri.path, true) { + SaveAsDialog(this, saveUri.path!!, true) { saveBitmapToFile(bitmap, it, true) } } else if (saveUri.scheme == "content") { @@ -643,7 +643,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } private fun applyFilter(filterItem: FilterItem) { - val newBitmap = Bitmap.createBitmap(filterInitialBitmap) + val newBitmap = Bitmap.createBitmap(filterInitialBitmap!!) default_image_view.setImageBitmap(filterItem.filter.processFilter(newBitmap)) } @@ -748,7 +748,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (isCropIntent) { if (saveUri.scheme == "file") { - saveBitmapToFile(bitmap, saveUri.path, true) + saveBitmapToFile(bitmap, saveUri.path!!, true) } else { var inputStream: InputStream? = null var outputStream: OutputStream? = null @@ -757,7 +757,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener bitmap.compress(CompressFormat.JPEG, 100, stream) inputStream = ByteArrayInputStream(stream.toByteArray()) outputStream = contentResolver.openOutputStream(saveUri) - inputStream.copyTo(outputStream) + inputStream.copyTo(outputStream!!) } finally { inputStream?.close() outputStream?.close() @@ -771,7 +771,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener finish() } } else if (saveUri.scheme == "file") { - SaveAsDialog(this, saveUri.path, true) { + SaveAsDialog(this, saveUri.path!!, true) { saveBitmapToFile(bitmap, it, true) } } else if (saveUri.scheme == "content") { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index ce6615589..37b9a8c46 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -723,10 +723,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null private fun isGetImageContentIntent(intent: Intent) = isGetContentIntent(intent) && - (intent.type.startsWith("image/") || intent.type == MediaStore.Images.Media.CONTENT_TYPE) + (intent.type!!.startsWith("image/") || intent.type == MediaStore.Images.Media.CONTENT_TYPE) private fun isGetVideoContentIntent(intent: Intent) = isGetContentIntent(intent) && - (intent.type.startsWith("video/") || intent.type == MediaStore.Video.Media.CONTENT_TYPE) + (intent.type!!.startsWith("video/") || intent.type == MediaStore.Video.Media.CONTENT_TYPE) private fun isGetAnyContentIntent(intent: Intent) = isGetContentIntent(intent) && intent.type == "*/*" @@ -773,14 +773,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun fillExtraOutput(resultData: Intent): Uri? { - val file = File(resultData.data.path) + val file = File(resultData.data!!.path!!) var inputStream: InputStream? = null var outputStream: OutputStream? = null try { - val output = intent.extras.get(MediaStore.EXTRA_OUTPUT) as Uri + val output = intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri inputStream = FileInputStream(file) outputStream = contentResolver.openOutputStream(output) - inputStream.copyTo(outputStream) + inputStream.copyTo(outputStream!!) } catch (e: SecurityException) { showErrorToast(e) } catch (ignored: FileNotFoundException) { @@ -794,8 +794,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun fillPickedPaths(resultData: Intent, resultIntent: Intent) { - val paths = resultData.extras.getStringArrayList(PICKED_PATHS) - val uris = paths.map { getFilePublicUri(File(it), BuildConfig.APPLICATION_ID) } as ArrayList + val paths = resultData.extras!!.getStringArrayList(PICKED_PATHS) + val uris = paths!!.map { getFilePublicUri(File(it), BuildConfig.APPLICATION_ID) } as ArrayList val clipData = ClipData("Attachment", arrayOf("image/*", "video/*"), ClipData.Item(uris.removeAt(0))) uris.forEach { @@ -808,8 +808,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun fillIntentPath(resultData: Intent, resultIntent: Intent) { val data = resultData.data - val path = if (data.toString().startsWith("/")) data.toString() else data.path - val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID) + val path = if (data.toString().startsWith("/")) data.toString() else data!!.path + val uri = getFilePublicUri(File(path!!), BuildConfig.APPLICATION_ID) val type = path.getMimeType() resultIntent.setDataAndTypeAndNormalize(uri, type) resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 409dbdd35..71080ca0d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -114,10 +114,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList if (mUri!!.scheme == "file") { if (filename.contains('.')) { bottom_actions.beGone() - handleLockedFolderOpening(mUri!!.path.getParentPath()) { success -> + handleLockedFolderOpening(mUri!!.path!!.getParentPath()) { success -> if (success) { - rescanPaths(arrayListOf(mUri!!.path)) - sendViewPagerIntent(mUri!!.path) + rescanPaths(arrayListOf(mUri!!.path!!)) + sendViewPagerIntent(mUri!!.path!!) } finish() } @@ -130,7 +130,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList bottom_actions.beGone() handleLockedFolderOpening(path.getParentPath()) { success -> if (success) { - rescanPaths(arrayListOf(mUri!!.path)) + rescanPaths(arrayListOf(mUri!!.path!!)) sendViewPagerIntent(path) } finish() @@ -154,7 +154,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } mIsVideo = type == TYPE_VIDEOS - mMedium = Medium(null, filename, mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type, 0, false, 0L) + mMedium = Medium(null, filename, mUri.toString(), mUri!!.path!!.getParentPath(), 0, 0, file.length(), type, 0, false, 0L) supportActionBar?.title = mMedium!!.name bundle.putSerializable(MEDIUM, mMedium) @@ -272,7 +272,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } private fun showProperties() { - PropertiesDialog(this, mUri!!.path) + PropertiesDialog(this, mUri!!.path!!) } private fun isFileTypeVisible(path: String): Boolean { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt index 56d5d01cd..a6941c2b4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SetWallpaperActivity.kt @@ -63,7 +63,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete } private fun handleImage(intent: Intent) { - uri = intent.data + uri = intent.data!! if (uri.scheme != "file" && uri.scheme != "content") { toast(R.string.unknown_file_location) finish() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index f521b1f99..845235403 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -258,7 +258,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { - mPath = intent.extras.getString(REAL_FILE_PATH) + mPath = intent.extras!!.getString(REAL_FILE_PATH)!! } if (mPath.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 438487891..f4254781a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -237,12 +237,12 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList, mediumDao try { val destination = "$recycleBinPath/$source" val fileDocument = getSomeDocumentFile(source) - inputStream = applicationContext.contentResolver.openInputStream(fileDocument?.uri) + inputStream = applicationContext.contentResolver.openInputStream(fileDocument?.uri!!) out = getFileOutputStreamSync(destination, source.getMimeType()) var copiedSize = 0L val buffer = ByteArray(DEFAULT_BUFFER_SIZE) - var bytes = inputStream.read(buffer) + var bytes = inputStream!!.read(buffer) while (bytes >= 0) { out!!.write(buffer, 0, bytes) copiedSize += bytes diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 4b083aad3..6d126dbce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -94,7 +94,7 @@ class Config(context: Context) : BaseConfig(context) { set(isThirdPartyIntent) = prefs.edit().putBoolean(IS_THIRD_PARTY_INTENT, isThirdPartyIntent).apply() var pinnedFolders: Set - get() = prefs.getStringSet(PINNED_FOLDERS, HashSet()) + get() = prefs.getStringSet(PINNED_FOLDERS, HashSet())!! set(pinnedFolders) = prefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply() var showAll: Boolean @@ -133,7 +133,7 @@ class Config(context: Context) : BaseConfig(context) { } var excludedFolders: MutableSet - get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet()) + get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet())!! set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply() fun addIncludedFolder(path: String) { @@ -155,7 +155,7 @@ class Config(context: Context) : BaseConfig(context) { } var includedFolders: MutableSet - get() = prefs.getStringSet(INCLUDED_FOLDERS, HashSet()) + get() = prefs.getStringSet(INCLUDED_FOLDERS, HashSet())!! set(includedFolders) = prefs.edit().remove(INCLUDED_FOLDERS).putStringSet(INCLUDED_FOLDERS, includedFolders).apply() var autoplayVideos: Boolean @@ -263,7 +263,7 @@ class Config(context: Context) : BaseConfig(context) { else R.integer.media_columns_vertical_scroll) var albumCovers: String - get() = prefs.getString(ALBUM_COVERS, "") + get() = prefs.getString(ALBUM_COVERS, "")!! set(albumCovers) = prefs.edit().putString(ALBUM_COVERS, albumCovers).apply() fun parseAlbumCovers(): ArrayList { @@ -320,7 +320,7 @@ class Config(context: Context) : BaseConfig(context) { set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply() var tempFolderPath: String - get() = prefs.getString(TEMP_FOLDER_PATH, "") + get() = prefs.getString(TEMP_FOLDER_PATH, "")!! set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply() var viewTypeFolders: Int @@ -348,7 +348,7 @@ class Config(context: Context) : BaseConfig(context) { set(wasNewAppShown) = prefs.edit().putBoolean(WAS_NEW_APP_SHOWN, wasNewAppShown).apply() var lastFilepickerPath: String - get() = prefs.getString(LAST_FILEPICKER_PATH, "") + get() = prefs.getString(LAST_FILEPICKER_PATH, "")!! set(lastFilepickerPath) = prefs.edit().putString(LAST_FILEPICKER_PATH, lastFilepickerPath).apply() var tempSkipDeleteConfirmation: Boolean @@ -412,7 +412,7 @@ class Config(context: Context) : BaseConfig(context) { // if a user hides a folder, then enables temporary hidden folder displaying, make sure we show it properly var everShownFolders: Set - get() = prefs.getStringSet(EVER_SHOWN_FOLDERS, getEverShownFolders()) + get() = prefs.getStringSet(EVER_SHOWN_FOLDERS, getEverShownFolders())!! set(everShownFolders) = prefs.edit().putStringSet(EVER_SHOWN_FOLDERS, everShownFolders).apply() private fun getEverShownFolders() = hashSetOf( diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index a17eabeea..965771e9c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -61,7 +61,7 @@ class MediaFetcher(val context: Context) { val selection = "${getSelectionQuery(filterMedia)} ${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL) GROUP BY (${MediaStore.Images.ImageColumns.BUCKET_ID}" val selectionArgs = getSelectionArgsQuery(filterMedia).toTypedArray() val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) - folders.addAll(parseCursor(cursor)) + folders.addAll(parseCursor(cursor!!)) val config = context.config val shouldShowHidden = config.shouldShowHidden