/about-icons

Android library to easily give credit if using icons which require attribution

Primary LanguageKotlinApache License 2.0Apache-2.0

Android About Icons Library

API Jitpack last commit license


About this project

This Android library simplifies the exhausting process of giving credits to licensed icons which require attribution (like icons from flaticon.com or fontawesome.com in the free plan).

YOU CAN DOWNLOAD THE SAMPLE APP here:

If you want to build the app on your own, build the debug build variant.

This was my very first library and I'm still a student so the progress might not be as fast as on other projects.

Features

  • automatically recognizing the icons to show based on file name (further information here)
  • automatically retrieving the information and credits by reading related string arrays (further information here)
  • automatically highlight icons who have been modified by reading related string entry (further information here)

How to use

1. Implementation

Add this to your root build.gradle file:

allprojects {
  repositories {
    maven { url "https://jitpack.io" }
  }
}

Then add this to your module's build.gradle file:

dependencies {
  implementation 'com.github.cyb3rko:about-icons:lastest-version'
}

2. Mark icons

Afterwards you have to add an underscore to every icon filename you want the library to attribute.
If you don't add an underscore, the icon is ignored.

Example:

3. Add information

Now you have to add the information the library needs for attributing.
Do this by adding a string array for each icon with the icon name as string array name (without the underscore; it doesn't matter in which .xml file):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string-array name="icon_alink">
        <item>Dave Gandy</item>
        <item>flaticon.com</item>
        <item>https://www.flaticon.com/free-icon/external-link-symbol_25284</item>
        <item>false</item>
        <item>cc_by_3.0</item>
    </string-array>

    <string-array name="icon_art">
        <item>xnimrodx</item>
        <item>flaticon.com</item>
        <item>https://www.flaticon.com/free-icon/computer_2905155</item>
    </string-array>
    ...
</resources>

4. Create view

At last just create a new AboutIcons object, pass the context and the drawable class, and get the view by calling get().
Optionally you can configure your AboutIcons page using following config methods:

.setTitle(customTitle: String)
.setTitleSize(customSize: Float)
.setModificationTitle(customTitle: String)
.setModificationTitleSize(customSize: Float)
.hideModificationAnnotation()

HINT: If you want to hide the title, simply call "setTitle("")", then the title layout will be hidden

Simple example for a fragment: Kotlin

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
    super.onCreateView(inflater, container, savedInstanceState)

    return AboutIcons(requireContext(), R.drawable::class.java, supportFragmentManager).get()
}

Java Activity

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new AboutIcons(this, R.drawable.class, getSupportFragmentManager()).get());
}

Advanced example (using configuration) for a fragment:
Kotlin:

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
    super.onCreateView(inflater, container, savedInstanceState)
    
    val aboutIcons = AboutIcons(requireContext(), R.drawable::class.java, supportFragmentManager)
            .setTitle("Your Title")
            .hideModificationAnnotation();

     return aboutIcons.get()
}

Java Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    AboutIcons aboutIcons = new AboutIcons(this, R.drawable.class, getSupportFragmentManager())
            .setTitle("Your Title")
            .setModificationTitleSize(6f)
            .hideModificationAnnotation();

    setContentView(aboutIcons.get());
}

Proguard Minify Compatibility

If you have minify enabled and you let it shrink the resources this library is most likely to not be able to find your icons you want to give credit to.

Then simply add the following to your proguard rules:

-keep class .R
-keep class **.R$* {
    <fields>;
}

Planned improvements

  • improving scroll performance
  • adding simple licensing information for several icon library websites

Screenshots

Contribute

Of course I'm happy about any kind of contribution.

Feel free to open issues for new features or bug reports. If you want to directly contribute code just open pull requests.

Apps using this library

If you want to add an app here, just open a new issue / PR.

LogViewer for openHAB by Cyb3rko

Used Libraries

Click here to see the list
Android Licenses Library by Cyb3rKo licensed under Apache License 2.0

Used Icons

Click here to see the list
Multiple Icons made by Freepik from www.flaticon.com
Multiple Icons made by Dave Gandy from www.flaticon.com

License

Copyright © 2022, Cyb3rKo

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.