[app] Hide empty system preference category (#547)

This commit is contained in:
Wang Han 2021-05-08 04:37:54 +08:00 committed by GitHub
parent 5f68cbea36
commit f69755827a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -45,6 +45,7 @@ import androidx.preference.SwitchPreference;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.snackbar.Snackbar;
import com.takisoft.preferencex.PreferenceCategory;
import com.takisoft.preferencex.PreferenceFragmentCompat;
import org.lsposed.manager.BuildConfig;
@ -286,9 +287,11 @@ public class SettingsActivity extends BaseActivity {
});
}
PreferenceCategory prefGroupSystem = findPreference("settings_group_system");
SwitchPreference prefShowHiddenIcons = findPreference("show_hidden_icon_apps_enabled");
if (prefShowHiddenIcons != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
if (prefGroupSystem != null && prefShowHiddenIcons != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
&& requireActivity().checkSelfPermission(Manifest.permission.WRITE_SECURE_SETTINGS) == PackageManager.PERMISSION_GRANTED) {
prefGroupSystem.setVisible(true);
prefShowHiddenIcons.setVisible(true);
prefShowHiddenIcons.setChecked(Settings.Global.getInt(
requireActivity().getContentResolver(), "show_hidden_icon_apps_enabled", 1) != 0);

View File

@ -82,7 +82,9 @@
</com.takisoft.preferencex.PreferenceCategory>
<com.takisoft.preferencex.PreferenceCategory
android:title="@string/settings_group_system">
android:key="settings_group_system"
android:title="@string/settings_group_system"
app:isPreferenceVisible="false">
<SwitchPreference
android:defaultValue="true"
android:key="show_hidden_icon_apps_enabled"