@@ -35,10 +35,9 @@ import com.github.code.gambit.utility.extention.show
35
35
import com.github.code.gambit.utility.extention.showDefaultMaterialAlert
36
36
import com.github.code.gambit.utility.extention.snackbar
37
37
import com.github.code.gambit.utility.sharedpreference.LastEvaluatedKeyManager
38
+ import com.github.code.gambit.utility.sharedpreference.UserManager
38
39
import com.google.android.material.bottomsheet.BottomSheetBehavior
39
40
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
40
- import com.takusemba.spotlight.OnSpotlightListener
41
- import com.takusemba.spotlight.OnTargetListener
42
41
import com.takusemba.spotlight.Spotlight
43
42
import com.takusemba.spotlight.Target
44
43
import com.takusemba.spotlight.shape.Circle
@@ -74,6 +73,9 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
74
73
@Inject
75
74
lateinit var lekManager: LastEvaluatedKeyManager
76
75
76
+ @Inject
77
+ lateinit var userManager: UserManager
78
+
77
79
private lateinit var fileSearchComponent: FileSearchComponent
78
80
private lateinit var filterComponent: FilterComponent
79
81
@@ -125,7 +127,6 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
125
127
setUpFileRecyclerView()
126
128
registerEventCallbacks()
127
129
viewModel.setEvent(HomeEvent .GetFiles )
128
- // Handler().postDelayed({ spotlight() }, 6000)
129
130
}
130
131
131
132
private fun registerEventCallbacks () {
@@ -206,7 +207,7 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
206
207
}
207
208
208
209
private fun setUpFileRecyclerView () {
209
- adapter.bindEmptyListView (binding.noFileIllustrationContainer)
210
+ adapter.bindEmptyView (binding.noFileIllustrationContainer)
210
211
val layoutManager = LinearLayoutManager (requireContext())
211
212
binding.fileList.layoutManager = layoutManager
212
213
binding.fileList.setHasFixedSize(false )
@@ -303,6 +304,7 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
303
304
binding.topContainer.show()
304
305
binding.swipeRefresh.show()
305
306
binding.fileList.show()
307
+ spotlight()
306
308
}
307
309
308
310
private fun showShimmer () {
@@ -313,70 +315,64 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
313
315
}
314
316
315
317
private fun spotlight () {
318
+ if (userManager.isHomeOnBoarded()) {
319
+ return
320
+ }
316
321
val targets = ArrayList <Target >()
317
322
318
323
val firstRoot = FrameLayout (requireContext())
319
- val first = layoutInflater.inflate(R .layout.home_first_spot, firstRoot)
320
- val firstTarget = Target .Builder ()
321
- .setAnchor(requireMainActivity().getAddFab())
322
- .setShape(Circle (120f ))
323
- .setOverlay(first)
324
- .setOnTargetListener(object : OnTargetListener {
325
- override fun onEnded () {}
326
- override fun onStarted () {}
327
- })
328
- .build()
324
+ val first = layoutInflater.inflate(R .layout.home_add_file_spot, firstRoot)
325
+ val firstTarget = getTarget(requireMainActivity().getAddFab(), first, 250 )
329
326
330
327
val secondRoot = FrameLayout (requireContext())
331
- val second = layoutInflater.inflate(R .layout.home_second_spot, secondRoot)
332
- val secondTarget = Target .Builder ()
333
- .setAnchor(binding.searchButton)
334
- .setShape(Circle (50f ))
335
- .setOverlay(second)
336
- .setOnTargetListener(object : OnTargetListener {
337
- override fun onEnded () {}
338
- override fun onStarted () {}
339
- }).build()
340
-
341
- val thirdTarget = Target .Builder ()
342
- .setAnchor(binding.filterButton)
343
- .setShape(Circle (50f ))
344
- .setOverlay(second)
345
- .setOnTargetListener(object : OnTargetListener {
346
- override fun onEnded () {}
347
- override fun onStarted () {}
348
- }).build()
328
+ val second = layoutInflater.inflate(R .layout.home_drag_spot, secondRoot)
329
+ val secondTarget = getTarget(requireMainActivity().getDragView(), second, 100 )
330
+
331
+ val thirdRoot = FrameLayout (requireContext())
332
+ val third = layoutInflater.inflate(R .layout.home_search_filter_spot, thirdRoot)
333
+ val thirdTarget = getTarget(binding.searchButton, third)
334
+
335
+ val fourthTarget = getTarget(binding.filterButton, third)
349
336
350
337
targets.add(firstTarget)
351
338
targets.add(secondTarget)
352
339
targets.add(thirdTarget)
340
+ targets.add(fourthTarget)
353
341
354
342
val spotlight = Spotlight .Builder (requireActivity())
355
343
.setTargets(targets)
356
344
.setBackgroundColorRes(R .color.spotlightBackground)
357
345
.setDuration(1000L )
358
346
.setAnimation(DecelerateInterpolator (2f ))
359
- .setOnSpotlightListener(object : OnSpotlightListener {
360
- override fun onStarted () {}
361
- override fun onEnded () {}
362
- }).build()
347
+ .build()
363
348
364
349
spotlight.start()
365
350
366
351
val nextTarget = View .OnClickListener { spotlight.next() }
367
352
368
- // val closeSpotlight = View.OnClickListener { spotlight.finish() }
353
+ val closeSpotlight = View .OnClickListener {
354
+ userManager.updateHomeOnBoardingState()
355
+ spotlight.finish()
356
+ }
369
357
370
358
first.findViewById<View >(R .id.next_button).setOnClickListener(nextTarget)
371
- second.findViewById<View >(R .id.next_button).setOnClickListener {
359
+ second.findViewById<View >(R .id.next_button).setOnClickListener(nextTarget)
360
+ third.findViewById<View >(R .id.next_button).setOnClickListener {
372
361
spotlight.next()
373
- second .findViewById<TextView >(R .id.title_text).text = getString(R .string.use_filters)
374
- second .findViewById<TextView >(R .id.info_text).text =
362
+ third .findViewById<TextView >(R .id.title_text).text = getString(R .string.use_filters)
363
+ third .findViewById<TextView >(R .id.info_text).text =
375
364
getString(R .string.or_you_can_filter_files_based_on_dates_they_were_uploaded)
376
- second.findViewById<View >(R .id.arrow).animate().rotation(105f ).setDuration(500 ).start()
365
+ third.findViewById<View >(R .id.arrow).animate().rotation(105f ).setDuration(500 ).start()
366
+ third.findViewById<View >(R .id.next_button).setOnClickListener(closeSpotlight)
377
367
}
378
368
}
379
369
370
+ private fun getTarget (anchorView : View , overlay : View , radius : Int = 50): Target {
371
+ return Target .Builder ().setAnchor(anchorView).setShape(Circle (radius.toFloat()))
372
+ .setOverlay(overlay)
373
+ .build()
374
+ }
375
+
380
376
private fun showFilter () {
381
377
animateBottomNav(0f )
382
378
binding.overlay.show()
@@ -399,6 +395,7 @@ class HomeFragment : Fragment(R.layout.fragment_home), FileUrlClickCallback, Bot
399
395
400
396
fun closeSearch () {
401
397
hideKeyboard()
398
+ adapter.bindEmptyView(binding.noFileIllustrationContainer)
402
399
adapter.restore()
403
400
searchBinding.root.hide()
404
401
showBottomNav()
0 commit comments