Skip to content

Commit

Permalink
[MERGE] #121 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#121] 생성 완료뷰 / 알림 권한 설정
  • Loading branch information
Marchbreeze authored Aug 24, 2024
2 parents 9d3aab1 + dc5171b commit bf9ad34
Show file tree
Hide file tree
Showing 10 changed files with 258 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class MainViewModel
private val _postResetResult = MutableSharedFlow<Boolean>()
val postResetResult: SharedFlow<Boolean> = _postResetResult

private val _notificationState =
MutableStateFlow<GenerateStatus>(GenerateStatus.NEW_REQUEST_AVAILABLE)
private val _notificationState = MutableStateFlow(GenerateStatus.NEW_REQUEST_AVAILABLE)
val notificationState: StateFlow<GenerateStatus> = _notificationState

var currentStatus: GenerateStatus = GenerateStatus.NEW_REQUEST_AVAILABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class SelfieFragment() : BaseFragment<FragmentSelfieBinding>(R.layout.fragment_s

override fun onResume() {
super.onResume()

setSavedImages()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package kr.genti.presentation.result.waiting

import android.Manifest
import android.app.Activity
import android.content.DialogInterface
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import android.view.View
import android.view.WindowManager
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.app.ActivityCompat
import kr.genti.core.base.BaseDialog
import kr.genti.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.DialogPushBinding
import timber.log.Timber

class PushDialog :
BaseDialog<DialogPushBinding>(R.layout.dialog_push) {
private lateinit var requestPermissionLauncher: ActivityResultLauncher<String>

override fun onStart() {
super.onStart()
dialog?.window?.apply {
setLayout(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setRequestPermissionLauncher()
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

initCloseBtnListener()
initGetAlarmBtnListener()
}

private fun initCloseBtnListener() {
binding.btnClose.setOnSingleClickListener { dismiss() }
}

private fun initGetAlarmBtnListener() {
binding.btnGetAlarm.setOnSingleClickListener {
requestAlarmPermission()
}
}

private fun setRequestPermissionLauncher() {
requestPermissionLauncher =
registerForActivityResult(ActivityResultContracts.RequestPermission()) { isGranted ->
Timber.d(isGranted.toString())
dismiss()
}
}

private fun isAlreadyRejectedPermission(): Boolean =
ActivityCompat.shouldShowRequestPermissionRationale(
requireActivity(),
Manifest.permission.POST_NOTIFICATIONS,
)

private fun requestAlarmPermission() {
if (isAlreadyRejectedPermission()) {
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
data = Uri.parse("package:" + requireActivity().packageName)
startActivity(this)
}
} else {
requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}

override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)

with(requireActivity()) {
setResult(Activity.RESULT_OK)
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package kr.genti.presentation.result.waiting

import android.Manifest
import android.app.Activity
import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
Expand All @@ -19,6 +23,8 @@ import kr.genti.presentation.util.AmplitudeManager.PROPERTY_PAGE

@AndroidEntryPoint
class WaitingActivity : BaseActivity<ActivityWaitBinding>(R.layout.activity_wait) {
private var pushDialog: PushDialog? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand All @@ -34,27 +40,55 @@ class WaitingActivity : BaseActivity<ActivityWaitBinding>(R.layout.activity_wait
mapOf(PROPERTY_PAGE to "picwaiting"),
mapOf(PROPERTY_BTN to "gomain"),
)
setResult(Activity.RESULT_OK)
finish()
startPushDialogOrFinish()
}
}

private fun setOnBackPressed() {
val onBackPressedCallback =
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
setResult(Activity.RESULT_OK)
finish()
startPushDialogOrFinish()
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun startPushDialogOrFinish() {
if (isPermissionNeeded()) {
pushDialog = PushDialog()
pushDialog?.show(supportFragmentManager, DIALOG_PUSH)
} else {
setResult(Activity.RESULT_OK)
finish()
}
}

private fun isPermissionNeeded(): Boolean =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
ContextCompat.checkSelfPermission(
this.applicationContext,
Manifest.permission.POST_NOTIFICATIONS,
) != PackageManager.PERMISSION_GRANTED
} else {
false
}

private fun setStatusBarTransparent() {
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
v.updatePadding(bottom = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom)
insets
}
}

override fun onDestroy() {
super.onDestroy()

pushDialog = null
}

companion object {
private const val DIALOG_PUSH = "DIALOG_PUSH"
}
}
Binary file added presentation/src/main/res/drawable/img_alarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions presentation/src/main/res/layout/activity_finished.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
app:layout_constraintTop_toBottomOf="@id/iv_finished_ghost" />

<com.airbnb.lottie.LottieAnimationView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="@id/iv_finished_image_3_2"
app:layout_constraintEnd_toEndOf="@id/iv_finished_image_3_2"
app:layout_constraintStart_toStartOf="@id/iv_finished_image_3_2"
Expand Down Expand Up @@ -155,8 +155,8 @@
app:layout_constraintTop_toBottomOf="@id/iv_finished_logo_2_3" />

<com.airbnb.lottie.LottieAnimationView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_width="80dp"
android:layout_height="80dp"
app:layout_constraintBottom_toBottomOf="@id/iv_finished_image_2_3"
app:layout_constraintEnd_toEndOf="@id/iv_finished_image_2_3"
app:layout_constraintStart_toStartOf="@id/iv_finished_image_2_3"
Expand Down
111 changes: 111 additions & 0 deletions presentation/src/main/res/layout/dialog_push.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>


</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/view_push_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/img_error_bg_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/view_push_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-80dp"
android:adjustViewBounds="true"
android:src="@drawable/img_error_bg_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_get_alarm" />

<View
android:layout_width="0dp"
android:layout_marginTop="-20dp"
android:layout_marginHorizontal="0.1dp"
android:layout_height="0dp"
android:background="@color/background_white"
app:layout_constraintBottom_toTopOf="@id/view_push_bottom"
app:layout_constraintEnd_toEndOf="@id/view_push_bottom"
app:layout_constraintStart_toStartOf="@id/view_push_bottom"
app:layout_constraintTop_toBottomOf="@id/view_push_top" />

<ImageView
android:id="@+id/btn_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="14dp"
android:src="@drawable/ic_close_dialog"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tv_push_title"
style="@style/TextAppearance.Genti.Headline4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="44dp"
android:layout_marginTop="26dp"
android:gravity="center"
android:text="@string/push_tv_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/iv_push_alarm"
android:layout_width="75dp"
android:layout_height="75dp"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
android:adjustViewBounds="true"
android:src="@drawable/img_alarm"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_push_title" />

<TextView
android:id="@+id/tv_push_subtitle"
style="@style/TextAppearance.Genti.BodySmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="@string/push_tv_subtitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/iv_push_alarm" />

<TextView
android:id="@+id/btn_get_alarm"
style="@style/TextAppearance.Genti.Headline4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="29dp"
android:layout_marginTop="16dp"
android:background="@drawable/shape_green1_fill_6_rect"
android:gravity="center"
android:paddingVertical="6dp"
android:text="@string/push_btn_get_alarm"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_push_subtitle" />

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>
6 changes: 3 additions & 3 deletions presentation/src/main/res/layout/item_feed_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_loading_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="70dp"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/lottie_loading_image" />
Expand Down
Loading

0 comments on commit bf9ad34

Please sign in to comment.