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) {
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)

View file

@ -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 {

View file

@ -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"

View file

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