adding some exclamation marks in preparation for sdk 29

This commit is contained in:
tibbi 2019-11-25 22:41:57 +01:00
parent 67d4c1ecbe
commit 1d0f129e85
8 changed files with 36 additions and 36 deletions

View file

@ -145,7 +145,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
return return
} }
uri = intent.data uri = intent.data!!
if (uri.scheme != "file" && uri.scheme != "content") { if (uri.scheme != "file" && uri.scheme != "content") {
toast(R.string.unknown_file_location) toast(R.string.unknown_file_location)
finish() finish()
@ -153,9 +153,9 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { 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 { uri = when {
isPathOnOTG(realPath) -> uri isPathOnOTG(realPath!!) -> uri
realPath.startsWith("file:/") -> Uri.parse(realPath) realPath.startsWith("file:/") -> Uri.parse(realPath)
else -> Uri.fromFile(File(realPath)) else -> Uri.fromFile(File(realPath))
} }
@ -305,7 +305,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
try { try {
if (isNougatPlus()) { if (isNougatPlus()) {
inputStream = contentResolver.openInputStream(uri) inputStream = contentResolver.openInputStream(uri)
oldExif = ExifInterface(inputStream) oldExif = ExifInterface(inputStream!!)
} }
} catch (e: Exception) { } catch (e: Exception) {
} finally { } finally {
@ -317,7 +317,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} else if (editor_draw_canvas.isVisible()) { } else if (editor_draw_canvas.isVisible()) {
val bitmap = editor_draw_canvas.getBitmap() val bitmap = editor_draw_canvas.getBitmap()
if (saveUri.scheme == "file") { if (saveUri.scheme == "file") {
SaveAsDialog(this, saveUri.path, true) { SaveAsDialog(this, saveUri.path!!, true) {
saveBitmapToFile(bitmap, it, true) saveBitmapToFile(bitmap, it, true)
} }
} else if (saveUri.scheme == "content") { } else if (saveUri.scheme == "content") {
@ -643,7 +643,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
} }
private fun applyFilter(filterItem: FilterItem) { private fun applyFilter(filterItem: FilterItem) {
val newBitmap = Bitmap.createBitmap(filterInitialBitmap) val newBitmap = Bitmap.createBitmap(filterInitialBitmap!!)
default_image_view.setImageBitmap(filterItem.filter.processFilter(newBitmap)) default_image_view.setImageBitmap(filterItem.filter.processFilter(newBitmap))
} }
@ -748,7 +748,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
if (isCropIntent) { if (isCropIntent) {
if (saveUri.scheme == "file") { if (saveUri.scheme == "file") {
saveBitmapToFile(bitmap, saveUri.path, true) saveBitmapToFile(bitmap, saveUri.path!!, true)
} else { } else {
var inputStream: InputStream? = null var inputStream: InputStream? = null
var outputStream: OutputStream? = null var outputStream: OutputStream? = null
@ -757,7 +757,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
bitmap.compress(CompressFormat.JPEG, 100, stream) bitmap.compress(CompressFormat.JPEG, 100, stream)
inputStream = ByteArrayInputStream(stream.toByteArray()) inputStream = ByteArrayInputStream(stream.toByteArray())
outputStream = contentResolver.openOutputStream(saveUri) outputStream = contentResolver.openOutputStream(saveUri)
inputStream.copyTo(outputStream) inputStream.copyTo(outputStream!!)
} finally { } finally {
inputStream?.close() inputStream?.close()
outputStream?.close() outputStream?.close()
@ -771,7 +771,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
finish() finish()
} }
} else if (saveUri.scheme == "file") { } else if (saveUri.scheme == "file") {
SaveAsDialog(this, saveUri.path, true) { SaveAsDialog(this, saveUri.path!!, true) {
saveBitmapToFile(bitmap, it, true) saveBitmapToFile(bitmap, it, true)
} }
} else if (saveUri.scheme == "content") { } else if (saveUri.scheme == "content") {

View file

@ -723,10 +723,10 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null private fun isGetContentIntent(intent: Intent) = intent.action == Intent.ACTION_GET_CONTENT && intent.type != null
private fun isGetImageContentIntent(intent: Intent) = isGetContentIntent(intent) && 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) && 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 == "*/*" private fun isGetAnyContentIntent(intent: Intent) = isGetContentIntent(intent) && intent.type == "*/*"
@ -773,14 +773,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
private fun fillExtraOutput(resultData: Intent): Uri? { private fun fillExtraOutput(resultData: Intent): Uri? {
val file = File(resultData.data.path) val file = File(resultData.data!!.path!!)
var inputStream: InputStream? = null var inputStream: InputStream? = null
var outputStream: OutputStream? = null var outputStream: OutputStream? = null
try { try {
val output = intent.extras.get(MediaStore.EXTRA_OUTPUT) as Uri val output = intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri
inputStream = FileInputStream(file) inputStream = FileInputStream(file)
outputStream = contentResolver.openOutputStream(output) outputStream = contentResolver.openOutputStream(output)
inputStream.copyTo(outputStream) inputStream.copyTo(outputStream!!)
} catch (e: SecurityException) { } catch (e: SecurityException) {
showErrorToast(e) showErrorToast(e)
} catch (ignored: FileNotFoundException) { } catch (ignored: FileNotFoundException) {
@ -794,8 +794,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
private fun fillPickedPaths(resultData: Intent, resultIntent: Intent) { private fun fillPickedPaths(resultData: Intent, resultIntent: Intent) {
val paths = resultData.extras.getStringArrayList(PICKED_PATHS) val paths = resultData.extras!!.getStringArrayList(PICKED_PATHS)
val uris = paths.map { getFilePublicUri(File(it), BuildConfig.APPLICATION_ID) } as ArrayList val uris = paths!!.map { getFilePublicUri(File(it), BuildConfig.APPLICATION_ID) } as ArrayList
val clipData = ClipData("Attachment", arrayOf("image/*", "video/*"), ClipData.Item(uris.removeAt(0))) val clipData = ClipData("Attachment", arrayOf("image/*", "video/*"), ClipData.Item(uris.removeAt(0)))
uris.forEach { uris.forEach {
@ -808,8 +808,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun fillIntentPath(resultData: Intent, resultIntent: Intent) { private fun fillIntentPath(resultData: Intent, resultIntent: Intent) {
val data = resultData.data val data = resultData.data
val path = if (data.toString().startsWith("/")) data.toString() else data.path val path = if (data.toString().startsWith("/")) data.toString() else data!!.path
val uri = getFilePublicUri(File(path), BuildConfig.APPLICATION_ID) val uri = getFilePublicUri(File(path!!), BuildConfig.APPLICATION_ID)
val type = path.getMimeType() val type = path.getMimeType()
resultIntent.setDataAndTypeAndNormalize(uri, type) resultIntent.setDataAndTypeAndNormalize(uri, type)
resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

View file

@ -114,10 +114,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
if (mUri!!.scheme == "file") { if (mUri!!.scheme == "file") {
if (filename.contains('.')) { if (filename.contains('.')) {
bottom_actions.beGone() bottom_actions.beGone()
handleLockedFolderOpening(mUri!!.path.getParentPath()) { success -> handleLockedFolderOpening(mUri!!.path!!.getParentPath()) { success ->
if (success) { if (success) {
rescanPaths(arrayListOf(mUri!!.path)) rescanPaths(arrayListOf(mUri!!.path!!))
sendViewPagerIntent(mUri!!.path) sendViewPagerIntent(mUri!!.path!!)
} }
finish() finish()
} }
@ -130,7 +130,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
bottom_actions.beGone() bottom_actions.beGone()
handleLockedFolderOpening(path.getParentPath()) { success -> handleLockedFolderOpening(path.getParentPath()) { success ->
if (success) { if (success) {
rescanPaths(arrayListOf(mUri!!.path)) rescanPaths(arrayListOf(mUri!!.path!!))
sendViewPagerIntent(path) sendViewPagerIntent(path)
} }
finish() finish()
@ -154,7 +154,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} }
mIsVideo = type == TYPE_VIDEOS 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 supportActionBar?.title = mMedium!!.name
bundle.putSerializable(MEDIUM, mMedium) bundle.putSerializable(MEDIUM, mMedium)
@ -272,7 +272,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} }
private fun showProperties() { private fun showProperties() {
PropertiesDialog(this, mUri!!.path) PropertiesDialog(this, mUri!!.path!!)
} }
private fun isFileTypeVisible(path: String): Boolean { private fun isFileTypeVisible(path: String): Boolean {

View file

@ -63,7 +63,7 @@ class SetWallpaperActivity : SimpleActivity(), CropImageView.OnCropImageComplete
} }
private fun handleImage(intent: Intent) { private fun handleImage(intent: Intent) {
uri = intent.data uri = intent.data!!
if (uri.scheme != "file" && uri.scheme != "content") { if (uri.scheme != "file" && uri.scheme != "content") {
toast(R.string.unknown_file_location) toast(R.string.unknown_file_location)
finish() finish()

View file

@ -258,7 +258,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { 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()) { if (mPath.isEmpty()) {

View file

@ -237,12 +237,12 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, mediumDao
try { try {
val destination = "$recycleBinPath/$source" val destination = "$recycleBinPath/$source"
val fileDocument = getSomeDocumentFile(source) val fileDocument = getSomeDocumentFile(source)
inputStream = applicationContext.contentResolver.openInputStream(fileDocument?.uri) inputStream = applicationContext.contentResolver.openInputStream(fileDocument?.uri!!)
out = getFileOutputStreamSync(destination, source.getMimeType()) out = getFileOutputStreamSync(destination, source.getMimeType())
var copiedSize = 0L var copiedSize = 0L
val buffer = ByteArray(DEFAULT_BUFFER_SIZE) val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
var bytes = inputStream.read(buffer) var bytes = inputStream!!.read(buffer)
while (bytes >= 0) { while (bytes >= 0) {
out!!.write(buffer, 0, bytes) out!!.write(buffer, 0, bytes)
copiedSize += bytes copiedSize += bytes

View file

@ -94,7 +94,7 @@ class Config(context: Context) : BaseConfig(context) {
set(isThirdPartyIntent) = prefs.edit().putBoolean(IS_THIRD_PARTY_INTENT, isThirdPartyIntent).apply() set(isThirdPartyIntent) = prefs.edit().putBoolean(IS_THIRD_PARTY_INTENT, isThirdPartyIntent).apply()
var pinnedFolders: Set<String> var pinnedFolders: Set<String>
get() = prefs.getStringSet(PINNED_FOLDERS, HashSet<String>()) get() = prefs.getStringSet(PINNED_FOLDERS, HashSet<String>())!!
set(pinnedFolders) = prefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply() set(pinnedFolders) = prefs.edit().putStringSet(PINNED_FOLDERS, pinnedFolders).apply()
var showAll: Boolean var showAll: Boolean
@ -133,7 +133,7 @@ class Config(context: Context) : BaseConfig(context) {
} }
var excludedFolders: MutableSet<String> var excludedFolders: MutableSet<String>
get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet()) get() = prefs.getStringSet(EXCLUDED_FOLDERS, HashSet())!!
set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply() set(excludedFolders) = prefs.edit().remove(EXCLUDED_FOLDERS).putStringSet(EXCLUDED_FOLDERS, excludedFolders).apply()
fun addIncludedFolder(path: String) { fun addIncludedFolder(path: String) {
@ -155,7 +155,7 @@ class Config(context: Context) : BaseConfig(context) {
} }
var includedFolders: MutableSet<String> var includedFolders: MutableSet<String>
get() = prefs.getStringSet(INCLUDED_FOLDERS, HashSet<String>()) get() = prefs.getStringSet(INCLUDED_FOLDERS, HashSet<String>())!!
set(includedFolders) = prefs.edit().remove(INCLUDED_FOLDERS).putStringSet(INCLUDED_FOLDERS, includedFolders).apply() set(includedFolders) = prefs.edit().remove(INCLUDED_FOLDERS).putStringSet(INCLUDED_FOLDERS, includedFolders).apply()
var autoplayVideos: Boolean var autoplayVideos: Boolean
@ -263,7 +263,7 @@ class Config(context: Context) : BaseConfig(context) {
else R.integer.media_columns_vertical_scroll) else R.integer.media_columns_vertical_scroll)
var albumCovers: String var albumCovers: String
get() = prefs.getString(ALBUM_COVERS, "") get() = prefs.getString(ALBUM_COVERS, "")!!
set(albumCovers) = prefs.edit().putString(ALBUM_COVERS, albumCovers).apply() set(albumCovers) = prefs.edit().putString(ALBUM_COVERS, albumCovers).apply()
fun parseAlbumCovers(): ArrayList<AlbumCover> { fun parseAlbumCovers(): ArrayList<AlbumCover> {
@ -320,7 +320,7 @@ class Config(context: Context) : BaseConfig(context) {
set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply() set(loopSlideshow) = prefs.edit().putBoolean(SLIDESHOW_LOOP, loopSlideshow).apply()
var tempFolderPath: String 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() set(tempFolderPath) = prefs.edit().putString(TEMP_FOLDER_PATH, tempFolderPath).apply()
var viewTypeFolders: Int var viewTypeFolders: Int
@ -348,7 +348,7 @@ class Config(context: Context) : BaseConfig(context) {
set(wasNewAppShown) = prefs.edit().putBoolean(WAS_NEW_APP_SHOWN, wasNewAppShown).apply() set(wasNewAppShown) = prefs.edit().putBoolean(WAS_NEW_APP_SHOWN, wasNewAppShown).apply()
var lastFilepickerPath: String 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() set(lastFilepickerPath) = prefs.edit().putString(LAST_FILEPICKER_PATH, lastFilepickerPath).apply()
var tempSkipDeleteConfirmation: Boolean 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 // if a user hides a folder, then enables temporary hidden folder displaying, make sure we show it properly
var everShownFolders: Set<String> var everShownFolders: Set<String>
get() = prefs.getStringSet(EVER_SHOWN_FOLDERS, getEverShownFolders()) get() = prefs.getStringSet(EVER_SHOWN_FOLDERS, getEverShownFolders())!!
set(everShownFolders) = prefs.edit().putStringSet(EVER_SHOWN_FOLDERS, everShownFolders).apply() set(everShownFolders) = prefs.edit().putStringSet(EVER_SHOWN_FOLDERS, everShownFolders).apply()
private fun getEverShownFolders() = hashSetOf( private fun getEverShownFolders() = hashSetOf(

View file

@ -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 selection = "${getSelectionQuery(filterMedia)} ${MediaStore.Images.ImageColumns.BUCKET_ID} IS NOT NULL) GROUP BY (${MediaStore.Images.ImageColumns.BUCKET_ID}"
val selectionArgs = getSelectionArgsQuery(filterMedia).toTypedArray() val selectionArgs = getSelectionArgsQuery(filterMedia).toTypedArray()
val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null)
folders.addAll(parseCursor(cursor)) folders.addAll(parseCursor(cursor!!))
val config = context.config val config = context.config
val shouldShowHidden = config.shouldShowHidden val shouldShowHidden = config.shouldShowHidden