MostafaTaghipour/ThemeManager


An Android theme manager with all the features. Everything you expect from a theme manager, contains apply theme to whole app, multiple themes, night mode, styles , ...

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.mostafataghipour:thememanager:1.0.0'
	}
	dependencies {
		implementation("com.github.mostafataghipour:thememanager:1.0.0")
	}
	<dependency>
	    <groupId>com.github.mostafataghipour</groupId>
	    <artifactId>thememanager</artifactId>
	    <version>1.0.0</version>
	</dependency>

                            
    libraryDependencies += "com.github.mostafataghipour" % "thememanager" % "1.0.0"
        
        

                            
    :dependencies [[com.github.mostafataghipour/thememanager "1.0.0"]]
        
        

Readme


AndroidThemeManager

iOS version is here

AndroidThemeManger is a theme manager for Android:

  • Apply theme at runtime
  • Support multiple theme
  • Supports night mode

themes

Requirements

  • Api 14+

Installation

Add JitPack to repositories in your project's root build.gradle file:

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

Add the dependency to your module's build.gradle file:

dependencies {
    ...
    implementation 'com.github.MostafaTaghipour:thememanager:1.0.0'
}

Usage

  • Define app theme (s):
<resources xmlns:tools="http://schemas.android.com/tools">

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.DayNight">
  </style>

  <style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
  </style>

  <style name="AppTheme.NoActionBar.Red">
    <item name="colorPrimary">@color/colorPrimary_Red</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark_Red</item>
    <item name="colorAccent">@color/colorAccent_Red</item>
  </style>

</resources>
  • Set app theme like below:
ThemeManager.getInstance().currentTheme = R.style.AppTheme_NoActionBar_Red
ThemeManager.getInstance().nightMode = AppCompatDelegate.MODE_NIGHT_YES
  • Set activities theme like this:
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  ThemeManager.getInstance().applyTheme(this)
}
  • Thats it, enjoy it

Author

Mostafa Taghipour, mostafa@taghipour.me

License

AndroidThemeManager is available under the MIT license. See the LICENSE file for more info.