diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt index 42c607406..74706095a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt @@ -87,13 +87,14 @@ class Utils { fun shareMedium(medium: Medium, activity: Activity) { val shareTitle = activity.resources.getString(R.string.share_via) - val intent = Intent() val file = File(medium.path) val uri = Uri.fromFile(file) - intent.action = Intent.ACTION_SEND - intent.putExtra(Intent.EXTRA_STREAM, uri) - intent.type = medium.getMimeType() - activity.startActivity(Intent.createChooser(intent, shareTitle)) + Intent().apply { + action = Intent.ACTION_SEND + putExtra(Intent.EXTRA_STREAM, uri) + type = medium.getMimeType() + activity.startActivity(Intent.createChooser(this, shareTitle)) + } } fun isAStorageRootFolder(context: Context, path: String) = context.isAStorageRootFolder(path) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index e7490878d..8fcf6ec05 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -17,10 +17,11 @@ import com.simplemobiletools.gallery.models.Medium import java.io.File open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClickListener { + private var mIsFullScreen = true + lateinit var mUri: Uri + lateinit var mFragment: ViewPagerFragment + companion object { - private var mUri: Uri? = null - private var mFragment: ViewPagerFragment? = null - private var mIsFullScreen = false var mIsVideo = false } @@ -30,24 +31,22 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic mUri = intent.data ?: return - mIsFullScreen = true - val bundle = Bundle() - val file = File(mUri!!.toString()) - val medium = Medium(file.name, mUri!!.toString(), mIsVideo, 0, file.length()) + val file = File(mUri.toString()) + val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length()) bundle.putSerializable(Constants.MEDIUM, medium) if (savedInstanceState == null) { mFragment = if (mIsVideo) VideoFragment() else PhotoFragment() - mFragment!!.listener = this - mFragment!!.arguments = bundle + mFragment.listener = this + mFragment.arguments = bundle supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() } hideUI() - if (mUri!!.scheme == "content") { + if (mUri.scheme == "content") { val proj = arrayOf(MediaStore.Images.Media.TITLE) - val cursor = contentResolver.query(mUri!!, proj, null, null, null) + val cursor = contentResolver.query(mUri, proj, null, null, null) if (cursor != null && cursor.count != 0) { val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) cursor.moveToFirst() @@ -55,13 +54,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic } cursor?.close() } else { - title = mUri!!.toString().getFilenameFromPath() + title = mUri.toString().getFilenameFromPath() } } override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) - mFragment!!.updateItem() + mFragment.updateItem() } override fun onCreateOptionsMenu(menu: Menu): Boolean { diff --git a/app/src/main/res/layout/photo_video_item.xml b/app/src/main/res/layout/photo_video_item.xml index 7e2f0d5b9..fb7382661 100644 --- a/app/src/main/res/layout/photo_video_item.xml +++ b/app/src/main/res/layout/photo_video_item.xml @@ -11,6 +11,7 @@ android:id="@+id/play_outline" android:layout_width="@dimen/play_outline_size" android:layout_height="@dimen/play_outline_size" + android:layout_margin="@dimen/tiny_margin" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:src="@mipmap/play_outline" diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 62d6dfb44..88a5aff64 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,5 +1,6 @@ 16dp + 2dp 4dp 8dp 150dp