{"id":19383741,"url":"https://github.com/urbandroid-team/sleep-captcha-support","last_synced_at":"2025-04-23T21:32:01.436Z","repository":{"id":72085537,"uuid":"48115382","full_name":"urbandroid-team/sleep-captcha-support","owner":"urbandroid-team","description":"Sleep as Android - Captcha support library","archived":false,"fork":false,"pushed_at":"2024-07-10T14:54:06.000Z","size":91,"stargazers_count":16,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-02T20:22:05.975Z","etag":null,"topics":["android","sleep","smart-alarm"],"latest_commit_sha":null,"homepage":"http://sleep.urbandroid.org","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbandroid-team.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-16T14:33:32.000Z","updated_at":"2025-03-20T14:50:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"69f56d72-5662-4e30-9ab1-2fddb8d5b391","html_url":"https://github.com/urbandroid-team/sleep-captcha-support","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbandroid-team%2Fsleep-captcha-support","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbandroid-team%2Fsleep-captcha-support/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbandroid-team%2Fsleep-captcha-support/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbandroid-team%2Fsleep-captcha-support/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbandroid-team","download_url":"https://codeload.github.com/urbandroid-team/sleep-captcha-support/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250517964,"owners_count":21443865,"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","sleep","smart-alarm"],"created_at":"2024-11-10T09:27:38.292Z","updated_at":"2025-04-23T21:32:01.145Z","avatar_url":"https://github.com/urbandroid-team.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sleep as Android - Captcha support\n\n## Introduction\n\nThis open-source library contains classes that are useful for developing\nadditional captcha into Sleep as Android application.\n\n## Usage\n\nWhen you use Gradle add the following maven repository and dependency with the latest version\nto your `build.gradle` file to use the library:\n\n```groovy\nrepositories {\n    jcenter()\n}\n\ndependencies {\n    compile 'com.urbandroid.sleep:captcha-support:0.3.3@aar'\n}\n```\n## Captcha Manifest\n\nYour captcha activity must be exported and single top. OPEN action is mandatory in intent filter otherwise\nSleep as Android will not find your captcha.\n\n```xml\n\u003cmanifest ... \u003e\n\n    \u003capplication ... \u003e\n\n        \u003cactivity\n            android:name=\".MyCleverCaptchaActivity\"\n            android:launchMode=\"singleTop\"\n            android:label=\"@string/captcha_label\"\n            android:exported=\"true\"\n            \u003e\n            \u003cmeta-data android:name=\"com.urbandroid.sleep.captcha.meta.has_difficulty\" android:value=\"true\"/\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"com.urbandroid.sleep.captcha.intent.action.OPEN\"/\u003e\n            \u003c/intent-filter\u003e\n        \u003c/activity\u003e\n    \u003c/application\u003e\n\n\u003c/manifest\u003e\n```\n## CaptchaSupport object\n\nAll interaction between Sleep and Captcha is covered by CaptchaSupport object. It must\nbe created inside onCreate and onNewIntent method of Activity. Also proper releasing captcha support\nreceivers must be called from onDestroy method.\n\n```java\n    private CaptchaSupport captchaSupport;\n\n    protected void onCreate(final Bundle savedInstanceState) {\n        ...\n        captchaSupport = CaptchaSupportFactory.create(this);\n        ...\n    }\n\n    protected void onNewIntent(Intent intent) {\n        super.onNewIntent(intent);\n        captchaSupport = CaptchaSupportFactory.create(this, intent);\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n        captchaSupport.destroy();\n    }\n\n```\n\nNote that, creation captcha support object in onNewIntent has different constructor and must have 2-nd argument intent.\n\nWhen CaptchaSupport object is created you can\n* check in which mode (Preview, Configuration, Operational) is captcha running by CaptchaSupport.getMode()\nor CaptchaSupport.isPreviewMode(), isOperationalMode(), isConfigurationMode()\n* get difficulty (1-5) - use CaptchaSupport.getDifficulty()\n* set up time remaining listener CaptchaSupport.setRemainingTimeListener()\n* call solved method when captcha is successfully resolved\n* call unsolved method when captcha was not solved but user left activity\n* call alive in order to reset timeout for solving captcha\n* or use advanced features like CaptchaFinder for getting list of all available captchas on mobile\nand launch them via CaptchaLauncher\n\n## Difficulty\nIn case your captcha need support several level of difficulty, put following lines in AndroidManifest file,\n```xml\n    \u003cactivity ...\u003e\n        ...\n        \u003cmeta-data android:name=\"com.urbandroid.sleep.captcha.meta.has_difficulty\" android:value=\"true\"/\u003e\n        ...\n    \u003c/activity\u003e\n```\nIn order to get current captcha difficulty, call CaptchaSupport.getDifficulty().\nUse CaptchaDifficulty annotation to get all possible values.\n\n## Captcha Order\nWhen your application contains more than one captcha activity, you can find out useful to sort them in\nSleep app by declaring order.\n```xml\n    \u003cactivity ...\u003e\n        ...\n        \u003cmeta-data android:name=\"com.urbandroid.sleep.captcha.meta.order\" android:value=\"1\"/\u003e\n        ...\n    \u003c/activity\u003e\n    \u003cactivity ...\u003e\n        ...\n        \u003cmeta-data android:name=\"com.urbandroid.sleep.captcha.meta.order\" android:value=\"2\"/\u003e\n        ...\n    \u003c/activity\u003e\n```\n\n## Captcha Configuration\n\nIn case your captcha requires any kind of additional configuration you have two options\n\n### 1. Add CONFIG action into your Captcha Activity\n\n```xml\n    \u003cactivity\n        android:name=\".MyCleverCaptchaActivity\"\n        ...\n        \u003e\n        \u003cintent-filter\u003e\n            \u003caction android:name=\"com.urbandroid.sleep.captcha.intent.action.OPEN\"/\u003e\n            \u003caction android:name=\"com.urbandroid.sleep.captcha.intent.action.CONFIG\"/\u003e\n        \u003c/intent-filter\u003e\n    \u003c/activity\u003e\n```\nWhen CaptchaSupport object (onCreate/onNewIntent) is created, you should check mode in which\ncaptcha is running. To detect mode call either isConfigurationMode() and/or isOperationalMode().\n\n### 2. Create special config activity referring to your captcha activity\n\n    \u003cactivity\n        android:name=\".MyCleverCaptchaActivity\"\n      ...\u003e\n\n      \u003cintent-filter\u003e\n        \u003caction android:name=\"com.urbandroid.sleep.captcha.intent.action.OPEN\"/\u003e\n      \u003c/intent-filter\u003e\n    \u003c/activity\u003e\n\n    \u003cactivity\n        android:name=\".MyCleverCaptchaConfigActivity\"\n      ...\u003e\n\n      \u003cmeta-data android:name=\"com.urbandroid.sleep.captcha.meta.for_captcha\" android:value=\".MyCleverCaptchaActivity\"/\u003e\n      \u003cintent-filter\u003e\n        \u003caction android:name=\"com.urbandroid.sleep.captcha.intent.action.CONFIG\"/\u003e\n      \u003c/intent-filter\u003e\n    \u003c/activity\u003e\n\nThis is preferable way doing captcha configuration since it separates two aspects of captcha\nand creates less messy code handling two modes in one activity (as per case 1).\n\n\n## Recommendation\n* Don't forget to define your activity with exported=\"true\" and as singleTop otherwise the captcha\n  will not be accessible and/or duplicated.\n* CaptchaSupport object must be created in Activity.onCreate or onPostCreate method and also onNewIntent\n* override Activity.onUserInteraction() method to call CaptchaSupport.alive() method\n* override Activity.onBackPressed() method to call CaptchaSupport.unsolved()\n\n## Read more and get started\n\nCheck simple github project captcha [examples] or read more on the [website][website].\n\n[examples]: https://github.com/urbandroid-team/sleep-captcha-examples/\n[issues]: https://github.com/urbandroid-team/sleep-captcha-support/issues\n[website]: http://sleep.urbandroid.org/documentation/developer-api/captcha-api\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbandroid-team%2Fsleep-captcha-support","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbandroid-team%2Fsleep-captcha-support","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbandroid-team%2Fsleep-captcha-support/lists"}