-
Couldn't load subscription status.
- Fork 6.2k
fix info and setting fragment profile menu item click #359
base: iosched_2020
Are you sure you want to change the base?
Changes from all commits
6b377dd
fcacad1
497e9fd
220bea8
beccb0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,3 +39,4 @@ _sandbox | |
|
|
||
| # Android Studio captures folder | ||
| captures/ | ||
| tools/iosched-codestyle.xml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,33 +29,44 @@ import com.google.android.material.tabs.TabLayoutMediator | |
| import com.google.samples.apps.iosched.R | ||
| import com.google.samples.apps.iosched.databinding.FragmentInfoBinding | ||
| import com.google.samples.apps.iosched.shared.analytics.AnalyticsHelper | ||
| import com.google.samples.apps.iosched.shared.result.EventObserver | ||
| import com.google.samples.apps.iosched.ui.MainActivityViewModel | ||
| import com.google.samples.apps.iosched.ui.MainNavigationFragment | ||
| import com.google.samples.apps.iosched.ui.schedule.ScheduleFragment | ||
| import com.google.samples.apps.iosched.ui.signin.SignInDialogFragment | ||
| import com.google.samples.apps.iosched.ui.signin.SignOutDialogFragment | ||
| import com.google.samples.apps.iosched.ui.signin.setupProfileMenuItem | ||
| import com.google.samples.apps.iosched.util.doOnApplyWindowInsets | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
| import javax.inject.Inject | ||
|
|
||
| @AndroidEntryPoint | ||
| class InfoFragment : MainNavigationFragment() { | ||
|
|
||
| @Inject lateinit var analyticsHelper: AnalyticsHelper | ||
|
|
||
| private lateinit var binding: FragmentInfoBinding | ||
|
|
||
| private val viewModel: MainActivityViewModel by viewModels() | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| inflater: LayoutInflater, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo these whitespace changes |
||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = FragmentInfoBinding.inflate(inflater, container, false).apply { | ||
| lifecycleOwner = viewLifecycleOwner | ||
| } | ||
| binding.viewpager.doOnApplyWindowInsets { v, insets, padding -> | ||
| v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom) | ||
| } | ||
|
|
||
| viewModel.navigateToSignInDialogAction.observe(viewLifecycleOwner, EventObserver { | ||
| openSignInDialog() | ||
| }) | ||
|
|
||
| viewModel.navigateToSignOutDialogAction.observe(viewLifecycleOwner, EventObserver { | ||
| openSignOutDialog() | ||
| }) | ||
| return binding.root | ||
| } | ||
|
|
||
|
|
@@ -81,6 +92,17 @@ class InfoFragment : MainNavigationFragment() { | |
| } | ||
| } | ||
|
|
||
|
|
||
| private fun openSignInDialog() { | ||
| val dialog = SignInDialogFragment() | ||
| dialog.show(requireActivity().supportFragmentManager, InfoFragment.DIALOG_NEED_TO_SIGN_IN) | ||
| } | ||
|
|
||
| private fun openSignOutDialog() { | ||
| val dialog = SignOutDialogFragment() | ||
| dialog.show(requireActivity().supportFragmentManager, InfoFragment.DIALOG_CONFIRM_SIGN_OUT) | ||
| } | ||
|
|
||
| private fun trackInfoScreenView(position: Int) { | ||
| val pageName = getString(INFO_TITLES[position]) | ||
| analyticsHelper.sendScreenView("Info - $pageName", requireActivity()) | ||
|
|
@@ -97,16 +119,20 @@ class InfoFragment : MainNavigationFragment() { | |
|
|
||
| companion object { | ||
|
|
||
| private const val DIALOG_NEED_TO_SIGN_IN = "dialog_need_to_sign_in" | ||
| private const val DIALOG_CONFIRM_SIGN_OUT = "dialog_confirm_sign_out" | ||
|
|
||
|
|
||
| private val INFO_TITLES = arrayOf( | ||
| R.string.event_title, | ||
| R.string.travel_title, | ||
| R.string.faq_title | ||
| R.string.event_title, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo these whitespace changes |
||
| R.string.travel_title, | ||
| R.string.faq_title | ||
| ) | ||
| private val INFO_PAGES = arrayOf( | ||
| { EventFragment() }, | ||
| { TravelFragment() }, | ||
| { FaqFragment() } | ||
| // TODO: Track the InfoPage performance b/130335745 | ||
| { EventFragment() }, | ||
| { TravelFragment() }, | ||
| { FaqFragment() } | ||
| // TODO: Track the InfoPage performance b/130335745 | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,20 +31,28 @@ import com.google.samples.apps.iosched.databinding.FragmentSettingsBinding | |
| import com.google.samples.apps.iosched.shared.result.EventObserver | ||
| import com.google.samples.apps.iosched.ui.MainActivityViewModel | ||
| import com.google.samples.apps.iosched.ui.MainNavigationFragment | ||
| import com.google.samples.apps.iosched.ui.info.InfoFragment | ||
| import com.google.samples.apps.iosched.ui.signin.SignInDialogFragment | ||
| import com.google.samples.apps.iosched.ui.signin.SignOutDialogFragment | ||
| import com.google.samples.apps.iosched.ui.signin.setupProfileMenuItem | ||
| import com.google.samples.apps.iosched.util.doOnApplyWindowInsets | ||
| import dagger.hilt.android.AndroidEntryPoint | ||
|
|
||
| @AndroidEntryPoint | ||
| class SettingsFragment : MainNavigationFragment() { | ||
|
|
||
| companion object { | ||
| private const val DIALOG_NEED_TO_SIGN_IN = "dialog_need_to_sign_in" | ||
| private const val DIALOG_CONFIRM_SIGN_OUT = "dialog_confirm_sign_out" | ||
| } | ||
|
|
||
| private val viewModel: SettingsViewModel by viewModels() | ||
| private val mainActivityViewModel: MainActivityViewModel by viewModels() | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, | ||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| inflater: LayoutInflater, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo these whitespace changes |
||
| container: ViewGroup?, | ||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
|
|
||
| viewModel.navigateToThemeSelector.observe(viewLifecycleOwner, EventObserver { | ||
|
|
@@ -61,9 +69,26 @@ class SettingsFragment : MainNavigationFragment() { | |
| binding.settingsScroll.doOnApplyWindowInsets { v, insets, padding -> | ||
| v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom) | ||
| } | ||
| mainActivityViewModel.navigateToSignInDialogAction.observe(viewLifecycleOwner, EventObserver { | ||
| openSignInDialog() | ||
| }) | ||
|
|
||
| mainActivityViewModel.navigateToSignOutDialogAction.observe(viewLifecycleOwner, EventObserver { | ||
| openSignOutDialog() | ||
| }) | ||
|
|
||
| return binding.root | ||
| } | ||
|
|
||
| private fun openSignInDialog() { | ||
| val dialog = SignInDialogFragment() | ||
| dialog.show(requireActivity().supportFragmentManager, SettingsFragment.DIALOG_NEED_TO_SIGN_IN) | ||
| } | ||
|
|
||
| private fun openSignOutDialog() { | ||
| val dialog = SignOutDialogFragment() | ||
| dialog.show(requireActivity().supportFragmentManager, SettingsFragment.DIALOG_CONFIRM_SIGN_OUT) | ||
| } | ||
| } | ||
|
|
||
| @BindingAdapter(value = ["dialogTitle", "fileLink"], requireAll = true) | ||
|
|
@@ -74,10 +99,10 @@ fun createDialogForFile(button: View, dialogTitle: String, fileLink: String) { | |
| webView.settings.useWideViewPort = true | ||
| webView.settings.loadWithOverviewMode = true | ||
| AlertDialog.Builder(context) | ||
| .setTitle(dialogTitle) | ||
| .setView(webView) | ||
| .create() | ||
| .show() | ||
| .setTitle(dialogTitle) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please undo these whitespace changes |
||
| .setView(webView) | ||
| .create() | ||
| .show() | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is not supposed to be ignored. We check it in so that others (like yourself) can use the same code style when contributing to the project. Please revert this change and revert the changes to that file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line still needs to be removed.