From 6f4aa1f87a34a87ab2e6161a43ec9a6264ab0e8e Mon Sep 17 00:00:00 2001 From: figonzal1 Date: Sat, 15 Jul 2023 18:32:48 -0400 Subject: [PATCH] avances en nuevas UI de compartir sismos #39 Signed-off-by: figonzal1 --- .../core/utils/GoogleMapsExt.kt | 4 +- .../quake_feature/ui/QuakeDetailsActivity.kt | 17 +++++- .../ui/dialog/ShareQuakeBottomSheetDialog.kt | 55 ++++++++++++++++++ .../drawable/round_add_instagram_story.xml | 14 +++++ app/src/main/res/layout/fragment_maps.xml | 2 +- ...m_sheet.xml => quake_map_bottom_sheet.xml} | 0 .../res/layout/share_quake_bottom_sheet.xml | 58 +++++++++++++++++++ .../layout/share_quake_bottom_sheet_item.xml | 46 +++++++++++++++ 8 files changed, 191 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/dialog/ShareQuakeBottomSheetDialog.kt create mode 100644 app/src/main/res/drawable/round_add_instagram_story.xml rename app/src/main/res/layout/{quake_bottom_sheet.xml => quake_map_bottom_sheet.xml} (100%) create mode 100644 app/src/main/res/layout/share_quake_bottom_sheet.xml create mode 100644 app/src/main/res/layout/share_quake_bottom_sheet_item.xml diff --git a/app/src/main/java/cl/figonzal/lastquakechile/core/utils/GoogleMapsExt.kt b/app/src/main/java/cl/figonzal/lastquakechile/core/utils/GoogleMapsExt.kt index e8a36a35..be3c384e 100644 --- a/app/src/main/java/cl/figonzal/lastquakechile/core/utils/GoogleMapsExt.kt +++ b/app/src/main/java/cl/figonzal/lastquakechile/core/utils/GoogleMapsExt.kt @@ -10,7 +10,7 @@ import android.os.Build import android.view.View import cl.figonzal.lastquakechile.R import cl.figonzal.lastquakechile.core.utils.views.* -import cl.figonzal.lastquakechile.databinding.QuakeBottomSheetBinding +import cl.figonzal.lastquakechile.databinding.QuakeMapBottomSheetBinding import cl.figonzal.lastquakechile.quake_feature.domain.model.Quake import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.model.Circle @@ -169,7 +169,7 @@ fun Context.configMapType() = SharedPrefUtil(this).getData( fun Context.setBottomSheetQuakeData( quake: Quake, - binding: QuakeBottomSheetBinding + binding: QuakeMapBottomSheetBinding ) { with(binding.sheetContent) { diff --git a/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/QuakeDetailsActivity.kt b/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/QuakeDetailsActivity.kt index 2315628d..8323ec61 100644 --- a/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/QuakeDetailsActivity.kt +++ b/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/QuakeDetailsActivity.kt @@ -27,6 +27,7 @@ import cl.figonzal.lastquakechile.core.utils.* import cl.figonzal.lastquakechile.core.utils.views.* import cl.figonzal.lastquakechile.databinding.ActivityQuakeDetailsBinding import cl.figonzal.lastquakechile.quake_feature.domain.model.Quake +import cl.figonzal.lastquakechile.quake_feature.ui.dialog.ShareQuakeBottomSheetDialog import com.google.android.gms.ads.* import com.google.android.gms.ads.nativead.NativeAd import com.google.android.gms.ads.nativead.NativeAdView @@ -86,6 +87,7 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU -> { this?.getParcelable(QUAKE, Quake::class.java) } + else -> this?.get(QUAKE) as Quake } isSnapshotRequest = this?.getBoolean(IS_SNAPSHOT_REQUEST_FROM_BOTTOM_SHEET) as Boolean @@ -172,6 +174,7 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { null -> { View.INVISIBLE } + else -> { nativeAd.starRating?.let { (starRatingView as RatingBar).rating = it.toFloat() @@ -191,6 +194,7 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { vc?.hasVideoContent() == true -> vc.videoLifecycleCallbacks = object : VideoController.VideoLifecycleCallbacks() { } + else -> { //refreshAd() } @@ -335,7 +339,15 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { //Seteo de floating buttons binding.fabShare.setOnClickListener { _ -> Timber.d("Share button clicked") - this@QuakeDetailsActivity.makeSnapshot(p0, it) + + + val shareQuakeBottomSheetDialog = ShareQuakeBottomSheetDialog() + shareQuakeBottomSheetDialog.show( + supportFragmentManager, + "ShareQuakeBottomSheetDialog" + ) + + //this@QuakeDetailsActivity.makeSnapshot(p0, it) } if (isSnapshotRequest == true) { @@ -343,7 +355,7 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { lifecycleScope.launch { delay(1000) - this@QuakeDetailsActivity.makeSnapshot(p0, it) + //this@QuakeDetailsActivity.makeSnapshot(p0, it) } } } @@ -422,6 +434,7 @@ class QuakeDetailsActivity : AppCompatActivity(), OnMapReadyCallback { Timber.d("Home up clicked") finish() } + R.id.layers_menu -> { googleMap?.let { diff --git a/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/dialog/ShareQuakeBottomSheetDialog.kt b/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/dialog/ShareQuakeBottomSheetDialog.kt new file mode 100644 index 00000000..eb63d3db --- /dev/null +++ b/app/src/main/java/cl/figonzal/lastquakechile/quake_feature/ui/dialog/ShareQuakeBottomSheetDialog.kt @@ -0,0 +1,55 @@ +package cl.figonzal.lastquakechile.quake_feature.ui.dialog + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.content.res.ResourcesCompat +import cl.figonzal.lastquakechile.R +import cl.figonzal.lastquakechile.databinding.ShareQuakeBottomSheetBinding +import com.google.android.material.bottomsheet.BottomSheetDialogFragment + +class ShareQuakeBottomSheetDialog : BottomSheetDialogFragment() { + + + private var _binding: ShareQuakeBottomSheetBinding? = null + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + + _binding = ShareQuakeBottomSheetBinding.inflate(layoutInflater, container, false) + + + binding.include1.tvTitle.text = "Agregar a historia" + binding.include2.tvTitle.text = "Tuitear" + + binding.include1.ivIcon.setImageDrawable( + ResourcesCompat.getDrawable( + resources, + R.drawable.round_add_instagram_story, + requireContext().theme + ) + ) + binding.include2.ivIcon.setImageDrawable( + ResourcesCompat.getDrawable( + resources, + R.drawable.round_add_instagram_story, + requireContext().theme + ) + ) + + binding.include1.root.setOnClickListener { + } + + + binding.include2.root.setOnClickListener { + } + + return binding.root + } + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/round_add_instagram_story.xml b/app/src/main/res/drawable/round_add_instagram_story.xml new file mode 100644 index 00000000..2933d523 --- /dev/null +++ b/app/src/main/res/drawable/round_add_instagram_story.xml @@ -0,0 +1,14 @@ + + + + diff --git a/app/src/main/res/layout/fragment_maps.xml b/app/src/main/res/layout/fragment_maps.xml index b6579196..d632bb5f 100644 --- a/app/src/main/res/layout/fragment_maps.xml +++ b/app/src/main/res/layout/fragment_maps.xml @@ -23,7 +23,7 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/share_quake_bottom_sheet_item.xml b/app/src/main/res/layout/share_quake_bottom_sheet_item.xml new file mode 100644 index 00000000..cb899d28 --- /dev/null +++ b/app/src/main/res/layout/share_quake_bottom_sheet_item.xml @@ -0,0 +1,46 @@ + + + + + + + + + + \ No newline at end of file