For #21493 show onboarding dialog for home sections
parent
f338d64a4c
commit
f15291757b
@ -0,0 +1,43 @@
|
||||
/* 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/. */
|
||||
|
||||
package org.mozilla.fenix.onboarding
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.databinding.FragmentOnboardingHomeDialogBinding
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
/**
|
||||
* Dialog displayed once when one or multiples of these sections are shown in the home screen
|
||||
* recentTabs,recentBookmarks,historyMetadata or pocketArticles.
|
||||
*/
|
||||
class HomeOnboardingDialogFragment : DialogFragment() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setStyle(STYLE_NO_TITLE, R.style.HomeOnboardingDialogStyle)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? = inflater.inflate(R.layout.fragment_onboarding_home_dialog, container, false)
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val binding = FragmentOnboardingHomeDialogBinding.bind(view)
|
||||
|
||||
binding.finishButton.setOnClickListener {
|
||||
context?.settings()?.let { settings ->
|
||||
settings.hasShownHomeOnboardingDialog = true
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,222 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never"
|
||||
android:fitsSystemWindows="true"
|
||||
android:fillViewport="true"
|
||||
android:background="@drawable/scrim_background"
|
||||
android:scrollbars="none">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/dialog_background"
|
||||
android:layout_marginTop="16dp" >
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/firefox_logo"
|
||||
android:layout_width="59dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="30dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_firefox" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/welcome_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginHorizontal="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:lineHeight="24sp"
|
||||
android:text="@string/onboarding_home_screen_title"
|
||||
android:textAppearance="@style/Header20TextStyle"
|
||||
android:textAlignment="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/firefox_logo" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
android:layout_marginHorizontal="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:lineHeight="24sp"
|
||||
android:textAppearance="@style/Body14TextStyle"
|
||||
android:text="@string/onboarding_home_screen_description"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/welcome_title" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/home_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/home_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/description"
|
||||
app:srcCompat="@drawable/mozac_ic_home"
|
||||
app:tint="?primaryText" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/home_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:layout_marginTop="26dp"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_home_title"
|
||||
android:textAppearance="@style/Header14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/home_icon"
|
||||
app:layout_constraintTop_toBottomOf="@id/description" />
|
||||
|
||||
<View
|
||||
android:id="@+id/home_placeholder"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/home_description"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/home_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_home_description"
|
||||
android:textAppearance="@style/Body14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/home_placeholder"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cleaner_tab_tray_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/cleaner_tab_tray_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/home_description"
|
||||
app:srcCompat="@drawable/ic_multiple_tabs"
|
||||
app:tint="?primaryText" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/cleaner_tab_tray_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:layout_marginTop="26dp"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_cleaner_tab_tray_title"
|
||||
android:textAppearance="@style/Header14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cleaner_tab_tray_icon"
|
||||
app:layout_constraintTop_toBottomOf="@id/home_description" />
|
||||
|
||||
<View
|
||||
android:id="@+id/cleaner_tab_tray_placeholder"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/cleaner_tab_tray_description"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cleaner_tab_tray_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/cleaner_tab_tray_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_cleaner_tab_tray_description"
|
||||
android:textAppearance="@style/Body14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cleaner_tab_tray_placeholder"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cleaner_tab_tray_title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/useful_history_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/useful_history_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cleaner_tab_tray_description"
|
||||
app:srcCompat="@drawable/ic_history"
|
||||
app:tint="?primaryText" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/useful_history_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:layout_marginTop="26dp"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_useful_history_title"
|
||||
android:textAppearance="@style/Header14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/useful_history_icon"
|
||||
app:layout_constraintTop_toBottomOf="@id/cleaner_tab_tray_description" />
|
||||
|
||||
<View
|
||||
android:id="@+id/useful_history_placeholder"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:layout_constraintEnd_toStartOf="@id/useful_history_description"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/useful_history_icon" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/useful_history_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="@dimen/oboarding_home_dialog_margin_horizontal"
|
||||
android:lineHeight="20sp"
|
||||
android:text="@string/onboarding_home_screen_section_useful_history_description"
|
||||
android:textAppearance="@style/Body14TextStyle"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/useful_history_placeholder"
|
||||
app:layout_constraintTop_toBottomOf="@+id/useful_history_title" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/finish_button"
|
||||
style="@style/PositiveButton"
|
||||
android:layout_marginHorizontal="64dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:background="@drawable/onboarding_padded_background"
|
||||
android:backgroundTint="?accent"
|
||||
android:text="@string/onboarding_finish"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/useful_history_description" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
Loading…
Reference in New Issue