Commit f227fe02 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

layout for share refactored

parent 76e62401
package com.biganto.visual.roompark.presentation.screen.photo
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.view.View
import android.view.WindowManager
......@@ -14,11 +18,16 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.conductor.dialogs.ChooseResolutionDialogController
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import com.bluelinelabs.conductor.RouterTransaction
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.textview.MaterialTextView
import timber.log.Timber
import java.io.FileOutputStream
import javax.inject.Inject
......@@ -68,6 +77,55 @@ class PhotoScreenController :
handleBack()
}
@OnClick(R.id.share_image_button)
fun onShareImage(){
val img = (photoViewPager.adapter as PhotosAdapter)
.getCurrentItem(photoViewPager.currentItem)
.resolutionList
.maxBy { it.resHeight*it.resWidth }
?.url?:""
Timber.d(" sssssssssss $img")
Glide.with(photoViewPager)
.asBitmap()
.load(img)
.into(object :CustomTarget<Bitmap>(){
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
Timber.d(" eeee $img")
val uri = writeFile("${img.hashCode()}.jpg",resource)
Timber.d(" zzz zz zz $uri")
Timber.d(" zzz zz zz ${Uri.parse(uri)}")
val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, Uri.parse(uri))
putExtra(Intent.EXTRA_SUBJECT, "subject");
putExtra(Intent.EXTRA_TITLE, "room park");
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
type = "image/jpeg";
}
startActivity(Intent.createChooser(shareIntent, resources?.getText(R.string.share_house_photo)))
}
override fun onLoadCleared(placeholder: Drawable?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
})
}
private fun writeFile(fileName: String?, bitmap: Bitmap): String {
val f = FileModule.getDirectory(activity!!,FileModule.FileDirectory.Albums(fileName))
val outputStream = FileOutputStream(f)
outputStream.use {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, it)
it.flush()
}
return f.absolutePath
}
override fun onAttach(view: View) {
// tempSystemUiFlag = activity?.window?.decorView?.systemUiVisibility
super.onAttach(view)
......
......@@ -34,6 +34,8 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
fun indexById(id:Int):Int = list.indexOfFirst { it.photoId == id }
fun getCurrentItem(pos:Int) = list[pos]
override val vhKlazz = PhotosViewHolder::class
......
......@@ -52,28 +52,26 @@
app:layout_constraintGuide_end="80dp" />
<ImageView
android:id="@+id/show_full_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/share_image_button"
android:layout_width="40dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:padding="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/iic_full_view" />
app:srcCompat="@drawable/ic_share" />
<ImageView
android:id="@+id/choose_size_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="40dp"
android:layout_height="0dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/iic_full_view"/>
app:srcCompat="@drawable/ic_ratio" />
<com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider
android:id="@+id/photosPreviewSlider"
......@@ -87,7 +85,7 @@
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/choose_size_button"
app:layout_constraintStart_toEndOf="@+id/show_full_button"
app:layout_constraintStart_toEndOf="@+id/share_image_button"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0" />
......
......@@ -91,6 +91,7 @@
<string name="estate_type_other_short">ОБ.%s</string>
<string name="tour_not_allowed">Запуск туров пока недоступен!</string>
<string name="content_description_close">Close</string>
<string name="share_house_photo">Поделиться изображением</string>
<!--endregion-->
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment