Feature: Added a toggle to disable animations.
This commit is contained in:
@@ -179,6 +179,10 @@ class PreferenceHelper @Inject constructor(@ApplicationContext context: Context)
|
||||
get() = prefs.getBoolean(Constants.TOGGLE_SETTING_LOCK, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.TOGGLE_SETTING_LOCK, value).apply()
|
||||
|
||||
var disableAnimations: Boolean
|
||||
get() = prefs.getBoolean(Constants.DISABLE_ANIMATIONS, false)
|
||||
set(value) = prefs.edit().putBoolean(Constants.DISABLE_ANIMATIONS, value).apply()
|
||||
|
||||
var searchEngines: Constants.SearchEngines
|
||||
get() {
|
||||
return try {
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -14,6 +16,7 @@ import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
@@ -191,16 +194,38 @@ class DrawFragment : Fragment(),
|
||||
RecyclerView.SCROLL_STATE_DRAGGING -> {
|
||||
onTop = !recyclerView.canScrollVertically(-1)
|
||||
if (onTop) binding.searchViewText.hideKeyboard()
|
||||
if (onTop && !recyclerView.canScrollVertically(1))
|
||||
findNavController().popBackStack()
|
||||
if (onTop && !recyclerView.canScrollVertically(1)) {
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Up)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_DrawFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RecyclerView.SCROLL_STATE_IDLE -> {
|
||||
if (!recyclerView.canScrollVertically(1)) {
|
||||
binding.searchViewText.hideKeyboard()
|
||||
} else if (!recyclerView.canScrollVertically(-1)) {
|
||||
if (onTop) findNavController().popBackStack()
|
||||
else binding.searchViewText.showKeyboard()
|
||||
if (onTop) {
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Up)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_DrawFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
} else binding.searchViewText.showKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,12 +238,32 @@ class DrawFragment : Fragment(),
|
||||
return object : OnSwipeTouchListener(context) {
|
||||
override fun onSwipeLeft() {
|
||||
super.onSwipeLeft()
|
||||
findNavController().navigateUp()
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Left)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_DrawFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSwipeRight() {
|
||||
super.onSwipeRight()
|
||||
findNavController().navigateUp()
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Right)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_DrawFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +418,9 @@ class HomeFragment : Fragment(),
|
||||
}
|
||||
|
||||
Constants.Action.ShowAppList -> {
|
||||
val actionTypeNavOptions: NavOptions = appHelper.getActionType(actionType)
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(actionType)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_HomeFragment_to_DrawFragment,
|
||||
@@ -430,7 +432,9 @@ class HomeFragment : Fragment(),
|
||||
|
||||
|
||||
Constants.Action.ShowFavoriteList -> {
|
||||
val actionTypeNavOptions: NavOptions = appHelper.getActionType(actionType)
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(actionType)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_HomeFragment_to_FavoriteFragment,
|
||||
@@ -441,7 +445,9 @@ class HomeFragment : Fragment(),
|
||||
}
|
||||
|
||||
Constants.Action.ShowHiddenList -> {
|
||||
val actionTypeNavOptions: NavOptions = appHelper.getActionType(actionType)
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(actionType)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_HomeFragment_to_HiddenFragment,
|
||||
@@ -465,7 +471,9 @@ class HomeFragment : Fragment(),
|
||||
}
|
||||
|
||||
Constants.Action.ShowWidgets -> {
|
||||
val actionTypeNavOptions: NavOptions = appHelper.getActionType(actionType)
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(actionType)
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_HomeFragment_to_WidgetsFragment,
|
||||
|
||||
@@ -127,6 +127,7 @@ class SettingsFeaturesFragment : Fragment(),
|
||||
automaticOpenAppSwitchCompat.isChecked = preferenceHelper.automaticOpenApp
|
||||
searchFromStartSwitchCompat.isChecked = preferenceHelper.searchFromStart
|
||||
lockSettingsSwitchCompat.isChecked = preferenceHelper.settingsLock
|
||||
disableAnimationsSwitchCompat.isChecked = preferenceHelper.disableAnimations
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,6 +362,12 @@ class SettingsFeaturesFragment : Fragment(),
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
|
||||
disableAnimationsSwitchCompat.setOnCheckedChangeListener { _, isChecked ->
|
||||
preferenceViewModel.setDisableAnimations(isChecked)
|
||||
val feedbackType = if (isChecked) "on" else "off"
|
||||
appHelper.triggerHapticFeedback(context, feedbackType)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -389,8 +389,10 @@ class WidgetFragment : Fragment(),
|
||||
return object : OnSwipeTouchListener(context) {
|
||||
override fun onLongClick() {
|
||||
super.onLongClick()
|
||||
val actionTypeNavOptions: NavOptions =
|
||||
appHelper.getActionType(Constants.Swipe.DoubleTap)
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.DoubleTap)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_WidgetsFragment_to_WidgetsSettingsFragment,
|
||||
@@ -398,17 +400,36 @@ class WidgetFragment : Fragment(),
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
override fun onSwipeLeft() {
|
||||
super.onSwipeLeft()
|
||||
findNavController().navigateUp()
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Left)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_WidgetsFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSwipeRight() {
|
||||
super.onSwipeRight()
|
||||
findNavController().navigateUp()
|
||||
val actionTypeNavOptions: NavOptions? =
|
||||
if (preferenceHelper.disableAnimations) null
|
||||
else appHelper.getActionType(Constants.Swipe.Right)
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
findNavController().navigate(
|
||||
R.id.action_WidgetsFragment_to_HomeFragment,
|
||||
null,
|
||||
actionTypeNavOptions
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ object Constants {
|
||||
const val SEARCH_FROM_START = "SEARCH_FROM_START"
|
||||
const val FILTER_STRENGTH = "FILTER_STRENGTH"
|
||||
const val TOGGLE_SETTING_LOCK = "TOGGLE_SETTING_LOCK"
|
||||
const val DISABLE_ANIMATIONS = "DISABLE_ANIMATIONS"
|
||||
|
||||
const val HOME_DATE_ALIGNMENT = "HOME_DATE_ALIGNMENT"
|
||||
const val HOME_TIME_ALIGNMENT = "HOME_TIME_ALIGNMENT"
|
||||
|
||||
@@ -46,6 +46,7 @@ class PreferenceViewModel @Inject constructor(
|
||||
private val searchFromStartLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val autoKeyboardLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val lockSettingsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val disableAnimationsLiveData: MutableLiveData<Boolean> = MutableLiveData()
|
||||
private val appGroupPaddingSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
private val appPaddingSizeLiveData: MutableLiveData<Float> = MutableLiveData()
|
||||
|
||||
@@ -278,6 +279,11 @@ class PreferenceViewModel @Inject constructor(
|
||||
lockSettingsLiveData.postValue((preferenceHelper.settingsLock))
|
||||
}
|
||||
|
||||
fun setDisableAnimations(disableAnimations: Boolean) {
|
||||
preferenceHelper.disableAnimations = disableAnimations
|
||||
disableAnimationsLiveData.postValue((preferenceHelper.disableAnimations))
|
||||
}
|
||||
|
||||
fun setAppLanguage(appLanguage: Constants.Language) {
|
||||
preferenceHelper.appLanguage = appLanguage
|
||||
appLanguageLiveData.postValue((preferenceHelper.appLanguage))
|
||||
|
||||
@@ -183,6 +183,37 @@
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/disableAnimations_text"
|
||||
style="@style/TextDefaultStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="left|center"
|
||||
android:text="@string/settings_display_disable_animations"
|
||||
android:textSize="@dimen/text_large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="RtlHardcoded" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/disableAnimations_switchCompat"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.8"
|
||||
android:thumb="@drawable/shape_switch_thumb"
|
||||
app:track="@drawable/selector_switch"
|
||||
tools:ignore="TouchTargetSizeCheck" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
<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>
|
||||
|
||||
<fragment
|
||||
@@ -82,7 +86,13 @@
|
||||
android:id="@+id/DrawFragment"
|
||||
android:name="com.github.droidworksstudio.launcher.ui.drawer.DrawFragment"
|
||||
android:label="@string/draw_fragment_label"
|
||||
tools:layout="@layout/fragment_draw" />
|
||||
tools:layout="@layout/fragment_draw">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_DrawFragment_to_HomeFragment"
|
||||
app:destination="@id/HomeFragment" />
|
||||
</fragment>
|
||||
|
||||
|
||||
<fragment
|
||||
android:id="@+id/FavoriteFragment"
|
||||
|
||||
@@ -102,6 +102,7 @@
|
||||
<string name="settings_display_auto_open_apps">Auto Open Last App</string>
|
||||
<string name="settings_search_from_start">Search From Start</string>
|
||||
<string name="settings_display_lock_settings">Lock Settings</string>
|
||||
<string name="settings_display_disable_animations">Disable Animations</string>
|
||||
|
||||
<string name="settings_appearance_text_size_title">Size</string>
|
||||
<string name="settings_appearance_color_title">Color</string>
|
||||
|
||||
Reference in New Issue
Block a user