• Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Decoupling resource declaration from resource resolution on Android.

Deferred Resources

An Android library that decouples resource declaration (without Context) from resource resolution (with Context). This allows the resolver (Activity, Fragment, or View) to be agnostic to the source (standard resources, attributes, or values fetched from an API), and allows repository/configuration layers to remain ignorant of Android's Context.

See the project website for API documentation.

Download

Maven Central

Deferred Resources is available on Maven Central. Snapshots of the development version are available in Sonatype's Snapshots repository.

implementation "com.backbase.oss.deferredresources:deferred-resources:$version"
implementation "com.backbase.oss.deferredresources:deferred-resources-view-extensions:$version"
implementation "com.backbase.oss.deferredresources:deferred-resources-compose-adapter:$version"
implementation "com.backbase.oss.deferredresources:deferred-resources-animation-lottie:$version"

Use

In the logic layer, declare the resource values however you like, without worrying about their resolution or about Context:

class LocalViewModel : MyViewModel {
    override fun getText(): DeferredText = DeferredText.Resource(R.string.someText)
    override fun getTextColor(): DeferredColor = DeferredColor.Attribute(R.attr.colorOnBackground)
    override fun getTextSize(): DeferredDimension = DeferredDimension.Attribute(R.attr.bodyTextSize)
}

class RemoteViewModel(private val api: Api) : MyViewModel {
    override fun getText(): DeferredText = DeferredText.Constant(api.fetchText())
    override fun getTextColor(): DeferredColor = DeferredColor.Constant(api.fetchTextColor())
    override fun getTextSize(): DeferredDimension =
        DeferredDimension.Constant(api.fetchTextSize(), DeferredDimension.Constant.Unit.SP)
}

In the view layer, resolve a deferred resource to display it:

val text: DeferredText = viewModel.getText()
val textColor: DeferredColor = viewModel.getTextColor()
val textSize: DeferredDimension = viewModel.getTextSize()
textView.text = text.resolve(context)
textView.setTextColor(textColor.resolve(context))
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, deferredSize.resolveExact(context))

With view extensions, this is even simpler:

textView.setText(viewModel.getText())
textView.setTextColor(viewModel.getTextColor())
textView.setTextSize(viewModel.getTextSize())

Text types

Various types of text are supported: DeferredText for basic text, DeferredFormattedString for formatted text, DeferredPlurals for pluralized text, and DeferredFormattedPlurals for formatted, pluralized text. Additionally, it's possible to "partially resolve" these more complex text types to be more basic without yet having a Context.

val deferredFormattedPlurals = DeferredFormattedPlurals.Resource(R.plurals.formatted_plurals)

// If you have the format args, quantity, and Context:
val string: String = deferredFormattedPlurals.resolve(context, 5, "million")

// If you have the format args and quantity, but no Context:
val deferredText: DeferredText = deferredFormattedPlurals.withQuantityAndFormatArgs(5, "million")

// If you have only the quantity:
val deferredFormattedString: DeferredFormattedString = deferredFormattedPlurals.withQuantity(5)

// If you have only the format args:
val deferredPlurals: DeferredPlurals = deferredFormattedPlurals.withFormatArgs("million")

All text-related types can eventually be converted to DeferredText through similar extensions.

Jetpack Compose UI

For each Deferred Resources type, the experimental deferred-resources-compose-adapter library offers a remember* function to resolve the Deferred item to a standard Compose UI type.

val color: Color = rememberResolvedColor(deferredColor)
val size: Dp = rememberResolvedDp(deferredDimension)
val icon: Painter = rememberResolvedPainter(deferredDrawable)

All of these APIs are marked as @ExperimentalComposeAdapter and should not be considered stable. Their behavior and binary compatibility are not guaranteed.

Lottie animations

For each Drawable type, the deferred-resources-animation-lottie library offers a new DeferredLottieDrawable class which resolves Lottie files into a LottieDrawable. This API is useful if one wishes to configure animations in their app.

License

Copyright 2020 Backbase R&D, B.V.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

backbase-openapi-tools

Backbase Open Api Tools (boat) helps manage large OpenAPI projects
Mustache
42
star
2

golden-sample-services

This project is a development of a small set of [Backbase Service SDK](https://community.backbase.com/documentation/ServiceSDK/latest/index), Spring Boot and Spring Cloud based Microservices projects that implement microservices design patterns, cloud-native recommendations, and coding best practices.
JavaScript
37
star
3

bb-cli

Command line tools for working with Backbase CXP.
JavaScript
33
star
4

variants

A command-line tool to setup deployment variants for iOS and Android, alongside a working CI/CD setup.
Swift
31
star
5

stream-services

Stream Services are an Open-Source accelerator to connect with Backbase "out-of-the-box" components responsible for orchestrating calls to Banking Services.
Java
26
star
6

golden-sample-app

This example project is a reference implementation to showcase a number of best practices to use when building a new Angular SPA that leverages Backbase components and libraries.
TypeScript
25
star
7

bb-fuel

Backbase DBS data loader tool for test and demo data.
Java
17
star
8

mosaic-rest-js

Javascript library for connecting to portal REST API, browser and nodeJS compatible
JavaScript
13
star
9

blade

The Backbase Local Application Development Environment (Blade) is a convenience plugin to run WAR files in an embedded Tomcat container.
Java
10
star
10

docker-compose-examples

A set of Docker compose files to demo Backbase docker images
Shell
10
star
11

helm-k8s-local

helm-k8s-local
Shell
8
star
12

bb-lp-cli

JavaScript
8
star
13

documentation-code-samples

Java
7
star
14

golden-sample-app-android

This example project is a reference implementation to showcase a number of best practices to use when building a new Android journey that leverages Backbase components and libraries.
Kotlin
6
star
15

project-golden-samples

Golden Samples for CS Project specific use cases
HTML
6
star
16

boat-bay

Java
4
star
17

backend-interview-snippets

Code snippets used in interviews with backend developers
Java
4
star
18

twilio-integration-service

Twilio integration service demo for Backbase DBS
Java
4
star
19

angular-devkit

TypeScript
4
star
20

bb-bower-resolver

Backbase Launchpad resolver for bower
JavaScript
4
star
21

blimp

Backbase Liquibase Integration Maven Plugin
Java
4
star
22

amazon-ses-connector

This service is used by the Message Delivery capability, and provides integration to Amazon SES for sending emails.
Java
4
star
23

filesystem-bower-resolver

Filesystem resolver for bower
JavaScript
4
star
24

engagements-data

Build docker image with pre-populated Engage Defaults and can be customised with customer-specific settings and used by Provisioner and this is part of Digital Engage product (Engagements Capability).
HTML
4
star
25

twilio-sms-connector

This service is used by the Message Delivery capability, and provides integration to Twilio Messaging for sending SMS.
Java
4
star
26

stream-mambu

Java
3
star
27

arrangement-behaviour-extension

Java
3
star
28

fiserv-integration-bill-pay

Fiserv CheckFree integration service demo for Backbase DBS Bill Pay.
Java
3
star
29

install-bash-script

Backbase IPS and CX6 services installation in Tomcat via bash script
Shell
3
star
30

symitar-core-banking-client

A backend accelerator library supporting integrations for Jack Henry's Symitar core.
Java
3
star
31

workflows

Reusable GitHub Actions Workflows for Backbase Opensource
3
star
32

api-simulator

A service that's capable of registering itself in a service registry and simulate request handling based solely on an API specification and the examples it contains.
Java
3
star
33

event-emitter

Event emitter allows you to produce testing events using REST to the underlying message broker.
Java
3
star
34

golden-sample-app-ios

The golden sample app provides a opportunity to show samples, examples and best practices internally and externally of Backbase methods, processes and the Backbase way of working.
Swift
3
star
35

bb-k8s-operator

A Kubernetes Operator to import statics
Java
3
star
36

meta-maven-plugin

Java
2
star
37

space-generator

Java
2
star
38

mock-channel-connector

This service is used by the Message Delivery capability for mocking any channel.
Java
2
star
39

backbase-services-toolkit

Provides a convenient, consistent and automated tool to enable Backbase backend developers to build services faster.
Kotlin
2
star
40

backend-live-coding-interview-1

Java
2
star
41

designsystem.backbase.io

HTML
2
star
42

backbase.github.io

Backbase Engineering Blog – markdown-based blog for Backbase engineers to share knowledge with community
TypeScript
1
star
43

accelerator-project-guides

OpenSource at Backbase
1
star
44

mx-integration-transactions

MX integration service demo for transaction categorization in Backbase DBS Transactions.
Java
1
star
45

bitrise-step-security-checks

Shell
1
star
46

payment-order-integration

Example code for payments integration service.
Java
1
star
47

.github

OpenSource at Backbase
1
star
48

notifications-create-global-notification-extension

Java
1
star
49

local-backend-setup

Java
1
star
50

cs-na-workshop

TypeScript
1
star
51

payments-examples

Various examples of payments integration, extension and configuration
Java
1
star
52

payments-batch-integration-sample

Java
1
star
53

access-control-generate-clients

Java
1
star
54

experience-dockerization-ref

An example of how to configure your project to dockerize an existing application
TypeScript
1
star
55

drive-wealth-connector

This project provide accelerator for wealth integration services using Yahoo Finance as Market News provider Drive-wealth integration as wealth provider
Java
1
star
56

scdf-maven-plugin

Java
1
star
57

flow-mobile-templates

Kotlin
1
star
58

contact-manager-extension

This example shows you how to modify the default behavior of the Contacts presentation service.
Java
1
star
59

ParcelableTest

A small Android test library that makes it easy to test Parcelables.
Java
1
star
60

marqueta-cards-service

Java
1
star
61

eslint-plugin-no-old-dependencies

ESLint plugin which checks if correct version of common library is used by other libraries
TypeScript
1
star
62

sample-service-with-access-control

Java
1
star
63

gc-ai-transformer

OpenSource at Backbase
1
star
64

fastlane-plugin-release_notes_generator

A fastlane plugin to generate release notes
Ruby
1
star
65

bb-protractor-accessibility-plugin

TypeScript
1
star
66

WhatsNewJourney

An example journey that showcases how Remote Config’s feature toggles can be used to also provide feature discovery to new features through remote content.
Swift
1
star