From 3155437da2a21f88e1ed1e53e26353d8463f766c Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 13 Jul 2014 23:27:04 +0100 Subject: [PATCH] exported config service --- AndroidManifest.xml | 6 +++++- AndroidManifest.xml.pattern | 6 +++++- .../android/fbreader/api/FBReaderIntents.java | 1 + .../android/fbreader/config/ConfigShadow.java | 8 ++++++-- .../android/fbreader/config/SQLiteConfig.java | 4 +--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index d0faed218..4c111ef40 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -135,7 +135,11 @@ - + + + + + diff --git a/AndroidManifest.xml.pattern b/AndroidManifest.xml.pattern index a403ba135..82fcff004 100644 --- a/AndroidManifest.xml.pattern +++ b/AndroidManifest.xml.pattern @@ -135,7 +135,11 @@ - + + + + + diff --git a/src/org/geometerplus/android/fbreader/api/FBReaderIntents.java b/src/org/geometerplus/android/fbreader/api/FBReaderIntents.java index 9d70504bd..c22a77d4f 100644 --- a/src/org/geometerplus/android/fbreader/api/FBReaderIntents.java +++ b/src/org/geometerplus/android/fbreader/api/FBReaderIntents.java @@ -31,6 +31,7 @@ public abstract class FBReaderIntents { String API_CALLBACK = "android.fbreader.action.API_CALLBACK"; String VIEW = "android.fbreader.action.VIEW"; String CANCEL_MENU = "android.fbreader.action.CANCEL_MENU"; + String CONFIG_SERVICE = "android.fbreader.action.CONFIG_SERVICE"; String LIBRARY_SERVICE = "android.fbreader.action.LIBRARY_SERVICE"; String BOOK_INFO = "android.fbreader.action.BOOK_INFO"; String LIBRARY = "android.fbreader.action.LIBRARY"; diff --git a/src/org/geometerplus/android/fbreader/config/ConfigShadow.java b/src/org/geometerplus/android/fbreader/config/ConfigShadow.java index 3481e1794..de6713cc5 100644 --- a/src/org/geometerplus/android/fbreader/config/ConfigShadow.java +++ b/src/org/geometerplus/android/fbreader/config/ConfigShadow.java @@ -28,7 +28,11 @@ import android.os.RemoteException; import org.geometerplus.zlibrary.core.options.Config; +import org.geometerplus.android.fbreader.api.FBReaderIntents; + public final class ConfigShadow extends Config implements ServiceConnection { + static final String OPTION_CHANGE_EVENT_ACTION = "fbreader.config_service.option_change_event"; + private final Context myContext; private volatile ConfigInterface myInterface; private final List myDeferredActions = new LinkedList(); @@ -50,7 +54,7 @@ public final class ConfigShadow extends Config implements ServiceConnection { public ConfigShadow(Context context) { myContext = context; context.bindService( - new Intent(context, ConfigService.class), + FBReaderIntents.defaultIntent(FBReaderIntents.Action.CONFIG_SERVICE), this, Service.BIND_AUTO_CREATE ); @@ -183,7 +187,7 @@ public final class ConfigShadow extends Config implements ServiceConnection { // method from ServiceConnection interface public synchronized void onServiceConnected(ComponentName name, IBinder service) { myInterface = ConfigInterface.Stub.asInterface(service); - myContext.registerReceiver(myReceiver, new IntentFilter(SQLiteConfig.OPTION_CHANGE_EVENT_ACTION)); + myContext.registerReceiver(myReceiver, new IntentFilter(OPTION_CHANGE_EVENT_ACTION)); while (!myDeferredActions.isEmpty()) { myDeferredActions.remove(0).run(); } diff --git a/src/org/geometerplus/android/fbreader/config/SQLiteConfig.java b/src/org/geometerplus/android/fbreader/config/SQLiteConfig.java index cf37b1a75..835e857e0 100644 --- a/src/org/geometerplus/android/fbreader/config/SQLiteConfig.java +++ b/src/org/geometerplus/android/fbreader/config/SQLiteConfig.java @@ -30,8 +30,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; final class SQLiteConfig extends ConfigInterface.Stub { - static final String OPTION_CHANGE_EVENT_ACTION = "fbreader.config_service.option_change_event"; - private final Service myService; private final SQLiteDatabase myDatabase; @@ -163,7 +161,7 @@ final class SQLiteConfig extends ConfigInterface.Stub { private void sendChangeEvent(String group, String name, String value) { myService.sendBroadcast( - new Intent(OPTION_CHANGE_EVENT_ACTION) + new Intent(ConfigShadow.OPTION_CHANGE_EVENT_ACTION) .putExtra("group", group) .putExtra("name", name) .putExtra("value", value)