{"id":13607669,"url":"https://github.com/WhiteDog-Apps/FoldableActivity_Android","last_synced_at":"2025-04-12T14:30:52.818Z","repository":{"id":38795640,"uuid":"375837725","full_name":"WhiteDog-Apps/FoldableActivity_Android","owner":"WhiteDog-Apps","description":"Android library that simplifies the logic necessary to detect state changes in foldable devices","archived":false,"fork":false,"pushed_at":"2023-09-22T11:40:15.000Z","size":189,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-07T13:37:08.306Z","etag":null,"topics":["android","android-library","flip","fold","foldable","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/WhiteDog-Apps.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-10T21:46:27.000Z","updated_at":"2022-09-14T18:01:10.000Z","dependencies_parsed_at":"2023-09-23T11:44:52.977Z","dependency_job_id":null,"html_url":"https://github.com/WhiteDog-Apps/FoldableActivity_Android","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteDog-Apps%2FFoldableActivity_Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteDog-Apps%2FFoldableActivity_Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteDog-Apps%2FFoldableActivity_Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WhiteDog-Apps%2FFoldableActivity_Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WhiteDog-Apps","download_url":"https://codeload.github.com/WhiteDog-Apps/FoldableActivity_Android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581020,"owners_count":21128092,"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":["android","android-library","flip","fold","foldable","kotlin"],"created_at":"2024-08-01T19:01:20.555Z","updated_at":"2025-04-12T14:30:52.536Z","avatar_url":"https://github.com/WhiteDog-Apps.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"[![](https://jitpack.io/v/WhiteDog-Apps/FoldableActivity_Android.svg)](https://jitpack.io/#WhiteDog-Apps/FoldableActivity_Android)\n\n# FoldableActivity\nAndroid library that simplifies the logic necessary to detect state changes in foldable devices,\n\n## Setup\n#### 1. Add the JitPack repository to your \"settings.gradle\" file if you didn't add before.\n```gradle\npluginManagement {\n...\n}\ndependencyResolutionManagement {\n    ...\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n...\n```\n\n#### 2. Add the dependency\n```gradle\ndependencies {\n    implementation 'com.github.WhiteDog-Apps:FoldableActivity_Android:1.0.4'\n}\n```\n\n## Usage\n#### 1.  Make your activity inherit from FoldableActivity\n```kotlin\nclass MainActivity: FoldableActivity() {\n    ...\n}\n```\n\n#### 2.  Implements members\n```kotlin\n    override fun getRootView(): View {\n    // Return the view where you will control the fold\n}\n\noverride fun onFoldablePostureChanged(foldPosture: FoldPosture, foldPositionFromEnd: Int) {\n    // Update UI\n}\n```\n\n## Example\n```kotlin\n    // 1. Make your activity inherit from FoldableActivity\nclass MainActivity: FoldableActivity() {\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n    }\n\n    // 2. Implements members\n    override fun getRootView(): View {\n        return findViewById\u003cConstraintLayout\u003e(R.id.motion_layout_guides_root)\n    }\n\n    override fun onFoldablePostureChanged(foldPosture: FoldPosture, foldPositionFromEnd: Int) {\n        when(foldPosture) {\n            FoldPosture.TABLE_TOP -\u003e {\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_tabletop, foldPositionFromEnd)\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_book, 0)\n            }\n            FoldPosture.BOOK      -\u003e {\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_tabletop, 0)\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_book, foldPositionFromEnd)\n            }\n            else                  -\u003e {\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_tabletop, 0)\n                ConstraintLayout.getSharedValues().fireNewValue(R.id.rg_motion_layout_guides_book, 0)\n            }\n        }\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWhiteDog-Apps%2FFoldableActivity_Android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWhiteDog-Apps%2FFoldableActivity_Android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWhiteDog-Apps%2FFoldableActivity_Android/lists"}