@@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat
2020import androidx.fragment.app.Fragment
2121import androidx.fragment.app.viewModels
2222import androidx.lifecycle.lifecycleScope
23+ import androidx.navigation.NavOptions
2324import androidx.navigation.fragment.findNavController
2425import androidx.recyclerview.widget.StaggeredGridLayoutManager
2526import com.github.droidworksstudio.common.hideKeyboard
@@ -297,37 +298,37 @@ class HomeFragment : Fragment(),
297298 @RequiresApi(Build .VERSION_CODES .P )
298299 override fun onDoubleClick () {
299300 super .onDoubleClick()
300- handleOtherAction(preferenceHelper.doubleTapAction)
301+ handleOtherAction(preferenceHelper.doubleTapAction, Constants . Swipe . DoubleTap )
301302 }
302303
303304 @RequiresApi(Build .VERSION_CODES .P )
304305 override fun onSwipeUp () {
305306 super .onSwipeUp()
306- handleOtherAction(preferenceHelper.swipeUpAction)
307+ handleOtherAction(preferenceHelper.swipeUpAction, Constants . Swipe . Up )
307308 }
308309
309310 @RequiresApi(Build .VERSION_CODES .P )
310311 override fun onSwipeDown () {
311312 super .onSwipeDown()
312- handleOtherAction(preferenceHelper.swipeDownAction)
313+ handleOtherAction(preferenceHelper.swipeDownAction, Constants . Swipe . Down )
313314 }
314315
315316 @RequiresApi(Build .VERSION_CODES .P )
316317 override fun onSwipeLeft () {
317318 super .onSwipeLeft()
318- handleOtherAction(preferenceHelper.swipeLeftAction)
319+ handleOtherAction(preferenceHelper.swipeLeftAction, Constants . Swipe . Left )
319320 }
320321
321322 @RequiresApi(Build .VERSION_CODES .P )
322323 override fun onSwipeRight () {
323324 super .onSwipeRight()
324- handleOtherAction(preferenceHelper.swipeRightAction)
325+ handleOtherAction(preferenceHelper.swipeRightAction, Constants . Swipe . Right )
325326 }
326327 }
327328 }
328329
329330 @RequiresApi(Build .VERSION_CODES .P )
330- private fun handleOtherAction (action : Constants .Action ) {
331+ private fun handleOtherAction (action : Constants .Action , actionType : Constants . Swipe ) {
331332 when (action) {
332333// Constants.Action.OpenApp -> {}
333334
@@ -341,14 +342,25 @@ class HomeFragment : Fragment(),
341342 }
342343
343344 Constants .Action .ShowAppList -> {
345+ val actionTypeNavOptions: NavOptions = getActionType(actionType)
344346 Handler (Looper .getMainLooper()).post {
345- findNavController().navigate(R .id.action_HomeFragment_to_DrawFragment)
347+ findNavController().navigate(
348+ R .id.action_HomeFragment_to_DrawFragment,
349+ null ,
350+ actionTypeNavOptions
351+ )
346352 }
347353 }
348354
355+
349356 Constants .Action .ShowFavoriteList -> {
357+ val actionTypeNavOptions: NavOptions = getActionType(actionType)
350358 Handler (Looper .getMainLooper()).post {
351- findNavController().navigate(R .id.action_HomeFragment_to_FavoriteFragment)
359+ findNavController().navigate(
360+ R .id.action_HomeFragment_to_FavoriteFragment,
361+ null ,
362+ actionTypeNavOptions
363+ )
352364 }
353365 }
354366
@@ -361,6 +373,17 @@ class HomeFragment : Fragment(),
361373 ActionService .instance()?.showRecents()
362374 }
363375
376+ Constants .Action .ShowWidgets -> {
377+ val actionTypeNavOptions: NavOptions = getActionType(actionType)
378+ Handler (Looper .getMainLooper()).post {
379+ findNavController().navigate(
380+ R .id.action_HomeFragment_to_WidgetsFragment,
381+ null ,
382+ actionTypeNavOptions
383+ )
384+ }
385+ }
386+
364387 Constants .Action .OpenPowerDialog -> {
365388 ActionService .runAccessibilityMode(context)
366389 ActionService .instance()?.openPowerDialog()
@@ -375,6 +398,55 @@ class HomeFragment : Fragment(),
375398 }
376399 }
377400
401+ private fun getActionType (actionType : Constants .Swipe ): NavOptions {
402+ return when (actionType) {
403+ Constants .Swipe .DoubleTap -> {
404+ NavOptions .Builder ()
405+ .setEnterAnim(R .anim.zoom_in)
406+ .setExitAnim(R .anim.zoom_out)
407+ .setPopEnterAnim(R .anim.zoom_in)
408+ .setPopExitAnim(R .anim.zoom_out)
409+ .build()
410+ }
411+
412+ Constants .Swipe .Up -> {
413+ NavOptions .Builder ()
414+ .setEnterAnim(R .anim.slide_in_top)
415+ .setExitAnim(R .anim.slide_out_top)
416+ .setPopEnterAnim(R .anim.slide_in_bottom)
417+ .setPopExitAnim(R .anim.slide_out_bottom)
418+ .build()
419+ }
420+
421+ Constants .Swipe .Down -> {
422+ NavOptions .Builder ()
423+ .setEnterAnim(R .anim.slide_in_bottom)
424+ .setExitAnim(R .anim.slide_out_bottom)
425+ .setPopEnterAnim(R .anim.slide_in_top)
426+ .setPopExitAnim(R .anim.slide_out_top)
427+ .build()
428+ }
429+
430+ Constants .Swipe .Left -> {
431+ NavOptions .Builder ()
432+ .setEnterAnim(R .anim.slide_in_right)
433+ .setExitAnim(R .anim.slide_out_right)
434+ .setPopEnterAnim(R .anim.slide_in_left)
435+ .setPopExitAnim(R .anim.slide_out_left)
436+ .build()
437+ }
438+
439+ Constants .Swipe .Right -> {
440+ NavOptions .Builder ()
441+ .setEnterAnim(R .anim.slide_in_left)
442+ .setExitAnim(R .anim.slide_out_left)
443+ .setPopEnterAnim(R .anim.slide_in_right)
444+ .setPopExitAnim(R .anim.slide_out_right)
445+ .build()
446+ }
447+ }
448+ }
449+
378450 private fun trySettings () {
379451 lifecycleScope.launch(Dispatchers .Main ) {
380452 biometricPrompt = BiometricPrompt (this @HomeFragment,
0 commit comments