mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
unused code has been removed
This commit is contained in:
parent
0bf87697a7
commit
6a25dd54e9
17 changed files with 0 additions and 1158 deletions
|
@ -25,7 +25,6 @@ import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
|
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
|
||||||
import org.geometerplus.zlibrary.core.options.ZLIntegerRangeOption;
|
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.core.resources.ZLResource;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.view.style.*;
|
import org.geometerplus.zlibrary.text.view.style.*;
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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);
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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<String> getValues();
|
|
||||||
|
|
||||||
public abstract void onAccept(String value);
|
|
||||||
|
|
||||||
public void onReset() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.zlibrary.core.dialogs;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|
||||||
|
|
||||||
public abstract class ZLDialogContent {
|
|
||||||
private final ZLResource myResource;
|
|
||||||
protected final ArrayList<ZLOptionView> Views = new ArrayList<ZLOptionView>();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,8 +24,6 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
public abstract class ZLDialogManager {
|
public abstract class ZLDialogManager {
|
||||||
protected static ZLDialogManager ourInstance;
|
protected static ZLDialogManager ourInstance;
|
||||||
|
|
||||||
public static final String COLOR_KEY = "color";
|
|
||||||
|
|
||||||
protected ZLDialogManager() {
|
protected ZLDialogManager() {
|
||||||
ourInstance = this;
|
ourInstance = this;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +33,4 @@ public abstract class ZLDialogManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void wait(String key, Runnable runnable);
|
public abstract void wait(String key, Runnable runnable);
|
||||||
|
|
||||||
protected static ZLResource getResource() {
|
|
||||||
return ZLResource.resource("dialog");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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();
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.zlibrary.core.dialogs;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|
||||||
|
|
||||||
public abstract class ZLOptionsDialog {
|
|
||||||
private final ZLResource myResource;
|
|
||||||
protected final ArrayList<ZLDialogContent> myTabs = new ArrayList<ZLDialogContent>();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
|
@ -1,127 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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<String> optionNames = myData.myOptionNames;
|
|
||||||
final HashMap<String,ZLColorOption> options = myData.myOptions;
|
|
||||||
final HashMap<String,ZLColor> 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<String> 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<String> myOptionNames = new ArrayList<String>();
|
|
||||||
private final HashMap<String,ZLColor> myCurrentColors = new HashMap<String,ZLColor>();
|
|
||||||
private final HashMap<String,ZLColorOption> myOptions = new HashMap<String,ZLColorOption>();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,234 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,140 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,146 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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<View> myAndroidViews = new ArrayList<View>();
|
|
||||||
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<View> getAndroidViews() {
|
|
||||||
if (myAndroidViews.isEmpty()) {
|
|
||||||
final ArrayList<ZLOptionView> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.zlibrary.ui.android.dialogs;
|
|
||||||
|
|
||||||
interface ZLAndroidDialogInterface {
|
|
||||||
void setActivity(DialogActivity activity);
|
|
||||||
void endActivity();
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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();
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2010 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.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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -65,23 +65,4 @@ public class ZLAndroidApplication extends Application {
|
||||||
new ZLAndroidDialogManager();
|
new ZLAndroidDialogManager();
|
||||||
new ZLAndroidLibrary(this);
|
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<Object,Object> myData = new HashMap<Object,Object>();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue