Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaba
fenix
Commits
ef38c364
Commit
ef38c364
authored
Dec 02, 2020
by
ekager
Browse files
For #16397 - Fixes SignOutFragment crash and invisible button
parent
52836aa7
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/org/mozilla/fenix/settings/account/SignOutFragment.kt
View file @
ef38c364
...
...
@@ -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.BottomShee
tDialogFragment
import
androidx.appcompat.app.AppCompa
tDialogFragment
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
:
BottomShee
tDialogFragment
()
{
class
SignOutFragment
:
AppCompa
tDialogFragment
()
{
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
()
}
}
}
}
...
...
app/src/main/res/layout/fragment_sign_out.xml
View file @
ef38c364
<?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.Material
Button
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"
...
...
app/src/main/res/values/styles.xml
View file @
ef38c364
...
...
@@ -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"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment