Initial
This commit is contained in:
commit
868bf973c7
83
build.xml
Normal file
83
build.xml
Normal file
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<project name="AcceLockView" default="jar" basedir=".">
|
||||
<description>Builds, tests, and runs the project .</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
pre-init: called before initialization of project properties
|
||||
post-init: called after initialization of project properties
|
||||
pre-preprocess: called before text preprocessing of sources
|
||||
post-preprocess: called after text preprocessing of sources
|
||||
pre-compile: called before source compilation
|
||||
post-compile: called after source compilation
|
||||
pre-obfuscate: called before obfuscation
|
||||
post-obfuscate: called after obfuscation
|
||||
pre-preverify: called before preverification
|
||||
post-preverify: called after preverification
|
||||
pre-jar: called before jar building
|
||||
post-jar: called after jar building
|
||||
pre-build: called before final distribution building
|
||||
post-build: called after final distribution building
|
||||
pre-clean: called before cleaning build products
|
||||
post-clean: called after cleaning build products
|
||||
|
||||
Example of pluging a my-special-task after the compilation could look like
|
||||
|
||||
<target name="post-compile">
|
||||
<my-special-task>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</my-special-task>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
Other way how to customize the build is by overriding existing main targets.
|
||||
The target of interest are:
|
||||
|
||||
preprocess: preprocessing
|
||||
extract-libs: extraction of libraries and resources
|
||||
compile: compilation
|
||||
create-jad: construction of jad and jar manifest source
|
||||
obfuscate: obfuscation
|
||||
preverify: preverification
|
||||
jar: jar archive building
|
||||
run: execution
|
||||
debug: execution in debug mode
|
||||
build: building of the final distribution
|
||||
javadoc: javadoc generation
|
||||
|
||||
Example of overriding the target for project execution could look like
|
||||
|
||||
<target name="run" depends="init,jar">
|
||||
<my-special-exec jadfile="${dist.dir}/${dist.jad}"/>
|
||||
</target>
|
||||
|
||||
Be careful about correct dependencies when overriding original target.
|
||||
Again, for list of available properties which you can use check the target
|
||||
you are overriding in nbproject/build-impl.xml file.
|
||||
|
||||
A special target for-all-configs can be used to run some specific targets for
|
||||
all project configurations in a sequence. File nbproject/build-impl.xml
|
||||
already contains some "for-all" targets:
|
||||
|
||||
jar-all
|
||||
javadoc-all
|
||||
clean-all
|
||||
|
||||
Example of definition of target iterating over all project configurations:
|
||||
|
||||
<target name="jar-all">
|
||||
<property name="target.to.call" value="jar"/>
|
||||
<antcall target="for-all-configs"/>
|
||||
</target>
|
||||
|
||||
-->
|
||||
</project>
|
1247
nbproject/build-impl.xml
Normal file
1247
nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
nbproject/genfiles.properties
Normal file
8
nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
build.xml.data.CRC32=8fbe159c
|
||||
build.xml.script.CRC32=312b9483
|
||||
build.xml.stylesheet.CRC32=9c6a911d
|
||||
nbproject/build-impl.xml.data.CRC32=8fbe159c
|
||||
nbproject/build-impl.xml.script.CRC32=1a76ba78
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=e46c2d22
|
7
nbproject/private/private.properties
Normal file
7
nbproject/private/private.properties
Normal file
@ -0,0 +1,7 @@
|
||||
#Wed, 05 Jan 2011 12:46:31 +0200
|
||||
app-version.autoincrement=true
|
||||
config.active=
|
||||
deployment.counter=15
|
||||
deployment.number=0.0.14
|
||||
javadoc.preview=true
|
||||
netbeans.user=C:\\Users\\aNNiMON\\Documents\\NetBeansProjects\\_NBModules\\Pastebin\\build\\testuserdir
|
5
nbproject/private/private.xml
Normal file
5
nbproject/private/private.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
</project-private>
|
142
nbproject/project.properties
Normal file
142
nbproject/project.properties
Normal file
@ -0,0 +1,142 @@
|
||||
abilities=MMAPI=1.1,SATSAJCRMI=1.0,SATSACRYPTO=1.0,lib/jsr256.jar=1.0,JSR82=1.1,JSR226=1.0,MIDP=2.0,JSR229=1.1.0,SATSAAPDU=1.0,CLDC=1.1,JSR177=1.0,JSR179=1.0.1,J2MEWS=1.0,WMA=2.0,JSR172=1.0,ColorScreen,OBEX=1.0,JSR238=1.0,JSR211=1.0,JSR234=1.0,lib/midpapi21.jar=1.0,JSR75=1.0,JSR184=1.1,SATSAPKI=1.0,ScreenHeight=225,ScreenColorDepth=8,JSR180=1.1.0,J2MEXMLRPC=1.0,
|
||||
all.configurations=\
|
||||
application.args=
|
||||
application.description=
|
||||
application.description.detail=
|
||||
application.name=
|
||||
application.vendor=Vendor
|
||||
build.classes.dir=${build.dir}/compiled
|
||||
build.classes.excludes=**/*.java,**/*.form,**/*.class,**/.nbintdb,**/*.mvd,**/*.wsclient,**/*.vmd
|
||||
build.dir=build/${config.active}
|
||||
build.root.dir=build
|
||||
debug.level=debug
|
||||
debugger.timeout=
|
||||
deployment.copy.target=deploy
|
||||
deployment.instance=default
|
||||
deployment.jarurl=${dist.jar}
|
||||
deployment.method=NONE
|
||||
deployment.override.jarurl=false
|
||||
dist.dir=dist/${config.active}
|
||||
dist.jad=AcceLockView.jad
|
||||
dist.jar=AcceLockView.jar
|
||||
dist.javadoc.dir=${dist.dir}/doc
|
||||
dist.root.dir=dist
|
||||
extra.classpath=
|
||||
filter.exclude.tests=false
|
||||
filter.excludes=changelog.txt
|
||||
filter.more.excludes=**/overview.html,**/package.html
|
||||
filter.use.standard=true
|
||||
jar.compress=true
|
||||
javac.debug=true
|
||||
javac.deprecation=false
|
||||
javac.encoding=UTF-8
|
||||
javac.optimize=false
|
||||
javac.source=1.3
|
||||
javac.target=1.3
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
libs.classpath=
|
||||
main.class=
|
||||
main.class.class=applet
|
||||
manifest.apipermissions=
|
||||
manifest.file=manifest.mf
|
||||
manifest.is.liblet=false
|
||||
manifest.jad=
|
||||
manifest.manifest=
|
||||
manifest.midlets=MIDlet-1: AcceLockView,/res/icon.png,Main\n
|
||||
manifest.others=MIDlet-Vendor: aNNiMON\nMIDlet-Name: AcceLockView\nMIDlet-Version: 1.1\n
|
||||
manifest.pushregistry=
|
||||
name=aNMPWR
|
||||
no.dependencies=false
|
||||
nokiaS80.application.icon=
|
||||
nsicom.application.monitorhost=
|
||||
nsicom.application.runremote=
|
||||
nsicom.application.runverbose=
|
||||
nsicom.remoteapp.location=\\My Documents\\NetBeans Applications
|
||||
nsicom.remotevm.location=\\Windows\\creme\\bin\\CrEme.exe
|
||||
obfuscated.classes.dir=${build.dir}/obfuscated
|
||||
obfuscation.custom=-keep public class * extends javax.microedition.midlet.MIDlet \n-obfuscationdictionary E:\\SETUPS\\Disk\\Programming\\Java\\compact.txt\n-dontusemixedcaseclassnames\n-repackageclasses ''
|
||||
obfuscation.level=1
|
||||
obfuscator.destjar=${build.dir}/obfuscated.jar
|
||||
obfuscator.srcjar=${build.dir}/before-obfuscation.jar
|
||||
platform.active=Sony_Ericsson_SDK_2_5_0_6_for_the_Java_TM__ME_Platform_Emulator_
|
||||
platform.active.description=Sony Ericsson SDK 2.5.0.6 for the Java(TM) ME Platform(Emulator)
|
||||
platform.apis=JSR234-1.0,J2ME-WS-1.0,JSR238-1.0,MMAPI-1.1,JSR256-1.1,NokiaUI-1.0,JSR75-1.0,WMA-2.0,JSR82-1.1
|
||||
platform.bootclasspath=${platform.home}/lib/jsr256.jar:${platform.home}/lib/jsr238.jar:${platform.home}/lib/jsr082.jar:${platform.home}/lib/nokiaext.jar:${platform.home}/lib/jsr75.jar:${platform.home}/lib/mmapi.jar:${platform.home}/lib/j2me-ws.jar:${platform.home}/lib/wma20.jar:${platform.home}/lib/jsr234.jar:${platform.home}/lib/cldcapi11.jar:${platform.home}/lib/midpapi20.jar
|
||||
platform.configuration=CLDC-1.1
|
||||
platform.device=SonyEricsson_JP8_240x320_Emu
|
||||
platform.fat.jar=true
|
||||
platform.profile=MIDP-2.0
|
||||
platform.trigger=CLDC
|
||||
platform.type=UEI-1.0.1
|
||||
preprocessed.dir=${build.dir}/preprocessed
|
||||
preverify.classes.dir=${build.dir}/preverified
|
||||
preverify.sources.dir=${build.dir}/preverifysrc
|
||||
resources.dir=resources
|
||||
ricoh.application.email=
|
||||
ricoh.application.fax=
|
||||
ricoh.application.icon=
|
||||
ricoh.application.target-jar=
|
||||
ricoh.application.telephone=
|
||||
ricoh.application.uid=91211980
|
||||
ricoh.application.version=
|
||||
ricoh.dalp.application-desc.auto-run=false
|
||||
ricoh.dalp.application-desc.energy-save=
|
||||
ricoh.dalp.application-desc.exec-auth=
|
||||
ricoh.dalp.application-desc.visible=true
|
||||
ricoh.dalp.argument=
|
||||
ricoh.dalp.codebase=
|
||||
ricoh.dalp.display-mode.color=true
|
||||
ricoh.dalp.display-mode.is-4line-support=false
|
||||
ricoh.dalp.display-mode.is-hvga-support=true
|
||||
ricoh.dalp.display-mode.is-vga-support=false
|
||||
ricoh.dalp.display-mode.is-wvga-support=false
|
||||
ricoh.dalp.information.abbreviation=
|
||||
ricoh.dalp.information.icon.basepath=
|
||||
ricoh.dalp.information.icon.location=
|
||||
ricoh.dalp.information.is-icon-used=true
|
||||
ricoh.dalp.install.destination=hdd
|
||||
ricoh.dalp.install.mode.auto=true
|
||||
ricoh.dalp.install.work-dir=hdd
|
||||
ricoh.dalp.is-managed=true
|
||||
ricoh.dalp.resources.dsdk.version=2.0
|
||||
ricoh.dalp.resources.jar.basepath=
|
||||
ricoh.dalp.resources.jar.version=
|
||||
ricoh.dalp.version=
|
||||
ricoh.icon.invert=false
|
||||
ricoh.platform.target.version=
|
||||
run.cmd.options=
|
||||
run.jvmargs=
|
||||
run.method=STANDARD
|
||||
run.security.domain=trusted
|
||||
run.use.security.domain=false
|
||||
savaje.application.icon=
|
||||
savaje.application.icon.focused=
|
||||
savaje.application.icon.small=
|
||||
savaje.application.uid=TBD
|
||||
savaje.bundle.base=
|
||||
savaje.bundle.debug=false
|
||||
savaje.bundle.debug.port=
|
||||
semc.application.caps=
|
||||
semc.application.icon=
|
||||
semc.application.icon.count=
|
||||
semc.application.icon.splash=
|
||||
semc.application.icon.splash.installonly=false
|
||||
semc.application.uid=E3524877
|
||||
semc.certificate.path=
|
||||
semc.private.key.password=
|
||||
semc.private.key.path=
|
||||
sign.alias=
|
||||
sign.enabled=false
|
||||
sign.keystore=
|
||||
src.dir=src
|
||||
use.emptyapis=true
|
||||
use.preprocessor=false
|
10
nbproject/project.xml
Normal file
10
nbproject/project.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.kjava.j2meproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2me-project">
|
||||
<name>AcceLockView</name>
|
||||
<minimum-ant-version>1.6</minimum-ant-version>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
147
src/AccelUtil.java
Normal file
147
src/AccelUtil.java
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* aNNiMON 2010
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.io.Connector;
|
||||
import javax.microedition.sensor.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class AccelUtil implements DataListener {
|
||||
|
||||
private int[] channels;
|
||||
private String[] channelNames;
|
||||
private SensorConnection sensor;
|
||||
private String URL; //URL для коннекта
|
||||
private int numChannels; //количество каналов
|
||||
private int dataType; //тип приёма данных
|
||||
private double
|
||||
minValue,//минимальное значение
|
||||
maxValue; //максимальное значение
|
||||
//Сохранённые
|
||||
private Vector saved;
|
||||
|
||||
public AccelUtil() {
|
||||
saved = new Vector();
|
||||
getInfo();
|
||||
}
|
||||
|
||||
public void checkKeys(int key) {
|
||||
if(key==Rms.keyC) savePositions();
|
||||
else if(key==Rms.keyF) saved.removeAllElements();
|
||||
}
|
||||
|
||||
public void savePositions() {
|
||||
saved.addElement(new Pos(channels[0], channels[1], channels[2]));
|
||||
}
|
||||
|
||||
public boolean isInPosition() {
|
||||
int x,y,z;
|
||||
x = channels[0];
|
||||
y = channels[1];
|
||||
z = channels[2];
|
||||
int SENS = Rms.sensetivity;
|
||||
int n = saved.size();
|
||||
for(int i = 0; i<n; i++) {
|
||||
Pos ps = (Pos)saved.elementAt(i);
|
||||
if( (ps.x > x-SENS) && (ps.x < x+SENS) &&
|
||||
(ps.y > y-SENS) && (ps.y < y+SENS) &&
|
||||
(ps.z > z-SENS) && (ps.z < z+SENS)) {
|
||||
if(Rms.lightsOff) com.nokia.mid.ui.DeviceControl.setLights(0, 100);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(Rms.lightsOff) com.nokia.mid.ui.DeviceControl.setLights(0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void getInfo() {
|
||||
//Получаем список ВСЕХ сенсоров
|
||||
SensorInfo[] info = SensorManager.findSensors(null, null);
|
||||
if (info==null || info.length==0) return; //ничего не нашли, выходим
|
||||
//Сканируем найденные сенсоры
|
||||
for(int i=0; i<info.length; i++) {
|
||||
//Узнаём тип устройства
|
||||
String quantity = info[i].getQuantity().toLowerCase();
|
||||
//Нам нужен acceleration
|
||||
if(quantity.startsWith("accel")) {
|
||||
//Нашли девайс
|
||||
SensorInfo s = info[i];
|
||||
//Получаем URL для коннекта с ним
|
||||
URL = s.getUrl();
|
||||
//Получаем каналы приёма данных
|
||||
ChannelInfo[] ci = s.getChannelInfos();
|
||||
//Получаем количество каналов
|
||||
numChannels = ci.length;
|
||||
//Инициализируем переменные
|
||||
channels = new int[numChannels];
|
||||
channelNames = new String[numChannels];
|
||||
//Получаем тип приёма данных (TYPE_DOUBLE = 1, TYPE_INT = 2, TYPE_OBJECT = 4)
|
||||
dataType = ci[0].getDataType();
|
||||
MeasurementRange mr = ci[0].getMeasurementRanges()[0];
|
||||
//Получаем минимальное значение
|
||||
minValue = mr.getSmallestValue();
|
||||
//Получаем максимальное значение
|
||||
maxValue = mr.getLargestValue();
|
||||
//Получаем названия каналов (axis_x, axis_y, axis_z)
|
||||
for (int j = 0; j < numChannels; j++) {
|
||||
channelNames[j] = ci[j].getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Для того, чтобы подключить DataListener, нужно соединение
|
||||
try {
|
||||
//Открываем соединение, по раннее полученному URL
|
||||
sensor = (SensorConnection) Connector.open(URL);
|
||||
sensor.setDataListener(this, 1); //1 - размер буфера
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void dataReceived(SensorConnection sensor, Data[] data, boolean isDataLost) {
|
||||
//Обработка данных
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
//Получаем имя канала и сравниваем с сохраненными раннее
|
||||
//Данные получаем в виде int от -1024 до 1024
|
||||
for(int j = 0; j < numChannels; j++) {
|
||||
String name = data[i].getChannelInfo().getName();
|
||||
if (name.equals(channelNames[j])) {
|
||||
channels[j] = getValue(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Преобразование в int [-1024...+1024]
|
||||
*/
|
||||
private int getValue(Object o) {
|
||||
int value = 0;
|
||||
double doublevalue = 0;
|
||||
if(dataType == ChannelInfo.TYPE_INT) {
|
||||
doublevalue = ((Data) o).getIntValues()[0];
|
||||
}else if(dataType == ChannelInfo.TYPE_DOUBLE) {
|
||||
doublevalue = ((Data) o).getDoubleValues()[0];
|
||||
}
|
||||
if(doublevalue>=0) value = (int) (doublevalue * 1024 / maxValue);
|
||||
else value = (int) (doublevalue * (-1024) / minValue);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private class Pos {
|
||||
int x,y,z;
|
||||
|
||||
Pos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
}
|
244
src/BufDataInputStream.java
Normal file
244
src/BufDataInputStream.java
Normal file
@ -0,0 +1,244 @@
|
||||
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class BufDataInputStream extends InputStream implements DataInput {
|
||||
|
||||
public static byte buffer[];
|
||||
public static int capacity, is_available, bpos, blen;
|
||||
protected InputStream is;
|
||||
|
||||
public BufDataInputStream(InputStream iis) throws IOException {
|
||||
bpos = blen = 0;
|
||||
is = iis;
|
||||
capacity = is_available = is.available();
|
||||
buffer = new byte[capacity];
|
||||
if (is != null) is.read(buffer);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (is != null) is.close();
|
||||
}
|
||||
|
||||
public int available() {
|
||||
return blen - bpos + is_available;
|
||||
}
|
||||
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public void seek(int pos) {
|
||||
bpos = pos;
|
||||
}
|
||||
|
||||
public int tell() throws IOException {
|
||||
return capacity - available();
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (bpos > buffer.length) {
|
||||
return -1;
|
||||
}
|
||||
return ((int) buffer[bpos++]) & 0xFF;
|
||||
}
|
||||
|
||||
public int readBack() throws IOException {
|
||||
if (bpos == 0) {
|
||||
if (available() == capacity) return -1;
|
||||
int old = tell();
|
||||
bpos = old;
|
||||
}
|
||||
return ((int) buffer[--bpos]) & 0xFF;
|
||||
}
|
||||
|
||||
public boolean readBoolean() throws IOException {
|
||||
int r = read();
|
||||
if (r == -1) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
return r != 0;
|
||||
}
|
||||
|
||||
public byte readByte() throws IOException {
|
||||
int r = read();
|
||||
if (r == -1) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
return (byte) r;
|
||||
}
|
||||
|
||||
public char readChar() throws IOException {
|
||||
return (char) ((readUnsignedByte() << 8) | readUnsignedByte());
|
||||
}
|
||||
|
||||
public void readFully(byte[] b) throws IOException {
|
||||
if (read(b) < b.length) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
}
|
||||
|
||||
public void readFully(byte[] b, int off, int len) throws IOException {
|
||||
if (read(b, off, len) < len) {
|
||||
throw new IOException("EOF");
|
||||
}
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (readUnsignedByte() << 24) |
|
||||
(readUnsignedByte() << 16) |
|
||||
(readUnsignedByte() << 8) |
|
||||
(readUnsignedByte());
|
||||
}
|
||||
|
||||
public long readLong() throws IOException {
|
||||
byte bb[] = new byte[8];
|
||||
readFully(bb);
|
||||
return (bb[0] << 24) |
|
||||
(bb[1] << 16) |
|
||||
(bb[2] << 8) |
|
||||
(bb[3]);
|
||||
}
|
||||
|
||||
public short readShort() throws IOException {
|
||||
return (short) ((readUnsignedByte() << 8) | readUnsignedByte());
|
||||
}
|
||||
|
||||
public int readUnsignedByte() throws IOException {
|
||||
return ((int) readByte()) & 0xFF;
|
||||
}
|
||||
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return ((int) readShort()) & 0xFFFF;
|
||||
}
|
||||
|
||||
public int skipBytes(int len) throws IOException {
|
||||
return (int) skip(len);
|
||||
}
|
||||
|
||||
public String readUTF() throws IOException, UTFDataFormatException {
|
||||
int n = readUnsignedShort();
|
||||
byte b[] = new byte[n];
|
||||
readFully(b);
|
||||
return new String(b, 0, b.length, "UTF-8");
|
||||
}
|
||||
|
||||
public char readCharUTF() throws IOException, UTFDataFormatException {
|
||||
int b, c, d;
|
||||
b = read();
|
||||
if (b == -1) {
|
||||
return (char) -1;
|
||||
}
|
||||
if ((b & 0x80) == 0) {
|
||||
return (char) b;
|
||||
} else if ((b & 0xE0) == 0xC0) {
|
||||
c = read();
|
||||
if ((c & 0xC0) != 0x80) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
return (char) (((b & 0x1F) << 6) | (c & 0x3F));
|
||||
} else if ((b & 0xF0) == 0xE0) {
|
||||
c = read();
|
||||
d = read();
|
||||
if ((c & 0xC0) != 0x80 || (d & 0xC0) != 0x80) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
return (char) (((b & 0x0F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F));
|
||||
}
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
|
||||
public char readCharBackUTF() throws IOException, UTFDataFormatException {
|
||||
int b, c, d;
|
||||
d = readBack();
|
||||
c = readBack();
|
||||
b = readBack();
|
||||
if (d == -1) {
|
||||
return (char) -1;
|
||||
}
|
||||
if ((d & 0x80) == 0) {
|
||||
read();
|
||||
read();
|
||||
return (char) d;
|
||||
} else if ((c & 0xE0) == 0xC0 && (d & 0xC0) == 0x80) {
|
||||
read();
|
||||
return (char) (((c & 0x1F) << 6) | (d & 0x3F));
|
||||
} else if ((b & 0xF0) == 0xE0 && (c & 0xC0) == 0x80 && (d & 0xC0) == 0x80) {
|
||||
return (char) (((b & 0x0F) << 12) | ((c & 0x3F) << 6) | (d & 0x3F));
|
||||
}
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
|
||||
public String readUTF(int count) throws IOException, UTFDataFormatException {
|
||||
String s = "";
|
||||
int i = 0;
|
||||
while (i < count && available() > 0) {
|
||||
s += readCharUTF();
|
||||
i++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public int skipUTF(int count) throws IOException, UTFDataFormatException {
|
||||
byte b;
|
||||
int i = 0, r = 0;
|
||||
while (i < count) {
|
||||
b = readByte();
|
||||
if ((b & 0x80) == 0) {
|
||||
r++;
|
||||
} else if ((((int) b) & 0xE0) == 0xC0) {
|
||||
readByte();
|
||||
r += 2;
|
||||
} else if ((((int) b) & 0xF0) == 0xE0) {
|
||||
readShort();
|
||||
r += 3;
|
||||
} else {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
public boolean checkBOM() {
|
||||
try {
|
||||
if (available() < 3 ||
|
||||
read() != 0xEF ||
|
||||
read() != 0xBB ||
|
||||
read() != 0xBF) {
|
||||
return false;
|
||||
}
|
||||
} catch (IOException iox) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean find(byte[] b) {
|
||||
if (b == null) return false;
|
||||
int po = 0;
|
||||
for (int i = bpos + 1; i < buffer.length; i++) {
|
||||
po = 0;
|
||||
if (buffer[i] == b[0]) {
|
||||
for (int j = 0; j < b.length; j++) { //System.out.println("b "+b[j]);
|
||||
if (buffer[i + j] == b[j]) {
|
||||
po += 1;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
if (po == b.length) {
|
||||
bpos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (po > 0);
|
||||
}
|
||||
|
||||
public float readFloat() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double readDouble() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
}
|
75
src/Effects.java
Normal file
75
src/Effects.java
Normal file
@ -0,0 +1,75 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Effects {
|
||||
|
||||
public static Image effect(Image img) {
|
||||
int[] pixel = new int[img.getWidth() * img.getHeight()];
|
||||
img.getRGB(pixel, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
|
||||
for (int io = 0; io < pixel.length; io++) {
|
||||
int qa = (pixel[io] >> 24) & 0xff;
|
||||
int qr = (pixel[io] >> 16) & 0xff;
|
||||
int qg = (pixel[io] >> 8) & 0xff;
|
||||
int qb = pixel[io] & 0xff;
|
||||
qr += UI.osv;if(qr>255) qr=255;if(qr<0) qr=0;
|
||||
qg += UI.osv;if(qg>255) qg=255;if(qg<0) qg=0;
|
||||
qb += UI.osv;if(qb>255) qb=255;if(qb<0) qb=0;
|
||||
pixel[io] = (qa << 24) | (qr << 16) | (qg << 8) | qb;
|
||||
|
||||
}
|
||||
return Image.createRGBImage(pixel, img.getWidth(), img.getHeight(), true);
|
||||
}
|
||||
|
||||
public static Image osv(Image img, byte mode) {
|
||||
int[] ar = new int[] {-255, -200, -150, -100, -50, 0, 50, 100, 150, 200, 255};
|
||||
//{-255,-60,-50,-40,-30,-20,-10,0,10,20,30,40,50,60,255};
|
||||
int osv = ar[mode];
|
||||
int[] pixel = new int[img.getWidth() * img.getHeight()];
|
||||
img.getRGB(pixel, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
|
||||
for (int io = 0; io < pixel.length; io++) {
|
||||
int qa = (pixel[io] >> 24) & 0xff;
|
||||
int qr = (pixel[io] >> 16) & 0xff;
|
||||
int qg = (pixel[io] >> 8) & 0xff;
|
||||
int qb = pixel[io] & 0xff;
|
||||
qr += osv;if(qr>255) qr=255;if(qr<0) qr=0;
|
||||
qg += osv;if(qg>255) qg=255;if(qg<0) qg=0;
|
||||
qb += osv;if(qb>255) qb=255;if(qb<0) qb=0;
|
||||
pixel[io] = (qa << 24) | (qr << 16) | (qg << 8) | qb;
|
||||
|
||||
}
|
||||
return Image.createRGBImage(pixel, img.getWidth(), img.getHeight(), true);
|
||||
}
|
||||
|
||||
public static Image Resize(Image temp, int newX, int newY)
|
||||
{
|
||||
newX=Math.abs(newX)+1; newY=Math.abs(newY)+1;
|
||||
int rgb[] = new int[temp.getWidth() * temp.getHeight()];
|
||||
temp.getRGB(rgb, 0, temp.getWidth(), 0, 0, temp.getWidth(), temp.getHeight());
|
||||
int rgb2[] = rescaleArray(rgb, temp.getWidth(), temp.getHeight(), newX, newY);
|
||||
Image temp2 = Image.createRGBImage(rgb2, newX, newY, true);
|
||||
return temp2;
|
||||
}
|
||||
|
||||
private static int[] rescaleArray(int ini[], int x, int y, int x2, int y2) {
|
||||
int out[] = new int[x2 * y2];
|
||||
for(int yy = 0; yy < y2; yy++) {
|
||||
int dy = (yy * y) / y2;
|
||||
for(int xx = 0; xx < x2; xx++) {
|
||||
int dx = (xx * x) / x2;
|
||||
out[x2 * yy + xx] = ini[x * dy + dx];
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static int acolor(int argb, char c) {
|
||||
if(c=='a') return ((argb >> 24) & 0xff);
|
||||
else if(c=='r') return ((argb >> 16) & 0xff);
|
||||
else if(c=='g') return ((argb >> 8) & 0xff);
|
||||
else if(c=='b') return (argb & 0xff);
|
||||
else return argb;
|
||||
}
|
||||
}
|
40
src/FWCashe.java
Normal file
40
src/FWCashe.java
Normal file
@ -0,0 +1,40 @@
|
||||
import javax.microedition.lcdui.Font;
|
||||
import java.util.Vector;
|
||||
|
||||
public class FWCashe {
|
||||
protected static Vector fwc = new Vector();
|
||||
protected static Vector fwc_f = new Vector();
|
||||
protected Object font;
|
||||
protected byte[][] caches;
|
||||
|
||||
public static FWCashe getCache(Object font) {
|
||||
int t = fwc.size();
|
||||
for (int i = 0; i < t; i++) {
|
||||
if (fwc_f.elementAt(i).equals(font))
|
||||
return (FWCashe)fwc.elementAt(i);
|
||||
}
|
||||
fwc_f.addElement(font);
|
||||
FWCashe f;
|
||||
fwc.addElement(f = new FWCashe (font));
|
||||
return f;
|
||||
}
|
||||
|
||||
protected FWCashe(Object font) {
|
||||
this.font = font;
|
||||
caches = new byte [256][];
|
||||
for (int i = 0; i < 256; i++)
|
||||
caches[i] = null;
|
||||
}
|
||||
|
||||
public int charWidth (char ch) {
|
||||
int hi = (ch >> 8)&0xFF, lo = (ch)&0xFF;
|
||||
if (caches[hi] == null) {
|
||||
caches[hi] = new byte [256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
caches [hi][i] = -1;
|
||||
}
|
||||
if (caches [hi][lo] == -1)
|
||||
caches [hi][lo] = (byte) Fonts.charWidth(font, ch);
|
||||
return caches [hi][lo];
|
||||
}
|
||||
}
|
38
src/Fonts.java
Normal file
38
src/Fonts.java
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
import javax.microedition.lcdui.Font;
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Fonts {
|
||||
|
||||
public static int getHeight(Object fnt) {
|
||||
if(fnt instanceof Font) {
|
||||
return ((Font) (fnt)).getHeight();
|
||||
}else{
|
||||
return ((TMyPngFont) (fnt)).getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public static int charWidth(Object fnt, char ch) {
|
||||
if(fnt instanceof Font) {
|
||||
return ((Font) (fnt)).charWidth(ch);
|
||||
}else{
|
||||
return ((TMyPngFont) (fnt)).CharWidth((byte) ch);
|
||||
}
|
||||
}
|
||||
|
||||
public static int stringWidth(Object fnt, String s) {
|
||||
if(fnt instanceof Font) {
|
||||
return ((Font) (fnt)).stringWidth(s);
|
||||
}else{
|
||||
return ((TMyPngFont) (fnt)).TextWidth(s);
|
||||
}
|
||||
}
|
||||
}
|
49
src/InputStreamDecoder.java
Normal file
49
src/InputStreamDecoder.java
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class InputStreamDecoder
|
||||
{
|
||||
private int enc;
|
||||
private BufDataInputStream bdis;
|
||||
|
||||
public InputStreamDecoder (BufDataInputStream bdis, String enc) throws UnsupportedEncodingException
|
||||
{
|
||||
if (enc.compareTo ("UTF-8") == 0) this.enc = 1;
|
||||
else if (enc.compareTo ("windows-1251") == 0) this.enc = 2;
|
||||
else throw new UnsupportedEncodingException ("Encoding " + enc + " is not supported");
|
||||
this.bdis = bdis;
|
||||
}
|
||||
|
||||
public char readChar() throws IOException
|
||||
{
|
||||
char c = (char)(-1);
|
||||
if (bdis.available () > 0)
|
||||
{
|
||||
if (enc == 2)
|
||||
{
|
||||
int i = bdis.read();
|
||||
if (i != -1)
|
||||
c = StringEncoder.decodeCharCP1251((byte)i);
|
||||
}
|
||||
else if (enc == 1) {int i = bdis.readCharUTF(); c = (char) (i);}
|
||||
else throw new IOException ("Internal InputStreamDecoder error");
|
||||
}
|
||||
return (char) (c);
|
||||
}
|
||||
|
||||
public char readCharBack () throws IOException
|
||||
{
|
||||
if (bdis.tell () <= 0) return (char)(-1);
|
||||
if (enc == 1) {
|
||||
int i = bdis.readCharBackUTF();
|
||||
return (char) (i);
|
||||
}
|
||||
else if (enc == 2) {
|
||||
int i = bdis.readBack();
|
||||
if (i == -1) return (char)(-1);
|
||||
return StringEncoder.decodeCharCP1251 ((byte)(i));
|
||||
}
|
||||
throw new IOException ("error");
|
||||
}
|
||||
}
|
17
src/Key.java
Normal file
17
src/Key.java
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sinaz
|
||||
*/
|
||||
public class Key {
|
||||
|
||||
public static int leftSoftKey = -6;//ALL Devices
|
||||
public static int rightSoftKey = -7;//ALL Devices
|
||||
public static int Back = -11;//SonyEricsson
|
||||
public static int C = -8;//SonyEricsson
|
||||
public static int Focus = -25;//SonyEricsson
|
||||
}
|
64
src/Landscape.java
Normal file
64
src/Landscape.java
Normal file
@ -0,0 +1,64 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Landscape {
|
||||
|
||||
public static Image I;
|
||||
public static Graphics G;
|
||||
private static int w,h;
|
||||
|
||||
public static void drawImage() {
|
||||
UI.drawRect(G, UI.col1, UI.col2, 0, 0, w, h);
|
||||
}
|
||||
|
||||
public static void init(int w, int h) {
|
||||
Landscape.w = w; Landscape.h = h;
|
||||
I = Image.createImage(w, h);
|
||||
G = I.getGraphics();
|
||||
}
|
||||
|
||||
public static void draw(Graphics g) {
|
||||
g.drawRegion(I, 0, 0, w, h, 5, 0, 0, 20);
|
||||
}
|
||||
|
||||
public static int reverseKey(int key) {
|
||||
if(!Rms.landscape) return key;
|
||||
switch(key) {
|
||||
case 50://KEY_NUM2:
|
||||
key = 52;//KEY_NUM4;
|
||||
break;
|
||||
case 52://KEY_NUM4:
|
||||
key = 56;//KEY_NUM8;
|
||||
break;
|
||||
case 54://KEY_NUM6:
|
||||
key = 50;//KEY_NUM2;
|
||||
break;
|
||||
case 56://KEY_NUM8:
|
||||
key = 54;//KEY_NUM6;
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public static int reverseActionKey(int ga) {
|
||||
if(!Rms.landscape) return ga;
|
||||
switch(ga) {
|
||||
case 1://UP:
|
||||
ga = 2;//LEFT;
|
||||
break;
|
||||
case 2://LEFT:
|
||||
ga = 6;//DOWN;
|
||||
break;
|
||||
case 5://RIGHT:
|
||||
ga = 1;//UP;
|
||||
break;
|
||||
case 6://DOWN:
|
||||
ga = 5;//RIGHT;
|
||||
break;
|
||||
}
|
||||
return ga;
|
||||
}
|
||||
}
|
125
src/Loading.java
Normal file
125
src/Loading.java
Normal file
@ -0,0 +1,125 @@
|
||||
import java.io.InputStream;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Loading extends Canvas implements Runnable {
|
||||
|
||||
private int w,h, sleep;
|
||||
private byte mode;
|
||||
private Thread thr;
|
||||
private Image logo1;
|
||||
private long lt;
|
||||
private boolean slp;
|
||||
private String aNMPWR;
|
||||
|
||||
public Loading() {
|
||||
setFullScreenMode(true);
|
||||
slp = true;
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
mode=0; sleep=3000;
|
||||
try {
|
||||
logo1 = load("/res/logo1.mdat", 3407);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
thr = new Thread(this);
|
||||
thr.start();
|
||||
}
|
||||
|
||||
public final void paint(Graphics g) {
|
||||
g.setColor(0x100201);
|
||||
g.fillRect(0,0,w,h);
|
||||
switch(mode) {
|
||||
case 1:
|
||||
g.drawImage(logo1, w/2, h/2, 3);
|
||||
g.setColor(0x990000);
|
||||
g.drawString(aNMPWR, w/2, 5, 17);
|
||||
repaint();
|
||||
break;
|
||||
case 2:
|
||||
slp = false;
|
||||
System.gc();
|
||||
Main.midlet.dsp.setCurrent(new aNMPWR());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
lt = System.currentTimeMillis();
|
||||
mode++;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public final void keyPressed(int key) {
|
||||
if(getGameAction(key)==FIRE) {
|
||||
lt = System.currentTimeMillis();
|
||||
mode++;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while(true) {
|
||||
if(!slp) break;
|
||||
if(System.currentTimeMillis()-lt>sleep) {
|
||||
mode++;
|
||||
lt = System.currentTimeMillis();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Image load(String str, int ii) {
|
||||
try {
|
||||
byte[] abyte0 = new byte[ii];
|
||||
InputStream dis = getClass().getResourceAsStream(str);
|
||||
dis.read(abyte0, 0, ii);
|
||||
BufDataInputStream bdis = new BufDataInputStream(dis);
|
||||
aNMPWR = bdis.readUTF();
|
||||
dis.close();
|
||||
int j;
|
||||
if (ii < 100) j = 10 + ii % 10;
|
||||
else if (ii < 200) j = 50 + ii % 20;
|
||||
else if (ii < 300) j = 80 + ii % 20;
|
||||
else j = 100 + ii % 50;
|
||||
for (int k = 0; k < j; k++) {
|
||||
byte byte0 = abyte0[k];
|
||||
abyte0[k] = abyte0[ii - k - 1];
|
||||
abyte0[ii - k - 1] = byte0;
|
||||
}
|
||||
byte[] start = new byte[] {(byte) 0x89, (byte) 0x50, (byte) 0x4E, (byte) 0x47,
|
||||
(byte) 0x0D, (byte) 0x0A, (byte) 0x1A, (byte) 0x0A,
|
||||
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0D,
|
||||
(byte) 0x49, (byte) 0x48, (byte) 0x44, (byte) 0x52};
|
||||
byte[] end = new byte[] {(byte) 0x49, (byte) 0x45, (byte) 0x4E, (byte) 0x44,
|
||||
(byte) 0xAE, (byte) 0x42, (byte) 0x60, (byte) 0x82};
|
||||
byte[] png = new byte[start.length+abyte0.length+end.length];
|
||||
int y = start.length;
|
||||
System.arraycopy(start, 0, png, 0, y);
|
||||
System.arraycopy(abyte0, 0, png, y, abyte0.length);
|
||||
y+=abyte0.length;
|
||||
System.arraycopy(end, 0, png, y, end.length);
|
||||
start=null;
|
||||
end=null;
|
||||
abyte0=null;
|
||||
//save(png);
|
||||
return Image.createImage(png, 0, png.length);
|
||||
} catch (Exception in) {
|
||||
in.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* private void save(byte[] png) throws IOException {
|
||||
javax.microedition.io.file.FileConnection fc = (javax.microedition.io.file.FileConnection) javax.microedition.io.Connector.open("file:///c:/anm.png");
|
||||
fc.create();
|
||||
java.io.OutputStream is = fc.openOutputStream();
|
||||
is.write(png);
|
||||
is.close();
|
||||
fc.close();
|
||||
|
||||
}*/
|
||||
}
|
35
src/Main.java
Normal file
35
src/Main.java
Normal file
@ -0,0 +1,35 @@
|
||||
import javax.microedition.midlet.*;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Main extends MIDlet {
|
||||
|
||||
public Display dsp;
|
||||
public static Main midlet;
|
||||
public static String name;
|
||||
public Loading cnv;
|
||||
|
||||
public Main () {
|
||||
midlet = this;
|
||||
}
|
||||
|
||||
public void startApp() {
|
||||
Rms.loadBookMarks();
|
||||
cnv = new Loading();
|
||||
cnv.setFullScreenMode(true);
|
||||
name = "AcceLockView";
|
||||
Util.getUI("/res/skin.ini");
|
||||
dsp = Display.getDisplay(this);
|
||||
dsp.setCurrent(cnv);
|
||||
}
|
||||
|
||||
public void pauseApp() {
|
||||
}
|
||||
|
||||
public void destroyApp(boolean un) {
|
||||
Rms.saveBookMarks();
|
||||
notifyDestroyed();
|
||||
}
|
||||
}
|
50
src/Options.java
Normal file
50
src/Options.java
Normal file
@ -0,0 +1,50 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/*
|
||||
* aNNiMON 2011
|
||||
* For more info visit http://annimon.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Options extends Form implements CommandListener{
|
||||
|
||||
private Displayable pv;
|
||||
private Command back, ok;
|
||||
private TextField key_C, key_F, sens;
|
||||
private ChoiceGroup cRC;
|
||||
|
||||
public Options(Displayable ds) {
|
||||
super("Настройки");
|
||||
pv = ds;
|
||||
ok = new Command("Ok", Command.OK, 1);
|
||||
back = new Command("Назад", Command.BACK, 3);
|
||||
cRC = new ChoiceGroup ("", ChoiceGroup.MULTIPLE);
|
||||
cRC.append("Выключать подсветку", null);
|
||||
cRC.setSelectedIndex(0, Rms.lightsOff);
|
||||
sens = new TextField("Чувствительность", String.valueOf(Rms.sensetivity), 3, TextField.NUMERIC);
|
||||
key_C = new TextField("Код клавиши установки", String.valueOf(Rms.keyC), 3, TextField.DECIMAL);
|
||||
key_F = new TextField("Код клавиши сброса", String.valueOf(Rms.keyF), 3, TextField.DECIMAL);
|
||||
append(cRC);
|
||||
append(sens);
|
||||
append(key_C);
|
||||
append(key_F);
|
||||
addCommand(back);
|
||||
addCommand(ok);
|
||||
setCommandListener(Options.this);
|
||||
}
|
||||
|
||||
public void commandAction(Command c, Displayable d) {
|
||||
if (c==back) Main.midlet.dsp.setCurrent(pv);
|
||||
else if(c == ok) {
|
||||
Rms.lightsOff = cRC.isSelected(0);
|
||||
Rms.sensetivity = Integer.parseInt(sens.getString());
|
||||
Rms.keyC = Integer.parseInt(key_C.getString());
|
||||
Rms.keyF = Integer.parseInt(key_F.getString());
|
||||
Main.midlet.dsp.setCurrent(pv);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
190
src/Rms.java
Normal file
190
src/Rms.java
Normal file
@ -0,0 +1,190 @@
|
||||
import java.io.*;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.rms.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Rms {
|
||||
|
||||
private static RecordStore bookmarksStore;
|
||||
private static final String bookmarksName = "ALV_bkmrk";
|
||||
protected static Vector bookmarks = new Vector();
|
||||
private static final String rmsName = "ALV";
|
||||
private static RecordStore rmsStore;
|
||||
public static boolean firstStart = true;
|
||||
public static boolean landscape = false;
|
||||
public static boolean fsmode = true;
|
||||
public static boolean lightsOff = false;
|
||||
public static byte osvmode = 5;
|
||||
public static int sensetivity = 80;
|
||||
public static int keyC = -8; //Установка
|
||||
public static int keyF = -25; //Сброс
|
||||
//public static int run = 0;
|
||||
|
||||
protected static class BookMarkRecord {
|
||||
|
||||
public String name;
|
||||
public int srcStart;
|
||||
public int srcEnd;
|
||||
}
|
||||
|
||||
public static void setBookMark(String name, int strpos, int endpos) {
|
||||
BookMarkRecord bmr = null;
|
||||
for (int i = 0; i < bookmarks.size(); i++) {
|
||||
bmr = (BookMarkRecord) bookmarks.elementAt(i);
|
||||
if (bmr.name.equals(name)) {
|
||||
bmr.srcStart = strpos;
|
||||
bmr.srcEnd = endpos;
|
||||
return;
|
||||
}
|
||||
}
|
||||
bmr = new BookMarkRecord();
|
||||
bmr.name = name;
|
||||
bmr.srcStart = strpos;
|
||||
bmr.srcEnd = endpos;
|
||||
bookmarks.addElement(bmr);
|
||||
}
|
||||
|
||||
public static int[] getBookMark(String name) {
|
||||
BookMarkRecord bmr = null;
|
||||
int[] r = new int[3];
|
||||
r[0]=-666;
|
||||
for (int i = 0; i < bookmarks.size(); i++) {
|
||||
bmr = (BookMarkRecord) bookmarks.elementAt(i);
|
||||
if (bmr.name.equals(name)) {
|
||||
r[0] = bmr.srcStart;
|
||||
r[1] = bmr.srcEnd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохранение закладок
|
||||
*/
|
||||
public static void saveBookMarks() {
|
||||
saveOptions();
|
||||
try {
|
||||
RecordStore.deleteRecordStore(bookmarksName);
|
||||
} catch (RecordStoreException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
bookmarksStore = RecordStore.openRecordStore(bookmarksName, true);
|
||||
|
||||
for (int i = 0; i < bookmarks.size(); i++) {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(baos);
|
||||
|
||||
dos.writeUTF(((BookMarkRecord) bookmarks.elementAt(i)).name);
|
||||
dos.writeInt(((BookMarkRecord) bookmarks.elementAt(i)).srcStart);
|
||||
dos.writeInt(((BookMarkRecord) bookmarks.elementAt(i)).srcEnd);
|
||||
|
||||
byte b[] = baos.toByteArray();
|
||||
bookmarksStore.addRecord(b, 0, b.length);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
bookmarksStore.closeRecordStore();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Чтение закладок из хранилища
|
||||
*/
|
||||
public static void loadBookMarks() {
|
||||
restoreOptions();
|
||||
bookmarks.removeAllElements();
|
||||
try {
|
||||
bookmarksStore = RecordStore.openRecordStore(bookmarksName, true);
|
||||
try {
|
||||
for (RecordEnumeration enumX = bookmarksStore.enumerateRecords(null, null, true); enumX.hasNextElement();) {
|
||||
int recId = enumX.nextRecordId();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(bookmarksStore.getRecord(recId));
|
||||
DataInputStream dis = new DataInputStream(bais);
|
||||
|
||||
BookMarkRecord bmr = new BookMarkRecord();
|
||||
bmr.name = dis.readUTF();
|
||||
bmr.srcStart = dis.readInt();
|
||||
bmr.srcEnd = dis.readInt();
|
||||
|
||||
bookmarks.addElement(bmr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
bookmarksStore.closeRecordStore();
|
||||
} catch (RecordStoreNotFoundException e) {
|
||||
} catch (RecordStoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveOptions() {
|
||||
if (rmsStore != null) {
|
||||
byte[] options = null;
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream(baos);
|
||||
dos.writeBoolean(firstStart);
|
||||
dos.writeInt(TextView.fntTextc);
|
||||
dos.writeByte(osvmode);
|
||||
dos.writeBoolean(fsmode);
|
||||
dos.writeBoolean(landscape);
|
||||
dos.writeInt(sensetivity);
|
||||
dos.writeInt(keyC);
|
||||
dos.writeInt(keyF);
|
||||
dos.writeBoolean(lightsOff);
|
||||
//dos.writeInt(run);
|
||||
dos.flush();
|
||||
options = baos.toByteArray();
|
||||
dos.close();
|
||||
rmsStore.setRecord(1, options, 0, options.length);
|
||||
} catch (InvalidRecordIDException ridex) {
|
||||
try {
|
||||
rmsStore.addRecord(options, 0, options.length);
|
||||
} catch (RecordStoreException ex) {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
if (rmsStore != null) {
|
||||
try {
|
||||
rmsStore.closeRecordStore();
|
||||
rmsStore = null;
|
||||
} catch (RecordStoreException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreOptions() {
|
||||
try {
|
||||
rmsStore = RecordStore.openRecordStore(rmsName, true);
|
||||
} catch (RecordStoreException ex) {
|
||||
rmsStore = null;
|
||||
}
|
||||
if (rmsStore != null) {
|
||||
try {
|
||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(rmsStore.getRecord(1)));
|
||||
firstStart = dis.readBoolean();
|
||||
TextView.fntTextc = dis.readInt();
|
||||
osvmode = dis.readByte();
|
||||
fsmode = dis.readBoolean();
|
||||
landscape = dis.readBoolean();
|
||||
sensetivity = dis.readInt();
|
||||
keyC = dis.readInt();
|
||||
keyF = dis.readInt();
|
||||
lightsOff = dis.readBoolean();
|
||||
//run = dis.readInt() + 1;
|
||||
dis.close();
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
src/StringEncoder.java
Normal file
30
src/StringEncoder.java
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
public class StringEncoder
|
||||
{
|
||||
protected static char cp1251 [] =
|
||||
{
|
||||
'\u0410', '\u0411', '\u0412', '\u0413', '\u0414', '\u0415', '\u0416',
|
||||
'\u0417', '\u0418', '\u0419', '\u041A', '\u041B', '\u041C', '\u041D',
|
||||
'\u041E', '\u041F', '\u0420', '\u0421', '\u0422', '\u0423', '\u0424',
|
||||
'\u0425', '\u0426', '\u0427', '\u0428', '\u0429', '\u042A', '\u042B',
|
||||
'\u042C', '\u042D', '\u042E', '\u042F', '\u0430', '\u0431', '\u0432',
|
||||
'\u0433', '\u0434', '\u0435', '\u0436', '\u0437', '\u0438', '\u0439',
|
||||
'\u043A', '\u043B', '\u043C', '\u043D', '\u043E', '\u043F', '\u0440',
|
||||
'\u0441', '\u0442', '\u0443', '\u0444', '\u0445', '\u0446', '\u0447',
|
||||
'\u0448', '\u0449', '\u044A', '\u044B', '\u044C', '\u044D', '\u044E',
|
||||
'\u044F'
|
||||
};
|
||||
|
||||
public static char decodeCharCP1251 (byte b)
|
||||
{
|
||||
int ich = b & 0xff;
|
||||
if (ich == 0xb8) // ё
|
||||
return 0x0451;
|
||||
else if (ich == 0xa8) // Ё
|
||||
return 0x0401;
|
||||
else if (ich >= 0xc0)
|
||||
return cp1251[ich-192];
|
||||
return (char)ich;
|
||||
}
|
||||
}
|
146
src/TMyPngFont.java
Normal file
146
src/TMyPngFont.java
Normal file
@ -0,0 +1,146 @@
|
||||
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.microedition.lcdui.Graphics;
|
||||
import javax.microedition.lcdui.Image;
|
||||
|
||||
public class TMyPngFont //extends TMyFont
|
||||
{
|
||||
|
||||
private Image FontImage = null;
|
||||
private short CharOffsetX[] = null;
|
||||
private short CharOffsetY[] = null;
|
||||
private byte CharWidth[] = null;
|
||||
private InputStream is;
|
||||
private byte height;
|
||||
private int textColor;
|
||||
private int backgroundColor;
|
||||
|
||||
int ReadWord() throws IOException {
|
||||
return (is.read() & 0xff) | (is.read() & 0xff) << 8;
|
||||
}
|
||||
|
||||
int ReadInt() throws IOException {
|
||||
return ((is.read() & 0xff) | (is.read() & 0xff) << 8) | ((is.read() & 0xff) | (is.read() & 0xff) << 8) << 16;
|
||||
}
|
||||
|
||||
byte ReadByte() throws IOException {
|
||||
return (byte) is.read();
|
||||
}
|
||||
|
||||
public TMyPngFont(String s) throws Exception {
|
||||
try {
|
||||
CharOffsetX = new short[256];
|
||||
CharOffsetY = new short[256];
|
||||
CharWidth = new byte[256];
|
||||
is = getClass().getResourceAsStream(s);
|
||||
if (ReadWord() != 13313)
|
||||
{
|
||||
is.close();
|
||||
throw new Exception();
|
||||
}
|
||||
ReadInt();
|
||||
height = ReadByte();
|
||||
ReadByte();
|
||||
textColor = ReadInt();
|
||||
backgroundColor = ReadInt();
|
||||
for (int l = 0; l < 32; l++) {
|
||||
CharOffsetX[l] = 0;
|
||||
CharOffsetY[l] = 0;
|
||||
CharWidth[l] = 0;
|
||||
}
|
||||
short word0 = 0;
|
||||
short word1 = 0;
|
||||
for (int i1 = 32; i1 < 256; i1++) {
|
||||
byte byte2 = ReadByte();
|
||||
if (word0 + byte2 > 200) {
|
||||
word0 = 0;
|
||||
word1 += ((short) height);
|
||||
}
|
||||
CharOffsetX[i1] = word0;
|
||||
CharOffsetY[i1] = word1;
|
||||
CharWidth[i1] = byte2;
|
||||
word0 += ((short) (byte2));
|
||||
}
|
||||
int imgsize = ReadInt();
|
||||
byte imgbyte[] = new byte[imgsize];
|
||||
is.read(imgbyte, 0, imgsize);
|
||||
is.close();
|
||||
FontImage = Image.createImage(imgbyte, 0, imgsize);
|
||||
backgroundColor = ChangeColor(0, backgroundColor);
|
||||
} catch (Exception exception) {
|
||||
throw new Exception();
|
||||
} catch (OutOfMemoryError outofmemoryerror) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetColor(int newcolor) {
|
||||
textColor = ChangeColor(newcolor |= 0xff000000, textColor);
|
||||
}
|
||||
|
||||
private int ChangeColor(int newcolor, int textColor) {
|
||||
textColor |= 0xff000000;
|
||||
int width = FontImage.getWidth();
|
||||
int height = FontImage.getHeight();
|
||||
int lenght = width * height;
|
||||
int pixelARGB[] = new int[lenght];
|
||||
FontImage.getRGB(pixelARGB, 0, width, 0, 0, width, height);
|
||||
for (int pos = 0; pos < lenght; pos++) {
|
||||
if (pixelARGB[pos] == textColor) {
|
||||
pixelARGB[pos] = newcolor;
|
||||
}
|
||||
}
|
||||
FontImage = Image.createRGBImage(pixelARGB, width, height, true);
|
||||
return textColor = newcolor - 0xff000000;
|
||||
}
|
||||
|
||||
public void DrawText(Graphics g, int x, int y, String s) {
|
||||
int[] clip = getClip(g);
|
||||
for (int k = 0; k < s.length(); k++) {
|
||||
int ch = s.charAt(k);
|
||||
/* unicode to ansi */
|
||||
ch = ch == 0x401 ? 0xa8 : ch == 0x451 ? 0xb8 : ch;
|
||||
ch = ch > 0x400 ? ch - 0x350 : ch;
|
||||
char c = (char) ch;
|
||||
if (CharWidth[c] == 0) continue;
|
||||
if (x + CharWidth[c] >= 0) {
|
||||
g.setClip(x, y, ((int) (CharWidth[c])), ((int) height));
|
||||
g.drawImage(FontImage, x - CharOffsetX[c], y - CharOffsetY[c], 20);
|
||||
}
|
||||
x += ((int) (CharWidth[c]));
|
||||
}
|
||||
g.setClip(clip[0], clip[1], clip[2], clip[3]);
|
||||
}
|
||||
|
||||
public int TextWidth(String s) {
|
||||
int j = 0;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
int ch = s.charAt(i);
|
||||
ch = ch == /*<2A>*/ 0x401 ? 0xa8 : ch == /*<2A>*/ 0x451 ? 0xb8 : ch;
|
||||
ch = ch > 0x400 ? ch - 0x350 : ch;//if (c > '\377') c = '\0';
|
||||
j += ((int) (CharWidth[ch]));
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public int CharWidth(byte byte0) {
|
||||
int i = ((int) (byte0));
|
||||
if (i < 0) i = 256 + i;
|
||||
return ((int) (CharWidth[i]));
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
private int[] getClip(Graphics g) {
|
||||
int[] a = new int[4];
|
||||
a[0]=g.getClipX(); a[1]=g.getClipY();
|
||||
a[2]=g.getClipWidth(); a[3]=g.getClipHeight();
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
731
src/TextView.java
Normal file
731
src/TextView.java
Normal file
@ -0,0 +1,731 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
import java.io.*;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.io.ConnectionNotFoundException;
|
||||
import javax.microedition.io.Connector;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class TextView extends Canvas {
|
||||
|
||||
public Displayable parent;
|
||||
// Чтение и запись текста
|
||||
private Image im;
|
||||
private BufDataInputStream bdis = null;
|
||||
private InputStreamDecoder isd = null;
|
||||
private String enc = null;
|
||||
private int scrStart, scrEnd, aupause, dry, iy;
|
||||
public static int fntTextc = 1;
|
||||
private int maxnumFont = 9;
|
||||
private boolean auto, center;
|
||||
//тред
|
||||
private boolean up,down;
|
||||
// Отрисовка текста и заголовок
|
||||
private FWCashe fch;
|
||||
private Object fntText;
|
||||
private String caption, dmi, lines[], url, urlname, imgname;
|
||||
private int linesPerScreen, fntTextHeight, w, h, lineposes[];
|
||||
private boolean wordWrapGlobal = true;
|
||||
// Полноэкранный режим
|
||||
private int color = UI.def;//буфер для цвета
|
||||
private int header, footer;
|
||||
private int fore = 0x000080;
|
||||
private int imgsh;
|
||||
private boolean showimage = false;
|
||||
private boolean showinf;
|
||||
|
||||
private AccelUtil au;
|
||||
|
||||
public TextView(AccelUtil au) {
|
||||
setFullScreenMode(true);
|
||||
this.au = au;
|
||||
initScreenModes();
|
||||
aupause=2; showinf=false;
|
||||
fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
fntTextHeight = Fonts.getHeight(fntText);
|
||||
fch = FWCashe.getCache(fntText);
|
||||
linesPerScreen = (h - 2*UI.getSoftBarHeight()) / (fntTextHeight+1)-1;
|
||||
lines = new String[linesPerScreen];
|
||||
lineposes = new int[linesPerScreen + 1];
|
||||
// инициализация переменных i/o
|
||||
bdis = null;
|
||||
isd = null;
|
||||
// фулл/не фулл скрин
|
||||
setFSMode(!Rms.fsmode);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
fntTextHeight = Fonts.getHeight(fntText);
|
||||
fch = FWCashe.getCache(fntText);
|
||||
linesPerScreen =(h - 2*UI.getSoftBarHeight()) / (fntTextHeight+1)-1;
|
||||
lines = new String[linesPerScreen];
|
||||
lineposes = new int[linesPerScreen + 1];
|
||||
// фулл/не фулл скрин
|
||||
setFSMode(Rms.fsmode);
|
||||
}
|
||||
|
||||
private void setFSMode(boolean nm) {
|
||||
Rms.fsmode = nm;
|
||||
int ft = Fonts.getHeight(fntText);
|
||||
if (!Rms.fsmode) {
|
||||
header = UI.getSoftBarHeight();
|
||||
footer = UI.getSoftBarHeight();
|
||||
} else {
|
||||
header = footer = 0;
|
||||
ft -= 1;
|
||||
}
|
||||
linesPerScreen =(h - (header+footer)) / (ft+1)-1;
|
||||
lines = new String[linesPerScreen];
|
||||
lineposes = new int[linesPerScreen + 1];
|
||||
if (bdis != null) {
|
||||
try {
|
||||
bdis.seek(scrStart);
|
||||
readScreen(wordWrapGlobal);
|
||||
} catch (Exception x) {
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void openStream(InputStream is) {
|
||||
clearScreen();
|
||||
if (bdis != null) bdis = null;
|
||||
try {
|
||||
bdis = new BufDataInputStream(is);
|
||||
try {
|
||||
detectEncoding();
|
||||
} catch (Exception exception) {
|
||||
enc = "windows-1251";
|
||||
}
|
||||
isd = new InputStreamDecoder(bdis, enc);
|
||||
if(scrStart < 0) scrStart = 0;
|
||||
bdis.seek(scrStart);
|
||||
if (is != null) {
|
||||
readScreen(wordWrapGlobal);
|
||||
repaint();
|
||||
}
|
||||
Main.midlet.dsp.setCurrent(this);
|
||||
} catch (Exception iox) {
|
||||
iox.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void detectEncoding() throws Exception {
|
||||
enc = "windows-1251";// 0xEFBBBF
|
||||
if (BufDataInputStream.buffer[0]==-17 && BufDataInputStream.buffer[1]==-69 && BufDataInputStream.buffer[2]==-65) enc="UTF-8";
|
||||
else if (checkUTF()) enc = "UTF-8";
|
||||
}
|
||||
|
||||
private boolean checkUTF() {
|
||||
if (bdis.available() <= 0) return false;
|
||||
String utf = "АЕИЙОУЭЮЯаеийоуэюя";
|
||||
int ch = 0;
|
||||
for (int i = 0; i < utf.length(); i++) {
|
||||
try {
|
||||
if (bdis.find((""+utf.charAt(i)).getBytes("UTF-8"))) ch++;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
BufDataInputStream.bpos = 0;
|
||||
}
|
||||
return (ch != 0);
|
||||
}
|
||||
|
||||
public void openFile(final String file, Displayable parent, String title) {
|
||||
this.parent = parent;
|
||||
//System.out.println(file);
|
||||
dmi=imgname=urlname=url="";
|
||||
caption = title;
|
||||
auto = center = false;
|
||||
switchFont(); getBKMRK();
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
InputStream is = null;
|
||||
if(file.equals("/res/about")) is = getClass().getResourceAsStream(file);
|
||||
else is = Connector.openInputStream("file://"+file);
|
||||
//FileConnection fc = (FileConnection) Connector.open("file://"+file);
|
||||
//is = fc.openInputStream();
|
||||
openStream(is);
|
||||
} catch (Exception x) {
|
||||
x.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void getBKMRK() {
|
||||
int[] lk = Rms.getBookMark(caption);
|
||||
if (lk[0] != -666) {
|
||||
scrStart = lk[0];
|
||||
scrEnd = lk[1];
|
||||
}
|
||||
setFSMode(false);
|
||||
}
|
||||
|
||||
private void closeStream() {
|
||||
Rms.setBookMark(caption, scrStart, scrEnd);
|
||||
if (bdis != null) {
|
||||
try {
|
||||
bdis.close();
|
||||
} catch (IOException iox) {
|
||||
iox.printStackTrace();
|
||||
}
|
||||
bdis = null;
|
||||
}
|
||||
if (parent != null) {
|
||||
Main.midlet.dsp.setCurrent(parent);
|
||||
parent = null;
|
||||
} else {
|
||||
Main.midlet.dsp.setCurrent(new aNMPWR());
|
||||
}
|
||||
}
|
||||
|
||||
private String readString(boolean wordWrap) {
|
||||
String s = "";
|
||||
int otst;
|
||||
if(UI.otst<0) center=true;
|
||||
else center=false;
|
||||
otst=Math.abs(UI.otst);
|
||||
int maxStrWidth = w - (otst+5);
|
||||
char c = '0', cmin1 = (char) -1;
|
||||
int afterspace = -1, cut = 0, strwidth = 0;
|
||||
try {
|
||||
if (bdis == null || bdis.available() <= 0) return null;
|
||||
|
||||
do {
|
||||
c = isd.readChar();
|
||||
|
||||
if(c=='i') {//img
|
||||
char ch='i';
|
||||
String u = "i"; int ul = fch.charWidth(ch);
|
||||
for(int i=0; i<3; i++) {
|
||||
ch=isd.readChar();
|
||||
u+=ch; ul+=fch.charWidth(ch);
|
||||
}
|
||||
if(u.equals("img/")) {
|
||||
do{ch=isd.readChar(); if(ch=='\n') break; u+=ch;}while(ch!=' ');//дочитываем url до конца
|
||||
String imgurl = u.substring(3).trim(); u="";
|
||||
//System.out.println(imgurl);
|
||||
im = getImage(imgurl);
|
||||
do{ch=isd.readChar(); if(ch=='\n') break; u+=ch;}while(ch!=' ');
|
||||
imgname = u.replace('_', ' '); u="";
|
||||
dmi = imgname.equals("")?urlname:imgname;
|
||||
continue;
|
||||
}else{
|
||||
s+=u; strwidth+=ul; continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(c=='h') {//парсинг http ссылок
|
||||
char ch='h';
|
||||
String u = "h"; int ul = fch.charWidth(ch);
|
||||
for(int i=0; i<6; i++) {
|
||||
ch=isd.readChar();
|
||||
u+=ch; ul+=fch.charWidth(ch);
|
||||
}
|
||||
if(u.equals("http://")) {
|
||||
do{ch=isd.readChar(); if(ch=='\n') break; u+=ch;}while(ch!=' ');//дочитываем url до конца
|
||||
url = u.replace('^','-').substring(7).trim(); u="";
|
||||
do{ch=isd.readChar(); if(ch=='\n') break; u+=ch;}while(ch!=' ');
|
||||
urlname = u.replace('_', ' '); u="";
|
||||
dmi = imgname.equals("")?urlname:imgname;
|
||||
continue;
|
||||
}else{
|
||||
s+=u; strwidth+=ul; continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (c != cmin1 && c != '\r') {s += c; strwidth += fch.charWidth(c); }
|
||||
|
||||
if ((c == cmin1) || (c == '\n')) {// новая строка или конец файла
|
||||
wordWrap = false;
|
||||
break;
|
||||
}
|
||||
if (c == ' ') afterspace = 0;
|
||||
else if (afterspace >= 0) afterspace++;
|
||||
} while (strwidth < maxStrWidth);
|
||||
|
||||
if (wordWrap && afterspace >= 0) cut += afterspace;
|
||||
else if (strwidth > maxStrWidth && c != ' ') cut = 1;
|
||||
if (cut > 0) {
|
||||
s = s.substring(0, s.length() - cut);
|
||||
if (enc.compareTo("UTF-8") != 0) {
|
||||
bdis.seek(bdis.tell() - cut);
|
||||
} else {
|
||||
for (int i = 0; i < cut; i++) {
|
||||
isd.readCharBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException iox) {
|
||||
return null;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private String readStringBack(boolean wordWrap) {
|
||||
String s = "";
|
||||
int otst;
|
||||
if(UI.otst<0) center=true;
|
||||
else center=false;
|
||||
otst=Math.abs(UI.otst);
|
||||
int maxStrWidth = w - (otst+5);
|
||||
char c = '0', cmin1 = (char) -1;
|
||||
int afterspace = -1;
|
||||
int cut = 0;
|
||||
int strwidth = 0;
|
||||
try {
|
||||
if (bdis == null || bdis.tell() <= 0) return null;
|
||||
|
||||
do {
|
||||
c = isd.readCharBack();
|
||||
if (c != cmin1 && c != '\r') {
|
||||
s = c + s;
|
||||
strwidth += fch.charWidth(c);
|
||||
}
|
||||
if ((c == cmin1) || (c == '\n' && s.length() > 1)) // новая строка или начало файла
|
||||
{
|
||||
wordWrap = false;
|
||||
break;
|
||||
}
|
||||
if (c == ' ') afterspace = 1;
|
||||
else if (c == '\n') afterspace = 0;
|
||||
else if (afterspace >= 0) afterspace++;
|
||||
} while (strwidth < maxStrWidth);
|
||||
|
||||
if (wordWrap && afterspace >= 0 && s.length() > afterspace) cut += afterspace;
|
||||
else if ((strwidth > maxStrWidth && c != ' ') || (c == '\n' && s.length() > 1)) cut = 1;
|
||||
if (cut > 0) {
|
||||
s = s.substring(cut, s.length());
|
||||
if (enc.compareTo("UTF-8") != 0) bdis.seek(bdis.tell() + cut);
|
||||
else {
|
||||
for (int i = 0; i < cut; i++) {
|
||||
isd.readChar();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException iox) {
|
||||
return null;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private void readScreen(boolean wordWrap) {
|
||||
try {
|
||||
for (int i = 0; i < linesPerScreen; i++) {
|
||||
lineposes[i] = bdis.tell();
|
||||
lines[i] = readString(wordWrap);
|
||||
}
|
||||
lineposes[linesPerScreen] = bdis.tell();
|
||||
scrStart = lineposes[0];
|
||||
scrEnd = lineposes[linesPerScreen];
|
||||
} catch (IOException iox) {
|
||||
iox.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearScreen() {
|
||||
for (int i = 0; i < linesPerScreen; i++) {
|
||||
lineposes[i] = 0;
|
||||
lines[i] = null;
|
||||
}
|
||||
lineposes[linesPerScreen] = 0;
|
||||
}
|
||||
|
||||
private void lineUp() {
|
||||
if(scrStart>0) iy+=5;
|
||||
if(iy<Fonts.getHeight(fntText)) return;
|
||||
else iy=0;
|
||||
try {
|
||||
if (scrStart > 0) {
|
||||
bdis.seek(scrStart);
|
||||
scrEnd = lineposes[linesPerScreen] = lineposes[linesPerScreen - 1];
|
||||
for (int i = linesPerScreen - 1; i > 0; i--) {
|
||||
lines[i] = lines[i - 1];
|
||||
lineposes[i] = lineposes[i - 1];
|
||||
}
|
||||
lines[0] = readStringBack(wordWrapGlobal);
|
||||
scrStart = lineposes[0] = bdis.tell();
|
||||
bdis.seek(scrEnd);
|
||||
}
|
||||
} catch (IOException iox) {
|
||||
}
|
||||
}
|
||||
|
||||
private void lineDown() {
|
||||
if (scrEnd < bdis.getCapacity()) iy-=5;
|
||||
if(iy>0) return;
|
||||
else iy=Fonts.getHeight(fntText);
|
||||
try {
|
||||
if (scrEnd < bdis.getCapacity()) {
|
||||
scrStart = lineposes[1];
|
||||
for (int i = 0; i < linesPerScreen - 1; i++) {
|
||||
lines[i] = lines[i + 1];
|
||||
lineposes[i] = lineposes[i + 1];
|
||||
}
|
||||
lineposes[linesPerScreen - 1] = lineposes[linesPerScreen];
|
||||
lines[linesPerScreen - 1] = readString(wordWrapGlobal);
|
||||
lineposes[linesPerScreen] = scrEnd = bdis.tell();
|
||||
}
|
||||
} catch (IOException iox) {}
|
||||
}
|
||||
|
||||
private void screenUp() {
|
||||
try {
|
||||
bdis.seek(scrStart);
|
||||
for (int i = 0; i < linesPerScreen; i++) {
|
||||
readStringBack(false);
|
||||
}
|
||||
readScreen(wordWrapGlobal);
|
||||
} catch (Exception iox) {}
|
||||
}
|
||||
|
||||
private void screenDown() {
|
||||
try {
|
||||
if (scrEnd < bdis.getCapacity()) {
|
||||
readScreen(wordWrapGlobal);
|
||||
}
|
||||
} catch (Exception iox) {}
|
||||
}
|
||||
|
||||
private void initScreenModes() {
|
||||
if(Rms.landscape) {
|
||||
w = getHeight();
|
||||
h = getWidth();
|
||||
Landscape.init(w, h);
|
||||
}else{
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
if(Rms.landscape) {
|
||||
if(checkosvmode()) {
|
||||
g.setColor(0xFFFFFF-osvcolor(0x67));
|
||||
g.fillRect(0, 0, w, h);
|
||||
} else Landscape.drawImage();
|
||||
portrait(Landscape.G);
|
||||
Landscape.draw(g);
|
||||
}else{
|
||||
if(checkosvmode()) {
|
||||
g.setColor(0xFFFFFF-osvcolor(0x67));
|
||||
g.fillRect(0, 0, w, h);
|
||||
} else {
|
||||
UI.drawRect(g, UI.col1, UI.col2, 0, 0, w, h);
|
||||
}
|
||||
portrait(g);
|
||||
}
|
||||
if(up) lineUp();
|
||||
else if(down) lineDown();
|
||||
if(auto) {
|
||||
try {Thread.sleep(20*aupause);} catch (InterruptedException ex) {ex.printStackTrace();}
|
||||
lineDown();
|
||||
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void portrait(Graphics g) {
|
||||
if(!au.isInPosition() && (!caption.equals("О программе"))) {
|
||||
UI.drawScreensaver(g);
|
||||
return;
|
||||
}
|
||||
if(showimage) {
|
||||
if(imgsh<(w/2)) imgsh+=5;
|
||||
UI.ACLS(g, w, h, 0x77000000);
|
||||
g.drawImage(im, imgsh, h/2, 3);
|
||||
UI.drawMenuInterface(g,imgname,"Закрыть",urlname);
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
g.setColor(osvcolor(UI.def));
|
||||
boolean png = fntText instanceof TMyPngFont;
|
||||
if(!png) g.setFont((Font)fntText);
|
||||
else if (Rms.osvmode==0 || Rms.osvmode==10) ((TMyPngFont) fntText).SetColor(osvcolor(UI.def));
|
||||
int otst; center=(UI.otst<0); otst=Math.abs(UI.otst); //выравнивание
|
||||
for (int i = 0; i < linesPerScreen; i++) {
|
||||
if (lines[i] != null) {
|
||||
try {
|
||||
parse(g, lines[i], otst, header+2+iy+i*(fntTextHeight + 1), i);
|
||||
} catch (Exception ex) {
|
||||
if(png) {
|
||||
((TMyPngFont) fntText).DrawText(g, otst, header + iy + 2 + i * (fntTextHeight + 1), lines[i].replace('\n',' '));//.drawString(, , Graphics.HCENTER | Graphics.TOP);
|
||||
}else{
|
||||
if(center) g.drawString(lines[i].replace('\n',' '), w/2, header + iy + 2 + i * (fntTextHeight + 1), Graphics.HCENTER | Graphics.TOP);
|
||||
else g.drawString(lines[i].replace('\n',' '), otst, header + iy + 2 + i * (fntTextHeight + 1), Graphics.LEFT | Graphics.TOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
drawPosition(g);
|
||||
if(showinf) {
|
||||
UI.drawRect(g, UI.curcol1, UI.curcol2, 0, h-UI.getSoftBarHeight()*2, w, UI.getSoftBarHeight());
|
||||
if(!png) g.setColor(UI.textcolor);
|
||||
//else ((TMyPngFont) fntText).SetColor(UI.textcolor);
|
||||
int cur = (scrStart+scrEnd)/2;
|
||||
int pr = cur*100/bdis.getCapacity();
|
||||
String t = String.valueOf(pr)+"% "+cur+ " из "+ bdis.getCapacity();
|
||||
if(png) ((TMyPngFont) fntText).DrawText(g, w/2-Fonts.stringWidth(fntText, t)/2, h-UI.getSoftBarHeight()-fntTextHeight, t);
|
||||
else g.drawString(t, w/2, h-UI.getSoftBarHeight(), 33);
|
||||
}
|
||||
if(Rms.fsmode) return;
|
||||
if(auto) UI.drawMenuInterface(g,caption+" "+Integer.toString(aupause),dmi,"Назад");
|
||||
else UI.drawMenuInterface(g,caption,dmi,"Назад");
|
||||
}
|
||||
|
||||
protected void keyPressed(int key) {
|
||||
int ga = getGameAction(key);
|
||||
ga = Landscape.reverseActionKey(ga);
|
||||
if (ga==UP) up=true;
|
||||
else if (ga==DOWN) down=true;
|
||||
else if (ga==RIGHT) {
|
||||
if(auto) {if(aupause<25)aupause++;}
|
||||
else screenDown();
|
||||
} else if (ga==LEFT) {
|
||||
if(auto) {if(aupause>0)aupause--;}
|
||||
else screenUp();
|
||||
} else if (ga==FIRE) auto=!auto;
|
||||
else if (key==KEY_NUM1) {//Прыгнуть вверх
|
||||
scrStart = bdis.bpos = 0;
|
||||
readScreen(wordWrapGlobal);
|
||||
} else if (key==KEY_NUM7) {//Прыгнуть вниз
|
||||
bdis.bpos = bdis.capacity - 3;
|
||||
readScreen(wordWrapGlobal);
|
||||
} else if (key==KEY_NUM3) {
|
||||
fntTextc++;
|
||||
if (fntTextc > maxnumFont) fntTextc = 1;
|
||||
switchFont();
|
||||
} else if (key==KEY_NUM9) {
|
||||
fntTextc--;
|
||||
if (fntTextc < 1) fntTextc = maxnumFont;
|
||||
switchFont();
|
||||
} else if (key==KEY_NUM0) {
|
||||
Rms.osvmode++;
|
||||
if(Rms.osvmode>10) Rms.osvmode=0;
|
||||
repaint();
|
||||
} else if (key==KEY_STAR) {
|
||||
showinf=!showinf;
|
||||
} else if (key==Key.leftSoftKey) {
|
||||
if (leftSoft()) {
|
||||
return;
|
||||
}
|
||||
} else if (key==Key.rightSoftKey) {
|
||||
rightSoft();
|
||||
} else if (key==Key.Back) closeStream();
|
||||
else if(key==KEY_POUND) setFSMode(!Rms.fsmode);
|
||||
au.checkKeys(key);
|
||||
repaint();
|
||||
}
|
||||
|
||||
private boolean leftSoft() {
|
||||
if (im != null) {
|
||||
showimage = !showimage;
|
||||
imgsh = -im.getWidth() / 2;
|
||||
return true;
|
||||
}
|
||||
if (url.equals("")) return true;
|
||||
try {
|
||||
Main.midlet.platformRequest("http://" + url.toLowerCase());
|
||||
} catch (ConnectionNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void rightSoft() {
|
||||
if (showimage && !url.equals("")) {
|
||||
try {
|
||||
Main.midlet.platformRequest("http://" + url.toLowerCase());
|
||||
} catch (ConnectionNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else closeStream();
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
dry = piy;
|
||||
int y = UI.getSoftBarHeight();
|
||||
if(pix<2*y && piy>h-y) {
|
||||
if (leftSoft()) {
|
||||
return;
|
||||
}
|
||||
}else if(pix>w-2*y && piy>h-y) {
|
||||
rightSoft();
|
||||
}
|
||||
}
|
||||
|
||||
protected void pointerDragged(int pix, int piy) {
|
||||
if(dry>piy) {
|
||||
while(dry>piy) {
|
||||
dry-=2;
|
||||
lineDown();
|
||||
}
|
||||
}else{
|
||||
while(dry<piy) {
|
||||
dry+=2;
|
||||
lineUp();
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void keyReleased(int keyCode) {
|
||||
int ga = getGameAction(keyCode);
|
||||
ga = Landscape.reverseActionKey(ga);
|
||||
if (ga==UP) up=false;
|
||||
else if (ga==DOWN) down=false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void keyRepeated(int keyCode) {
|
||||
int ga = getGameAction(keyCode);
|
||||
ga = Landscape.reverseActionKey(ga);
|
||||
if (ga==RIGHT) screenDown();
|
||||
else if (ga==LEFT) screenUp();
|
||||
}
|
||||
|
||||
private void parse(Graphics g, String all, int xcar, int ycar, int il) throws Exception {
|
||||
int x=0;
|
||||
String cen = "";
|
||||
boolean png = fntText instanceof TMyPngFont;
|
||||
String[] cs = threshold(all, ' ', true);
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
String s = cs[i].toLowerCase();
|
||||
if (s.length()>1 && s.startsWith("#")) {
|
||||
color = getColor(g, s.substring(1).toLowerCase());
|
||||
//i++;
|
||||
continue;
|
||||
}else{
|
||||
int temp = Fonts.stringWidth(fntText, cs[i]+" ");
|
||||
if(!png) g.setColor(osvcolor(color));
|
||||
//else ((TMyPngFont) fntText).SetColor(osvcolor(color));
|
||||
if(center || png) {
|
||||
cen+=cs[i].replace('\n',' ')+" ";//
|
||||
} else {
|
||||
//if(png) ((TMyPngFont) fntText).DrawText(g, x+xcar, ycar, cs[i].replace('\n',' '));
|
||||
g.drawString(cs[i].replace('\n',' '), x+xcar, ycar, 20);
|
||||
x+=temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(center) {
|
||||
if(png) ((TMyPngFont) fntText).DrawText(g, w/2-Fonts.stringWidth(fntText, cen)/2, ycar, cen);
|
||||
else g.drawString(cen, w/2, ycar, 17);
|
||||
}else{
|
||||
if(png) ((TMyPngFont) fntText).DrawText(g, xcar, ycar, cen);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPosition(Graphics g) {
|
||||
g.setColor(fore);
|
||||
int slall = h - header - footer;
|
||||
int slpos = 0;
|
||||
int slend = 0;
|
||||
try {
|
||||
slpos = header + slall * scrStart / bdis.getCapacity();
|
||||
slend = header + slall * scrEnd / bdis.getCapacity();
|
||||
if (slend > h - footer) slend = h - footer;
|
||||
} catch (Exception iox) {
|
||||
return;
|
||||
}
|
||||
g.drawLine(w - 1, slpos, w - 1, slend);
|
||||
}
|
||||
|
||||
private Image getImage(String path) {
|
||||
Image img = Image.createImage(1, 1);
|
||||
try {
|
||||
img = Image.createImage(path);
|
||||
} catch (IOException ex) {
|
||||
try {
|
||||
img = Image.createImage(getClass().getResourceAsStream(path));
|
||||
} catch (IOException ex1) {
|
||||
ex1.printStackTrace();
|
||||
}
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
private String[] threshold(String s, char c, boolean remove) {
|
||||
Vector ml = new Vector();
|
||||
int j = s.length();
|
||||
String s2 = "";
|
||||
for(int k = 0; k < j; k++) {
|
||||
int i = s.charAt(k);
|
||||
if(i == c) {
|
||||
if(s2.length() > 0) {
|
||||
if(!remove) s2+=" "+String.valueOf(c);
|
||||
ml.addElement(s2);
|
||||
s2 = "";
|
||||
}
|
||||
} else {
|
||||
s2 = s2 + String.valueOf((char)i);
|
||||
}
|
||||
}
|
||||
if(s2.length() > 0) {
|
||||
if(!remove) s2+=" "+String.valueOf(c);
|
||||
ml.addElement(s2);
|
||||
}
|
||||
String[] m = new String[ml.size()];
|
||||
ml.copyInto(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
private int getColor(Graphics g, String q) {
|
||||
if (q.equals("yellow")) return clr(255, 255, 0);
|
||||
if (q.equals("pink")) return clr(255, 192, 203);
|
||||
if (q.equals("orange")) return clr(255, 165, 0);
|
||||
if (q.equals("gold")) return clr(255, 215, 0);
|
||||
if (q.equals("lime")) return clr(0, 255, 0);
|
||||
if (q.equals("red")) return clr(255, 0, 0);
|
||||
if (q.equals("green")) return clr(0, 128, 0);
|
||||
if (q.equals("blue")) return clr(0, 0, 255);
|
||||
if (q.equals("black")) return clr(0, 0, 0);
|
||||
if (q.equals("white")) return clr(255, 255, 255);
|
||||
if (q.equals("purple")) return clr(0, 0, 255);
|
||||
if (q.equals("maroon")) return clr(128, 0, 0);
|
||||
if (q.equals("0")) return 0;
|
||||
if (q.length()==6) return Integer.parseInt(q,16);
|
||||
return UI.def;
|
||||
}
|
||||
|
||||
private int clr(int r, int g, int b) {
|
||||
int rgb = (r << 16) | (g << 8) | b;
|
||||
return rgb;
|
||||
}
|
||||
|
||||
private int osvcolor(int def) {
|
||||
int col = def;
|
||||
if (Rms.osvmode==0) col=0xFFFFFF;
|
||||
else if (Rms.osvmode==10) col=0;
|
||||
return col;
|
||||
}
|
||||
|
||||
private boolean checkosvmode() {
|
||||
return (Rms.osvmode==0 || Rms.osvmode==10);
|
||||
}
|
||||
|
||||
private void switchFont() {
|
||||
switch (fntTextc) {
|
||||
case 1: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL); break;
|
||||
case 2: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL); break;
|
||||
case 3: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM); break;
|
||||
case 4: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM); break;
|
||||
case 5: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_LARGE); break;
|
||||
case 6: fntText = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE); break;
|
||||
}
|
||||
if(fntTextc>6 && fntTextc<=maxnumFont) {
|
||||
try {
|
||||
fntText = new TMyPngFont("/res/" + String.valueOf(fntTextc - 6));
|
||||
((TMyPngFont)fntText).SetColor(osvcolor(UI.def));
|
||||
} catch (Exception ex) {
|
||||
fntTextc=1; switchFont();
|
||||
}
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
}
|
136
src/UI.java
Normal file
136
src/UI.java
Normal file
@ -0,0 +1,136 @@
|
||||
|
||||
import java.util.Calendar;
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class UI {
|
||||
|
||||
protected static final Font smallFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
protected static final Font bigboldFont = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE);
|
||||
public static Font stFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
|
||||
public static Font bstFont = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM);
|
||||
public static int col1=0xD0419f62, col2=0xD077da9a;
|
||||
public static int curcol1=0xDCF8D6, curcol2=0x75B68C;
|
||||
public static int textcolor=0xFFFFFF, timecolor=0xFFFFFF;
|
||||
public static int textnc = 0x296321, shadow = 0x282828, def = 0xFFFFFF;
|
||||
public static int osv=180;
|
||||
public static int otst = 2;
|
||||
//int col1=0xD0419f62, col2=0xD077da9a;джунгли
|
||||
private static int MFHeight = smallFont.getHeight();
|
||||
private static boolean isLight=false;
|
||||
|
||||
public static void drawMenuInterface(Graphics g, String title, String leftsoft, String rightsoft) {
|
||||
drawTitle(g, title);
|
||||
drawTimeSoftBar(g, leftsoft, rightsoft);
|
||||
}
|
||||
|
||||
public static void drawTimeSoftBar(Graphics g, String left, String right) {
|
||||
int w = g.getClipWidth(); int h = g.getClipHeight();
|
||||
int y = h - getSoftBarHeight() + 1;
|
||||
int fontHeight = MFHeight;
|
||||
int cY = (h + y + 1 - fontHeight) / 2;
|
||||
showTime(g, smallFont, w/2, h);
|
||||
g.setColor(textcolor);
|
||||
g.setFont(smallFont);
|
||||
if (left != null) {
|
||||
if(Rms.landscape) {
|
||||
g.drawString(left, w-2, cY, Graphics.TOP | Graphics.RIGHT);
|
||||
}else g.drawString(left, 2, cY, Graphics.TOP | Graphics.LEFT);
|
||||
}
|
||||
if (right != null) {
|
||||
if(Rms.landscape) {
|
||||
g.drawString(right, w-2, 2, Graphics.TOP | Graphics.RIGHT);
|
||||
}else g.drawString(right, (w-2), cY, Graphics.TOP | Graphics.RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawScreensaver(Graphics g) {
|
||||
int w = g.getClipWidth();
|
||||
int h = g.getClipHeight();
|
||||
g.setColor(0);
|
||||
showTime(g, bigboldFont, w/2, h/2);
|
||||
}
|
||||
|
||||
public static void drawTitle(Graphics g, String title) {
|
||||
int w = g.getClipWidth();
|
||||
if (isLight) {
|
||||
g.setColor(col1);
|
||||
g.fillRect(0, 0, w, getSoftBarHeight() + 1);
|
||||
} else {
|
||||
drawRect(g, col1, col2, 0, 0, w, getSoftBarHeight() + 1);
|
||||
}
|
||||
if (title != null) {
|
||||
g.setColor(textcolor);
|
||||
g.setFont(smallFont);
|
||||
if(Rms.landscape) g.drawString(title, 2, 2, 20);
|
||||
else g.drawString(title, w/2, 2, Graphics.TOP | Graphics.HCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawPointerEvents(Graphics g) {
|
||||
int w = g.getClipWidth(); int h = g.getClipHeight();
|
||||
int q = getSoftBarHeight();
|
||||
g.setColor(col1);
|
||||
g.fillTriangle(w-q, h-q, w-q-q, h-q-q, w, h-q-q);
|
||||
g.fillTriangle(w-q, q, w-q-q, q+q, w, q+q);
|
||||
}
|
||||
|
||||
public static void showTime(Graphics g, Font font, int x, int y) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int w = g.getClipWidth(); int h = g.getClipHeight();
|
||||
String s = calendar.get(11) + "";
|
||||
String s1 = calendar.get(12) + "";
|
||||
if (s.length() == 1) s = "0" + s;
|
||||
if (s1.length() == 1) s1 = "0" + s1;
|
||||
int r1=Effects.acolor(col2, 'r');
|
||||
int g1=Effects.acolor(col2, 'g');
|
||||
int b1=Effects.acolor(col2, 'b');
|
||||
int fh=UI.getSoftBarHeight()-2;
|
||||
g.setColor(r1, g1, b1);
|
||||
g.fillRect(0, (h-fh)+1, w, fh);
|
||||
int k = font.stringWidth(s + ":" + s1) / 2;
|
||||
g.setFont(font);
|
||||
g.setColor(timecolor);
|
||||
g.drawString(s + ":" + s1, x - k, y, 36);
|
||||
}
|
||||
|
||||
public static void drawRect(Graphics g, int color1, int color2, int x1, int y1, int w, int h) {
|
||||
int r1 = ((color1 & 0xFF0000) >> 16);
|
||||
int g1 = ((color1 & 0x00FF00) >> 8);
|
||||
int b1 = (color1 & 0x0000FF);
|
||||
int r2 = ((color2 & 0xFF0000) >> 16);
|
||||
int g2 = ((color2 & 0x00FF00) >> 8);
|
||||
int b2 = (color2 & 0x0000FF);
|
||||
|
||||
int count = h / 3;
|
||||
if (count < 0) count = -count;
|
||||
if (count < 8) count = 8;
|
||||
int crd1, crd2;
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
crd1 = i * h / count + y1;
|
||||
crd2 = (i + 1) * h / count + y1;
|
||||
if (crd1 == crd2) continue;
|
||||
g.setColor(i * (r2 - r1) / (count - 1) + r1, i * (g2 - g1) / (count - 1) + g1, i * (b2 - b1) / (count - 1) + b1);
|
||||
g.fillRect(x1, crd1, w, crd2 - crd1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ACLS(Graphics g, int w, int h, int color) {
|
||||
int[] pixelArray = new int[w * h];
|
||||
for (int io = 0; io < pixelArray.length; io++) {
|
||||
pixelArray[io] = color;
|
||||
}
|
||||
g.drawRGB(pixelArray, 0, w, 0, 0, w, h, true);
|
||||
}
|
||||
|
||||
public static int getSoftBarHeight() {
|
||||
return smallFont.getHeight() + 2;
|
||||
}
|
||||
}
|
159
src/Util.java
Normal file
159
src/Util.java
Normal file
@ -0,0 +1,159 @@
|
||||
import java.io.*;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import javax.microedition.io.Connector;
|
||||
import javax.microedition.io.file.*;
|
||||
import javax.microedition.lcdui.Image;
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
private static Enumeration en;
|
||||
|
||||
public static String[] getFiles(String s) {
|
||||
Vector vector = new Vector();
|
||||
try {
|
||||
FileConnection fc = null;
|
||||
if ("/".equals(s)) {
|
||||
en = FileSystemRegistry.listRoots();
|
||||
} else {
|
||||
fc = (FileConnection) Connector.open("file://" + s, 1);
|
||||
en = fc.list();
|
||||
}
|
||||
String s1;
|
||||
for (; en.hasMoreElements(); vector.addElement(s1)) {
|
||||
s1 = (String) en.nextElement();
|
||||
}
|
||||
if (fc != null) {
|
||||
fc.close();
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
}
|
||||
if ("/".equals(s)) {
|
||||
vector.addElement("Настройки");
|
||||
vector.addElement("О программе");
|
||||
}
|
||||
String[] as;
|
||||
as = new String[vector.size()];
|
||||
vector.copyInto(as);
|
||||
String as1[] = new String[as.length];
|
||||
int i = 0;
|
||||
for (int j = 0; j < as.length; j++) {
|
||||
if (as[j].indexOf("/") != -1) {
|
||||
as1[i] = as[j];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < as.length; k++) {
|
||||
if (as[k].indexOf("/") == -1) {
|
||||
as1[i] = as[k];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return as1;
|
||||
}
|
||||
|
||||
public static String[] getDataAList(String path) {
|
||||
return getFiles(path);
|
||||
}
|
||||
|
||||
public static String getText(InputStream is) {
|
||||
StringBuffer strBuff = new StringBuffer();
|
||||
int ch = 0;
|
||||
try {
|
||||
while ((ch = is.read()) != -1) {
|
||||
strBuff.append(StringEncoder.decodeCharCP1251((byte)ch));//(char) ((ch >= 0xc0 && ch <= 0xFF) ? (ch + 0x350) : ch));
|
||||
}
|
||||
} catch (Exception e) {e.printStackTrace();}
|
||||
return strBuff.toString();
|
||||
}
|
||||
|
||||
public static Image getImage(String s, String s1) {
|
||||
Image image = Image.createImage(1, 1);
|
||||
String fileName = s+s1;
|
||||
if(!fileName.startsWith("file://")) fileName="file://"+fileName;
|
||||
FileConnection fc;
|
||||
try {
|
||||
fc = (FileConnection) Connector.open(fileName, Connector.READ);
|
||||
InputStream fis = fc.openInputStream();
|
||||
image = Image.createImage(fis);
|
||||
fis.close();
|
||||
fc.close();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
public static String[] threshold(String s, String s1, boolean data)
|
||||
{
|
||||
Vector ml = new Vector();
|
||||
char c = s1.charAt(0);
|
||||
int j = s.length();
|
||||
String s2 = "";
|
||||
for(int k = 0; k < j; k++)
|
||||
{
|
||||
int i = s.charAt(k);
|
||||
if(i == c)
|
||||
{
|
||||
if(s2.length() > 0)
|
||||
{
|
||||
if(data) ml.addElement(s2.substring(0, s2.lastIndexOf('-')).replace('^', '-').trim());
|
||||
else ml.addElement(s2.substring(s2.lastIndexOf('-')+1).replace('^', '-').trim());
|
||||
s2 = "";
|
||||
}
|
||||
} else
|
||||
{
|
||||
s2 = s2 + String.valueOf((char)i);
|
||||
}
|
||||
}
|
||||
if(s2.length() > 0) {
|
||||
if(data) ml.addElement(s2.substring(0, s2.lastIndexOf('-')).replace('^', '-').trim());
|
||||
else ml.addElement(s2.substring(s2.lastIndexOf('-')+1).replace('^', '-').trim());
|
||||
}
|
||||
String[] m;
|
||||
m = new String[ml.size()];
|
||||
ml.copyInto(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static void getUI(String path) {
|
||||
try {
|
||||
String[] k = null;
|
||||
InputStream is = Main.midlet.getClass().getResourceAsStream(path);
|
||||
k = threshold(getText(is), "\n", false);
|
||||
UI.col1 = color(k[0]);
|
||||
UI.col2 = color(k[1]);
|
||||
UI.curcol1 = color(k[2]);
|
||||
UI.curcol2 = color(k[3]);
|
||||
UI.osv = Integer.parseInt(k[4].trim().replace('^', '-'));
|
||||
UI.textcolor = color(k[5]);
|
||||
UI.timecolor = color(k[6]);
|
||||
UI.textnc = color(k[7]);
|
||||
UI.shadow = color(k[8]);
|
||||
UI.def = color(k[9]);
|
||||
UI.otst = Integer.parseInt(k[10].trim());
|
||||
is.close();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static int color(String str) {
|
||||
int i = 0;
|
||||
try {
|
||||
i=Integer.parseInt(str.trim(), 16);
|
||||
}catch(Exception ex) {
|
||||
i=Integer.parseInt(str.trim());
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
82
src/Viewer.java
Normal file
82
src/Viewer.java
Normal file
@ -0,0 +1,82 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
/**
|
||||
* @author aNNiMON
|
||||
*/
|
||||
public class Viewer extends Canvas {
|
||||
|
||||
private int w,h,x,y;
|
||||
private Image img, timg;
|
||||
private Displayable qb = null;
|
||||
private int imageWidth,imageHeight,stx,sty;
|
||||
private AccelUtil au;
|
||||
|
||||
public Viewer(Image img, Displayable q, AccelUtil au) {
|
||||
setFullScreenMode(true);
|
||||
this.au = au;
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
qb=q;
|
||||
this.img=timg=img;
|
||||
init();
|
||||
stx = 10;
|
||||
sty = 10;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
imageWidth = img.getWidth();
|
||||
imageHeight = img.getHeight();
|
||||
x=w/2;
|
||||
y=h/2;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
setFullScreenMode(true);
|
||||
UI.drawRect(g, UI.col1, UI.col2, 0, 0, w, h);
|
||||
if(!au.isInPosition()) {
|
||||
UI.drawScreensaver(g);
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
g.drawImage(img, x, y, Graphics.HCENTER | Graphics.VCENTER);
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void sizeChanged(int w, int h) {
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
init();
|
||||
super.sizeChanged(w, h);
|
||||
}
|
||||
|
||||
public void keyPressed(int key) {
|
||||
int ga=getGameAction(key);
|
||||
if (ga == UP && y<imageHeight/2) {y=y+sty<imageHeight/2 ? y+sty : y + (imageHeight/2-y);}
|
||||
else if (ga == DOWN && y>(h-imageHeight/2)) {y=y-sty>(h-imageHeight/2) ? y-sty : y + (h-imageHeight/2-y);}
|
||||
else if (ga == LEFT && x<imageWidth/2) {x=x+stx<imageWidth/2 ? x+stx : x + (imageWidth/2-x); }
|
||||
else if (ga == RIGHT && x>(w-imageWidth/2)) {x=x-stx>(w-imageWidth/2) ? x-stx : x + (w-imageWidth/2-x);}
|
||||
else if (ga == FIRE || key==Key.rightSoftKey || key==Key.leftSoftKey) {
|
||||
Main.midlet.dsp.setCurrent(qb);
|
||||
}else if(key==KEY_STAR) {
|
||||
if((imageHeight<=h) && (imageWidth<=w)) {
|
||||
if (timg.getHeight()!=imageHeight) img = timg;
|
||||
else return;
|
||||
}else{
|
||||
if(imageHeight>imageWidth) img = Effects.Resize(img, imageWidth*h/imageHeight, h);
|
||||
else img = Effects.Resize(img, w, imageHeight*w/imageWidth);
|
||||
}
|
||||
init();
|
||||
}
|
||||
au.checkKeys(key);
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
if(qb!=null) Main.midlet.dsp.setCurrent(qb);
|
||||
}
|
||||
|
||||
public void keyRepeated(int key) {
|
||||
keyPressed(key);
|
||||
}
|
||||
|
||||
}
|
307
src/aNMPWR.java
Normal file
307
src/aNMPWR.java
Normal file
@ -0,0 +1,307 @@
|
||||
import javax.microedition.lcdui.*;
|
||||
|
||||
|
||||
public class aNMPWR extends Canvas implements Runnable {
|
||||
|
||||
public String pathFile, aaall;
|
||||
private int FileY, CursorY, startPrintFile;
|
||||
private int cu, h, w, sh, fh;
|
||||
private Font MainFont = Font.getFont(Font.STYLE_PLAIN, Font.STYLE_PLAIN, Font.SIZE_SMALL);
|
||||
private Font BordFont = Font.getFont(Font.STYLE_PLAIN, Font.STYLE_BOLD, Font.SIZE_SMALL);
|
||||
private String[][] data = new String[10][50];
|
||||
private int[] index = new int[10];
|
||||
private int idx=0, len=0;
|
||||
private int bb=0;
|
||||
private long ty;
|
||||
private boolean prkr=false, moveleft=true;
|
||||
private int chm;//плавный курсор
|
||||
private Thread thr;
|
||||
private AccelUtil au;
|
||||
private String[] TypeImg = {
|
||||
"gif","jpeg","jpg","bmp","png"
|
||||
};
|
||||
|
||||
public aNMPWR() {
|
||||
this("/");
|
||||
}
|
||||
|
||||
public aNMPWR(String s) {
|
||||
setFullScreenMode(true);
|
||||
FileY = 0; CursorY = 0; startPrintFile = 0; cu = 0;
|
||||
pathFile = s;
|
||||
thr = new Thread(this);
|
||||
initScreenModes();
|
||||
fh = MainFont.getHeight() + 2;
|
||||
sh = BordFont.getHeight() + 3;
|
||||
chm = 0;
|
||||
au = new AccelUtil();
|
||||
thr.start();
|
||||
restart();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while(true) {
|
||||
if(prkr) {
|
||||
if(moveleft) {
|
||||
if (bb > -(len-w)) {
|
||||
bb -= 2;
|
||||
} else {moveleft=!moveleft;}
|
||||
}else{
|
||||
if (bb < 0) {
|
||||
bb += 2;
|
||||
//if(Rms.run>=InputStreamDecoder.bb) Main.midlet.destroyApp(true);
|
||||
} else {moveleft=!moveleft;}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
} catch (Exception ex) {}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initScreenModes() {
|
||||
if(Rms.landscape) {
|
||||
w = getHeight();
|
||||
h = getWidth();
|
||||
Landscape.init(w, h);
|
||||
}else{
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
setFullScreenMode(true);
|
||||
if(Rms.landscape) {
|
||||
Landscape.drawImage();
|
||||
portrait(Landscape.G);
|
||||
Landscape.draw(g);
|
||||
}else{
|
||||
UI.drawRect(g, UI.col1, UI.col2, 0, 0, w, h);
|
||||
portrait(g);
|
||||
}
|
||||
}
|
||||
|
||||
public void portrait(Graphics g) {
|
||||
if(!au.isInPosition() && (!pathFile.equals("/"))) {
|
||||
UI.drawScreensaver(g);
|
||||
return;
|
||||
}
|
||||
mainDisp(g);
|
||||
if(pathFile.equals("/")) UI.drawMenuInterface(g, Main.name, "Выбор","Назад");
|
||||
else UI.drawMenuInterface(g, data[idx-1][index[idx-1]], "Выбор","Назад");
|
||||
if(hasPointerEvents()) UI.drawPointerEvents(g);
|
||||
if(chm<0) {chm+=fh/5;repaint();}
|
||||
if(chm>0) {chm-=fh/5;repaint();}
|
||||
}
|
||||
|
||||
private void mainDisp(Graphics g) {
|
||||
g.setFont(MainFont);
|
||||
g.translate(0, sh);
|
||||
FileY = 0;
|
||||
for (int i = startPrintFile; i < data[idx].length; i++) {
|
||||
if (FileY == CursorY) {
|
||||
FileY+=chm;
|
||||
drawCursor(g);
|
||||
g.setColor(UI.shadow);
|
||||
g.setFont(BordFont);
|
||||
len = BordFont.stringWidth(data[idx][i]);
|
||||
if(len<w) {
|
||||
prkr=false;
|
||||
g.drawString(data[idx][i], w/2, FileY+1, 17);
|
||||
}
|
||||
else {
|
||||
prkr=true;
|
||||
g.drawString(data[idx][i], bb, FileY+1, 20);
|
||||
}
|
||||
FileY -=chm;
|
||||
FileY += fh;
|
||||
continue;
|
||||
}
|
||||
g.setColor(UI.textnc);
|
||||
g.setFont(MainFont);
|
||||
g.drawString(data[idx][i], w/2, FileY+1, 17);
|
||||
FileY += fh;
|
||||
}
|
||||
g.translate(0, -sh);
|
||||
}
|
||||
|
||||
private void restart() {
|
||||
data[idx] = Util.getDataAList(pathFile);
|
||||
}
|
||||
|
||||
private void backDir() {
|
||||
if(pathFile.equals("/") || idx==0) {Main.midlet.destroyApp(true);}
|
||||
int i = pathFile.lastIndexOf('/', pathFile.length() - 2);
|
||||
if (i != -1 && idx>0) {
|
||||
pathFile = pathFile.substring(0, i + 1);
|
||||
} else {
|
||||
pathFile = "/";
|
||||
CursorY = 0;
|
||||
cu = 0;
|
||||
startPrintFile = 0;
|
||||
return;
|
||||
}
|
||||
idx--;
|
||||
CursorY = index[idx]*fh;
|
||||
cu = index[idx];
|
||||
startPrintFile = 0;
|
||||
}
|
||||
|
||||
private void nextDir(int s) {
|
||||
if(data[idx][s].toLowerCase().endsWith("/")) {
|
||||
pathFile += data[idx][s];
|
||||
index[idx]=s;
|
||||
idx++;
|
||||
restart();
|
||||
cu = 0;
|
||||
startPrintFile = 0;
|
||||
CursorY = 0;
|
||||
}else if(getType(TypeImg, data[idx][s])) {
|
||||
Image image1 = null;
|
||||
image1 = Util.getImage(pathFile, data[idx][s]);
|
||||
Main.midlet.dsp.setCurrent(new Viewer(image1, this, au));
|
||||
}else {
|
||||
if(data[idx][s].equals("Настройки")) {
|
||||
Main.midlet.dsp.setCurrent(new Options(this));
|
||||
}else{
|
||||
TextView tv = new TextView(au);
|
||||
if(data[idx][s].equals("О программе")) tv.openFile("/res/about", this, data[idx][s]);
|
||||
else tv.openFile(pathFile+data[idx][s], this, data[idx][s]);
|
||||
//Viewer tv = new Viewer(Util.getText(JM.midlet.getClass().getResourceAsStream(back[idx][s])), this);
|
||||
Main.midlet.dsp.setCurrent(tv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void keyPressed(int key) {
|
||||
bb=0;moveleft=true;
|
||||
int ga = getGameAction(key);
|
||||
ga = Landscape.reverseActionKey(ga);
|
||||
if (key == Key.leftSoftKey) nextDir(cu);
|
||||
if (key == Key.rightSoftKey || key==Key.Back || key==KEY_NUM0) backDir();
|
||||
if(key==KEY_STAR) {Rms.landscape=!Rms.landscape; initScreenModes();}
|
||||
switch (ga) {
|
||||
case RIGHT:
|
||||
case DOWN:
|
||||
cursorDown();
|
||||
break;
|
||||
case LEFT:
|
||||
case UP:
|
||||
cursorUp();
|
||||
break;
|
||||
case FIRE:
|
||||
nextDir(cu);
|
||||
break;
|
||||
}
|
||||
au.checkKeys(key);
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void pointerPressed(int pix, int piy) {
|
||||
int q = UI.getSoftBarHeight();
|
||||
if(pix<2*q && piy>h-q) {
|
||||
nextDir(cu);
|
||||
}else if((piy<h-q && piy>h-q-q) && (pix>w-2*q)) {
|
||||
cursorDown();
|
||||
}else if((piy>q && piy<q+q) && (pix>w-2*q)) {
|
||||
cursorUp();
|
||||
}else if(pix>w-2*q && piy>h-q) {
|
||||
backDir();
|
||||
}else{
|
||||
int cu1=cu;
|
||||
piy-=q;
|
||||
if(piy>0 && piy<data[idx].length*fh) {
|
||||
cu=startPrintFile+piy/fh;
|
||||
CursorY = piy/fh*fh;
|
||||
}
|
||||
if(System.currentTimeMillis()-ty<700 && cu1==cu) nextDir(cu);
|
||||
ty = System.currentTimeMillis();
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void keyRepeated(int key) {
|
||||
keyPressed(key);
|
||||
}
|
||||
|
||||
private void drawCursor(Graphics g) {
|
||||
int r1=Effects.acolor(UI.curcol1, 'r');int r2=Effects.acolor(UI.curcol2, 'r');
|
||||
int g1=Effects.acolor(UI.curcol1, 'g');int g2=Effects.acolor(UI.curcol2, 'g');
|
||||
int b1=Effects.acolor(UI.curcol1, 'b');int b2=Effects.acolor(UI.curcol2, 'b');
|
||||
int pr,pg,pb;
|
||||
int yn=0;
|
||||
int curw = BordFont.stringWidth(data[idx][cu])+1;
|
||||
if(UI.curcol1==UI.curcol2) {
|
||||
g.setColor(UI.curcol1);
|
||||
g.fillRect(0, FileY+1, w, fh);
|
||||
}else{
|
||||
for(int i=0; i<fh; i++) {
|
||||
for(int j=curw; j<curw+fh/2; j++) {
|
||||
pr=r1 + (((i - fh) + 1) * (r2 - r1)) / (fh - yn - 1) + (r2 - r1);
|
||||
pg=g1 + (((i - fh) + 1) * (g2 - g1)) / (fh - yn - 1) + (g2 - g1);
|
||||
pb=b1 + (((i - fh) + 1) * (b2 - b1)) / (fh - yn - 1) + (b2 - b1);
|
||||
int prgb=(pr+pg+pb)/3;
|
||||
g.setColor(prgb, prgb, prgb);
|
||||
g.drawLine(0, FileY+1+i, w, FileY+1+i);
|
||||
g.setColor(pr, pg, pb);
|
||||
g.drawLine(w/2-j/2-i, FileY+1+i, w/2+j/2+i, FileY+1+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cursorDown() {
|
||||
if (data[idx].length > 0) {
|
||||
if (cu == data[idx].length - 1) {
|
||||
CursorY = 0;
|
||||
cu = 0;
|
||||
startPrintFile = 0;
|
||||
} else if (cu > (h - 2 * sh) / fh - 3) {
|
||||
if (CursorY >= h - 2 * sh - 2 * fh) {
|
||||
startPrintFile++;
|
||||
cu++;
|
||||
} else {
|
||||
cu++;
|
||||
CursorY += fh;
|
||||
}
|
||||
} else {
|
||||
CursorY += fh;
|
||||
cu++;
|
||||
}
|
||||
chm=-fh;
|
||||
}
|
||||
}
|
||||
|
||||
private void cursorUp() {
|
||||
if (data[idx].length > 0) {
|
||||
if (cu == 0) {
|
||||
cu = data[idx].length - 1;
|
||||
if (data[idx].length > (h - 2 * sh) / fh) {
|
||||
startPrintFile = (data[idx].length - (h - 2 * sh) / fh) + 1;
|
||||
CursorY = (data[idx].length - 1 - startPrintFile) * fh;
|
||||
} else {
|
||||
CursorY = (data[idx].length - 1) * fh;
|
||||
}
|
||||
} else if ((CursorY == 0) & (cu > 0)) {
|
||||
startPrintFile--;
|
||||
cu--;
|
||||
} else if (CursorY > 0) {
|
||||
CursorY -= fh;
|
||||
cu--;
|
||||
}
|
||||
chm=fh;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getType(String[] t, String data) {
|
||||
for (int i = 0; i < t.length; i++) {
|
||||
if (data.toLowerCase().endsWith("." + t[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
21
src/res/about
Normal file
21
src/res/about
Normal file
@ -0,0 +1,21 @@
|
||||
AcceLockView
|
||||
|
||||
Автор: Виктор aNNiMON Мельник
|
||||
Автор идеи: Витёк 007 Гальченко
|
||||
|
||||
Программа для телефонов с поддержкой акселерометра. При определённом наклоне телефона, показывает файловый менеджер, в котором можно читать текст. При всех остальных наклонах - показывает заставку. Смысл заключается в следующем: открыл на телефоне шпаргалку, установил телефон в неподвижное состояние и нажал кнопку добавления позиции (кнопка фокусировки или C), списываем. Если кто-то посторонний возьмёт телефон, он увидит лишь заставку, так как наверняка не сможет установить телефон в нужное положение.
|
||||
|
||||
Версия 1.1:
|
||||
- Универсальная работа с акселерометром.
|
||||
- Добавлены настройки кодов клавиш и чувствительности.
|
||||
- Добавлен просмотрщик картинок.
|
||||
- Добавлена возможность выключения подсветки, вместо показа часов
|
||||
|
||||
Управление:
|
||||
Кнопка фокусировки камеры - сбросить все позиции
|
||||
C - добавление позиции
|
||||
* - повернуть экран горизонтально
|
||||
0, возврат, прав.софт - назад
|
||||
|
||||
aNNiMON (Melnik Software) 2011
|
||||
http://annimon.com/ оф.сайт
|
BIN
src/res/icon.png
Normal file
BIN
src/res/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 671 B |
BIN
src/res/logo1.mdat
Normal file
BIN
src/res/logo1.mdat
Normal file
Binary file not shown.
11
src/res/skin.ini
Normal file
11
src/res/skin.ini
Normal file
@ -0,0 +1,11 @@
|
||||
1 - 303030
|
||||
2 - 606060
|
||||
3 - A9A8E2
|
||||
4 - 0602C0
|
||||
5 - ^140
|
||||
6 - D46905
|
||||
7 - A5A575
|
||||
8 - FFFFE7
|
||||
9 - ffffff
|
||||
0 - ffffff
|
||||
1 - 4
|
Loading…
Reference in New Issue
Block a user