Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1 Date-time picker dailog orientation #679

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixing date-picker-dialogue-issues
  • Loading branch information
Anubhav Agrawal committed Aug 22, 2024
commit 5ce54a0bda9d02e15a54d6203e47a1faebd46577
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.microsoft.fluentuidemo.demos

import android.content.res.Configuration
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -79,6 +80,7 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
}

private var dateTimePickerDialog: DateTimePickerDialog? = null
private var isDialogShowing: Boolean = false

private lateinit var dateTimeBinding: ActivityDateTimePickerBinding

Expand Down Expand Up @@ -183,6 +185,7 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
singleModeTag = it.getString(SINGLE_MODE_TAG)
dialogMode = it.getSerializable(DIALOG_MODE) as? Mode
dialogDateTime = it.getSerializable(DIALOG_DATE_TIME) as? ZonedDateTime
isDialogShowing = savedInstanceState.getBoolean("isDialogShowing")
}

// DateTimePickers
Expand All @@ -202,8 +205,14 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
accessibilityManager.addAccessibilityStateChangeListener {
updateButtonsForAccessibility(it)
}
if(isDialogShowing) {
dateTimePickerDialog?.dismiss()
createDateTimePickerDialog()
}

}


override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putSerializable(DATE_TIME, dateTime)
Expand All @@ -215,6 +224,7 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
outState.putString(FRAGMENT_TAG, fragmentTag)
outState.putSerializable(DIALOG_MODE, dialogMode)
outState.putSerializable(DIALOG_DATE_TIME, dialogDateTime)
outState.putBoolean("isDialogShowing", dateTimePickerDialog?.isShowing ?: false)
Anubhvv marked this conversation as resolved.
Show resolved Hide resolved
}

override fun onDestroy() {
Expand Down Expand Up @@ -251,6 +261,7 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
getFragmentDateTime(),
getFragmentDuration()
)
dateTimePickerDialog?.onDateTimePickedListener = this
dateTimePicker.show(supportFragmentManager, picker.tag)
}

Expand All @@ -272,6 +283,13 @@ class DateTimePickerActivity : DemoActivity(), DateTimePickerDialog.OnDateTimePi
dialogDateTime = dateTime
}
}
dateTimePickerDialog?.onDateTimeSelectedListener =
object : DateTimePickerDialog.OnDateTimeSelectedListener{
override fun onDateTimeSelected(dateTime: ZonedDateTime, duration: Duration) {
dialogMode = getDialogMode()
dialogDateTime = dateTime
}
}

dateTimePickerDialog?.show()
}
Expand Down