{"id":37028088,"url":"https://github.com/ohmae/preference-activity-compat","last_synced_at":"2026-01-14T03:21:04.259Z","repository":{"id":57737459,"uuid":"133225465","full_name":"ohmae/preference-activity-compat","owner":"ohmae","description":"This is a compatibility class of PreferenceActivity","archived":false,"fork":false,"pushed_at":"2023-08-05T00:39:23.000Z","size":2339,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-20T17:16:16.811Z","etag":null,"topics":["android","android-library","settings"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohmae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-13T10:07:59.000Z","updated_at":"2024-04-20T17:16:16.812Z","dependencies_parsed_at":"2023-02-09T19:46:01.534Z","dependency_job_id":null,"html_url":"https://github.com/ohmae/preference-activity-compat","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/ohmae/preference-activity-compat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohmae%2Fpreference-activity-compat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohmae%2Fpreference-activity-compat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohmae%2Fpreference-activity-compat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohmae%2Fpreference-activity-compat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohmae","download_url":"https://codeload.github.com/ohmae/preference-activity-compat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohmae%2Fpreference-activity-compat/sbom","scorecard":{"id":703505,"data":{"date":"2025-08-11","repo":{"name":"github.com/ohmae/preference-activity-compat","commit":"396a46624fec976ec52977b8bfcacdbc2439a469"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/29 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'support'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T05:48:34.883Z","repository_id":57737459,"created_at":"2025-08-22T05:48:34.883Z","updated_at":"2025-08-22T05:48:34.883Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408825,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","settings"],"created_at":"2026-01-14T03:21:03.750Z","updated_at":"2026-01-14T03:21:04.246Z","avatar_url":"https://github.com/ohmae.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"*This Library is EOL. Please use [PreferenceHeaderFragmentCompat](https://developer.android.com/reference/androidx/preference/PreferenceHeaderFragmentCompat) instead.*\n===\n\n---\n\n# PreferenceActivityCompat\n[![license](https://img.shields.io/github/license/ohmae/preference-activity-compat.svg)](./LICENSE)\n[![GitHub release](https://img.shields.io/github/release/ohmae/preference-activity-compat.svg)](https://github.com/ohmae/preference-activity-compat/releases)\n[![GitHub issues](https://img.shields.io/github/issues/ohmae/preference-activity-compat.svg)](https://github.com/ohmae/preference-activity-compat/issues)\n[![GitHub closed issues](https://img.shields.io/github/issues-closed/ohmae/preference-activity-compat.svg)](https://github.com/ohmae/preference-activity-compat/issues?q=is%3Aissue+is%3Aclosed)\n![Maven Central](https://img.shields.io/maven-central/v/net.mm2d.preference/preference)\n\nThis is a compatibility library of `PreferenceActivity`.\n\nThis class can be used in much the same way as `PreferenceActivity`.\nMoreover, the material design is applied, It is also possible to manage `PreferenceFragmentCompat` instead of `PreferenceFragment`.\n\n## Background\n\nAs you know,\n[`PreferenceFragmentCompat`](https://developer.android.com/reference/android/support/v7/preference/PreferenceFragmentCompat)\nwhich is a compatibility class corresponding to [`PreferenceFragment`](https://developer.android.com/reference/android/preference/PreferenceFragment)\nis provided in SupportLibrary.\n([`com.android.support:preference-v7`](https://developer.android.com/topic/libraries/support-library/packages#v7-preference))\nBut compatibility class corresponding to [`PreferenceActivity`](https://developer.android.com/reference/android/preference/PreferenceActivity) is not provided.\n\nWhen adding a new activity in AndroidStudio, `AppCompatPreferenceActivity` is created by selecting \"Settings Activity\" from the gallery.\nGuessing from the name of \"`AppCompatPreferenceActivity`\", we will get an impression like the `PreferenceActivity` version of `AppCompatActivity`.\nIn the fact, it allows us to use some new APIs, but doesn't allows we to use material design theme in Android 4.x.\n\nAlso, since `AppCompatPreferenceActivity` can inflate only native Fragment, it can not inflate `PreferenceFragmentCompat` inheriting Fragment of support library.\nThere is also a Support Library version of [`PreferenceFragment`](https://developer.android.com/reference/android/support/v14/preference/PreferenceFragment)\nthat inherits the native Fragment.\n\nBut **the native Fragment is deprecated**.\n\n## Screenshots\n\n### Android 4.4 (Tablet)\n\n|PreferenceActivityCompat:smile:|Native PreferenceActivity:scream:|\n|-|-|\n|![](readme/4C4.png)|![](readme/4N4.png)|\n|![](readme/4C5.png)|![](readme/4N5.png)|\n\n### Android 7.1 (Tablet)\n\n|PreferenceActivityCompat:smile:|Native PreferenceActivity:smile:|\n|-|-|\n|![](readme/7C4.png)|![](readme/7N4.png)|\n|![](readme/7C5.png)|![](readme/7N5.png)|\n\n### Android 4.4 (Phone)\n\n#### PreferenceActivityCompat:smile:\n\n|![](readme/4C1.png)|![](readme/4C2.png)|![](readme/4C3.png)|\n|-|-|-|\n\n#### Native PreferenceActivity:scream:\n\n|![](readme/4N1.png)|![](readme/4N2.png)|![](readme/4N3.png)|\n|-|-|-|\n\n### Android 7.1 (Phone)\n\n#### PreferenceActivityCompat:smile:\n\n|![](readme/7C1.png)|![](readme/7C2.png)|![](readme/7C3.png)|\n|-|-|-|\n\n#### Native PreferenceActivity:smile:\n\n|![](readme/7N1.png)|![](readme/7N2.png)|![](readme/7N3.png)|\n|-|-|-|\n\n## How to use\n\njCenter will close in May. In 0.2.6 moved to mavenCentral from jcenter.  \nPlease note that the **groupID has changed**\n\nDownload from mavenCentral.  \nThe latest version is: ![Maven Central](https://img.shields.io/maven-central/v/net.mm2d.preference/preference)\n\n```gradle\ndependencies {\n    implementation 'net.mm2d.preference:preference:0.2.6'\n}\n```\n\nVersions below 0.2.6 were distributed with jCenter.\nHowever, jCenter will close and old versions are not migrated to mavenCentral.\nIf you need an older version, please use the Github Pages repository.\n\n```gradle\nrepositories {\n    maven { url = URI(\"https://ohmae.github.com/maven\") }\n}\n```\n\n```gradle\ndependencies {\n    implementation 'net.mm2d.preference:preference:0.2.5'\n}\n```\n\n0.1.0~ this library depends on androidx.\nIf you need to use support library 28.0.0, use 0.0.4.\n\nIf you are using ProGuard, to load preference-header from xml, you might need to add the following option.\n```\n-keep public class * extends androidx.preference.PreferenceFragmentCompat\n```\n\n## Restriction\n\nThis class is only partially compatible with\n[`PreferenceActivity`](https://developer.android.com/reference/android/preference/PreferenceActivity).\nOnly functions that are likely to be used are implemented.\n\ne.g.\n- The method to handle Preference is deprecated in Activity and is not implemented.\n- [`FragmentBreadCrumbs`](https://developer.android.com/reference/android/app/FragmentBreadCrumbs) is not used.\n\nThis class can handle only `preference-headers`.\n\nThis class was created with the premise of using\n[`PreferenceFragmentCompat`](https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat).\nTherefore, it is not a restriction of this class itself, but it has the same restrictions as `PreferenceFragmentCompat`.\n\n- We can't use `RingtonePreference`.\nThis is because `RingtonePreference` doesn't exist in the\n[`androidx.preference`](https://developer.android.com/reference/androidx/preference/package-summary) package.\n- `SwitchPreference` does not apply material design.\nBecause\n[`androidx.preference.SwitchPreference`](https://developer.android.com/reference/androidx/preference/SwitchPreference)\nis inflated.\nIf you want to apply material design, use\n[`SwitchPreferenceCompat`](https://developer.android.com/reference/androidx/preference/SwitchPreferenceCompat)\ninstead.\n\n[`androidx.preference`](https://developer.android.com/reference/androidx/preference/package-summary) has various problems, so I recommend to use this library together with other OSS for further improvement.\n\nPlease see the next section.\n\n## Migrate from AppCompatPreferenceActivity\n\n### 1. Add `preferenceTheme` in `PreferenceActivity`'s theme.\n```xml\n    \u003cstyle name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\"\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/colorPrimary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/colorPrimaryDark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/colorAccent\u003c/item\u003e\n\n+        \u003citem name=\"preferenceTheme\"\u003e@style/PreferenceCompatTheme\u003c/item\u003e\n    \u003c/style\u003e\n```\n\n### 2. Replace `SettingsActivity`'s super class\n```java\n- public class SettingsActivity extends AppCompatPreferenceActivity {\n+ public class SettingsActivity extends PreferenceActivityCompat {\n```\n\nAt that time, change the `isValidFragment` from `protected` to `public`.\n```java\n    @Override\n-     protected boolean isValidFragment(final String fragmentName) {\n+     public boolean isValidFragment(final String fragmentName) {\n```\n\nIf you override `onMenuItemSelected`, replace it with `onOptionsItemSelected`.\n```java\n    @Override\n-    public boolean onMenuItemSelected(int featureId, MenuItem item) {\n+    public boolean onOptionsItemSelected(final MenuItem item) {\n        final int id = item.getItemId();\n        if (id == android.R.id.home) {\n-            if (!super.onMenuItemSelected(featureId, item)) {\n+            if (!super.onOptionsItemSelected(item)) {\n                NavUtils.navigateUpFromSameTask(this);\n            }\n            return true;\n        }\n-        return super.onMenuItemSelected(featureId, item);\n+        return super.onOptionsItemSelected(item);\n    }\n```\n\nIf you use Kotlin.\n`onBuildHeaders` argument type must be `MutableList`.\nBecause `PreferenceActivityCompat` is implemented by Kotlin.\n\n```kotlin\n-    override fun onBuildHeaders(target: List\u003cHeader\u003e)\n+    override fun onBuildHeaders(target: MutableList\u003cHeader\u003e)\n```\n\n### 3. Replace `PreferenceFragment` to `PreferenceFragmentCompat`\n\nAnd implement `onCreatePreferences` instead of `onCreate`\n\n```java\n-     public static class GeneralPreferenceFragment extends PreferenceFragment {\n+     public static class GeneralPreferenceFragment extends PreferenceFragmentCompat {\n        @Override\n-         public void onCreate(final Bundle savedInstanceState) {\n-             super.onCreate(savedInstanceState);\n+         public void onCreatePreferences(final Bundle savedInstanceState,final String rootKey) {\n            addPreferencesFromResource(R.xml.native_pref_general);\n        }\n```\n\n### 4. Change package import\n\nUse `net.mm2d.preference.Header` instead of `android.preference.PreferenceActivity.Header`\n\n```java\n- import android.preference.PreferenceActivity.Header;\n+ import net.mm2d.preference.Header;\n```\n\nUse `androidx.preference` instead of `android.preference`\n\n```java\n- import android.preference.ListPreference;\n- import android.preference.Preference;\n- import android.preference.Preference.OnPreferenceChangeListener;\n- import android.preference.PreferenceFragment;\n- import android.preference.PreferenceManager;\n+ import androidx.preference.ListPreference;\n+ import androidx.preference.Preference;\n+ import androidx.preference.Preference.OnPreferenceChangeListener;\n+ import androidx.preference.PreferenceFragmentCompat;\n+ import androidx.preference.PreferenceManager;\n```\n\n### 5. Change namespace of attributes to `app` instead of `android` in xml of `preference-headers`\n\n```xml\n\u003cpreference-headers\n-     xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n+     xmlns:app=\"http://schemas.android.com/apk/res-auto\"\u003e\n    \u003cheader\n-         android:fragment=\"net.mm2d.preference.sample.SettingsActivity$GeneralPreferenceFragment\"\n-         android:icon=\"@drawable/ic_info_black_24dp\"\n-         android:title=\"@string/pref_header_general\"\n+         app:fragment=\"net.mm2d.preference.sample.SettingsActivity$GeneralPreferenceFragment\"\n+         app:icon=\"@drawable/ic_info_black_24dp\"\n+         app:title=\"@string/pref_header_general\"\n        /\u003e\n```\n\n### 6. Replace `SwtichPreference` to `SwitchPreferenceCompat`, if you need\n\n(This is a description of PreferenceFragmentCompat, not this library)\n\n```xml\n\u003cPreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n-     \u003cSwitchPreference\n+     \u003c!--suppress AndroidElementNotAllowed --\u003e\n+     \u003cSwitchPreferenceCompat\n        android:defaultValue=\"true\"\n        android:key=\"example_switch\"\n        android:summary=\"@string/pref_description_social_recommendations\"\n        android:title=\"@string/pref_title_social_recommendations\"\n        /\u003e\n```\n\nBecause SwitchPreference looks legacy in Android 4.4 or less.\n\n|SwitchPreference|SwitchPreferenceCompat|\n|:-:|:-:|\n|![](readme/switch-preference.png)|![](readme/switch-preference-compat.png)|\n\nIf your target is Android 5 or later, you do not have to replace it.\n\n### 7. Add `app:iconSpaceReserved=\"false\"`, If you do not need the space for the icon\n\n(This is a description of PreferenceFragmentCompat, not this library)\n\n```xml\n    \u003cPreference\n        android:title=\"@string/pref_title_system_sync_settings\"\n+         app:iconSpaceReserved=\"false\"\n        \u003e\n```\n\n|default|`app:iconSpaceReserved=\"false\"`|\n|:-:|:-:|\n|![](readme/icon-space-reserved-true.png)|![](readme/icon-space-reserved-false.png)|\n\n## Dependent OSS\n\n### PreferenceActivityCompat\n\n- [Kotlin](https://kotlinlang.org/)\n- [Android Jetpack](https://developer.android.com/jetpack/)\n  - androidx.appcompat:appcompat\n  - androidx.preference:preference\n  - androidx.core:core-ktx\n\n### Sample app\n\n- [Kotlin](https://kotlinlang.org/)\n- [Android Jetpack](https://developer.android.com/jetpack/)\n  - androidx.appcompat:appcompat\n  - androidx.preference:preference\n\n## Author\n大前 良介 (OHMAE Ryosuke)\nhttp://www.mm2d.net/\n\n## License\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohmae%2Fpreference-activity-compat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohmae%2Fpreference-activity-compat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohmae%2Fpreference-activity-compat/lists"}