Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.
/ MultiThemer Public archive

An Android Library that provides easy way to use as many app themes as you would like to

License

Notifications You must be signed in to change notification settings

Mini-Stren/MultiThemer

Repository files navigation

MultiThemer

Download License

An Android Library that provides easy way to use as many app themes as you would like to.

MultiThemer will save last used app's theme and restore it in app launch.

Demo

Get it on Google Play

Demo app using MultiThemer library is available in Google Play.

You can also check releases page for manual .apk download.

Source code for demo app is available here

Setup

Gradle

dependencies {
    compile 'com.github.ministren:multithemer:1.4.1'
}

Maven

<dependency>
  <groupId>com.github.ministren</groupId>
  <artifactId>multithemer</artifactId>
  <version>1.4.1</version>
  <type>pom</type>
</dependency>

Usage

Define your themes in styles.xml, or use up to 20 predefined themes in THEME enum class.

Initialization

Initialize MultiThemer in your Application class using method build(Application).

build(Application) will return Builder, which you can use to add themes, set icon to use in recent apps list, set SharedPreferences that will be used to save theme tag after theme change and set by default one of themes.

// Kotlin
MultiThemer.build(this)
        .useAppIcon(R.mipmap.ic_launcher)
        .addTheme("Red", R.style.Red)
        .addTheme("Indigo", R.style.Indigo, true)
        .addTheme("Blue", R.style.Blue)
        .addTheme("Green", R.style.Green)
        .addTheme("Orange", R.style.Orange)
        .initialize();
// Java
MultiThemer.INSTANCE.build(this)
        .useAppIcon(R.mipmap.ic_launcher)
        .addTheme("Red", R.style.Red)
        .addTheme("Indigo", R.style.Indigo, true)
        .addTheme("Blue", R.style.Blue)
        .addTheme("Green", R.style.Green)
        .addTheme("Orange", R.style.Orange)
        .initialize();

If you will not use any of Builder.addTheme() methods, it will automatically fill themes list with all predefined THEME themes. It will use THEME.INDIGO as default theme, or you can change it with Builder.setDefault(THEME).

While adding your own themes using one of Builder.addTheme() methods, don't forget to use for at least one Builder.addTheme() method with parameter isDefault = true, otherwise the first theme in the list will be used by default one.

Builder.setSharedPreferences(SharedPreferences) is optional. DefaultSharedPreferences will be used by default.

Change themes

To let your activities automatically apply app's active theme and restart after theme change extend them from MultiThemeActivity.

You can use MultiThemerListFragment to present all app's themes and give users easy way to switch between themes, or use getThemesList() and getActiveTheme() to write your own theme chooser.

License

Copyright 2017 Mini-Stren

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.

About

An Android Library that provides easy way to use as many app themes as you would like to

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages