diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c5af270da..573f74722 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -136,6 +136,7 @@
+
diff --git a/AndroidManifest.xml.pattern b/AndroidManifest.xml.pattern
index a1944e275..8646ff863 100644
--- a/AndroidManifest.xml.pattern
+++ b/AndroidManifest.xml.pattern
@@ -136,6 +136,7 @@
+
diff --git a/src/org/geometerplus/android/fbreader/FBReader.java b/src/org/geometerplus/android/fbreader/FBReader.java
index 56633f910..c29aa716c 100644
--- a/src/org/geometerplus/android/fbreader/FBReader.java
+++ b/src/org/geometerplus/android/fbreader/FBReader.java
@@ -29,8 +29,7 @@ import android.app.SearchManager;
import android.content.*;
import android.graphics.Color;
import android.net.Uri;
-import android.os.Bundle;
-import android.os.PowerManager;
+import android.os.*;
import android.view.*;
import android.widget.RelativeLayout;
@@ -59,6 +58,7 @@ import org.geometerplus.android.fbreader.api.*;
import org.geometerplus.android.fbreader.httpd.DataService;
import org.geometerplus.android.fbreader.library.BookInfoActivity;
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
+import org.geometerplus.android.fbreader.synchroniser.SynchroniserService;
import org.geometerplus.android.fbreader.tips.TipsActivity;
import org.geometerplus.android.util.*;
@@ -95,6 +95,17 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
private String myMenuLanguage;
final DataService.Connection DataConnection = new DataService.Connection();
+ private final ServiceConnection mySynchroniserConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName componentName, IBinder binder) {
+ System.err.println("SynchroniserService CONNECTED");
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName componentName) {
+ System.err.println("SynchroniserService DISCONNECTED");
+ }
+ };
private static final String PLUGIN_ACTION_PREFIX = "___";
private final List myPluginActions =
@@ -450,6 +461,12 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
protected void onResume() {
super.onResume();
+ bindService(
+ new Intent(this, SynchroniserService.class),
+ mySynchroniserConnection,
+ SynchroniserService.BIND_AUTO_CREATE
+ );
+
myStartTimer = true;
Config.Instance().runOnConnect(new Runnable() {
public void run() {
@@ -494,6 +511,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
setButtonLight(true);
}
myFBReaderApp.onWindowClosing();
+ unbindService(mySynchroniserConnection);
super.onPause();
}
diff --git a/src/org/geometerplus/android/fbreader/synchroniser/SynchroniserService.java b/src/org/geometerplus/android/fbreader/synchroniser/SynchroniserService.java
new file mode 100644
index 000000000..4a376ffd6
--- /dev/null
+++ b/src/org/geometerplus/android/fbreader/synchroniser/SynchroniserService.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010-2014 Geometer Plus
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+package org.geometerplus.android.fbreader.synchroniser;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
+
+public class SynchroniserService extends Service implements Runnable {
+ private final BookCollectionShadow myCollection = new BookCollectionShadow();
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ myCollection.bindToService(this, this);
+ return null;
+ }
+
+ @Override
+ public void run() {
+ System.err.println("SYNCHRONIZER BINDED TO LIBRARY");
+ }
+
+ @Override
+ public void onDestroy() {
+ myCollection.unbind();
+ System.err.println("SYNCHRONIZER UNBINDED FROM LIBRARY");
+ super.onDestroy();
+ }
+}