-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
258 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
presentation/src/main/java/kr/genti/presentation/result/waiting/PushDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.