All Projects → imandolatkia → Android-Animated-Theme-Manager

imandolatkia / Android-Animated-Theme-Manager

Licence: Apache-2.0 license
create your custom themes and change them dynamically with ripple animation

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Android-Animated-Theme-Manager

node-bitstamp
bitstamp REST and WS API Node.js client 💵
Stars: ✭ 58 (-89.26%)
Mutual labels:  ripple
cashuwallet
Cashu is a cryptocurrency wallet for smartphones. Be your own bank. Accept payments or spend crypto directly from your phone.
Stars: ✭ 35 (-93.52%)
Mutual labels:  ripple
material-ripple
💧 Material Design Ripple effect with jQuery and CSS
Stars: ✭ 20 (-96.3%)
Mutual labels:  ripple
vue-rippler
🎉 Custom ripple effect plugin for @vuejs
Stars: ✭ 45 (-91.67%)
Mutual labels:  ripple
CoinGecko
A C++20 library for CoinGecko--a cryptocurrency data service.
Stars: ✭ 69 (-87.22%)
Mutual labels:  ripple
RippleBackground
Ripple animation
Stars: ✭ 32 (-94.07%)
Mutual labels:  ripple
go-crypto-wallet
Cryptocurrency wallet for trading for Bitcoin, Bitcoin cash, Ethereum, ERC20, Ripple
Stars: ✭ 59 (-89.07%)
Mutual labels:  ripple
TheWorldExchange
A purely client-side wallet and direct interface showcasing the full functionality of Ripple / blockchain.
Stars: ✭ 34 (-93.7%)
Mutual labels:  ripple
CryptoCurrency
Page to keep track of value & profits of a portfolio of cryptocurrency (based on Coinmarketcap, Bitfinex and Binance)
Stars: ✭ 27 (-95%)
Mutual labels:  ripple
wallet-address-validator
Useful library for validation of Bitcoin, Litecoin, Ethereum and other cryptocoin addresses
Stars: ✭ 240 (-55.56%)
Mutual labels:  ripple
MTRipple
Repository for Ripple Effect
Stars: ✭ 24 (-95.56%)
Mutual labels:  ripple
Ripple-Auto-Installer
OSU! Ripple Stack Installation Helper
Stars: ✭ 21 (-96.11%)
Mutual labels:  ripple
MusicPlayer
Android music player example.
Stars: ✭ 20 (-96.3%)
Mutual labels:  ripple-animation
ng-ripple
Material ripple effects for AngularJs
Stars: ✭ 12 (-97.78%)
Mutual labels:  ripple
xrpl-dev-portal
Source code for xrpl.org including developer documentation
Stars: ✭ 330 (-38.89%)
Mutual labels:  ripple
rippled-php
A PHP library for rippled (XRP Ledger) communication.
Stars: ✭ 33 (-93.89%)
Mutual labels:  ripple
touchMyRipple
A simple library for apply the ripple effect where you want
Stars: ✭ 19 (-96.48%)
Mutual labels:  ripple
artunis-mobile
XRP Wallet app for Android and iOS, built in React Native.
Stars: ✭ 23 (-95.74%)
Mutual labels:  ripple
react-touch-ripple
Create ripple effect from Material Design with React
Stars: ✭ 27 (-95%)
Mutual labels:  ripple
FFF Protocol Core
FFF as a new generation of the underlying chain technology, applying power block chain of innovation and fall to the ground, will help the industry standard. FFF consensus mechanism: the application of a new work-proof mechanism, network contribution proof mechanism, refers to the contribution ability of servers, PC and other devices to improve …
Stars: ✭ 5 (-99.07%)
Mutual labels:  ripple

Android Animated Theme Manager Tweet

License Maven Central Generic badge Generic badge Generic badge CodeFactor Quality Gate Status

Create custom themes and change them dynamically with the ripple animation

We are open to any new feature request, bug fix request, and pull request.

Demo

animation-ripple-android-theme

download_from_google

Features

  • support java and kotlin projects.
  • change theme without recreating activities and fragments.
  • support multi fragments apps.
  • ripple animation.
  • reverse animation.
  • changeable animation duration.
  • changeable animation position.
  • animation listener.
  • observe changes of themes for custom actions with Livedata.
  • easy to use, 5 or 7 tiny steps.
  • support any android APIs (animation works on API>20).


How to install? Maven Central

Add the following line to app-level build.gradle file, in dependencies scope:

dependencies {
    ...
    implementation "com.dolatkia:animated-theme-manager:1.1.4"
}

How to use?

1- Create an abstract class that inherits from AppTheme. In this class create abstract methods to return related color for all UI element that you want to change them on each theme. For example, if you want to change the background color, text colors and icon colors in your firstActivity, do the following:

interface MyAppTheme : AppTheme {
    fun firstActivityBackgroundColor(context: Context): Int
    fun firstActivityTextColor(context: Context): Int
    fun firstActivityIconColor(context: Context): Int
    // any other methods for other elements
}
java

interface MyAppTheme extends AppTheme {
    int firstActivityBackgroundColor(@NotNull Context context);
    int firstActivityTextColor(@NotNull Context context);
    int firstActivityIconColor(@NotNull Context context);
    // any other methods for other elements
}

2- For each theme that you want in your app, create a class that extends from the class that was created in step 1 (MyAppTheme), and implement methods with related colors or resources, for example, if you want to have 3 themes, you should create 3 class and implement methods:

class LightTheme : MyAppTheme {

    override fun id(): Int { // set unique iD for each theme 
        return 0
    }

    override fun firstActivityBackgroundColor(context: Context): Int {
        return ContextCompat.getColor(context, R.color.background_light)
    }

    override fun firstActivityTextColor(context: Context): Int {
        return ContextCompat.getColor(context, R.color.text_light)
    }
    
     override fun firstActivityIconColor(context: Context): Int {
        return ContextCompat.getColor(context, R.color.icon_light)
    }
    
    ...
}

class NightTheme : MyAppTheme {...}
class PinkTheme : MyAppTheme {...}
java

public class LightTheme implements MyAppTheme {
    public int id() { // set unique iD for each theme 
        return 0;
    }

    public int firstActivityBackgroundColor(@NotNull Context context) {
        return ContextCompat.getColor(context, R.color.background_light);
    }

    public int firstActivityTextColor(@NotNull Context context) {
        return ContextCompat.getColor(context,  R.color.text_light);
    }

    public int firstActivityIconColor(@NotNull Context context) {
        return ContextCompat.getColor(context, R.color.icon_light);
    }
    
    ...
}
    
public class NightTheme implements MyAppTheme {...}
public class PinkTheme implements MyAppTheme {...}

3- Extend your activity from ThemeActivity:

MainActivity : ThemeActivity() {
...
}
java

public class MainActivity implements ThemeActivity {
...
}

4- Implement ThemeActivity's 2 abstract methods:

// to sync ui with selected theme
override fun syncTheme(appTheme: AppTheme) {
    // change ui colors with new appThem here

    val myAppTheme = appTheme as MyAppTheme
    // set background color
    binder.root.setBackgroundColor(myAppTheme.firstActivityBackgroundColor(this))

    //set text color
    binder.text.setTextColor(myAppTheme.activityTextColor(this))
        
    // set icons color
    binder.share.setColorFilter(myAppTheme.firstActivityIconColor(this))
    binder.gift.setColorFilter(myAppTheme.firstActivityIconColor(this))        
    ...
}

// to save the theme for the next time, save it in onDestroy() (exp: in pref or DB) and return it here.
// it just used for the first time (first activity).
override fun getStartTheme(): AppTheme {
    return LightTheme()
}
java

// to sync ui with selected theme
@Override
public void syncTheme(@NotNull AppTheme appTheme) {
    // change ui colors with new appThem here

    MyAppTheme myAppTheme = (MyAppTheme) appTheme;

    // set background color
    binder.getRoot().setBackgroundColor(myAppTheme.activityBackgroundColor(this));

    //set text color
    binder.text.setTextColor(myAppTheme.activityTextColor(this));

    // set icons color
    binder.share.setColorFilter(myAppTheme.activityBackgroundColor(this));
    binder.gift.setColorFilter(myAppTheme.activityBackgroundColor(this));
}

// to get start theme
@NotNull
@Override
public AppTheme getStartTheme() {
    return new LightTheme();
}

5- Change theme with the ThemeManager.instance.changeTheme() method:

// set change theme click listener
binder.lightButton.setOnClickListener {
  ThemeManager.instance.changeTheme(LightTheme(), it)
}
java

binder.lightButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      ThemeManager.Companion.getInstance().changeTheme(new LightTheme(), v, 600);
    }
});

The first argument is the selected theme.

The second argument is the view that animation starts from the center of it.

How to use in multi fragments app?

Repeat all previous 5 steps, and then:

6- Extend your fragments from ThemeFragment:

MyFragment : ThemeFragment() {
...
}
java

public class MyFragment implements ThemeFragment {
...
}

7- Implement ThemeFragment syncTheme abstract methods:

// to sync ui with selected theme
override fun syncTheme(appTheme: AppTheme) {
    // change ui colors with new appThem here
    ...
}
java

@Override
public void syncTheme(@NotNull AppTheme appTheme) {
    // change ui colors with new appThem here
    ...
}

Some other settings and customization:

✔️ reverse animation

If you want to use the reverse animation, call reverseChangeTheme() instead of changeTheme():

   binder.lightButton.setOnClickListener {
        ThemeManager.instance.reverseChangeTheme(LightTheme(), it)
   }

reverse ripple theme animation

✔️ change animation duration

If you want to change the animation duration, add your desired duration in milliseconds as the third argument of ThemeManager.instance.changeTheme(). The default value is 600:

   binder.lightButton.setOnClickListener {
        ThemeManager.instance.changeTheme(LightTheme(), it, 800)
   }

✔️ change animation center position

If you want to start animation somewhere other than the view that clicked, send a Coordinate object instead of a View in ThemeManager.instance.changeTheme()

   binder.lightButton.setOnClickListener {
          binder.nightButton.setOnClickListener {
            ThemeManager.instance.changeTheme(NightTheme(), Coordinate(10, 20)
        }
   }

where the Coordinate is:

 Coordinate(var x: Int, var y: Int) 

✔️ observe changes of themes yourself

If you want to observe changes of themes and do some custom action, you can use theme Livedata in any fragment or activity:

    ThemeManager.instance.getCurrentLiveTheme().observe(this) {
        Toast.makeText(this, "on Theme changed to ${it.id()}", Toast.LENGTH_SHORT).show()
    }

✔️ set animation listener

If you want to set an animation listener, use setThemeAnimationListener() method in your activity

     setThemeAnimationListener(MyThemeAnimationListener(this))

where the MyThemeAnimationListener is:

    class MyThemeAnimationListener(var context: Context) : ThemeAnimationListener{
        override fun onAnimationStart(animation: Animator) {
           Toast.makeText(context, "onAnimationStart", Toast.LENGTH_SHORT).show()
        }

        override fun onAnimationEnd(animation: Animator) {
            Toast.makeText(context, "onAnimationEnd", Toast.LENGTH_SHORT).show()
        }

        override fun onAnimationCancel(animation: Animator) {
            Toast.makeText(context, "onAnimationCancel", Toast.LENGTH_SHORT).show()
        }

        override fun onAnimationRepeat(animation: Animator) {
            Toast.makeText(context, "onAnimationRepeat", Toast.LENGTH_SHORT).show()
        }
    }

Stargazers

Stargazers repo roster for @imandolatkia/Android-Animated-Theme-Manager

Forkers

Forkers repo roster for @imandolatkia/Android-Animated-Theme-Manager

Quality gate

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].