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

sync options

This commit is contained in:
Nikolay Pultsin 2014-07-27 18:39:16 +01:00
parent 9527ba7d6a
commit d5579cd602
3 changed files with 63 additions and 2 deletions

View file

@ -319,7 +319,7 @@
<node name="series" value="Series"/>
</node>
<node name="Preferences">
<node name="synchronisation" value="Synchronisation">
<node name="sync" value="Synchronisation">
<node name="summary" value="Book network settings"/>
<node name="enable" value="Enable synchronisation">
<node name="summaryOn" value="Synchronise my library with FBReader book network server"/>
@ -327,7 +327,7 @@
</node>
<node name="uploadAllBooks" value="Upload all books to server">
<node name="always" value="Always"/>
<node name="wifi" value="If device is connected via Wi-Fi"/>
<node name="viaWifi" value="If device is connected via Wi-Fi"/>
<node name="never" value="Never"/>
</node>
<node name="positions" value="Reading positions">

View file

@ -80,6 +80,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final FooterOptions footerOptions = viewOptions.getFooterOptions();
final PageTurningOptions pageTurningOptions = new PageTurningOptions();
final ImageOptions imageOptions = new ImageOptions();
final SyncOptions syncOptions = new SyncOptions();
final ColorProfile profile = viewOptions.getColorProfile();
final ZLTextStyleCollection collection = viewOptions.getTextStyleCollection();
final ZLKeyBindings keyBindings = new ZLKeyBindings();
@ -120,6 +121,27 @@ public class PreferenceActivity extends ZLPreferenceActivity {
directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption, null
));
final Screen syncScreen = createPreferenceScreen("sync");
final PreferenceSet syncPreferences = new PreferenceSet.Enabler() {
@Override
protected Boolean detectState() {
return syncOptions.Enabled.getValue();
}
};
syncScreen.addPreference(new ZLBooleanPreference(
this, syncOptions.Enabled, syncScreen.Resource, "enable"
) {
@Override
protected void onClick() {
super.onClick();
syncPreferences.run();
}
});
syncPreferences.add(syncScreen.addOption(syncOptions.UploadAllBooks, "uploadAllBooks"));
syncPreferences.add(syncScreen.addOption(syncOptions.Positions, "positions"));
syncPreferences.add(syncScreen.addOption(syncOptions.Metainfo, "metainfo"));
syncPreferences.add(syncScreen.addOption(syncOptions.Bookmarks, "bookmarks"));
final Screen appearanceScreen = createPreferenceScreen("appearance");
appearanceScreen.addPreference(new LanguagePreference(
this, appearanceScreen.Resource, "language", ZLResource.interfaceLanguages()

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2007-2014 Geometer Plus <contact@geometerplus.com>
*
* 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.fbreader.fbreader.options;
import org.geometerplus.zlibrary.core.options.*;
public class SyncOptions {
public final ZLBooleanOption Enabled =
new ZLBooleanOption("Sync", "Enabled", false);
public static enum SyncCondition {
never, viaWifi, always
}
public final ZLEnumOption<SyncCondition> UploadAllBooks =
new ZLEnumOption<SyncCondition>("Sync", "UploadAllBooks", SyncCondition.viaWifi);
public final ZLBooleanOption Positions =
new ZLBooleanOption("Sync", "Positions", true);
public final ZLBooleanOption Bookmarks =
new ZLBooleanOption("Sync", "Bookmarks", true);
public final ZLBooleanOption Metainfo =
new ZLBooleanOption("Sync", "Metainfo", true);
}