Giter Site home page Giter Site logo

taltstidl / appcompat-extension-library Goto Github PK

View Code? Open in Web Editor NEW
304.0 11.0 42.0 2.87 MB

A library that builds on the AppCompat Design Library and provides additional common components such as AccountHeaderView, FloatingActionMenu, CircleImageView, Picker Dialogs, FlexibleToolbarLayout, Delightful Detail Drawables and TypefaceCompat.

License: Apache License 2.0

Java 100.00%
android material-design appcompat floatingactionmenu picker-dialogs navigation-drawer collapsingtoolbarlayout drawable roboto-fonts

appcompat-extension-library's Introduction

Latest Release API ![License](https://img.shields.io/badge/license-Apache 2.0-brightgreen.svg?style=flat)

AppCompat-Extension-Library

Header Graphics for the AppCompat Extension Library

Google's AppCompat Design Library provides some awesome components for your development and design needs. For some applications though those just aren't enough. This library tries to fill the gap and provides additional common components building on the official AppCompat Design Library. If you have any additional features you'd like to see as part of this ongoing effort feel free to open a new issue.

Currently there are the following components:

There are wikis for every component that explain the setup in more depth, so be sure to check them out. Here's a link to the Wiki Home Page

Importing the library

This library is available as a gradle dependency via JitPack.io. Just add the following lines to your app module build.gradle:

repositories { 
    maven { url "https://jitpack.io" }
}
dependencies {
    compile 'com.github.TR4Android:AppCompat-Extension-Library:v0.5.1'
}

The latest Release is Release 0.5.1. You can download a sample.apk with this release.

AccountHeaderView

The AccountHeaderView is a component that allows easy switching between accounts in the navigation drawer by clicking on the avatars on the header or by choosing from the dropdown list.

Main features:
  • Works seamlessly with the AppCompat Design Library's NavigationView so you have full access to its features and can easily switch to an official account header implementation as soon as Google releases it.
  • Includes a dropdown list of accounts (and optionally account addition and managment items) by hooking up to the internal ListView of the AppCompat Design Library's NavigationView in an almost magical way!
  • Automatically creates placeholder avatars with the name's initials when an image is not set to an Account (see Google's Gmail).
Basic setup:

Use the following layout as the app:headerLayout of the AppCompat Design Library's NavigationView:

<com.tr4android.support.extension.widget.AccountHeaderView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="@drawable/account_header_cover_background"
    android:layout_width="match_parent"
    android:layout_height="@dimen/account_header_height" />

Then add your accounts to the AccountHeaderView and add a listener for account selections:

accountHeaderView.addAccounts(new Account().setName("TR4Android").setEmail("[email protected]").setIconResource(R.drawable.account_drawer_profile_image_tr4android), ...);
accountHeaderView.setAccountSelectedListener(new AccountHeaderView.OnAccountSelectedListener() {
    @Override
    public void onAccountSelected(Account account) {   }

    @Override
    public void onAccountAddSelected() {   }

    @Override
    public void onAccountManageSelected() {   }
});

For the full documentation and customization options head over to the AccountHeaderView wiki.

FloatingActionMenu

The FloatingActionMenu is a wrapper for multiple FloatingActionButtons that takes the first FloatingActionButton as the main button that stays on screen and flings out all other FloatingActionButtons in speed dial fashion.

Main features:
  • Uses the AppCompat Design Library FloatingActionButton and thus has native elevation on Lollipop and above devices and even a shadow animation on pre-Lollipop devices!
  • Allows easy configuration of you main FloatingActionButton's icon animation: apply any rotation and optionally an alpha transition to a second icon (see Google's Inbox).
  • Works on all devices back to API level 7 just like the AppCompat Design Library!
Basic setup
<com.tr4android.support.extension.widget.FloatingActionMenu
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom" >
    
    <!-- Floating Action Buttons -->
    
</com.tr4android.support.extension.widget.FloatingActionMenu>

For the full documentation and customization options head over to the FloatingActionMenu wiki.

CircleImageView

The CircleImageView is a supercharged ImageView that provides the ability to set circular images as well as placeholders.

Main features:
  • Creates circular images using the AppCompat Support Library's RoundedBitmapDrawable which provides the best performance possible by using Romain Guys techniques!
  • Allows easy creation of placeholders with a colored circle and a letter (or letters) or an icon if an image should not available (see Google's Gmail email avatars).
Basic setup:

Instead of the default ImageView use the following in your layouts:

<com.tr4android.support.extension.widget.CircleImageView
    android:layout_width="40dp"
    android:layout_height="40dp" />

Then use setImage...() to set a circular image or setPlaceholder() to set a placeholder.

For the full documentation and customization options head over to the CircleImageView wiki.

Picker Dialogs

The AppCompatDatePickerDialog and AppCompatTimePickerDialog are native Android implementations of the picker dialogs detailed in the official Material Design guidelines.

Main features:

  • Uses the design presented in the Pickers section of the Material Design guidelines for a fully Material Design compliant user experience!
  • Works all the way back to API level 7 while maintaining important features (such as accessibility and right-to-left support) on API levels that support those.

Basic setup:

Setup your app theme by including the following lines (for dark themes remove the .Light part):

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- other attributes -->
    <item name="datePickerDialogTheme">@style/Theme.AppCompat.Light.DatePickerDialog</item>
    <item name="timePickerDialogTheme">@style/Theme.AppCompat.Light.TimePickerDialog</item>
</style>

Then use the AppCompatDatePickerDialog or AppCompatTimePickerDialog inside a DialogFragment (this example shows the AppCompatDatePickerDialog, but the process is quite similiar with the AppCompatTimePickerDialog):

public static class DatePickerFragment extends DialogFragment implements AppCompatDatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // Create a new instance of AppCompatDatePickerDialog and return it
        return new AppCompatDatePickerDialog(getActivity(), this, 2017, 3, 13);
    }

    public void onDateSet(AppCompatDatePicker view, int year, int month, int day) {
        // Do something with the date chosen by the user
    }
}

And later show this DialogFragment anywhere you need it:

DialogFragment datePicker = new DatePickerFragment();
datePicker.show(getSupportFragmentManager(), "datePicker");

For the full documentation and customization options head over to the Picker Dialogs wiki.

FlexibleToolbarLayout

The FlexibleToolbarLayout is a more advanced alternative to the already powerful CollapsingToolbarLayout that excels by also providing a scaled icon and subtitle along with the title.

Main features:
  • Collapses more than just a title! You can display a title, a subtitle and even an image which will all be scaled and animated while scrolling and you can style them to fit your personal needs.
  • Introduces more advanced elevation handling. The elevation you specified will no longer disappear when you have a solid background, but it still will if you have an immersive image.
Basic setup:
<android.support.design.widget.CoordinatorLayout>
    ...
    <android.support.design.widget.AppBarLayout>
        
        <com.tr4android.support.extension.widget.FlexibleToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:title="My title"
            app:subtitle="My subtitle"
            app:icon="@drawable/ic_my_icon"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin" />
        </com.tr4android.support.extension.widget.FlexibleToolbarLayout>
    </android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>

Then update your FlexibleToolbarLayout at runtime by using setTitle(), setSubtitle or setIcon().

For the full documentation and customization options head over to the FlexibleToolbarLayout wiki.

Delightful Detail Drawables

The Delightful Detail Drawables provide ready-to-use implementations of the beautifully crafted animations presented in the Delightful Details section of the Material Design guidelines.

Main features:
  • Let your users control their media with style by using the MediaControlDrawable which animates between the icons for media playback control (play, pause and stop) and works back to API level 7.
  • Indulge your users while they are waiting for their content to load by using the IndeterminateProgressDrawable which provides a compatibility implementation of the progress animation that works back to API level 7.
Basic setup:
// build a new MediaControlDrawable
final MediaControlDrawable drawable = new MediaControlDrawable.Builder(this)
        .setColor(Color.WHITE) // ... more options
        .build();
// build a new IndeterminateProgressDrawable
final IndeterminateProgressDrawable drawable = new IndeterminateProgressDrawable.Builder(this)
        .setColor(Color.WHITE) // ... more options
        .build();

For the full documentation and customization options head over to the Delightful Detail Drawables wiki.

TypefaceCompat

The TypefaceCompat utility has been removed in version 0.5.0 of this library. The official downloadable fonts or FontsContractCompat should be used instead. While apps will continue to compile, the Roboto typeface will no longer be applied on pre-Lollipop devices as the associated resources have been removed to conserve space.

The TypefaceCompat is a utility for supporting the newest Typography. It automatically sets the text size, color and typeface for the styles specified in the guidelines.

Main features:
  • Easily setup with one line of code in your Activity.
  • Use one of the TextAppearance.AppCompat.xxx styles or use your own styles!
  • Automatically sets textSize, textColor and fontFamiliy for the TextAppearance.AppCompat.xxx styles and loads the new Roboto typeface on pre-Lollipop devices using a cache!
Basic setup:

In your Activity (for ease of use in your BaseActivity, if you have one) add the following line before super.onCreate():

public class SampleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        TypefaceCompatFactory.installViewFactory(this);
        super.onCreate(savedInstanceState);
        ...
    }
}

Then use one of the TextAppearance.AppCompat.xxx styles via android:textAppearance="@style/TextAppearance.AppCompat.xxx" on your TextViews.

To achieve the correct line height use one of the predefined line_spacing_extra_xxx values via android:lineSpacingExtra="@dimen/line_spacing_extra_xxx" on your TextView.

For the full documentation and customization options head over to the TypefaceCompat wiki.

License

Copyright 2015 Thomas Robert Altstidl & fountaingeyser

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.

For the licenses of the dependencies check out the Licenses wiki.

appcompat-extension-library's People

Contributors

athospg avatar fountaingeyser avatar taltstidl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appcompat-extension-library's Issues

Date select Is not correct

public void onDateSet(AppCompatDatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
Toast.makeText(getContext(), "year="+year+"month="+month+"day="+day, Toast.LENGTH_SHORT).show();
}

The month is not corrent.For example,the current month is12,it will show 11.

Improve FlexibleToolbarLayout

There are a few things I'd like to do before releasing this:

  • Better right-to-left support
  • Methods for manually expanding and collapsing the FlexibleToolbarLayout (might be useful for choreographed transitions)

Add FlexibleToolbarLayout

The Design Support Library has a component called CollapsingToolbarLayout which is quite cool when used with a parallax image and only text. I can think of a few annoyances though, that I'd like to fix in my own version of this (FlexibleToolbarLayout):

  • The CollapsingToolbarLayout only allows text to be scaled. While this is enough for some cases, I'd like to be able to use an image, a title and a subtitle (much like in Telegram Messenger).
  • The CollapsingToolbarLayout doesn't render a shadow when not completely collapsed, even when there's no image involved, just a solid color.
  • The CollapsingToolbarLayout doesn't respond to touches within itself.

Pre lollipop problems

Hi, first let me say that I love your library but i'm having problems, even with your sample app your library doesn't seem to work on pre lollipop devices.

Show NullPointerException

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.tr4android.support.extension.drawable.ColorTransitionDrawable.setColorRatio(float)' on a null object reference

I have use updated version of android studio Android Studio Dolphin 2021.3.1 Patch 1.

Android studio previous version is proper work but after update show anytime NullPointerException.

Add MusicControlDrawable

This would be an implementation of the animation presented in the Delightful Details section of the Google Design guidelines. While only few developers will probably need this, it would still be cool to have it for those who do.

Improve FloatingActionMenu

Any other suggestions for improving the FloatingActionMenu? Feel free to comment below!

Checklist for Release 0.4.0:

  • The animation isn't quite the same as the Speed dial presented in the Material Design Guidelines
  • The labels should have elevation and state support (along with show and hide() methods for animation purposes), this will probably result in a new LabelView
  • The RotationTransitionDrawable should also rotate pre-Honeycomb with the help of the new ValueAnimatorCompat
  • The attributes should include one which allows you to customize the distance between buttons

Improve TypefaceCompat

Currently the TypefaceCompat implementation has a lot of .ttf files in the assets folder leading to larger apk sizes. It would be good to reduce the number of supported typefaces to a minimum while ensuring that all basic typography features are still implemented.
Also, the documentation need to be vastly improved (there currently is none 😁)

Checklist for Release 0.4.0:

  • Ability to properly detect system typefaces (see pull request #19)
  • Documentation

Improve AccountHeaderView

The AccountHeaderView will get a new set of additional features (see checklist below). If you have any additional requests for this component, please bring them forward in this issue. Thanks!

Checklist for Release 0.4.0:

  • Ability to make accounts selectable (via checkboxes)
  • Ability to show extra info on accounts (icon and text) to e.g. display unread message counts

Support for AppCompat 23.1.0

As expected, this release breaks a couple of things in my library (especially since they switched the NavigationView to use a RecyclerView now). I'm actively working on resolving those issues and getting a new release out as soon as possible. Hang in there 😃!

更新UI时,界面闪烁。

执行以下2句代码的时候,app界面会看见floatingActionMenu闪烁几次。
1、floatingActionMenu.removeButton(fab);
2、floatingActionMenu.addButton(fab);

希望在floatingActionMenu关闭的时候更新UI时,界面不闪烁。

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.