some smaller adjustments here and there

This commit is contained in:
tibbi 2016-11-13 22:13:16 +01:00
parent 376089984c
commit e2938a59ec
4 changed files with 20 additions and 18 deletions

View file

@ -87,13 +87,14 @@ class Utils {
fun shareMedium(medium: Medium, activity: Activity) { fun shareMedium(medium: Medium, activity: Activity) {
val shareTitle = activity.resources.getString(R.string.share_via) val shareTitle = activity.resources.getString(R.string.share_via)
val intent = Intent()
val file = File(medium.path) val file = File(medium.path)
val uri = Uri.fromFile(file) val uri = Uri.fromFile(file)
intent.action = Intent.ACTION_SEND Intent().apply {
intent.putExtra(Intent.EXTRA_STREAM, uri) action = Intent.ACTION_SEND
intent.type = medium.getMimeType() putExtra(Intent.EXTRA_STREAM, uri)
activity.startActivity(Intent.createChooser(intent, shareTitle)) type = medium.getMimeType()
activity.startActivity(Intent.createChooser(this, shareTitle))
}
} }
fun isAStorageRootFolder(context: Context, path: String) = context.isAStorageRootFolder(path) fun isAStorageRootFolder(context: Context, path: String) = context.isAStorageRootFolder(path)

View file

@ -17,10 +17,11 @@ import com.simplemobiletools.gallery.models.Medium
import java.io.File import java.io.File
open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClickListener { open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClickListener {
private var mIsFullScreen = true
lateinit var mUri: Uri
lateinit var mFragment: ViewPagerFragment
companion object { companion object {
private var mUri: Uri? = null
private var mFragment: ViewPagerFragment? = null
private var mIsFullScreen = false
var mIsVideo = false var mIsVideo = false
} }
@ -30,24 +31,22 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
mUri = intent.data ?: return mUri = intent.data ?: return
mIsFullScreen = true
val bundle = Bundle() val bundle = Bundle()
val file = File(mUri!!.toString()) val file = File(mUri.toString())
val medium = Medium(file.name, mUri!!.toString(), mIsVideo, 0, file.length()) val medium = Medium(file.name, mUri.toString(), mIsVideo, 0, file.length())
bundle.putSerializable(Constants.MEDIUM, medium) bundle.putSerializable(Constants.MEDIUM, medium)
if (savedInstanceState == null) { if (savedInstanceState == null) {
mFragment = if (mIsVideo) VideoFragment() else PhotoFragment() mFragment = if (mIsVideo) VideoFragment() else PhotoFragment()
mFragment!!.listener = this mFragment.listener = this
mFragment!!.arguments = bundle mFragment.arguments = bundle
supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit()
} }
hideUI() hideUI()
if (mUri!!.scheme == "content") { if (mUri.scheme == "content") {
val proj = arrayOf(MediaStore.Images.Media.TITLE) 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) { if (cursor != null && cursor.count != 0) {
val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE)
cursor.moveToFirst() cursor.moveToFirst()
@ -55,13 +54,13 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic
} }
cursor?.close() cursor?.close()
} else { } else {
title = mUri!!.toString().getFilenameFromPath() title = mUri.toString().getFilenameFromPath()
} }
} }
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig) super.onConfigurationChanged(newConfig)
mFragment!!.updateItem() mFragment.updateItem()
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {

View file

@ -11,6 +11,7 @@
android:id="@+id/play_outline" android:id="@+id/play_outline"
android:layout_width="@dimen/play_outline_size" android:layout_width="@dimen/play_outline_size"
android:layout_height="@dimen/play_outline_size" android:layout_height="@dimen/play_outline_size"
android:layout_margin="@dimen/tiny_margin"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:src="@mipmap/play_outline" android:src="@mipmap/play_outline"

View file

@ -1,5 +1,6 @@
<resources> <resources>
<dimen name="activity_margin">16dp</dimen> <dimen name="activity_margin">16dp</dimen>
<dimen name="tiny_margin">2dp</dimen>
<dimen name="small_padding">4dp</dimen> <dimen name="small_padding">4dp</dimen>
<dimen name="medium_padding">8dp</dimen> <dimen name="medium_padding">8dp</dimen>
<dimen name="dir_tmb_size">150dp</dimen> <dimen name="dir_tmb_size">150dp</dimen>