Automatically expand date time picker

pull/1722/head
Alex Baker 3 years ago
parent 4bc3162a5a
commit f8fd78a5b7

@ -3,7 +3,6 @@ package org.tasks.dialogs
import android.app.Activity import android.app.Activity
import android.app.Dialog import android.app.Dialog
import android.content.DialogInterface import android.content.DialogInterface
import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
@ -62,12 +61,14 @@ abstract class BaseDateTimePicker : BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dialog.setOnShowListener { dialog.setOnShowListener {
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { dialog
dialog.behavior.halfExpandedRatio = .75f .findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet)
val bottomSheet = dialog.findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet) ?.let { bottomSheet ->
BottomSheetBehavior.from(bottomSheet!!).state = BottomSheetBehavior.STATE_HALF_EXPANDED with (BottomSheetBehavior.from(bottomSheet)) {
dialog.behavior.peekHeight = bottomSheet.height state = BottomSheetBehavior.STATE_EXPANDED
} skipCollapsed = true
}
}
if (!closeAutomatically()) { if (!closeAutomatically()) {
addButtons(dialog) addButtons(dialog)

Loading…
Cancel
Save