Material Design 3 Theme Engine for Android

Overview

A Material Design 3 Theme Engine for Android

Android CI Maven Central License

This library allows you to set Material 3 themes to your app. You can also manage dark mode and dynamic colors in your app. All changes are saved to SharedPreferences no need to manage it manually.

Note: This library does not support dynamic colors on devices lower than Android 12 i.e. API 31.

Screenshots

Themes

Light Dark

Theme Chooser

Light Dark

How to use

Getting Started

Add the following gradle dependency to your build.gradle

dependencies {
  implementation 'io.github.prathameshmm02.themeEngine:themeEngine:1.0'
}

Usage

Theming is handled by ThemeEngine class. It is a singleton class and you can get the ThemeEngine instance as follows:

val themeEngine = ThemeEngine.getInstance(context)

Apply theme and night mode to given activity, in your activity's onCreate() method, call:

themeEngine.applyToActivity(this)

Apply theme and night mode to all activities by registering a ActivityLifecycleCallbacks to your application. In your application class’ onCreate() method, call:

themeEngine.applyToActivities(this)

Set Dark theme

Note : Dark theme change is handled no need to call activity.recreate()

// Light mode
themeEngine.themeMode = ThemeMode.LIGHT

// Dark mode
themeEngine.themeMode = ThemeMode.DARK

// Follow System
themeEngine.themeMode = ThemeMode.AUTO

Set Dynamic Colors, you may want to recreate activity after settings this property

themeEngine.isDynamicTheme = true

Set static theme

The theme used when dynamic color is disabled

themeEngine.staticTheme = R.style.Theme_ThemeEngine_Orange

Create ThemeChooserDialog for the user to choose static theme from, this returns an AlertDialog.

ThemeChooserDialogBuilder(this)

    // Set Title
    .setTitle(R.string.choose_theme)
    
    // Set positive button text and an OnClickListener on the button
    .setPositiveButton("OK") { position, theme ->
      // This sets staticTheme
      themeEngine.staticTheme = theme
      recreate()
    }
    
    // Set negative button text
    .setNegativeButton("Cancel")
    
    // Set neutral button text and an OnClickListener on the button
    .setNeutralButton("Default") { _, _ ->
        // This resets static theme
        themeEngine.resetTheme()
        // Recreates activity
        recreate()
    }
    
    // Set Dialog Icon
    .setIcon(R.drawable.ic_round_brush)
    
    // Create Alert Dialog
    .create()
    // Show Dialog
    .show()

Get current app theme, this returns a dynamic theme when dynamic color is enabled, a static theme otherwise.

val theme = themeEngine.getTheme()

Reset static theme to default

themeEngine.resetTheme()

Working

ThemeOverlays are used to apply theme colors to activities. This library contains 20 ThemeOverlays one of which is Dynamic which is used only when dynamic color is enabled other are used by user's choice.
The themes are created with MaterialThemeBuilder by using Material Colors.

You might also like...
Material design file manager for Android
Material design file manager for Android

Amaze File Manager Overview Open Source, light and smooth Based on Material Design guidelines Basic features like cut, copy, delete, compress, extract

Material design file manager for Android
Material design file manager for Android

Amaze File Manager Overview Open Source, light and smooth Based on Material Design guidelines Basic features like cut, copy, delete, compress, extract

An small android app based on banking logic, usilng SQLITE as database, material design, navigation drawer implemented
An small android app based on banking logic, usilng SQLITE as database, material design, navigation drawer implemented

Android Banking App Project - Using Sqlite The Banking app using java in android studio and sqlite for crud. Packages Used Material Design Contributin

OpenLibra client on Material Design

OpenLibra-Material This repositores aims to show examples about material design in a real app, the application is a client of the webpage OpenLibra a

Implementation of Instagram with Material Design (originally based on Emmanuel Pacamalan's concept)
Implementation of Instagram with Material Design (originally based on Emmanuel Pacamalan's concept)

InstaMaterial Updated Current source code contains UI elements from Design Support Library. If you still want to see how custom implementations of e.g

Material Design Calendar
Material Design Calendar

Etar Calendar Etar (from Arabic: إِيتَار) is an open source material designed calendar made for everyone! Why? Well, I wanted a simple, material desig

A simple material design app intro with cool animations and a fluent API.
A simple material design app intro with cool animations and a fluent API.

material-intro A simple material design app intro with cool animations and a fluent API. Very inspired by Google's app intros. Demo: A demo app is ava

MaterialDesignColorPalette 4.2 0.0 L3 Java This is a dev tool to visualize the colours of Material design defined on

MaterialDesignColorPalette This is a dev tool to visualize the colours of Material design defined on http://www.google.com/design/spec/style/color.htm

:octocat: A demo project based on MVVM architecture and material design & animations.
:octocat: A demo project based on MVVM architecture and material design & animations.

GithubFollows A simple demo project based on MVVM clean architecture and material design & animations. Architecture Specs & Open-source libraries Mini

Comments
  • How to Implement in java code pls help.

    How to Implement in java code pls help.

    How to Implement in java code pls help.

    ` ThemeChooserDialogBuilder(this)

    // Set Title
    .setTitle(R.string.choose_theme)
    
    // Set positive button text and an OnClickListener on the button
    .setPositiveButton("OK") { position, theme ->
      // This sets staticTheme
      themeEngine.staticTheme = theme
      recreate()
    }
    
    // Set negative button text
    .setNegativeButton("Cancel")
    
    // Set neutral button text and an OnClickListener on the button
    .setNeutralButton("Default") { _, _ ->
        // This resets static theme
        themeEngine.resetTheme()
        // Recreates activity
        recreate()
    }
    
    // Set Dialog Icon
    .setIcon(R.drawable.ic_round_brush)
    
    // Create Alert Dialog
    .create()
    // Show Dialog
    .show()
    

    `

    opened by vimalcvs 2
  • Implement Monet / Dynamic theme on all devices (Sort of)

    Implement Monet / Dynamic theme on all devices (Sort of)

    We have 19 Material3 themes at our disposal. So, the idea is to get the primary color from the wallpaper with the help of WallpaperManager (or Palette API on lower than Android 8.1 devices) and compare it with the array of primary colors of the M3 themes we have, and get the closest color to the primary color of the wallpaper from the array. HSL Color space has given the best results so far by ignoring L(lightness) in the process of trial and error.

    opened by prathameshmm02 0
Releases(1.1.0)
Owner
Prathamesh More
Programmer, Android is ♥
Prathamesh More
A simple app to showcase Androids Material Design and some of the cool new cool stuff in Android Lollipop. RecyclerView, CardView, ActionBarDrawerToggle, DrawerLayout, Animations, Android Compat Design, Toolbar

#Android-LollipopShowcase This is a simple showcase to show off Android's all new Material Design and some other cool new stuff which is (new) in Andr

Mike Penz 1.8k Nov 10, 2022
📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.

Material NavigationView for Android ?? ?? Android Library to implement Rich, Beautiful Material Navigation View for your project with Material Design

Shreyas Patil 198 Dec 17, 2022
Hanyang-ktheme-android - Kakaotalk theme with Ha-nyang and other characters from Hanyang University

한양대 ERICA 카카오톡 테마 한양대 ERICA의 캐릭터(하냥이/하이비비)를 사용한 카카오톡 테마의 Android 버전입니다. 캐릭터의 저작권은 한양대 ERICA에 있습니다. 정보 원저작자 : 한양대 ERICA 대외협력팀 작업자 : 이정인 (컴퓨터전공 17) 카카오톡

Jeongin Lee 0 Jan 5, 2022
GitHub IntelliJ IDEs theme pack

GitHub-theme-pack Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get familiar with the template documentation. Verify the

Alexey Ivanov 0 Nov 22, 2021
Theme for VSCode and JetBrains IDEs, based on morhetz/gruvbox but with a plainer color palette for syntax highlighting.

gruvbox-plain Theme for VSCode and JetBrains IDEs, based on morhetz/gruvbox but with a plainer color palette for syntax highlighting. Syntax Colors gr

null 2 Dec 28, 2022
A Multiplatform Compose Theme for your Compose app

A Multiplatform Compose Theme for your Compose app

theapache64 45 Oct 5, 2022
Android Chinese TTS Engine Base On Tensorflow TTS , use for TfLite Models Test。安卓离线中文TTS引擎,在TensorflowTTS基础上开发,用于TfLite模型测试。

Chinese TTS TF Lite 介绍 使用Kotlin + JetPack Compose + Tensorflow Lite开发的TTS引擎,可以完全离线使用。 可选两种模型:FastSpeech和Tacotron,这两种模型均来自TensorFlowTTS 文字转拼音方法来自:Tenso

benjamin wan 116 Jan 2, 2023
Kotlin Spring Boot on GCP App Engine Standard

Kotlin Spring Boot on GCP App Engine Standard Deploy locally git clone https://github.com/mvladoi/sinch-task.git cd springboot mvn spring-boot:run 7

Vladoi Marian 0 Nov 29, 2021
DroidFish is a feature-rich graphical chess user interface, combined with the very strong Stockfish chess engine.

Introduction DroidFish is a feature-rich graphical chess user interface, combined with the very strong Stockfish chess engine. DroidFish is primarily

Peter Österlund 233 Jan 4, 2023
Design patterns are typical solutions to common problems in software design

Design patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can customize to solve a particular design problem in your code.

hamid 4 Aug 30, 2022