mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
preferences code cleanup
This commit is contained in:
parent
147b0dffd1
commit
876c37f3cd
4 changed files with 15 additions and 58 deletions
|
@ -45,15 +45,9 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
final ColorProfile profile = fbReader.getColorProfile();
|
final ColorProfile profile = fbReader.getColorProfile();
|
||||||
|
|
||||||
final Screen directoriesScreen = createPreferenceScreen("directories");
|
final Screen directoriesScreen = createPreferenceScreen("directories");
|
||||||
directoriesScreen.addPreference(new ZLStringOptionPreference(
|
directoriesScreen.addOption(Paths.BooksDirectoryOption(), "books");
|
||||||
this, Paths.BooksDirectoryOption(),
|
|
||||||
directoriesScreen.Resource, "books"
|
|
||||||
));
|
|
||||||
if (AndroidFontUtil.areExternalFontsSupported()) {
|
if (AndroidFontUtil.areExternalFontsSupported()) {
|
||||||
directoriesScreen.addPreference(new ZLStringOptionPreference(
|
directoriesScreen.addOption(Paths.FontsDirectoryOption(), "fonts");
|
||||||
this, Paths.FontsDirectoryOption(),
|
|
||||||
directoriesScreen.Resource, "fonts"
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
class ZLEnumPreference<T extends Enum<T>> extends ZLStringListPreference {
|
class ZLEnumPreference<T extends Enum<T>> extends ZLStringListPreference {
|
||||||
private final ZLEnumOption<T> myOption;
|
private final ZLEnumOption<T> myOption;
|
||||||
|
|
||||||
ZLEnumPreference(Context context, ZLResource resource, String resourceKey, ZLEnumOption<T> option) {
|
ZLEnumPreference(Context context, ZLEnumOption<T> option, ZLResource resource, String resourceKey) {
|
||||||
super(context, resource, resourceKey);
|
super(context, resource, resourceKey);
|
||||||
myOption = option;
|
myOption = option;
|
||||||
|
|
||||||
|
|
|
@ -59,19 +59,21 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLPreference addOption(ZLBooleanOption option, String resourceKey) {
|
public ZLPreference addOption(ZLBooleanOption option, String resourceKey) {
|
||||||
ZLBooleanPreference preference =
|
return addPreference(
|
||||||
new ZLBooleanPreference(ZLPreferenceActivity.this, option, Resource, resourceKey);
|
new ZLBooleanPreference(ZLPreferenceActivity.this, option, Resource, resourceKey)
|
||||||
myScreen.addPreference(preference);
|
);
|
||||||
myPreferences.add(preference);
|
}
|
||||||
return preference;
|
|
||||||
|
public ZLPreference addOption(ZLStringOption option, String resourceKey) {
|
||||||
|
return addPreference(
|
||||||
|
new ZLStringOptionPreference(ZLPreferenceActivity.this, option, Resource, resourceKey)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Enum<T>> ZLPreference addOption(ZLEnumOption<T> option, String resourceKey) {
|
public <T extends Enum<T>> ZLPreference addOption(ZLEnumOption<T> option, String resourceKey) {
|
||||||
ZLEnumPreference<T> preference =
|
return addPreference(
|
||||||
new ZLEnumPreference<T>(ZLPreferenceActivity.this, Resource, resourceKey, option);
|
new ZLEnumPreference<T>(ZLPreferenceActivity.this, option, Resource, resourceKey)
|
||||||
myScreen.addPreference(preference);
|
);
|
||||||
myPreferences.add(preference);
|
|
||||||
return preference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2009-2011 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.android.fbreader.preferences;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.preference.Preference;
|
|
||||||
|
|
||||||
abstract class ZLSimplePreference extends Preference implements ZLPreference, Preference.OnPreferenceClickListener {
|
|
||||||
ZLSimplePreference(Context context) {
|
|
||||||
super(context);
|
|
||||||
setOnPreferenceClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void onAccept();
|
|
||||||
|
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
|
||||||
onClick();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void onClick();
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue