This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
fix info and setting fragment profile menu item click #359
Open
kareemradwan
wants to merge
5
commits into
google:iosched_2020
Choose a base branch
from
kareemradwan:fix-profile-menu-item-click
base: iosched_2020
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6b377dd
fix info and setting fragment profile menu item click
kareemradwan fcacad1
fix code style issue
kareemradwan 497e9fd
applied google code style to project
kareemradwan 220bea8
add code-style file in gitIgnore
kareemradwan beccb0d
remove iosched-codestyle from gitIgnore and apply google style
kareemradwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,33 +29,45 @@ 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 | ||
@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, | ||
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 +93,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 +120,21 @@ 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 const val DIALOG_SCHEDULE_HINTS = "dialog_schedule_hints" | ||
|
||
|
||
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 | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,20 +31,29 @@ 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 const val DIALOG_SCHEDULE_HINTS = "dialog_schedule_hints" | ||
} | ||
|
||
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 +70,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 +100,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() | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please undo these whitespace changes