Skip to content

Commit

Permalink
Fix custom nav always disable (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 authored Nov 2, 2023
1 parent b950f13 commit e748158
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
package com.sevtinge.hyperceiler.ui.fragment.systemui;

import android.provider.Settings;
import android.view.View;

import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.ui.base.BaseSettingsActivity;
import com.sevtinge.hyperceiler.ui.fragment.base.SettingsPreferenceFragment;

import moralnorm.preference.SwitchPreference;

public class NavigationSettings extends SettingsPreferenceFragment {
SwitchPreference customNav;

@Override
public int getContentResId() {
return R.xml.system_ui_navigation;
}

@Override
public View.OnClickListener addRestartListener() {
return view -> ((BaseSettingsActivity)getActivity()).showRestartDialog(
return view -> ((BaseSettingsActivity) getActivity()).showRestartDialog(
getResources().getString(R.string.system_ui),
"com.android.systemui"
);
}

private boolean isGestureNavigationEnabled() {
var defaultNavigationMode = 0;
var gestureNavigationMode = 2;

return Settings.Secure.getInt(requireContext().getContentResolver(), "navigation_mode", defaultNavigationMode) == gestureNavigationMode;
}

@Override
public void initPrefs() {
customNav = findPreference("prefs_key_system_ui_navigation_custom");
if (customNav != null) {
customNav.setEnabled(!isGestureNavigationEnabled());
customNav.setVisible(customNav.isEnabled());
}

}
}

0 comments on commit e748158

Please sign in to comment.