Skip to content

Commit

Permalink
Fix: Fixed the swipes to not use actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat committed Nov 29, 2024
1 parent 1d362a0 commit 98413aa
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal open class OnSwipeTouchListener(c: Context?) : OnTouchListener {
private inner class GestureListener : SimpleOnGestureListener() {
private val swipeThreshold: Int = 100
private val swipeVelocityThreshold: Int = 100
private val swipeScrollThreshold: Int = 100

override fun onDown(e: MotionEvent): Boolean {
return true
Expand Down Expand Up @@ -82,13 +83,13 @@ internal open class OnSwipeTouchListener(c: Context?) : OnTouchListener {

// Horizontal swipe
if (abs(diffX) > abs(diffY)) {
if (abs(diffX) > swipeThreshold && abs(distanceX) > swipeVelocityThreshold) {
if (abs(diffX) > swipeThreshold && abs(distanceX) > swipeScrollThreshold) {
if (diffX > 0) onSwipeRight() else onSwipeLeft()
}
}
// Vertical swipe
else {
if (abs(diffY) > swipeThreshold && abs(distanceY) > swipeVelocityThreshold) {
if (abs(diffY) > swipeThreshold && abs(distanceY) > swipeScrollThreshold) {
if (diffY > 0) onSwipeDown() else onSwipeUp()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class DrawFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_DrawFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand All @@ -220,7 +220,7 @@ class DrawFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_DrawFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand All @@ -244,7 +244,7 @@ class DrawFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_DrawFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand All @@ -259,7 +259,7 @@ class DrawFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_DrawFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class HomeFragment : Fragment(),
else appHelper.getActionType(actionType)
Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_HomeFragment_to_DrawFragment,
R.id.DrawFragment,
null,
actionTypeNavOptions
)
Expand All @@ -437,7 +437,7 @@ class HomeFragment : Fragment(),
else appHelper.getActionType(actionType)
Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_HomeFragment_to_FavoriteFragment,
R.id.FavoriteFragment,
null,
actionTypeNavOptions
)
Expand All @@ -450,7 +450,7 @@ class HomeFragment : Fragment(),
else appHelper.getActionType(actionType)
Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_HomeFragment_to_HiddenFragment,
R.id.HiddenFragment,
null,
actionTypeNavOptions
)
Expand All @@ -476,7 +476,7 @@ class HomeFragment : Fragment(),
else appHelper.getActionType(actionType)
Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_HomeFragment_to_WidgetsFragment,
R.id.WidgetsFragment,
null,
actionTypeNavOptions
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ class SettingsFragment : Fragment(),
private fun observeClickListener() {
binding.apply {
featuresSettings.setOnClickListener {
navController.navigate(R.id.action_SettingsFragment_to_SettingsFeaturesFragment)
navController.navigate(R.id.SettingsFeaturesFragment)
}

lookFeelSettings.setOnClickListener {
navController.navigate(R.id.action_SettingsFragment_to_SettingsLookFeelFragment)
navController.navigate(R.id.SettingsLookFeelFragment)
}

favoriteApps.setOnClickListener {
navController.navigate(R.id.action_SettingsFragment_to_FavoriteFragment)
navController.navigate(R.id.FavoriteFragment)
}

hiddenApps.setOnClickListener {
navController.navigate(R.id.action_SettingsFragment_to_HiddenFragment)
navController.navigate(R.id.HiddenFragment)
}

advancedSettings.setOnClickListener {
navController.navigate(R.id.action_SettingsFragment_to_SettingsAdvancedFragment)
navController.navigate(R.id.SettingsAdvancedFragment)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class WidgetFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_WidgetsFragment_to_WidgetsSettingsFragment,
R.id.WidgetsSettingsFragment,
null,
actionTypeNavOptions
)
Expand All @@ -410,7 +410,7 @@ class WidgetFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_WidgetsFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand All @@ -425,7 +425,7 @@ class WidgetFragment : Fragment(),

Handler(Looper.getMainLooper()).post {
findNavController().navigate(
R.id.action_WidgetsFragment_to_HomeFragment,
R.id.HomeFragment,
null,
actionTypeNavOptions
)
Expand Down
62 changes: 4 additions & 58 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,19 @@
android:id="@+id/HomeFragment"
android:name="com.github.droidworksstudio.launcher.ui.home.HomeFragment"
android:label="@string/home_fragment_label"
tools:layout="@layout/fragment_home">

<action
android:id="@+id/action_HomeFragment_to_DrawFragment"
app:destination="@id/DrawFragment" />
<action
android:id="@+id/action_HomeFragment_to_SettingsFragment"
app:destination="@id/SettingsFragment" />
<action
android:id="@+id/action_HomeFragment_to_FavoriteFragment"
app:destination="@id/FavoriteFragment" />
<action
android:id="@+id/action_HomeFragment_to_HiddenFragment"
app:destination="@id/HiddenFragment" />
<action
android:id="@+id/action_HomeFragment_to_WidgetsFragment"
app:destination="@id/WidgetsFragment" />
</fragment>
tools:layout="@layout/fragment_home" />

<fragment
android:id="@+id/SettingsFragment"
android:name="com.github.droidworksstudio.launcher.ui.settings.SettingsFragment"
android:label="@string/settings_fragment_label"
tools:layout="@layout/fragment_settings">
<action
android:id="@+id/action_SettingsFragment_to_FavoriteFragment"
app:destination="@id/FavoriteFragment" />
<action
android:id="@+id/action_SettingsFragment_to_HiddenFragment"
app:destination="@id/HiddenFragment" />
<action
android:id="@+id/action_SettingsFragment_to_SettingsAdvancedFragment"
app:destination="@id/SettingsAdvancedFragment" />
<action
android:id="@+id/action_SettingsFragment_to_SettingsFeaturesFragment"
app:destination="@id/SettingsFeaturesFragment" />
<action
android:id="@+id/action_SettingsFragment_to_SettingsLookFeelFragment"
app:destination="@id/SettingsLookFeelFragment" />
<action
android:id="@+id/action_SettingsFragment_to_WidgetsFragment"
app:destination="@id/WidgetsFragment" />
<action
android:id="@+id/action_SettingsFragment_to_WidgetsSettingsFragment"
app:destination="@id/WidgetsSettingsFragment" />
</fragment>
tools:layout="@layout/fragment_settings" />

<fragment
android:id="@+id/WidgetsFragment"
android:name="com.github.droidworksstudio.launcher.ui.widgets.WidgetFragment"
android:label="@string/widgets_fragment_label"
tools:layout="@layout/fragment_widgets">

<action
android:id="@+id/action_WidgetsFragment_to_WidgetsSettingsFragment"
app:destination="@id/WidgetsSettingsFragment" />

<action
android:id="@+id/action_WidgetsFragment_to_HomeFragment"
app:destination="@id/HomeFragment" />
</fragment>
tools:layout="@layout/fragment_widgets" />

<fragment
android:id="@+id/SettingsFeaturesFragment"
Expand All @@ -86,13 +38,7 @@
android:id="@+id/DrawFragment"
android:name="com.github.droidworksstudio.launcher.ui.drawer.DrawFragment"
android:label="@string/draw_fragment_label"
tools:layout="@layout/fragment_draw">

<action
android:id="@+id/action_DrawFragment_to_HomeFragment"
app:destination="@id/HomeFragment" />
</fragment>

tools:layout="@layout/fragment_draw" />

<fragment
android:id="@+id/FavoriteFragment"
Expand Down

0 comments on commit 98413aa

Please sign in to comment.