1
0
Fork 0
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:
Nikolay Pultsin 2011-01-08 21:57:07 +00:00
parent 147b0dffd1
commit 876c37f3cd
4 changed files with 15 additions and 58 deletions

View file

@ -45,15 +45,9 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final ColorProfile profile = fbReader.getColorProfile();
final Screen directoriesScreen = createPreferenceScreen("directories");
directoriesScreen.addPreference(new ZLStringOptionPreference(
this, Paths.BooksDirectoryOption(),
directoriesScreen.Resource, "books"
));
directoriesScreen.addOption(Paths.BooksDirectoryOption(), "books");
if (AndroidFontUtil.areExternalFontsSupported()) {
directoriesScreen.addPreference(new ZLStringOptionPreference(
this, Paths.FontsDirectoryOption(),
directoriesScreen.Resource, "fonts"
));
directoriesScreen.addOption(Paths.FontsDirectoryOption(), "fonts");
}
final Screen appearanceScreen = createPreferenceScreen("appearance");

View file

@ -27,7 +27,7 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
class ZLEnumPreference<T extends Enum<T>> extends ZLStringListPreference {
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);
myOption = option;

View file

@ -59,19 +59,21 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
}
public ZLPreference addOption(ZLBooleanOption option, String resourceKey) {
ZLBooleanPreference preference =
new ZLBooleanPreference(ZLPreferenceActivity.this, option, Resource, resourceKey);
myScreen.addPreference(preference);
myPreferences.add(preference);
return preference;
return addPreference(
new ZLBooleanPreference(ZLPreferenceActivity.this, option, Resource, resourceKey)
);
}
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) {
ZLEnumPreference<T> preference =
new ZLEnumPreference<T>(ZLPreferenceActivity.this, Resource, resourceKey, option);
myScreen.addPreference(preference);
myPreferences.add(preference);
return preference;
return addPreference(
new ZLEnumPreference<T>(ZLPreferenceActivity.this, option, Resource, resourceKey)
);
}
public void close() {

View file

@ -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();
}