Android library to display libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Fynn Godau 055432e71e Fix clipped layout, flatify layout 1 month ago
app Fix clipped layout, flatify layout 1 month ago
demo Pass Locale object to Translator instead of String 4 months ago
gradle/wrapper Upgrade gradle and android plugin version 6 months ago
.gitignore Add gradle properties file 6 months ago
LICENSE License under CC0 11 months ago
README.md Documentation for upcoming version 4 months ago
build.gradle Add new header and translator views and configurations 4 months ago
gradle.properties Add gradle properties file 6 months ago
gradlew Add gradle wrapper (maybe?) 11 months ago
screenshot.png Documentation for upcoming version 4 months ago
settings.gradle Add demo app module 6 months ago

README.md

aboutDirect

A library to display an about screen in an Android app. It was created for use with other Direct projects but may be used independently as well.

minSdkVersion 14
targetSdkVersion 28

Including in your project

Please use Jitpack to download compiled AAR packages. See how here.

Usage

Getting an Intent

To call AboutDirectActivity, you have to use the builder class AboutDirectActivity.IntentBuilder like seen here:

new AboutDirectActivity.IntentBuilder(context, R.string.app_name, BuildConfig.VERSION_NAME)
    .setContent(…)
    .build();

These are the calls that you can use to configure the builder class:

setContent(Object[])

Pass an array of Objects.

Valid Objects are:

  • Artwork
  • Fork
  • Library
  • License
  • OwnLicense
  • Translator

Each Object will be displayed by the About screen. All of them have similar constructors and look slightly different to each other when viewed.

For example, here's how a library is constructed:

new Library(String name, License license, @Nullable String foreword, String author, String url)
  • name: Name of the library
  • license: A license object. The License class has a small selection of licenses already hardcoded for you, including MIT and Apache 2.0, but you can construct your own license using new License(String name, String licenseText) as well.
  • foreword: Some people put one line or two of copyright statement above their paste of e.g. the MIT license. Use the foreword string in that case, or pass null.
  • author: Should fit into this sentence: "author is distributing this library."
  • plural (optional): Whether author is a word that needs to be referred to in plural
  • url: The website that the library can be found at. May be null, in that case the "open externally" button will be hidden.

For example, if you wanted to credit aboutDirect, add this line to your Library array:

new Library("aboutDirect", License.CC0_LICENSE, null, "Fynn Godau", "https://codeberg.org/fynngodau/librariesDirect"),

setIcon(@DrawableRes int)

Pass an icon resource to display it at the top to the left of the app's name.

setAppDeveloperName(String)

Pass the app developer's name to display it at the top below you app's name.

setAppDeveloperMastodon(String)

Pass a URL to display a Mastodon icon to the right of the developer's name that links to that URL.

setConsumer(ContextConsumer)

Pass an implementation of the ContextConsumer interface in case there is something you need to do after the activity has launched, like setting style dynamically.

Therefore, the activities Context is provided to you in the interface's accept(Context) method immediately before the layout is inflated.

Note that the ContextConsumer interface extends the Serializable interface. As such, all fields that your implementation has must also be Serializable. If you create a ContextConsumer implementation as a non-static inner class of an Activity (possibly by creating an anonymous class), the app will crash.

build()

Once you are done, call build() on the builder class to receive an Intent which you can start using startActivity(…).

Version 3 migration

  • The namespace of some classes changed. You need to fix your imports.
  • Consider switching to AboutDirectActivity instead of AboutLibrariesActivity. AboutLibrariesActivity has been deprecated and may be removed in a future release.

License

Because I think it would have been annoying to have to credit a library that is used to credit libraries, this library is licensed under CC0; no credits are required, even though they are welcome.

Screenshot

Screenshot