Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom nav always disable #14

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}

}
}