Giter VIP home page Giter VIP logo

material-about-library's Introduction

#material-about-library

Release Apache License 2.0

Makes it easy to create a beautiful about screen for your app. Generates an activity or fragment.

Idea from here: Heinrich Reimer's open-source-library-request-manager

Design inspired by Phonograph.

Demo

Get it on Google Play

Screenshots

| Demo App | Example | |:-:|:-:|:-:|:-:| | Demo App | Monitor | | ExampleMaterialAboutActivity.java | Monitor |

Features

  • Material design
  • Modular backend
  • Easy to implement
  • Simple but intuitive API

Dependency

material-about-library is available on jitpack.io

Gradle dependency:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    compile 'com.github.daniel-stoneuk:material-about-library:1.3.0'
}

Setup

Fragment tutorial coming soon, check out the demo app in the meantime

Step 1: Your Activity must extend MaterialAboutActivity and be in your AndroidManifest.xml:

public class ExampleMaterialAboutActivity extends MaterialAboutActivity {

    @Override
    protected MaterialAboutList getMaterialAboutList() {
        return new MaterialAboutList.Builder()
                .build();
    }
    
    @Override
    protected CharSequence getActivityTitle() {
        return getString(R.string.mal_title_about);
    }

}

Ensure that the theme extends 'Theme.Mal', and apply primary & accent colours.

<manifest ...>
    <application ...>
        <activity android:name=".ExampleMaterialAboutActivity"
            android:theme="@style/AppTheme.MaterialAboutActivity"/>
    </application>
</manifest>
    <style name="AppTheme.MaterialAboutActivity" parent="Theme.Mal" >
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Step 2: Add Cards:

Start building a "card" using MaterialAboutCard.Builder()

public class ExampleMaterialAboutActivity extends MaterialAboutActivity {

    @Override
    protected MaterialAboutList getMaterialAboutList() {
        MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

Give the card a title by calling .title on the Builder

        authorCardBuilder.title("Author");

Step 3: Add Items:

There are currently two types of item you can add to a card - MaterialAboutTitleItem and MaterialAboutActionItem. Planned items include "person" items which feature buttons to showcase a single person. Feel free to submit a PR or Issue for more item ideas.

  • MaterialAboutActionItem: Standard item with text, icon and optional subtext.
  • MaterialAboutTitleItem: Larger item with large icon (eg app icon) and larger text.

MaterialAboutTitleItem is created with MaterialAboutTitleItem.Builder() and lets you specify text and an icon.

        appCardBuilder.addItem(new MaterialAboutTitleItem.Builder()
                .text("Material About Library")
                .icon(R.mipmap.ic_launcher)
                .build());

MaterialAboutActionItem is created with MaterialAboutActionItem.Builder() and lets you specify text, sub-text, an icon and an OnClickListener.

        appCardBuilder.addItem(new MaterialAboutActionItem.Builder()
                .text("Version")
                .subText("1.0.0")
                .icon(R.drawable.ic_about_info)
                .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                    @Override
                    public void onClick() {
                        Toast.makeText(ExampleMaterialAboutActivity.this, "Version Tapped", Toast.LENGTH_SHORT).show();
                    }
                })
                .build());

Step 4: Return the list: Create a MaterialAboutList using MaterialAboutList.Builder(), passing in the cards you would like to display.

        return new MaterialAboutList.Builder()
                .addCard(supportCardBuilder.build())
                .build();
    }
}

Check out a working example in ExampleMaterialAboutActivity.java.

Tip: You can either use Strings / Drawables or Resources when creating MaterialAboutItem's

License

Copyright 2016 Daniel Stone

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.

material-about-library's People

Contributors

daniel-stoneuk avatar alouanemed avatar

Watchers

Soussi  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.