daily pastebin goal
96%
SHARE
TWEET

Untitled

MrBIMC Jul 10th, 2018 175 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        
  2. //BroadcastReceiver fetches, stores and notifies feature handlers of color updates.
  3.     override fun onReceive(context: Context, intent: Intent) {
  4.         Timber.d("Pluvius Broadcast Received, $intent")
  5.         if (isSameWallpaper() && intent.action == Intent.ACTION_WALLPAPER_CHANGED) {
  6.             return
  7.         }
  8.  
  9.         val wallpaper = wallpaperManager.drawable as BitmapDrawable
  10.         Palette.from(wallpaper.bitmap).maximumColorCount(32).generate {
  11.             saveColorValues(it)
  12.  
  13.             when (intent.action) {
  14.                 Intent.ACTION_WALLPAPER_CHANGED  -> {
  15.                     OverlayUpdateHandler(APP_FEATURE_ACCENT)
  16.                     OverlayUpdateHandler(APP_FEATURE_SYSTEMUI)
  17.                 }
  18.                 APP_FEATURE_ACCENT -> {
  19.                     OverlayUpdateHandler(APP_FEATURE_ACCENT)
  20.                 }
  21.                 APP_FEATURE_SYSTEMUI -> {
  22.                     OverlayUpdateHandler(APP_FEATURE_SYSTEMUI)
  23.                 }
  24.                 ACTION_TOTAL_WIPEOUT -> {
  25.                     OverlayUpdateHandler(APP_FEATURE_ACCENT)
  26.                     OverlayUpdateHandler(APP_FEATURE_SYSTEMUI)
  27.                 }
  28.             }
  29.         }
  30.     }
  31.  
  32. // here's list of color values it saves:
  33.     private fun saveColorValues(it: Palette) {
  34.         val col1 = it.getVibrantColor(Color.BLACK)
  35.         val col2 = it.getDominantColor(Color.BLACK)
  36.         val col3 = it.getMutedColor(Color.BLACK)
  37.  
  38.         val col4 = it.getDarkVibrantColor(Color.BLACK)
  39.         val col5 = it.getDarkMutedColor(Color.BLACK)
  40.  
  41.         val col6 = it.getLightMutedColor(Color.BLACK)
  42.         val col7 = it.getLightVibrantColor(Color.BLACK)
  43.  
  44.  
  45.         App.sp.edit().putInt(COLOR_VIBRANT, col1)
  46.                 .putInt(COLOR_DOMINANT, col2)
  47.                 .putInt(COLOR_MUTED, col3)
  48.                 .putInt(COLOR_DARK_VIBRANT, col4)
  49.                 .putInt(COLOR_DARK_MUTED, col5)
  50.                 .putInt(COLOR_LIGHT_MUTED, col6)
  51.                 .putInt(COLOR_LIGHT_VIBRANT, col7)
  52.                 .apply()
  53.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top