{"id":23376232,"url":"https://github.com/trustedshops-public/etrusted-android-trustbadge-library","last_synced_at":"2025-04-10T18:42:25.132Z","repository":{"id":93832710,"uuid":"560817987","full_name":"trustedshops-public/etrusted-android-trustbadge-library","owner":"trustedshops-public","description":"Show the TrustBadge on your Android app","archived":false,"fork":false,"pushed_at":"2025-04-02T16:19:54.000Z","size":5293,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-02T17:29:18.861Z","etag":null,"topics":["etrusted","trustbadge","trustedshops","trustedshops-sdk","tslibraries"],"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/trustedshops-public.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-02T10:37:46.000Z","updated_at":"2024-02-09T16:43:19.000Z","dependencies_parsed_at":"2024-05-31T23:47:25.439Z","dependency_job_id":"b2f1108c-b80c-49d4-b749-35428e95a8b9","html_url":"https://github.com/trustedshops-public/etrusted-android-trustbadge-library","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/trustedshops-public%2Fetrusted-android-trustbadge-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fetrusted-android-trustbadge-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fetrusted-android-trustbadge-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trustedshops-public%2Fetrusted-android-trustbadge-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trustedshops-public","download_url":"https://codeload.github.com/trustedshops-public/etrusted-android-trustbadge-library/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271910,"owners_count":21075800,"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":["etrusted","trustbadge","trustedshops","trustedshops-sdk","tslibraries"],"created_at":"2024-12-21T17:34:53.589Z","updated_at":"2025-04-10T18:42:25.112Z","avatar_url":"https://github.com/trustedshops-public.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# etrusted-android-trustbadge-library\n\n[![GitHub License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/trustedshops-public/etrusted-android-trustbadge-library/blob/main/LICENSE)\n[![codecov](https://codecov.io/gh/trustedshops-public/etrusted-android-trustbadge-library/branch/develop/graph/badge.svg?token=CnT4ETYgkH)](https://codecov.io/gh/trustedshops-public/etrusted-android-trustbadge-library)\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/trustedshops-public/etrusted-android-trustbadge-library/tree/develop.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/trustedshops-public/etrusted-android-trustbadge-library/tree/develop)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=trustedshops-public_etrusted-android-trustbadge-library\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=trustedshops-public_etrusted-android-trustbadge-library)\n\n\u003e This project is currently work in progress and used only be a few\n\u003e customers. APIs might not be stable yet and might change without\n\u003e further notice\n\nShow the Trustmark and the Shop Grade widget in your Android app, all in 5 steps!\n\nThe `Trustmark` widget shows the validity of your trust certificate by Trusted Shop:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/27926337/215702112-ae9ea5c8-76f1-479c-8d2c-fc6726204f06.jpg\" height=\"90\"\u003e\n\nIn case of an expired certificate, the Trustmark widgets is presented like the following instead:\n\n\u003cimg src=\"docs/img/screenshot-trustbadge-uncertified-default.png\" height=\"90\"\u003e\n\nThe `ShopGrade` widget expands to show shop rating and status with a simple animation. Currently, the widget shows the aggregate rating and the shop status.\nIn the future, the widget will also show the shop reviews.\n\n\u003cimg src=\"docs/img/shop_grade.gif\" height=\"100\"\u003e\n\nThe `ProductGrade` widget expands to show product rating with a simple animation. Currently, the widget shows the single product rating for a given `SKU` (See the step: **Implement the dependency**).\nIn the future, the widget will also show the product reviews.\n\n\u003cimg src=\"docs/img/product_grade.gif\" height=\"100\"\u003e\n\nThe `BuyerProtection` widget shows the amount of protection for the consumers' purchase. It can be shown in the checkout screen for that purpose.\n\n\u003cimg src=\"docs/img/guarantee.gif\" height=\"100\"\u003e\n\n\n## Usage\n**Requirements:**\n- Access to [eTrusted Control Center](https://app.etrusted.com)\n- Your `channelId` and `TSID`\n  For more info about how to get `channelId` and `TSID` read the [Getting the `channelId` and `TSID`]() sections (last section in this document).\n\nYou can add the Trustbadge widget to your Android project in 2 steps:\n\n1. [🐘 Implement the dependency](#1-🐘-implement-the-dependency)\n2. [🚀 Show the widget](#2-🚀-show-the-widget)\n\n### 1. 🐘 Implement the dependency\n- In your `app` module's `build.gradle` file, add the following line in your dependencies block:\n```kotlin\ndependencies {\n    implementation(\"com.etrusted.android.trustbadge.library:(version))\")\n}\n```\n- replace (version) with the latest version of the library. (See the releases page).\n- Sync the project and make sure it is successful. If it is not, please make sure that the configuration file is placed under project root directory (e.g. not inside the `app` module's directory)\n\n### 2. 🚀 Show the widget:\nWe recommend using Jetpack Compose to show the widget in your app.\n\n---\n#### Jetpack Compose Sample (Fastest):\n\n\u003cbr /\u003e\n\nUse the Trustbadge Compose function anywhere in your composables:\nExample of showing the `ShopGrade` widget:\n```kotlin\nTrustbadge(\n    badgeContext = TrustbadgeContext.ShopGrade,\n    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n)\n```\n\u003cimg src=\"docs/img/shop_grade.gif\" height=\"100\"\u003e\n\n\u003cbr /\u003e\n\nFor `ProductGrade`, it is required to provide the product `sku` as well, that way the widget shows the rating for a product with given `sku`:\n```kotlin\nTrustbadge(\n    badgeContext = TrustbadgeContext.ProductGrade(sku = \"1234-Ti-Bl\"),\n    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n)\n```\n\u003cimg src=\"docs/img/product_grade.gif\" height=\"100\"\u003e\n\n\u003cbr /\u003e\n\nShowing `BuyerProtection` widget, is also similar to the `ShopGrade`:\n```kotlin\nTrustbadge(\n    badgeContext = TrustbadgeContext.BuyerProtection,\n    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n)\n```\n\u003cimg src=\"docs/img/guarantee.gif\" height=\"100\"\u003e\n\n\u003cbr /\u003e\n\nAlign the badge anywhere in its parent using a standard `Modifier`. For example:\n```kotlin\nTrustbadge(\n    modifier = Modifier.align(Alignment.BottomStart),\n    badgeContext = TrustbadgeContext.ShopGrade,\n    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n)\n```\n\n\u003cbr /\u003e\n\nControl hiding or showing the badge using the `TrustbadgeState`:\n```kotlin\nval badgeState = rememberTrustbadgeState()\n\nTrustbadge(\n    state = badgeState,\n    badgeContext = TrustbadgeContext.ShopGrade,\n    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n)\n\n// then badgeState can be used in desired events\nLaunchedEffect(null) {\n    \n    // show the badge\n    badgeState.show()\n\n    // hide the badge\n    badgeState.hide()\n}\n```\n\nFor example, hide the badge when the user scrolls using the badge state and scroll state of a column:\n```kotlin\n@Composable\ninternal fun HideBadgeOnScroll(\n    scrollState: ScrollState,\n    badgeState: TrustbadgeState\n) {\n    if (scrollState.value == 0) {\n        badgeState.show()\n    } else {\n        LaunchedEffect(null) {\n            delay(1000)\n            badgeState.hide()\n        }\n    }\n}\n```\n\u003cimg src=\"docs/img/hide_on_scroll.gif\" height=\"100\"\u003e\n\nFor full example of hiding the badge when the user scrolls, see [`HomeScreen.kt`](app/src/main/java/com/etrusted/android/trustbadgeexample/ui/home/HomeScreen.kt) in the example app.\n\n\u003cbr /\u003e\n\n---\n#### Legacy XML Sample (Requires more configuration):\nUsing the Legacy UI system requires more steps to show the widget:\n\nFirst, add a `ComposeView` tag in your layout's XML file, for example:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003candroidx.compose.ui.platform.ComposeView\n        android:id=\"@+id/compose_view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\" /\u003e\n\n\u003c/LinearLayout\u003e\n```\n\nThen in your source file, inflate the layout and get the `ComposeView` using the XML ID, set a composition strategy that works best for you and call the `setContent()` to use Compose.\nExample of loading the Trustbadge in a fragment:\n```kotlin\noverride fun onCreateView(\n        inflater: LayoutInflater,\n        container: ViewGroup?,\n        savedInstanceState: Bundle?\n    ): View {\n        _binding = FragmentExampleBinding.inflate(inflater, container, false)\n        val view = binding.root\n        binding.composeView.apply {\n            // Dispose of the Composition when the view's LifecycleOwner\n            // is destroyed\n            setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)\n            setContent {\n                // In Compose world\n                Trustbadge(\n                    badgeContext = TrustbadgeContext.ShopGrade,\n                    tsid = \"X330A2E7D449E31E467D2F53A55DDD070\",\n                    channelId = \"chl-b309535d-baa0-40df-a977-0b375379a3cc\"\n                )\n            }\n        }\n        return view\n    }\n```\nFor more information about Compose interoperability with the legacy system, please refer to [Android official docs for Interoperability APIs](https://developer.android.com/jetpack/compose/interop/interop-apis).\n\n\u003cbr /\u003e\n\n### Dark Mode\nThe Trustbadge Widget now supports Dark Mode on Android.\nBy default, the widget will follow the system theme.\n\n\u003cimg src=\"docs/img/screenshot-trustbadge-uncertified-dark.png\" height=\"400\" /\u003e\n\nTo override the system theme, you can force the widget to use Dark Mode by wrapping the `Trustbadge` composable in a `TrustbadgeTheme` and setting the `darkTheme` parameter to `true` in the `TrustbadgeTheme`.\n\nExample of overriding the system theme to Dark Mode:\n```kotlin\nTrustbadgeTheme(darkTheme = true) {\n    Trustbadge(...)\n}\n```\n\nFor more information about forcing Dark Mode, please refer to [Android official docs for Force Dark](https://developer.android.com/develop/ui/views/theming/darktheme#force-dark).\n\n\u003cbr /\u003e\n\n---\nYour eTrusted `account` might contain more than one `channel`. The `Trustbadge` function requires a `channelId` to determine which channel it should choose to load the information from your `account`.\nPlease read the section [Getting `channelId` and `TSID`]() for more information about how to get that information.\n\nThe `Trustbadge` function requires a `badgeContext` to determine either showing the `TrustMark`, the `ShopGrade`, or the `BuyerProtection` widget.\nYou can simply pass either of the following options to set your desired `badgeContext`:\n\n```\n- TrustbadgeContext.TrustMark\n- TrustbadgeContext.ShopGrade\n- TrustbadgeContext.ProductGrade\n- TrustbadgeContext.BuyerProtection\n```\n\n## Getting `channelId` and `TSID`\n- You can find your `channelId` by navigating to your desired channel on [eTrustd Control Center](https://app.etrusted.com) in your browser. You can simply copy the `channelId` from the address bar (starts with `chl-`) for your desired channel as shown in the example image:\n\n\u003cimg width=\"500\" src=\"https://user-images.githubusercontent.com/27926337/215760110-6d00a5ec-3b0c-4458-a867-acf75d6afa8b.png\"\u003e\n\n- If you don't have a `TSID` (usually shared during the onboarding process with Trusted Shops), You can get your `TSID` by contacting Trsuted Shop via email: members@trustedshops.com\n\n## Support\nPlease [let us know](https://github.com/trustedshops-public/etrusted-android-trustbadge-library/issues) if you\nhave suggestions or questions. You may also contact Trusted Shop's mobile engineering team via email: mobileapp@trustedshops.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrustedshops-public%2Fetrusted-android-trustbadge-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrustedshops-public%2Fetrusted-android-trustbadge-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrustedshops-public%2Fetrusted-android-trustbadge-library/lists"}