{"id":21130299,"url":"https://github.com/BoD/android-switch-backport","last_synced_at":"2025-07-09T01:33:08.382Z","repository":{"id":3569466,"uuid":"4631621","full_name":"BoD/android-switch-backport","owner":"BoD","description":"A backport of the SwitchPreference component that was introduced on Android 4 (ICS / level 14).  This port works on Android 2.1+ (Eclair MR1 / level 7).","archived":false,"fork":false,"pushed_at":"2020-10-02T06:15:16.000Z","size":728,"stargazers_count":495,"open_issues_count":2,"forks_count":178,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-10-12T13:09:43.213Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BoD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-12T00:17:08.000Z","updated_at":"2024-05-23T04:29:06.000Z","dependencies_parsed_at":"2022-09-16T02:24:00.021Z","dependency_job_id":null,"html_url":"https://github.com/BoD/android-switch-backport","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoD%2Fandroid-switch-backport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoD%2Fandroid-switch-backport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoD%2Fandroid-switch-backport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BoD%2Fandroid-switch-backport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BoD","download_url":"https://codeload.github.com/BoD/android-switch-backport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225476370,"owners_count":17480215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-20T05:32:33.530Z","updated_at":"2024-11-20T05:32:43.635Z","avatar_url":"https://github.com/BoD.png","language":"Java","readme":"Android Switch Preference Backport\n===\n\nA backport of the [`SwitchPreference`](http://developer.android.com/reference/android/preference/SwitchPreference.html) component that was introduced on Android 4 (ICS / level 14).\n\nThis port works on Android 2.1+ (Eclair MR1 / level 7).\n\nThe current version of this library is `2.0.1`.\n\nIMPORTANT: THIS LIBRARY IS NOW DEPRECATED\n---\n\nSince the AppCompat library now includes a **Switch** widget backport ([`SwitchCompat`](http://developer.android.com/reference/android/support/v7/widget/SwitchCompat.html)), and a **SwitchPreference** widget backport ([`SwitchPreferenceCompat`](https://developer.android.com/reference/android/support/v7/preference/SwitchPreferenceCompat.html)), this library is no longer useful.\n\nI was glad to work on this library and to see that it has been used in many projects.\n\n\nHow to use\n---\n\n### Adding the library to your project\n\n#### Option 1: Gradle\n\nThe aar artifact is available at the **jcenter** repository. Declare the repository and the\ndependency in your `build.gradle` file:\n```groovy\nrepositories {\n    jcenter()\n}\n\n (...)\n\ndependencies {\n    compile 'org.jraf:android-switch-backport:2.0.1'\n}\n```\n\n#### Option 2: Android library project (ant / Eclipse)\n\nThis is an Android library project, you have to add it as a dependency to your project (please\nsee [this page](http://developer.android.com/guide/developing/projects/projects-eclipse.html#ReferencingLibraryProject)\nto know how to do that.)\n\n### Using the SwitchPreference\n\nOnce you have done that, have a theme for your application (or Activity), that declares the `asb_switchPreferenceStyle` item\nto be the value `@style/asb_Preference.SwitchPreference`.\n\nThe simplest way to do that is to create a `themes.xml` file in your project's `res/values` folder with this contents:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n\n    \u003cstyle name=\"Theme.App\" parent=\"Theme.AppCompat\"\u003e\n        \u003citem name=\"asb_switchPreferenceStyle\"\u003e@style/asb_Preference.SwitchPreference\u003c/item\u003e\n    \u003c/style\u003e\n\n\u003c/resources\u003e\n```\nAnd use it in your Application or Activity by updating your `AndroidManifest.xml` file:\n```xml\n(...)\n\u003capplication\n    android:theme=\"@style/Theme.App\"\n(...)\n```\n\nor\n```xml\n(...)\n\u003cactivity\n    android:theme=\"@style/Theme.App\"\n(...)\n```\n\nThen in your preferences xml file:\n\n```xml\n\u003cPreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\" \u003e\n\n    \u003corg.jraf.android.backport.switchwidget.SwitchPreference\n        android:key=\"testKey\"\n        android:title=\"SwitchPreference Test\"\n        app:asb_summaryOff=\"@string/summary_off\"\n        app:asb_summaryOn=\"@string/summary_on\" /\u003e\n\n\u003c/PreferenceScreen\u003e\n```\n\n### Sample app\n\nA sample app is available in the [sample](sample) folder, and also on the Play Store:\n[![Get it on Google Play](http://www.android.com/images/brand/get_it_on_play_logo_small.png)](https://play.google.com/store/apps/details?id=org.jraf.android.backport.switchwidget.sample)\n\nCredits\n---\n\nThe code was copied directly from the Android 5.0 (Lollipop / level 21) source code, then slightly tweaked by myself (BoD@JRAF.org) to make\nit run on 2.1+ (Eclair MR1 / level 7).\nThe v1 SwitchPreference was added by Intrications (intrications.com / github.com/intrications), also by taking code\nfrom Android and tweaking it a bit.  Other people also have contributed tweaks and fixes, please see this page for a detailed\nlist: https://github.com/BoD/android-switch-backport/graphs/contributors.\n\nContributing\n---\n\nPull requests are welcome, as long as they are consistent to the original SwitchPreference of the\nAndroid sdk.\n\nPlease do not contribute improvements that are not present in the original sdk classes!  I believe it would be\nconfusing for this backport to have a feature set different than the original sdk classes.\nIt would also lead to difficult situations if/when stopping using this backport and using the sdk classes instead\n(which should happen when dropping support for old platforms).  Thank you very much.\n\nLicence\n---\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoD%2Fandroid-switch-backport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBoD%2Fandroid-switch-backport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBoD%2Fandroid-switch-backport/lists"}