mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
do not start SyncService if synchronisation is disabled
This commit is contained in:
parent
efb39d2933
commit
40fa1142d1
5 changed files with 18 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
|||
* (planned) Tablet-oriented preferences dialog
|
||||
* (planned) Android L support
|
||||
* (planned) Automatic files download (from the book network)
|
||||
* (planned) Sync: single book upload
|
||||
|
||||
===== 2.1 (Sep ??, 2014) =====
|
||||
* New engine for mobipocket (a.k.a. Kindle) files: added support for huffdic compression and CSS
|
||||
|
@ -9,13 +10,12 @@
|
|||
* DjVu plugin support
|
||||
* (planned) Fixed authors list/tags list editing
|
||||
* (planned) Recently accessed books list (on the book network)
|
||||
* (planned) Do not start SyncService in synchronization is disabled
|
||||
* (planned) Sync: single book upload
|
||||
* Do not start SyncService if synchronization is disabled
|
||||
* Sync: 'synchronize positions only' option
|
||||
* Tips are back but disabled by default
|
||||
* Added Japanese localisation (by Tamotsu Takahashi and Naofumi Fukue)
|
||||
* Updated Dutch localization (by Frank Fesevur)
|
||||
* Updated Czech localization (by Marek Pavelka)
|
||||
* Updated Dutch localisation (by Frank Fesevur)
|
||||
* Updated Czech localisation (by Marek Pavelka)
|
||||
|
||||
===== 2.0.6 (Aug 23, 2014) =====
|
||||
* Version for old (2.*) devices does not use google services API
|
||||
|
|
|
@ -500,11 +500,11 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
SyncOperations.enableSync(this, true);
|
||||
|
||||
myStartTimer = true;
|
||||
Config.Instance().runOnConnect(new Runnable() {
|
||||
public void run() {
|
||||
SyncOperations.enableSync(FBReader.this, myFBReaderApp.SyncOptions);
|
||||
|
||||
final int brightnessLevel =
|
||||
getZLibrary().ScreenBrightnessLevelOption.getValue();
|
||||
if (brightnessLevel != 0) {
|
||||
|
@ -583,7 +583,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
SyncOperations.quickSync(this);
|
||||
SyncOperations.quickSync(this, myFBReaderApp.SyncOptions);
|
||||
|
||||
IsPaused = true;
|
||||
try {
|
||||
|
|
|
@ -168,7 +168,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
}
|
||||
|
||||
private void enableSynchronisation() {
|
||||
SyncOperations.enableSync(PreferenceActivity.this, syncOptions.Enabled.getValue());
|
||||
SyncOperations.enableSync(PreferenceActivity.this, syncOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,8 @@ import java.util.*;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.options.SyncOptions;
|
||||
|
||||
public abstract class SyncOperations {
|
||||
public static final String UPDATED = "android.fbreader.event.sync.UPDATED";
|
||||
|
||||
|
@ -35,12 +37,14 @@ public abstract class SyncOperations {
|
|||
String QUICK_SYNC = "android.fbreader.action.sync.QUICK_SYNC";
|
||||
}
|
||||
|
||||
public static void enableSync(Context context, boolean enable) {
|
||||
final String action = enable ? Action.START : Action.STOP;
|
||||
public static void enableSync(Context context, SyncOptions options) {
|
||||
final String action = options.Enabled.getValue() ? Action.START : Action.STOP;
|
||||
context.startService(new Intent(context, SyncService.class).setAction(action));
|
||||
}
|
||||
|
||||
public static void quickSync(Context context) {
|
||||
context.startService(new Intent(context, SyncService.class).setAction(Action.QUICK_SYNC));
|
||||
public static void quickSync(Context context, SyncOptions options) {
|
||||
if (options.Enabled.getValue()) {
|
||||
context.startService(new Intent(context, SyncService.class).setAction(Action.QUICK_SYNC));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ public class SyncService extends Service implements IBookCollection.Listener {
|
|||
final AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
|
||||
alarmManager.cancel(syncIntent());
|
||||
log("stopped");
|
||||
stopSelf();
|
||||
} else if (SyncOperations.Action.SYNC.equals(action)) {
|
||||
SQLiteCookieDatabase.init(this);
|
||||
myCollection.bindToService(this, myQuickSynchroniser);
|
||||
|
@ -417,7 +418,7 @@ public class SyncService extends Service implements IBookCollection.Listener {
|
|||
addBook(book);
|
||||
break;
|
||||
case Opened:
|
||||
SyncOperations.quickSync(this);
|
||||
SyncOperations.quickSync(this, mySyncOptions);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue