Colorful


Source link: https://github.com/garretyoder/Colorful

Colorful

Colorful is a dynamic theme library allowing you to change your apps' color schemes easily.

License

Colorful is licensed under the Apache 2.0 License, in common Android style.

Copyright 2016 Garret Yoder

Installation

Add jitpack to your maven sources

allprojects {

  repositories {

...

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

  
}
 
}

Add Colorful as a dependency to your build.gradle

dependencies {

  compile 'com.github.garretyoder:Colorful:1.1' 
}

Usage

In your Application class, you must initialize Colorful

public class SampleApp extends Application {

  @Override
  public void onCreate() {

super.onCreate();

Colorful.init(this);

  
}
 
}

Any Activity you wish to be themed must extend from CActivity

public class MainActivity extends CActivity

Alternatively you can call the following method after super.onCreate(savedInstanceState); and before setContentView();

Colorful.applyTheme(Activity activity);

You can also use Colorful.applyTheme(Activity activity, Boolean overrideBase); where overrideBase defines whether you want Colorful to override your base theme as well, or simply set the primary and accent colors. This allows you to use Colorful with your own pre-defined style, but will break light/dark functionality.

You can set the default theme colors Colorful will use with the defaults() method

public class SampleApp extends Application {

  @Override
  public void onCreate() {

super.onCreate();

Colorful.defaults()

  .primaryColor(Colorful.ThemeColor.RED)

  .accentColor(Colorful.ThemeColor.BLUE)

  .translucent(false)

  .dark(true);

Colorful.init(this);

  
}
 
}

You can set the colors at any time using the config method

Colorful.config(this)

  .primaryColor(Colorful.ThemeColor.RED)

  .accentColor(Colorful.ThemeColor.BLUE)

  .translucent(false)

  .dark(true)

  .apply();

After which you must call apply(); to save your changes

Colorful will handle saving and loading your theme preferences for you.

Color Chooser

Colorful has a inbuilt color chooser dialog that will return a ThemeColor object you can pass directly to Colorful

public class MainActivity extends CActivity {

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

setSupportActionBar(((Toolbar) findViewById(R.id.toolbar)));

 ColorPickerDialog dialog = new ColorPickerDialog(this);

dialog.setOnColorSelectedListener(new ColorPickerDialog.OnColorSelectedListener() {

 @Override

 public void onColorSelected(Colorful.ThemeColor color) {

  //TODO: Do something with the color

 
}

}
);

dialog.show();

  
}
 
}

Preference Item

Colorful has a inbuilt preference item that will automatically set Colorful's colors.

Use colorpicker:primary_color and colorpicker:accent_color to tell Colorful which value to set.


  <org.polaric.colorful.ColorPickerPreference

 android:title="@string/primary_color"

 android:summary="@string/primary_color_desc"

 colorpicker:primary_color="true"/>

 <org.polaric.colorful.ColorPickerPreference

 android:title="@string/accent_color"

 android:summary="@string/accent_color_desc"

 colorpicker:accent_color="true"/>

Screenshots

Resources

A helper class for Toolbar configuration.

Convalida is a simple, lightweight and powerful field validation library for Android.

This is a vertical seekbar like in the IOS 11 control center with an image at the bottom.

This is an Android library for cropping images. Move images smoothly, and crop images precisely.

Enjoy cropping!

An Android MVVM helper library which works really well with Android Data binding.

SweetPrefs alleviates the pain of using SharedPreferences on Android. It provides a simple interface to store and retrieve objects of any kind.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes