Commit 3c537a2e authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

Merge branch 'feature/share_photo' into develop

parents ffdb56e4 197e7c5e
package com.biganto.visual.roompark.presentation.screen.photo package com.biganto.visual.roompark.presentation.screen.photo
import android.content.Intent
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
...@@ -14,11 +16,13 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity ...@@ -14,11 +16,13 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.BigantoBaseController import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.conductor.dialogs.ChooseResolutionDialogController import com.biganto.visual.roompark.conductor.dialogs.ChooseResolutionDialogController
import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler 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.PhotoPreviewSlider
import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter import com.biganto.visual.roompark.presentation.screen.photo.util.PhotosAdapter
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import timber.log.Timber import timber.log.Timber
import java.io.FileOutputStream
import javax.inject.Inject import javax.inject.Inject
...@@ -68,6 +72,33 @@ class PhotoScreenController : ...@@ -68,6 +72,33 @@ class PhotoScreenController :
handleBack() handleBack()
} }
@OnClick(R.id.share_image_button)
fun onShareImage(){
val imgUrl =
(photoViewPager.adapter as PhotosAdapter)
.getCurrentItem(photoViewPager.currentItem)
.resolutionList
.maxBy { it.resHeight*it.resWidth }
?.url?:""
val shareIntent = Intent()
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
shareIntent.action = Intent.ACTION_SEND
shareIntent.type = "text/plain"
shareIntent.putExtra(Intent.EXTRA_TEXT, imgUrl)
startActivity(shareIntent)
}
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) { override fun onAttach(view: View) {
// tempSystemUiFlag = activity?.window?.decorView?.systemUiVisibility // tempSystemUiFlag = activity?.window?.decorView?.systemUiVisibility
super.onAttach(view) super.onAttach(view)
......
...@@ -34,6 +34,8 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() { ...@@ -34,6 +34,8 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
fun indexById(id:Int):Int = list.indexOfFirst { it.photoId == id } fun indexById(id:Int):Int = list.indexOfFirst { it.photoId == id }
fun getCurrentItem(pos:Int) = list[pos]
override val vhKlazz = PhotosViewHolder::class override val vhKlazz = PhotosViewHolder::class
......
...@@ -52,28 +52,26 @@ ...@@ -52,28 +52,26 @@
app:layout_constraintGuide_end="80dp" /> app:layout_constraintGuide_end="80dp" />
<ImageView <ImageView
android:id="@+id/show_full_button" android:id="@+id/share_image_button"
android:layout_width="24dp" android:layout_width="40dp"
android:layout_height="24dp" android:layout_height="0dp"
android:layout_marginStart="16dp" android:layout_marginStart="8dp"
android:layout_marginTop="16dp" android:layout_marginTop="12dp"
app:layout_constraintBottom_toBottomOf="parent" android:padding="8dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0" app:srcCompat="@drawable/ic_share" />
app:srcCompat="@drawable/iic_full_view" />
<ImageView <ImageView
android:id="@+id/choose_size_button" android:id="@+id/choose_size_button"
android:layout_width="24dp" android:layout_width="40dp"
android:layout_height="24dp" android:layout_height="0dp"
android:layout_marginTop="16dp" android:layout_marginTop="12dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent" android:padding="8dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" app:layout_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0" app:srcCompat="@drawable/ic_ratio" />
app:srcCompat="@drawable/iic_full_view"/>
<com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider <com.biganto.visual.roompark.presentation.screen.photo.util.PhotoPreviewSlider
android:id="@+id/photosPreviewSlider" android:id="@+id/photosPreviewSlider"
...@@ -87,7 +85,7 @@ ...@@ -87,7 +85,7 @@
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/choose_size_button" 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_constraintTop_toTopOf="@+id/guideline2"
app:layout_constraintVertical_bias="0.0" /> app:layout_constraintVertical_bias="0.0" />
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
<string name="estate_type_other_short">ОБ.%s</string> <string name="estate_type_other_short">ОБ.%s</string>
<string name="tour_not_allowed">Запуск туров пока недоступен!</string> <string name="tour_not_allowed">Запуск туров пока недоступен!</string>
<string name="content_description_close">Close</string> <string name="content_description_close">Close</string>
<string name="share_house_photo">Поделиться изображением</string>
<!--endregion--> <!--endregion-->
</resources> </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