From 6a25dd54e9a7e86d3cfd7d22866a76a908758411 Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Fri, 26 Nov 2010 03:51:04 +0000 Subject: [PATCH] unused code has been removed --- .../preferences/PreferenceActivity.java | 1 - .../core/dialogs/ZLColorOptionEntry.java | 36 --- .../core/dialogs/ZLComboOptionEntry.java | 62 ----- .../core/dialogs/ZLDialogContent.java | 75 ------ .../core/dialogs/ZLDialogManager.java | 6 - .../zlibrary/core/dialogs/ZLOptionEntry.java | 34 --- .../zlibrary/core/dialogs/ZLOptionView.java | 50 ---- .../core/dialogs/ZLOptionsDialog.java | 56 ----- .../optionEntries/ZLColorOptionBuilder.java | 127 ---------- .../ui/android/dialogs/DialogActivity.java | 43 ---- .../dialogs/ZLAndroidColorOptionView.java | 234 ------------------ .../dialogs/ZLAndroidComboOptionView.java | 140 ----------- .../dialogs/ZLAndroidDialogContent.java | 146 ----------- .../dialogs/ZLAndroidDialogInterface.java | 25 -- .../android/dialogs/ZLAndroidOptionView.java | 44 ---- .../dialogs/ZLAndroidOptionsDialog.java | 60 ----- .../android/library/ZLAndroidApplication.java | 19 -- 17 files changed, 1158 deletions(-) delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLColorOptionEntry.java delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLComboOptionEntry.java delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLDialogContent.java delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLOptionEntry.java delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLOptionView.java delete mode 100644 src/org/geometerplus/zlibrary/core/dialogs/ZLOptionsDialog.java delete mode 100644 src/org/geometerplus/zlibrary/core/optionEntries/ZLColorOptionBuilder.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/DialogActivity.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidColorOptionView.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidComboOptionView.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogContent.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogInterface.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionView.java delete mode 100644 src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionsDialog.java diff --git a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java index 51ecd0ec8..e1830abb6 100644 --- a/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java +++ b/src/org/geometerplus/android/fbreader/preferences/PreferenceActivity.java @@ -25,7 +25,6 @@ import android.preference.PreferenceScreen; import org.geometerplus.zlibrary.core.options.ZLIntegerOption; import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption; -import org.geometerplus.zlibrary.core.optionEntries.ZLColorOptionBuilder; import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.text.view.style.*; diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLColorOptionEntry.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLColorOptionEntry.java deleted file mode 100644 index 58bcbd5fc..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLColorOptionEntry.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -import org.geometerplus.zlibrary.core.util.ZLColor; - -public abstract class ZLColorOptionEntry extends ZLOptionEntry { - protected ZLColorOptionEntry() { - } - - public void onReset(ZLColor color) { - } - - public abstract ZLColor initialColor(); - - public abstract ZLColor getColor(); - - public abstract void onAccept(ZLColor color); -} diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLComboOptionEntry.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLComboOptionEntry.java deleted file mode 100644 index a2fd46e09..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLComboOptionEntry.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -import java.util.*; - -public abstract class ZLComboOptionEntry extends ZLOptionEntry { - private final boolean myEditable; - - protected ZLComboOptionEntry() { - myEditable = false; - } - - protected ZLComboOptionEntry(boolean editable) { - myEditable = editable; - } - - public void onValueSelected(int index) {} - - public final void onStringValueSelected(String value) { - int index = getValues().indexOf(value); - if (index != -1) { - onValueSelected(index); - } - } - - public boolean useOnValueEdited() { - return false; - } - - public void onValueEdited(String value) {} - - public final boolean isEditable() { - return myEditable; - } - - public abstract String initialValue(); - - public abstract ArrayList getValues(); - - public abstract void onAccept(String value); - - public void onReset() { - } -} diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogContent.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogContent.java deleted file mode 100644 index 2a77359a5..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogContent.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -import java.util.*; - -import org.geometerplus.zlibrary.core.resources.ZLResource; - -public abstract class ZLDialogContent { - private final ZLResource myResource; - protected final ArrayList Views = new ArrayList(); - - protected ZLDialogContent(ZLResource resource) { - myResource = resource; - } - - public final String getKey() { - return myResource.Name; - } - - public final String getDisplayName() { - return myResource.getValue(); - } - - public final String getValue(String key) { - return myResource.getResource(key).getValue(); - } - - public final ZLResource getResource(String key) { - return myResource.getResource(key); - } - - public abstract void addOptionByName(String name, ZLOptionEntry option); - - public final void addOption(String key, ZLOptionEntry option) { - addOptionByName(myResource.getResource(key).getValue(), option); - } - - protected final void accept() { - final int size = Views.size(); - for (int i = 0; i < size; i++) { - Views.get(i).onAccept(); - } - } - - final void reset() { - final int size = Views.size(); - for (int i = 0; i < size; i++) { - Views.get(i).reset(); - } - } - - protected final void addView(ZLOptionView view) { - if (view != null) { - Views.add(view); - } - } -} diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogManager.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogManager.java index f9601ac99..965c29fd9 100644 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogManager.java +++ b/src/org/geometerplus/zlibrary/core/dialogs/ZLDialogManager.java @@ -24,8 +24,6 @@ import org.geometerplus.zlibrary.core.resources.ZLResource; public abstract class ZLDialogManager { protected static ZLDialogManager ourInstance; - public static final String COLOR_KEY = "color"; - protected ZLDialogManager() { ourInstance = this; } @@ -35,8 +33,4 @@ public abstract class ZLDialogManager { } public abstract void wait(String key, Runnable runnable); - - protected static ZLResource getResource() { - return ZLResource.resource("dialog"); - } } diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionEntry.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionEntry.java deleted file mode 100644 index a42c2f58b..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionEntry.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -public abstract class ZLOptionEntry { - private ZLOptionView myView; - - public final void setView(ZLOptionView view) { - myView = view; - } - - public final void resetView() { - if (myView != null) { - myView.reset(); - } - } -} diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionView.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionView.java deleted file mode 100644 index 1c61e4931..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionView.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -public abstract class ZLOptionView { - protected final String myName; - protected final ZLOptionEntry myOption; - private boolean myInitialized; - - protected ZLOptionView(String name, ZLOptionEntry option) { - myName = name; - myOption = option; - myInitialized = false; - myOption.setView(this); - } - - protected abstract void reset(); - - public final void setVisible() { - myInitialized = true; - show(); - } - - protected abstract void show(); - - public final void onAccept() { - if (myInitialized) { - _onAccept(); - } - } - - protected abstract void _onAccept(); -} diff --git a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionsDialog.java b/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionsDialog.java deleted file mode 100644 index a8674ae2a..000000000 --- a/src/org/geometerplus/zlibrary/core/dialogs/ZLOptionsDialog.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.dialogs; - -import java.util.*; - -import org.geometerplus.zlibrary.core.resources.ZLResource; - -public abstract class ZLOptionsDialog { - private final ZLResource myResource; - protected final ArrayList myTabs = new ArrayList(); - - protected ZLOptionsDialog(ZLResource resource) { - myResource = resource; - } - - protected void acceptTab(ZLDialogContent tab) { - tab.accept(); - } - - protected void resetTab(ZLDialogContent tab) { - tab.reset(); - } - - protected void accept() { - final int size = myTabs.size(); - for (int i = 0; i < size; i++) { - myTabs.get(i).accept(); - } - } - - protected final ZLResource getTabResource(String key) { - return myResource.getResource("tab").getResource(key); - } - - public abstract ZLDialogContent createTab(String key); - - public abstract void run(int index); -} diff --git a/src/org/geometerplus/zlibrary/core/optionEntries/ZLColorOptionBuilder.java b/src/org/geometerplus/zlibrary/core/optionEntries/ZLColorOptionBuilder.java deleted file mode 100644 index f9bc15266..000000000 --- a/src/org/geometerplus/zlibrary/core/optionEntries/ZLColorOptionBuilder.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.core.optionEntries; - -import java.util.*; - -import org.geometerplus.zlibrary.core.options.ZLColorOption; -import org.geometerplus.zlibrary.core.util.*; - -import org.geometerplus.zlibrary.core.dialogs.*; - -public class ZLColorOptionBuilder { - private ZLColorOptionsData myData; - - public ZLColorOptionBuilder() { - myData = new ZLColorOptionsData(); - myData.myComboEntry = new ZLColorComboOptionEntry(myData); - myData.myColorEntry = new ZLMultiColorOptionEntry(myData); - } - - public void addOption(final String name, ZLColorOption option) { - myData.myOptionNames.add(name); - myData.myCurrentColors.put(name, option.getValue()); - myData.myOptions.put(name, option); - } - - public void setInitial(final String name) { - myData.myCurrentOptionName = name; - myData.myPreviousOptionName = name; - } - - public ZLOptionEntry comboEntry() { - return myData.myComboEntry; - } - - public ZLOptionEntry colorEntry() { - return myData.myColorEntry; - } - - private static class ZLMultiColorOptionEntry extends ZLColorOptionEntry { - private ZLColorOptionsData myData; - - public ZLMultiColorOptionEntry(ZLColorOptionsData data) { - myData = data; - } - - public ZLColor getColor() { - ZLColor color = myData.myCurrentColors.get(myData.myCurrentOptionName); - return (color != null) ? color : initialColor(); - } - - public ZLColor initialColor() { - return myData.myOptions.get(myData.myCurrentOptionName).getValue(); - } - - public void onAccept(ZLColor color) { - onReset(color); - final ArrayList optionNames = myData.myOptionNames; - final HashMap options = myData.myOptions; - final HashMap colors = myData.myCurrentColors; - final int len = optionNames.size(); - for (int i = 0; i < len; i++) { - String name = optionNames.get(i); - options.get(name).setValue(colors.get(name)); - } - } - - public void onReset(ZLColor color) { - myData.myCurrentColors.put(myData.myPreviousOptionName, color); - } - } - - private static class ZLColorComboOptionEntry extends ZLComboOptionEntry { - private ZLColorOptionsData myData; - - public ZLColorComboOptionEntry(ZLColorOptionsData data) { - myData = data; - } - - public ArrayList getValues() { - return myData.myOptionNames; - } - - public String initialValue() { - return myData.myCurrentOptionName; - } - - public void onAccept(String value) {} - - public void onReset() { - myData.myCurrentColors.clear(); - } - - public void onValueSelected(int index) { - myData.myCurrentOptionName = getValues().get(index); - myData.myColorEntry.resetView(); - myData.myPreviousOptionName = myData.myCurrentOptionName; - } - } - - private static class ZLColorOptionsData { - private ZLComboOptionEntry myComboEntry; - private ZLColorOptionEntry myColorEntry; - private String myCurrentOptionName; - private String myPreviousOptionName; - private final ArrayList myOptionNames = new ArrayList(); - private final HashMap myCurrentColors = new HashMap(); - private final HashMap myOptions = new HashMap(); - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/DialogActivity.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/DialogActivity.java deleted file mode 100644 index 499c0e130..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/DialogActivity.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import android.app.Activity; -import android.os.Bundle; - -import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication; - -public class DialogActivity extends Activity { - static final Object DIALOG_KEY = new Object(); - - private ZLAndroidDialogInterface myDialog; - - protected void onCreate(Bundle bundle) { - super.onCreate(bundle); - final ZLAndroidApplication application = (ZLAndroidApplication)getApplication(); - myDialog = (ZLAndroidDialogInterface)application.getData(DIALOG_KEY); - myDialog.setActivity(this); - } - - protected void onDestroy() { - myDialog.endActivity(); - super.onDestroy(); - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidColorOptionView.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidColorOptionView.java deleted file mode 100644 index 59e1272f9..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidColorOptionView.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import android.content.Context; -import android.view.*; -import android.widget.*; -import android.graphics.Color; - -import org.geometerplus.zlibrary.core.util.ZLColor; -import org.geometerplus.zlibrary.core.dialogs.ZLColorOptionEntry; -import org.geometerplus.zlibrary.core.resources.ZLResource; - -import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil; - -class ZLAndroidColorOptionView extends ZLAndroidOptionView { - private View myContainer; - private ComponentView myRedView; - private ComponentView myGreenView; - private ComponentView myBlueView; - private View myColorArea; - - protected ZLAndroidColorOptionView(ZLAndroidDialogContent tab, String name, ZLColorOptionEntry option) { - super(tab, name, option); - } - - private class ComponentView extends LinearLayout { - private int myValue; - private TextView myValueView; - private Button myLeftLeftButton; - private Button myLeftButton; - private Button myRightButton; - private Button myRightRightButton; - - ComponentView(Context context, String labelText, int initialValue) { - super(context); - setOrientation(LinearLayout.HORIZONTAL); - setHorizontalGravity(0x05); - - TextView label = new TextView(context); - label.setText(labelText + ":"); - label.setPadding(0, 6, 0, 6); - label.setTextSize(16); - - myLeftLeftButton = new Button(context) { - public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (myValue > 0) { - myValue -= 20; - if (myValue < 0) { - myValue = 0; - } - setComponentValue(myValue); - } - } - return true; - } - }; - myLeftLeftButton.setText("<<"); - myLeftLeftButton.setTextSize(14); - - myLeftButton = new Button(context) { - public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (myValue > 0) { - setComponentValue(--myValue); - } - } - return true; - } - }; - myLeftButton.setText("<"); - myLeftButton.setTextSize(14); - - myValueView = new TextView(context); - myValueView.setPadding(2, 6, 2, 6); - myValueView.setTextSize(16); - - myRightButton = new Button(context) { - public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (myValue < 255) { - setComponentValue(++myValue); - } - } - return true; - } - }; - myRightButton.setText(">"); - myRightButton.setTextSize(14); - - myRightRightButton = new Button(context) { - public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN) { - if (myValue < 255) { - myValue += 20; - if (myValue > 255) { - myValue = 255; - } - setComponentValue(myValue); - } - } - return true; - } - }; - myRightRightButton.setText(">>"); - myRightRightButton.setTextSize(14); - - myValue = initialValue; - setComponentValue(initialValue); - - addView(label, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); - addView(myLeftLeftButton, new LayoutParams(40, 40)); - addView(myLeftButton, new LayoutParams(40, 40)); - addView(myValueView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); - addView(myRightButton, new LayoutParams(40, 40)); - addView(myRightRightButton, new LayoutParams(40, 40)); - } - - int getComponentValue() { - return myValue; - } - - void setComponentValue(int value) { - myValue = value; - String txtValue = "" + value; - switch (txtValue.length()) { - case 1: - txtValue = " " + txtValue; - break; - case 2: - txtValue = " " + txtValue; - break; - } - myValueView.setText(txtValue); - myLeftLeftButton.setEnabled(value > 0); - myLeftButton.setEnabled(value > 0); - myRightButton.setEnabled(value < 255); - myRightRightButton.setEnabled(value < 255); - updateColorArea(); - } - }; - - void addAndroidViews() { - if (myContainer == null) { - final Context context = myTab.getContext(); - - LinearLayout layout = new LinearLayout(context); - layout.setOrientation(LinearLayout.HORIZONTAL); - layout.setPadding(0, 6, 0, 0); - - final ZLColorOptionEntry colorOption = (ZLColorOptionEntry)myOption; - final ZLColor color = colorOption.initialColor(); - - final ZLResource resource = ZLResource.resource(ZLAndroidDialogManager.COLOR_KEY); - myRedView = new ComponentView(context, resource.getResource("red").getValue(), color.Red); - myGreenView = new ComponentView(context, resource.getResource("green").getValue(), color.Green); - myBlueView = new ComponentView(context, resource.getResource("blue").getValue(), color.Blue); - - layout.setOrientation(LinearLayout.VERTICAL); - layout.addView(myRedView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - layout.addView(myGreenView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - layout.addView(myBlueView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - - myColorArea = new View(context); - layout.setPadding(20, 0, 20, 0); - myColorArea.setMinimumHeight(60); - myColorArea.setBackgroundColor(ZLAndroidColorUtil.rgb(color)); - layout.addView(myColorArea, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT)); - - myContainer = layout; - } - - myTab.addAndroidView(myContainer, true); - } - - private void updateColorArea() { - if (myColorArea != null) { - myColorArea.setBackgroundColor(Color.rgb( - myRedView.getComponentValue(), - myGreenView.getComponentValue(), - myBlueView.getComponentValue() - )); - } - } - - protected void reset() { - if (myContainer != null) { - final ZLColorOptionEntry colorOption = (ZLColorOptionEntry)myOption; - final ZLColor color = colorOption.getColor(); - colorOption.onReset(new ZLColor( - myRedView.getComponentValue(), - myGreenView.getComponentValue(), - myBlueView.getComponentValue() - )); - myRedView.setComponentValue(color.Red); - myGreenView.setComponentValue(color.Green); - myBlueView.setComponentValue(color.Blue); - myColorArea.setBackgroundColor(ZLAndroidColorUtil.rgb(color)); - } - } - - protected void _onAccept() { - if (myContainer != null) { - ((ZLColorOptionEntry)myOption).onAccept(new ZLColor( - myRedView.getComponentValue(), - myGreenView.getComponentValue(), - myBlueView.getComponentValue() - )); - myContainer = null; - myColorArea = null; - myRedView = null; - myGreenView = null; - myBlueView = null; - } - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidComboOptionView.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidComboOptionView.java deleted file mode 100644 index d84002236..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidComboOptionView.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import android.content.Context; -import android.view.*; -import android.widget.*; - -import org.geometerplus.zlibrary.core.dialogs.ZLComboOptionEntry; - -class ZLAndroidComboOptionView extends ZLAndroidOptionView { - private TextView myLabel; - private Spinner mySpinner; - - protected ZLAndroidComboOptionView(ZLAndroidDialogContent tab, String name, ZLComboOptionEntry option) { - super(tab, name, option); - } - - void addAndroidViews() { - final Context context = myTab.getContext(); - if (myName != null) { - if (myLabel == null) { - myLabel = new TextView(context); - myLabel.setText(myName); - myLabel.setPadding(0, 12, 0, 12); - myLabel.setTextSize(18); - } - myTab.addAndroidView(myLabel, false); - } - - if (mySpinner == null) { - mySpinner = new Spinner(context); - final ComboAdapter adapter = new ComboAdapter(); - mySpinner.setAdapter(adapter); - mySpinner.setOnItemSelectedListener(adapter); - mySpinner.setSelection(initialIndex((ZLComboOptionEntry)myOption)); - } - myTab.addAndroidView(mySpinner, true); - } - - private static int initialIndex(ZLComboOptionEntry comboEntry) { - int index = comboEntry.getValues().indexOf(comboEntry.initialValue()); - return (index >= 0) ? index : 0; - } - - protected void reset() { - final ZLComboOptionEntry comboEntry = (ZLComboOptionEntry)myOption; - comboEntry.onReset(); - if (mySpinner != null) { - mySpinner.setSelection(initialIndex(comboEntry)); - } - } - - protected void _onAccept() { - if (mySpinner != null) { - final EditText editor = ((ComboAdapter)mySpinner.getAdapter()).myEditor; - if (editor != null) { - ((ZLComboOptionEntry)myOption).onAccept(editor.getText().toString()); - } - myLabel = null; - mySpinner = null; - } - } - - private class ComboAdapter extends BaseAdapter implements Spinner.OnItemSelectedListener { - EditText myEditor; - - public void onItemSelected(AdapterView parent, View v, int position, long id) { - final ZLComboOptionEntry comboEntry = (ZLComboOptionEntry)myOption; - comboEntry.onValueSelected(position); - } - - public void onNothingSelected(AdapterView parent) { - } - - @Override - public View getDropDownView(int position, View convertView, ViewGroup parent) { - if (convertView == null) { - TextView textView = new TextView(parent.getContext()); - textView.setPadding(0, 12, 0, 12); - textView.setTextSize(20); - textView.setText((String)getItem(position)); - convertView = textView; - } else { - ((TextView)convertView).setText((String)getItem(position)); - } - return convertView; - } - - public View getView(int position, View convertView, ViewGroup parent) { - final ZLComboOptionEntry comboEntry = (ZLComboOptionEntry)myOption; - if (convertView != null) { - myEditor = (EditText)convertView; - } else { - myEditor = new EditText(parent.getContext()) { - protected boolean getDefaultEditable() { - return comboEntry.isEditable(); - } - }; - myEditor.setSingleLine(true); - } - myEditor.setText((String)getItem(position), TextView.BufferType.EDITABLE); - return myEditor; - } - - public int getCount() { - return ((ZLComboOptionEntry)myOption).getValues().size(); - } - - public Object getItem(int position) { - return ((ZLComboOptionEntry)myOption).getValues().get(position); - } - - public long getItemId(int position) { - return position; - } - - @Override - public boolean hasStableIds() { - return false; - } - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogContent.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogContent.java deleted file mode 100644 index d1bbb51c5..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogContent.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import java.util.ArrayList; - -import android.content.Context; -import android.view.*; -import android.widget.*; - -import org.geometerplus.zlibrary.core.resources.ZLResource; -import org.geometerplus.zlibrary.core.dialogs.*; -import org.geometerplus.zlibrary.core.util.ZLArrayUtils; - -class ZLAndroidDialogContent extends ZLDialogContent implements ZLAndroidDialogInterface { - private Context myContext; - protected ListView myListView; - - final ArrayList myAndroidViews = new ArrayList(); - private boolean[] mySelectableMarks = new boolean[10]; - - ZLAndroidDialogContent(Context context, ZLResource resource) { - super(resource); - myContext = context; - } - - public void setActivity(DialogActivity activity) { - createListView(activity); - activity.setContentView(myListView); - activity.setTitle(getDisplayName()); - } - - public void endActivity() { - accept(); - myAndroidViews.clear(); - } - - protected void createListView(Context context) { - myContext = context; - myListView = new ListView(context); - myListView.setAdapter(new ViewAdapter()); - } - - Context getContext() { - return myContext; - } - - private ArrayList getAndroidViews() { - if (myAndroidViews.isEmpty()) { - final ArrayList views = Views; - final int len = views.size(); - for (int i = 0; i < len; ++i) { - final ZLAndroidOptionView v = (ZLAndroidOptionView)views.get(i); - if (v.isVisible()) { - v.addAndroidViews(); - } - } - } - return myAndroidViews; - } - - void invalidateView() { - if (!myAndroidViews.isEmpty()) { - myAndroidViews.clear(); - myListView.setAdapter(new ViewAdapter()); - myListView.invalidate(); - } - } - - public void addOptionByName(String name, ZLOptionEntry option) { - if (name != null) { - name = name.replaceAll("&", ""); - } - ZLAndroidOptionView view = null; - if (option instanceof ZLComboOptionEntry) { - view = new ZLAndroidComboOptionView( - this, name, (ZLComboOptionEntry)option - ); - } else if (option instanceof ZLColorOptionEntry) { - view = new ZLAndroidColorOptionView( - this, name, (ZLColorOptionEntry)option - ); - } - if (view != null) { - view.setVisible(); - } - addView(view); - } - - void addAndroidView(View view, boolean isSelectable) { - if (view != null) { - boolean[] marks = mySelectableMarks; - final int len = marks.length; - final int index = myAndroidViews.size(); - if (index == len) { - marks = ZLArrayUtils.createCopy(marks, len, 2 * len); - mySelectableMarks = marks; - } - myAndroidViews.add(view); - marks[index] = isSelectable; - } - } - - private class ViewAdapter extends BaseAdapter { - public View getView(int position, View convertView, ViewGroup parent) { - return (View)getAndroidViews().get(position); - } - - /*public boolean areAllItemsSelectable() { - return true; - } - - public boolean isSelectable(int position) { - return mySelectableMarks[position]; - }*/ - - public int getCount() { - return getAndroidViews().size(); - } - - public Object getItem(int position) { - return ""; - } - - public long getItemId(int position) { - return position; - } - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogInterface.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogInterface.java deleted file mode 100644 index 5e51242d1..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidDialogInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -interface ZLAndroidDialogInterface { - void setActivity(DialogActivity activity); - void endActivity(); -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionView.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionView.java deleted file mode 100644 index 2165d953b..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionView.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import org.geometerplus.zlibrary.core.dialogs.ZLOptionView; -import org.geometerplus.zlibrary.core.dialogs.ZLOptionEntry; - -abstract class ZLAndroidOptionView extends ZLOptionView { - ZLAndroidDialogContent myTab; - private boolean myIsVisible; - - protected ZLAndroidOptionView(ZLAndroidDialogContent tab, String name, ZLOptionEntry option) { - super(name, option); - myTab = tab; - } - - final boolean isVisible() { - return myIsVisible; - } - - protected final void show() { - myIsVisible = true; - myTab.invalidateView(); - } - - abstract void addAndroidViews(); -} diff --git a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionsDialog.java b/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionsDialog.java deleted file mode 100644 index b2ae07b56..000000000 --- a/src/org/geometerplus/zlibrary/ui/android/dialogs/ZLAndroidOptionsDialog.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2007-2010 Geometer Plus - * - * 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.zlibrary.ui.android.dialogs; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; - -import org.geometerplus.zlibrary.core.dialogs.*; -import org.geometerplus.zlibrary.core.resources.ZLResource; - -import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication; - -public class ZLAndroidOptionsDialog extends ZLOptionsDialog { - private final Activity myMainActivity; - - public ZLAndroidOptionsDialog(Activity activity, ZLResource resource) { - super(resource); - myMainActivity = activity; - } - - private static void runDialog(Activity activity, ZLAndroidDialogInterface dialog) { - ((ZLAndroidApplication)activity.getApplication()).putData( - DialogActivity.DIALOG_KEY, dialog - ); - Intent intent = new Intent(); - intent.setClass(activity, DialogActivity.class); - activity.startActivity(intent); - } - - public void run(int index) { - final ZLAndroidDialogContent tab = (ZLAndroidDialogContent)myTabs.get(index); - runDialog(myMainActivity, tab); - } - - public ZLDialogContent createTab(String key) { - final Context context = myMainActivity; - final ZLDialogContent tab = - new ZLAndroidDialogContent(context, getTabResource(key)); - myTabs.add(tab); - return tab; - } -} diff --git a/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidApplication.java b/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidApplication.java index c65b4de0e..dc643171f 100644 --- a/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidApplication.java +++ b/src/org/geometerplus/zlibrary/ui/android/library/ZLAndroidApplication.java @@ -65,23 +65,4 @@ public class ZLAndroidApplication extends Application { new ZLAndroidDialogManager(); new ZLAndroidLibrary(this); } - - @Override - public void onTerminate() { - super.onTerminate(); - } - - public void putData(Object key, Object value) { - myData.put(key, value); - } - - public void removeData(Object key) { - myData.remove(key); - } - - public Object getData(Object key) { - return myData.get(key); - } - - private final HashMap myData = new HashMap(); }