Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding & Home Page Documentation #496

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.hackillinois.android.view

import android.content.Intent
import android.os.Bundle
import android.view.Window.FEATURE_NO_TITLE
import android.view.WindowManager
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
Expand Down Expand Up @@ -43,13 +42,15 @@ class OnboardingActivity : FragmentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestWindowFeature(FEATURE_NO_TITLE)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)

// gets rid of status bar at the top
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_onboarding)

view_pager.adapter = ScreenSlidePagerAdapter(this)
view_pager.offscreenPageLimit = 1

// connect toggled circle buttons to the view pager
TabLayoutMediator(tab_layout, view_pager) { tab, position ->
tab.select()
}.attach()
Expand All @@ -66,6 +67,7 @@ class OnboardingActivity : FragmentActivity() {
private inner class ScreenSlidePagerAdapter(fa: FragmentActivity) : FragmentStateAdapter(fa) {
override fun getItemCount(): Int = images.size

// create OnboardingPageFragment that shows each fragment in the carousel
override fun createFragment(position: Int): Fragment = OnboardingPageFragment.newInstance(
imageRes = images[position],
titleRes = titles[position],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat.getColor
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
Expand Down Expand Up @@ -38,8 +37,6 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL
private lateinit var currentEventsSection: EventsSection
private lateinit var upcomingEventsSection: EventsSection

// private lateinit var asyncEventsSection: EventsSection

private lateinit var daysValue: TextView
private lateinit var hoursValue: TextView
private lateinit var minutesValue: TextView
Expand All @@ -50,14 +47,10 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL

private var isActive = false

private val refreshIconSize = 100

private val numberOfUpcomingEvents = 2
private lateinit var layout: ConstraintLayout

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// create EventsSections for current and upcoming events
context?.let {
val currentHeaderColor = Color.WHITE
currentEventsSection = EventsSection(
Expand All @@ -66,7 +59,7 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL
currentHeaderColor,
false,
this,
it
it,
)
val upcomingHeaderColor = getColor(context!!, R.color.primaryTextColor)
upcomingEventsSection = EventsSection(
Expand All @@ -75,28 +68,17 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL
upcomingHeaderColor,
false,
this,
it
it,
)
// val asyncHeaderColor = Color.WHITE
// asyncEventsSection = EventsSection(
// mutableListOf(),
// "Async",
// asyncHeaderColor,
// false,
// this,
// it
// )
eventsListAdapter = SectionedRecyclerViewAdapter().apply {
addSection(currentEventsSection)
addSection(upcomingEventsSection)
// addSection(asyncEventsSection)
}
}

viewModel = ViewModelProvider(this).get(HomeViewModel::class.java)
viewModel.currentEventsLiveData.observe(this, Observer { updateCurrentEventsList(it) })
viewModel.upcomingEventsLiveData.observe(this, Observer { updateUpcomingEventsList(it) })
// viewModel.asyncEventsLiveData.observe(this, Observer { updateAsyncEventsList(it) })
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
Expand Down Expand Up @@ -125,7 +107,6 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL
when (position) {
0 -> "Current"
1 -> "Upcoming"
// 2 -> "Async"
else -> "Current"
}
}
Expand Down Expand Up @@ -190,13 +171,6 @@ class HomeFragment : Fragment(), CountdownManager.CountDownListener, EventClickL
return actualEvents
}

// private fun updateAsyncEventsList(events: List<Event>?) {
// events?.let {
// asyncEventsSection.updateEventsList(events)
// eventsListAdapter.notifyDataSetChanged()
// }
// }

override fun updateTime(timeUntil: Long) {
val timeInfo = TimeInfo(timeUntil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ class EventsSection(
private val headerColor: Int = Color.BLACK,
private val showTime: Boolean,
private val eventClickListener: EventClickListener,
private val context: Context
private val context: Context,
) :
Section(
SectionParameters.builder()
.itemResourceId(R.layout.event_tile)
.build()
.build(),
) {

override fun getContentItemsTotal() = eventsList.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class EventsSectionFragment : Fragment(), EventClickListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// get what type of events to display from arguments bundle
sectionNumber = arguments?.getInt(ARG_SECTION_NUM) ?: 0

val viewModel = parentFragment?.let { ViewModelProviders.of(it).get(HomeViewModel::class.java) }

val liveData = when (sectionNumber) {
0 -> viewModel?.currentEventsLiveData
1 -> viewModel?.upcomingEventsLiveData
// 2 -> viewModel?.asyncEventsLiveData
else -> viewModel?.currentEventsLiveData
}

Expand All @@ -61,14 +61,14 @@ class EventsSectionFragment : Fragment(), EventClickListener {
currentEvents = it
updateEvents(currentEvents)
}
}
},
)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View? {
val view = inflater.inflate(R.layout.fragment_schedule_day, container, false)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class OnboardingPageFragment : Fragment() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// set page's attributes from passed-in arguments bundle
val imageRes = requireArguments().getInt(IMAGE_RES_KEY)
val titleRes = requireArguments().getInt(TITLE_RES_KEY)
val descriptionRes = requireArguments().getInt(DESCRIPTION_RES_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class HomeViewModel : ViewModel() {
private val eventRepository = EventRepository.instance
var currentEventsLiveData: LiveData<List<Event>>
var upcomingEventsLiveData: LiveData<List<Event>>
// var asyncEventsLiveData: LiveData<List<Event>>

private val NEXT_TWO_HOURS_MS = 1000 * 60 * 120

Expand All @@ -23,7 +22,6 @@ class HomeViewModel : ViewModel() {
upcomingEventsLiveData = Transformations.switchMap(currentTime) { value ->
eventRepository.fetchEventsHappeningBetweenTimes(value, value + NEXT_TWO_HOURS_MS)
}
// asyncEventsLiveData = eventRepository.fetchAsyncEvents()
refresh()
}

Expand Down
Loading