diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/App.java b/android-app-core/src/main/java/org/solovyev/android/calculator/App.java index 2842253f..0f575d7d 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/App.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/App.java @@ -69,6 +69,9 @@ public final class App { private static volatile boolean initialized; + @Nonnull + private static CalculatorBroadcaster broadcaster; + private App() { throw new AssertionError(); } @@ -104,6 +107,7 @@ public final class App { App.locator = new ServiceLocator() { }; } + App.broadcaster = new CalculatorBroadcaster(application); App.initialized = true; } else { @@ -163,4 +167,9 @@ public final class App { checkInit(); return eventBus; } + + @Nonnull + public static CalculatorBroadcaster getBroadcaster() { + return broadcaster; + } } diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorBroadcaster.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorBroadcaster.java index 7a0a009a..5ad53464 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorBroadcaster.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorBroadcaster.java @@ -32,15 +32,15 @@ public final class CalculatorBroadcaster implements CalculatorEventListener { } } - private void sendDisplayStateChanged() { + public void sendDisplayStateChanged() { sendBroadcastIntent(ACTION_DISPLAY_STATE_CHANGED); } - private void sendEditorStateChangedIntent() { + public void sendEditorStateChangedIntent() { sendBroadcastIntent(ACTION_EDITOR_STATE_CHANGED); } - private void sendBroadcastIntent(@Nonnull String action) { + public void sendBroadcastIntent(@Nonnull String action) { context.sendBroadcast(new Intent(action)); } } diff --git a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java index 17c019c8..16dfe7ef 100644 --- a/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java +++ b/android-app-core/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java @@ -22,6 +22,8 @@ public final class CalculatorReceiver extends BroadcastReceiver { if (button != null) { button.onClick(context); } + + App.getBroadcaster().sendEditorStateChangedIntent(); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index 7a9d295c..bbf55b23 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -97,9 +97,6 @@ public class CalculatorApplication extends android.app.Application implements Sh @Nonnull protected final Handler uiHandler = new Handler(); - @Nonnull - private final CalculatorBroadcaster broadcaster = new CalculatorBroadcaster(this); - @Nonnull private final Wizards wizards = new CalculatorWizards(this); @@ -194,7 +191,7 @@ public class CalculatorApplication extends android.app.Application implements Sh calculator.addCalculatorEventListener(listener); } - calculator.addCalculatorEventListener(broadcaster); + calculator.addCalculatorEventListener(App.getBroadcaster()); Locator.getInstance().getCalculator().init();