{"id":16106579,"url":"https://github.com/stefan-niedermann/nextcloud-commons","last_synced_at":"2025-03-17T17:31:38.878Z","repository":{"id":38191532,"uuid":"239956263","full_name":"stefan-niedermann/nextcloud-commons","owner":"stefan-niedermann","description":"Library for common Nextcloud operations, like a Glide-SSO integration","archived":false,"fork":false,"pushed_at":"2024-04-19T14:13:22.000Z","size":796,"stargazers_count":7,"open_issues_count":3,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-21T22:39:48.578Z","etag":null,"topics":["android","glide","glideimageloader","nextcloud"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefan-niedermann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"liberapay":"stefan-niedermann","custom":"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=K7HVLE6J7SXXA"}},"created_at":"2020-02-12T07:57:36.000Z","updated_at":"2024-05-01T16:15:03.319Z","dependencies_parsed_at":"2023-10-20T16:37:13.414Z","dependency_job_id":"d94c6040-1831-4b5f-bbb6-b2f30c0988cd","html_url":"https://github.com/stefan-niedermann/nextcloud-commons","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefan-niedermann%2Fnextcloud-commons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefan-niedermann%2Fnextcloud-commons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefan-niedermann%2Fnextcloud-commons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefan-niedermann%2Fnextcloud-commons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefan-niedermann","download_url":"https://codeload.github.com/stefan-niedermann/nextcloud-commons/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243875054,"owners_count":20361935,"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","glide","glideimageloader","nextcloud"],"created_at":"2024-10-09T19:13:50.700Z","updated_at":"2025-03-17T17:31:38.872Z","avatar_url":"https://github.com/stefan-niedermann.png","language":"Kotlin","funding_links":["https://liberapay.com/stefan-niedermann","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=K7HVLE6J7SXXA"],"categories":[],"sub_categories":[],"readme":"# nextcloud-commons\n\n[![Latest Release](https://img.shields.io/github/v/tag/stefan-niedermann/nextcloud-commons?label=latest+release\u0026sort=semver)](https://github.com/stefan-niedermann/nextcloud-commons/tags)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9f784826834042e8b512d531cab84711)](https://www.codacy.com/manual/info_147/nextcloud-commons?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=stefan-niedermann/nextcloud-commons\u0026amp;utm_campaign=Badge_Grade)\n[![GitHub issues](https://img.shields.io/github/issues/stefan-niedermann/nextcloud-commons.svg)](https://github.com/stefan-niedermann/nextcloud-commons/issues)\n[![GitHub stars](https://img.shields.io/github/stars/stefan-niedermann/nextcloud-commons.svg)](https://github.com/stefan-niedermann/nextcloud-commons/stargazers)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\n- [What is this](#what-is-this)\n- [How to use](#how-to-use)\n- [Modules](#modules)\n  - [exception](#exception)\n  - [sso-glide](#sso-glide)\n  - [markdown](#markdown)\n- [Development](#development)\n- [License](#notebook-license)\n\n## What is this\n\nMany Android clients for Nextcloud apps need similar mechanisms. To reduce maintenance efforts and provide a similar look \u0026 feel, this library aims to provide tooling and support which can be useful for various Android clients.\n\n## How to use\n\nAdd this dependency to your `build.gradle`-file to include *all* modules at once:\n\n```groovy\nimplementation 'com.github.stefan-niedermann:nextcloud-commons:2.3.5'\n```\n\n## Modules\n\n### exception\n\n```groovy\nimplementation 'com.github.stefan-niedermann.nextcloud-commons:exception:2.3.5'\n```\n\nThis is a util class which provides methods for generating a rich stacktrace from a throwable containing additional information like the used files app and OS versions.\n\n#### Usage\n\n```java\ntry {\n  // …\n} catch (Exception exception) {\n  String debug = ExceptionUtil.getDebugInfos(context, exception);\n}\n```\n\n#### Example\n\n```\nApp Version: 2.17.1\nApp Version Code: 2017001\nServer App Version: 3.2.0\nApp Flavor: dev\n\nFiles App Version Code: 30120090\n\n---\n\nOS Version: 4.14.112+(5775370)\nOS API Level: 29\nDevice: generic_x86_64\nManufacturer: unknown\nModel (and Product): Android SDK built for x86_64 (sdk_phone_x86_64)\n\n---\n\njava.lang.RuntimeException: Unable to start activity ComponentInfo{it.niedermann.owncloud.notes.dev/it.niedermann.owncloud.notes.main.MainActivity}: java.lang.NumberFormatException: For input string: \"ASDF\"\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)\n\tat android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)\n\tat android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)\n\tat android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)\n\tat android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)\n\tat android.os.Handler.dispatchMessage(Handler.java:107)\n\tat android.os.Looper.loop(Looper.java:214)\n\tat android.app.ActivityThread.main(ActivityThread.java:7356)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)\nCaused by: java.lang.NumberFormatException: For input string: \"ASDF\"\n\tat java.lang.Integer.parseInt(Integer.java:615)\n\tat java.lang.Integer.parseInt(Integer.java:650)\n\tat it.niedermann.owncloud.notes.main.MainActivity.onCreate(MainActivity.java:180)\n\tat android.app.Activity.performCreate(Activity.java:7802)\n\tat android.app.Activity.performCreate(Activity.java:7791)\n\tat android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)\n\tat android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)\n\t... 11 more\n\n```\n\n### sso-glide\n\n```groovy\nimplementation 'com.github.stefan-niedermann.nextcloud-commons:sso-glide:2.3.5'\n```\n\nThis is a Glide-integration module. If you are using [Single Sign On](https://github.com/nextcloud/Android-SingleSignOn) you may want to also fetch avatars or other images via Glide but with the SSO network stack to avoid problems with self-signed certificates, 2fa and so on.\n\nTo make it work, you need also this dependencies in your `build.gradle`-file:\n\n```groovy\nimplementation 'com.github.bumptech.glide:glide:4.11.0'\nannotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'\n```\n\n#### Usage\n\nThen create a custom `AppGlideModule` at the place you want, like this:\n\n```java\n@GlideModule\npublic class CustomAppGlideModule extends AppGlideModule {\n  @Override\n  public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {\n    super.registerComponents(context, glide, registry);\n  }\n}\n```\n\nGlide will automatically recognize the custom `AppGlideModule` and process this library module.\n\n```java\nGlide.with(context)\n     .load(\"https://nextcloud.example.com/index.php/avatar/username/32\")\n     .into(myImageView);\n```\n\nwill make a request from the user which is stored as the current SingleSignOn account (see [here](https://github.com/nextcloud/Android-SingleSignOn#4-how-to-get-account-information)).\n\nIf you need to perform the request from another account (for example to display avatars in an account switcher), you can use a `SingleSignOnUrl` instance as `Url`:\n\n```java\nGlide.with(context)\n     .load(new SingleSignOnUrl(ssoAccount, \"https://nextcloud.example.com/index.php/avatar/username/32\"))\n     .into(myImageView);\n```\n\nThe `sso-glide` module also supports some automatic URL rewrites, such as:\n\n```java\nGlide.with(context)\n   // URLs from file shares with and without /index.php segment, with and without trailing / character\n     .load(\"https://nextcloud.example.com/s/Wr99tjfBCs96kxZ\")\n     .load(\"https://nextcloud.example.com/s/Wr99tjfBCs96kxZ/\")\n     .load(\"https://nextcloud.example.com/index.php/s/Wr99tjfBCs96kxZ\")\n     .load(\"https://nextcloud.example.com/index.php/s/Wr99tjfBCs96kxZ/\")\n     .load(\"https://nextcloud.example.com/index.php/s/Wr99tjfBCs96kxZ/download\")\n     .load(\"https://nextcloud.example.com/index.php/s/Wr99tjfBCs96kxZ/download/\")\n   // File ID URLs with and without /index.php segment, with and without trailing / character\n     .load(\"https://nextcloud.example.com/f/123456\")\n     .load(\"https://nextcloud.example.com/f/123456/\")\n     .load(\"https://nextcloud.example.com/index.php/f/123456\")\n     .load(\"https://nextcloud.example.com/index.php/f/123456/\")\n   // Everything mentioned above, if the nextcloud is not located at the root directory\n     .load(\"https://example.com/my-fancy-nextcloud/f/123456\")\n   // There is a fallback for every URL or path which does not start with /index.php or /remote.php\n   // In this case we will assume a path in the users directory (which needs to be properly URL encoded)\n     .load(\"/foo.png\")\n     .load(\"/foo%20bar.png\")\n     .load(\"/foo/bar%20baz.png\")\n     .into(myImageView);\n```\n\n### markdown\n\n```groovy\nimplementation('com.github.stefan-niedermann.nextcloud-commons:markdown:2.3.5') {\n  exclude group: 'org.jetbrains', module: 'annotations-java5'\n}\n```\n\nThis contains a markdown editor and viewer based on [Markwon](https://noties.io/Markwon/).\n\n#### Usage\n\nThe UI widgets `MarkdownViewerImpl` and `MarkdownEditorImpl` can just be treated as a `TextView` or an `EditText`:\n\n```xml\n\u003cit.niedermann.android.markdown.MarkdownViewerImpl\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\" /\u003e\n```\n```xml\n\u003cit.niedermann.android.markdown.MarkdownEditorImpl\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\" /\u003e\n```\n\nYou can implement against the `MarkdownEditor` interface, which allows you to add some special behavior like\n- highlight search terms\n- intercept link clicks\n- render user avatars next to `@user` mentions\n\nThe `MarkdownUtil` provides some helper tools to work with markdown.\n\n\n## Development\n\nIf you want to add this repository to your project to develop this library or use the latest version, you can add the following code to your gradle files:\n\n### `settings.gradle`\n\n```gradle\n// for markdown\ninclude ':markdown'\nproject(':markdown').projectDir = new File(settingsDir, '../nextcloud-commons/markdown')\n\n// for sso-glide\ninclude ':sso-glide'\nproject(':sso-glide').projectDir = new File(settingsDir, '../nextcloud-commons/sso-glide')\n\n// for exception\ninclude ':exception'\nproject(':exception').projectDir = new File(settingsDir, '../nextcloud-commons/exception')\n\n// It is also possible to provide absolute path's instead of relative ones.\n```\n\n### `build.gradle`\n\n(the app one, not the project-one)\n\n```gradle\ndependencies {\n    // …\n\n    implementation project(':markdown')\n    implementation project(':sso-glide')\n    implementation project(':exception')\n    \n    // …\n}\n```\n\nYou do not need to add all libraries, just add the ones you want to use in your project.\nYou also have to remove versioned libraries from above if you added them. \n\nHowever, it is not adivisable to check those into version control, because anyone else will not be able to build your project without having the local libraries configured.\n\n\n## :notebook: License\nThis project is licensed under the [GNU GENERAL PUBLIC LICENSE](/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefan-niedermann%2Fnextcloud-commons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefan-niedermann%2Fnextcloud-commons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefan-niedermann%2Fnextcloud-commons/lists"}