1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

exported config service

This commit is contained in:
Nikolay Pultsin 2014-07-13 23:27:04 +01:00
parent 12b2177009
commit 3155437da2
5 changed files with 18 additions and 7 deletions

View file

@ -135,7 +135,11 @@
<action android:name="android.fbreader.action.LIBRARY_SERVICE"/>
</intent-filter>
</service>
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService" android:exported="false"/>
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService">
<intent-filter>
<action android:name="android.fbreader.action.CONFIG_SERVICE"/>
</intent-filter>
</service>
<service android:name="org.geometerplus.android.fbreader.synchroniser.SynchroniserService" android:launchMode="singleTask" android:process=":synchroniser" android:exported="false"/>
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library" android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>

View file

@ -135,7 +135,11 @@
<action android:name="android.fbreader.action.LIBRARY_SERVICE"/>
</intent-filter>
</service>
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService" android:exported="false"/>
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService">
<intent-filter>
<action android:name="android.fbreader.action.CONFIG_SERVICE"/>
</intent-filter>
</service>
<service android:name="org.geometerplus.android.fbreader.synchroniser.SynchroniserService" android:launchMode="singleTask" android:process=":synchroniser" android:exported="false"/>
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library" android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>

View file

@ -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";

View file

@ -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<Runnable> myDeferredActions = new LinkedList<Runnable>();
@ -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();
}

View file

@ -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)