@NonNull @CheckReturnValue
  public static Observable<KeyboardTheme> observeCurrentTheme(@NonNull Context context) {
    final KeyboardThemeFactory factory = AnyApplication.getKeyboardThemeFactory(context);
    return Observable.<String>create(
            emitter -> {
              final SharedPreferences sp = DirectBootAwareSharedPreferences.create(context);
              final SharedPreferences.OnSharedPreferenceChangeListener listener =
                  (preferences, key) -> emitter.onNext(key);
              emitter.setCancellable(() -> sp.unregisterOnSharedPreferenceChangeListener(listener));
              sp.registerOnSharedPreferenceChangeListener(listener);
            })
        .filter(key -> key.startsWith(KeyboardThemeFactory.PREF_ID_PREFIX))
        .map(key -> factory.getEnabledAddOn())
        .startWith(factory.getEnabledAddOn())
        .distinctUntilChanged();
  }
@Test
  public void testObserveCurrentThemeFiredWhenPrefChanges() {
    final KeyboardThemeFactory keyboardThemeFactory =
        AnyApplication.getKeyboardThemeFactory(getApplicationContext());
    AtomicReference<KeyboardTheme> currentTheme = new AtomicReference<>();
    final Disposable disposable =
        KeyboardThemeFactory.observeCurrentTheme(getApplicationContext())
            .subscribe(currentTheme::set);

    Assert.assertEquals("8774f99e-fb4a-49fa-b8d0-4083f762250a", currentTheme.get().getId());

    keyboardThemeFactory.setAddOnEnabled("55d9797c-850c-40a8-9a5d-7467b55bd537", true);

    Assert.assertEquals("55d9797c-850c-40a8-9a5d-7467b55bd537", currentTheme.get().getId());

    disposable.dispose();

    keyboardThemeFactory.setAddOnEnabled("8774f99e-fb4a-49fa-b8d0-4083f762250a", true);
    // still same as before
    Assert.assertEquals("55d9797c-850c-40a8-9a5d-7467b55bd537", currentTheme.get().getId());
  }