Skip to content

Commit

Permalink
Lock screen orientation when showing the dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
0ranko0P committed Jan 31, 2022
1 parent a29d521 commit 8f82e52
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/main/java/me/ranko/autodark/ui/ActivationScopeDialog.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.ranko.autodark.ui

import android.app.Dialog
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
Expand All @@ -19,10 +20,18 @@ class ActivationScopeDialog : BottomSheetDialogFragment() {
val dialog = BottomSheetDialog(requireContext(), R.style.AppTheme_BottomSheetDialogDayNight)
dialog.setContentView(R.layout.dialog_activation_scope)
dialog.setOnShowListener {
val activity = requireActivity()
val savedOrientation = activity.requestedOrientation
activity.requestedOrientation =
ActivityInfo.SCREEN_ORIENTATION_LOCKED.or(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)

val root = dialog.findViewById<View>(R.id.title)!!.parent as View
val xposedContainer: ViewGroup = root.findViewById(R.id.container)
managerView = XposedManagerView(requireActivity(), xposedContainer)
root.findViewById<MaterialButton>(R.id.button).setOnClickListener { dismiss() }
root.findViewById<MaterialButton>(R.id.button).setOnClickListener {
dismiss()
activity.requestedOrientation = savedOrientation
}

val screenSize = ScreenSizeCalculator.getInstance().getScreenSize(requireActivity())
dialog.behavior.peekHeight = screenSize.y
Expand Down

0 comments on commit 8f82e52

Please sign in to comment.