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"]]
AndroidThemeManger is a theme manager for Android:
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'
}
<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>
ThemeManager.getInstance().currentTheme = R.style.AppTheme_NoActionBar_Red
ThemeManager.getInstance().nightMode = AppCompatDelegate.MODE_NIGHT_YES
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ThemeManager.getInstance().applyTheme(this)
}
Mostafa Taghipour, mostafa@taghipour.me
AndroidThemeManager is available under the MIT license. See the LICENSE file for more info.