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