Commit ef38c364 authored by ekager's avatar ekager
Browse files

For #16397 - Fixes SignOutFragment crash and invisible button

parent 52836aa7
......@@ -10,39 +10,36 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.fragment.app.DialogFragment
import com.google.android.material.bottomsheet.BottomSheetDialog
import org.mozilla.fenix.addons.runIfFragmentIsAttached
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import androidx.appcompat.app.AppCompatDialogFragment
import kotlinx.android.synthetic.main.fragment_sign_out.view.*
import kotlinx.coroutines.launch
import mozilla.components.service.fxa.manager.FxaAccountManager
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents
class SignOutFragment : BottomSheetDialogFragment() {
class SignOutFragment : AppCompatDialogFragment() {
private lateinit var accountManager: FxaAccountManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(DialogFragment.STYLE_NO_TITLE, R.style.FirefoxAccountsDialogStyle)
setStyle(STYLE_NO_TITLE, R.style.BottomSheet)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.setOnShowListener {
val bottomSheet = dialog.findViewById<View>(
com.google.android.material.R.id.design_bottom_sheet
) as FrameLayout
val behavior = BottomSheetBehavior.from(bottomSheet)
behavior.state = BottomSheetBehavior.STATE_EXPANDED
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
BottomSheetDialog(requireContext(), this.theme).apply {
setOnShowListener {
val bottomSheet =
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout
val behavior = BottomSheetBehavior.from(bottomSheet)
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
}
return dialog
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
......@@ -63,13 +60,15 @@ class SignOutFragment : BottomSheetDialogFragment() {
super.onViewCreated(view, savedInstanceState)
view.signOutDisconnect.setOnClickListener {
viewLifecycleOwner.lifecycleScope.launch {
lifecycleScope.launch {
requireComponents
.backgroundServices.accountAbnormalities.userRequestedLogout()
accountManager.logout()
}.invokeOnCompletion {
if (!findNavController().popBackStack(R.id.settingsFragment, false)) {
dismiss()
runIfFragmentIsAttached {
if (!findNavController().popBackStack(R.id.settingsFragment, false)) {
dismiss()
}
}
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
......@@ -15,24 +16,36 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
app:drawableStartCompat="@drawable/ic_info"
android:text="@string/sign_out_confirmation_message_2"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:drawableStartCompat="@drawable/ic_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/signOutCancel"
style="@style/SitePermissionCancelButton"
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:letterSpacing="0"
android:padding="10dp"
android:scrollbars="none"
android:text="@string/sign_out_cancel"
android:textAllCaps="false"
android:textColor="?primaryText"
android:textStyle="bold"
app:fontFamily="@font/metropolis_semibold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/signOutDisconnect"
app:layout_constraintTop_toBottomOf="@id/sign_out_message" />
<com.google.android.material.button.MaterialButton
android:id="@+id/signOutDisconnect"
style="@style/SitePermissionPrimaryButton"
style="@style/PositiveButton"
android:layout_width="wrap_content"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/sign_out_disconnect"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
......
......@@ -343,17 +343,6 @@
<item name="fontFamily">@font/metropolis_semibold</item>
</style>
<style name="SitePermissionCancelButton" parent="SitePermissionButton">
<item name="android:textColor">?accent</item>
<item name="android:backgroundTint">?foundation</item>
</style>
<style name="SitePermissionPrimaryButton" parent="SitePermissionButton">
<item name="android:background">@drawable/dialog_button_background</item>
<item name="android:textColor">?contrastText</item>
<item name="android:backgroundTint">?accent</item>
</style>
<style name="DialogStyleBase" parent="NormalTheme">
<item name="android:textAppearance">@style/TextAppearance.AppCompat</item>
<item name="android:colorControlNormal">?accentHighContrast</item>
......@@ -536,11 +525,6 @@
<item name="fontFamily">@font/metropolis_semibold</item>
</style>
<style name="FirefoxAccountsDialogStyle" parent="DialogStyleBase">
<item name="android:windowBackground">@drawable/scrim_background</item>
<item name="android:colorControlHighlight">@android:color/transparent</item>
</style>
<style name="ShareDialogStyle" parent="DialogStyleBase"/>
<style name="AboutItemText" parent="TextAppearance.MaterialComponents.Body2">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment