mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
more items
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1308 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
dbe5bad5ea
commit
1c3661dfa2
12 changed files with 72 additions and 37 deletions
|
@ -15,6 +15,9 @@ DONE убрать иконку сетевого поиска из библиот
|
||||||
** NetworkSearchService
|
** NetworkSearchService
|
||||||
DONE модель + функционал поиска
|
DONE модель + функционал поиска
|
||||||
** отображение результатов
|
** отображение результатов
|
||||||
|
** изменить вид библиотеки -- вместо дерева -- последовательные view без сдвига вправо (как в маркете)
|
||||||
|
** при нажатии на кнопку 'Esc' -- возвращаться к предыдущему view + прерывать загрузку, если она еще идет
|
||||||
|
** соответственно, каталог должен иметь не 2 состояния -- загружен/не загружен, а загружен полностью/не полностью/не загружен; в случае загрузки не полностью можно при повторном открытии продолжать загрузку с точки, где прервались (для тех каталогов, что подделены на куски по 20 (или сколько-то) книг
|
||||||
** восставление пароля (use default e-mail)
|
** восставление пароля (use default e-mail)
|
||||||
** пополнение счета в litres с помощью sms
|
** пополнение счета в litres с помощью sms
|
||||||
** Focus в Authentication dialog
|
** Focus в Authentication dialog
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.6.2
|
0.6.3
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.amse.ys.zip;
|
package org.amse.ys.zip;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
abstract class AbstractDeflatingDecompressor extends Decompressor {
|
abstract class AbstractDeflatingDecompressor extends Decompressor {
|
||||||
abstract void reset(MyBufferedInputStream inputStream, LocalFileHeader header);
|
abstract void reset(MyBufferedInputStream inputStream, LocalFileHeader header) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.amse.ys.zip;
|
package org.amse.ys.zip;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
final class CircularBuffer {
|
final class CircularBuffer {
|
||||||
static final int DICTIONARY_LENGTH = (1 << 15);
|
static final int DICTIONARY_LENGTH = (1 << 15);
|
||||||
private static final int DICTIONARY_MASK = DICTIONARY_LENGTH - 1;
|
private static final int DICTIONARY_MASK = DICTIONARY_LENGTH - 1;
|
||||||
|
@ -33,9 +35,9 @@ final class CircularBuffer {
|
||||||
myBytesReady -= length;
|
myBytesReady -= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte read() {
|
public byte read() throws IOException {
|
||||||
if (myBytesReady == 0) {
|
if (myBytesReady == 0) {
|
||||||
throw new RuntimeException("reading from empty buffer");
|
throw new ZipException("reading from empty buffer");
|
||||||
}
|
}
|
||||||
final byte result = myBuffer[myCurrentPosition++];
|
final byte result = myBuffer[myCurrentPosition++];
|
||||||
myCurrentPosition &= DICTIONARY_MASK;
|
myCurrentPosition &= DICTIONARY_MASK;
|
||||||
|
@ -48,9 +50,9 @@ final class CircularBuffer {
|
||||||
myBytesReady++;
|
myBytesReady++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void repeat(int length, int distance) {
|
public void repeat(int length, int distance) throws IOException {
|
||||||
if (myBytesReady + length > DICTIONARY_LENGTH) {
|
if (myBytesReady + length > DICTIONARY_LENGTH) {
|
||||||
throw new RuntimeException("circular buffer overflow");
|
throw new ZipException("circular buffer overflow");
|
||||||
}
|
}
|
||||||
int writePoint = (myCurrentPosition + myBytesReady) & DICTIONARY_MASK;
|
int writePoint = (myCurrentPosition + myBytesReady) & DICTIONARY_MASK;
|
||||||
int readPoint = (writePoint - distance) & DICTIONARY_MASK;
|
int readPoint = (writePoint - distance) & DICTIONARY_MASK;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public abstract class Decompressor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Decompressor init(MyBufferedInputStream is, LocalFileHeader header) throws ZipException {
|
public static Decompressor init(MyBufferedInputStream is, LocalFileHeader header) throws IOException {
|
||||||
switch (header.CompressionMethod) {
|
switch (header.CompressionMethod) {
|
||||||
case 0:
|
case 0:
|
||||||
return new NoCompressionDecompressor(is, header);
|
return new NoCompressionDecompressor(is, header);
|
||||||
|
@ -44,7 +44,7 @@ public abstract class Decompressor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int available() {
|
public int available() throws IOException {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,12 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
private final int[] myDistanceCodes = new int[1 << 15];
|
private final int[] myDistanceCodes = new int[1 << 15];
|
||||||
private final int[] myAuxCodes = new int[1 << 15];
|
private final int[] myAuxCodes = new int[1 << 15];
|
||||||
|
|
||||||
public DeflatingDecompressor(MyBufferedInputStream inputStream, LocalFileHeader header) {
|
public DeflatingDecompressor(MyBufferedInputStream inputStream, LocalFileHeader header) throws IOException {
|
||||||
super();
|
super();
|
||||||
reset(inputStream, header);
|
reset(inputStream, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(MyBufferedInputStream inputStream, LocalFileHeader header) {
|
void reset(MyBufferedInputStream inputStream, LocalFileHeader header) throws IOException {
|
||||||
myStream = inputStream;
|
myStream = inputStream;
|
||||||
myHeader = header;
|
myHeader = header;
|
||||||
myTotalLength = header.getCompressedSize();
|
myTotalLength = header.getCompressedSize();
|
||||||
|
@ -55,7 +55,7 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int available() {
|
public int available() throws IOException {
|
||||||
return myHeader.getUncompressedSize() - myCurrentPosition;
|
return myHeader.getUncompressedSize() - myCurrentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
}
|
}
|
||||||
distance = previousCode + 1 + readIntegerByBit(extraBits);
|
distance = previousCode + 1 + readIntegerByBit(extraBits);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("distance code > 29 found");
|
throw new ZipException("distance code > 29 found");
|
||||||
}
|
}
|
||||||
myOutputBuffer.repeat(length, distance);
|
myOutputBuffer.repeat(length, distance);
|
||||||
return length;
|
return length;
|
||||||
|
@ -253,7 +253,7 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
|
|
||||||
private void readHeader() throws IOException {
|
private void readHeader() throws IOException {
|
||||||
if ((myState != ST_HEADER) || (myBytesRead >= myTotalLength)) {
|
if ((myState != ST_HEADER) || (myBytesRead >= myTotalLength)) {
|
||||||
throw new RuntimeException("unexpected case of readheader call");
|
throw new ZipException("unexpected case of readheader call");
|
||||||
}
|
}
|
||||||
myTheBlockIsFinal = (getBit() != 0);
|
myTheBlockIsFinal = (getBit() != 0);
|
||||||
switch (readIntegerByBit(2)) {
|
switch (readIntegerByBit(2)) {
|
||||||
|
@ -327,7 +327,7 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
previous = false;
|
previous = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("error when reading dynamic Huffman codes");
|
throw new ZipException("error when reading dynamic Huffman codes");
|
||||||
}
|
}
|
||||||
previousNumber = previous ? previousNumber : 0;
|
previousNumber = previous ? previousNumber : 0;
|
||||||
for (int j = 0; j < repeatNumber; j++) {
|
for (int j = 0; j < repeatNumber; j++) {
|
||||||
|
@ -366,7 +366,7 @@ public class DeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
previous = false;
|
previous = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("error when reading dynamic Huffman codes");
|
throw new ZipException("error when reading dynamic Huffman codes");
|
||||||
}
|
}
|
||||||
previousNumber = (previous ? previousNumber : 0);
|
previousNumber = (previous ? previousNumber : 0);
|
||||||
for (int j = 0; j < repeatNumber; j++) {
|
for (int j = 0; j < repeatNumber; j++) {
|
||||||
|
|
|
@ -5,13 +5,15 @@ package org.amse.ys.zip;
|
||||||
* construcor, all fields are final.
|
* construcor, all fields are final.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class LocalFileHeader {
|
public class LocalFileHeader {
|
||||||
/**
|
/**
|
||||||
* Initilization of constants. Implements: versions, ...
|
* Initilization of constants. Implements: versions, ...
|
||||||
*/
|
*/
|
||||||
static final int FILE_HEADER_SIGNATURE = 0x04034b50;
|
static final int FILE_HEADER_SIGNATURE = 0x04034b50;
|
||||||
static final int FOLDER_HEADER_SIGNATURE = 0x02014b50;
|
static final int FOLDER_HEADER_SIGNATURE = 0x02014b50;
|
||||||
static final int DATA_DESCRIPTOR_SIGNATURE = 0x504b0708;
|
static final int DATA_DESCRIPTOR_SIGNATURE = 0x07084b50;
|
||||||
|
|
||||||
final int VersionNeededToExtract;
|
final int VersionNeededToExtract;
|
||||||
final int GeneralPurposeFlag;
|
final int GeneralPurposeFlag;
|
||||||
|
@ -25,7 +27,6 @@ public class LocalFileHeader {
|
||||||
LocalFileHeader(int versionNeededToExtract, int generalPurposeFlag,
|
LocalFileHeader(int versionNeededToExtract, int generalPurposeFlag,
|
||||||
int compressionMethod, int compressedSize, int uncompressedSize,
|
int compressionMethod, int compressedSize, int uncompressedSize,
|
||||||
int offsetOfLocalData, String fileName) {
|
int offsetOfLocalData, String fileName) {
|
||||||
|
|
||||||
VersionNeededToExtract = versionNeededToExtract;
|
VersionNeededToExtract = versionNeededToExtract;
|
||||||
GeneralPurposeFlag = generalPurposeFlag;
|
GeneralPurposeFlag = generalPurposeFlag;
|
||||||
CompressionMethod = compressionMethod;
|
CompressionMethod = compressionMethod;
|
||||||
|
@ -40,20 +41,20 @@ public class LocalFileHeader {
|
||||||
return mySizeIsKnown;
|
return mySizeIsKnown;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getCompressedSize() {
|
int getCompressedSize() throws IOException {
|
||||||
if (mySizeIsKnown) {
|
if (mySizeIsKnown) {
|
||||||
return myCompressedSize;
|
return myCompressedSize;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new ZipException(
|
||||||
"Error in getCompressedSize: file size is not known yet");
|
"Error in getCompressedSize: file size is not known yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getUncompressedSize() {
|
int getUncompressedSize() throws IOException {
|
||||||
if (mySizeIsKnown) {
|
if (mySizeIsKnown) {
|
||||||
return myUncompressedSize;
|
return myUncompressedSize;
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException(
|
throw new ZipException(
|
||||||
"Error in getUncompressedSize: file size is not known yet");
|
"Error in getUncompressedSize: file size is not known yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ public class NativeDeflatingDecompressor extends AbstractDeflatingDecompressor {
|
||||||
private int myOutBufferOffset;
|
private int myOutBufferOffset;
|
||||||
private int myOutBufferLength;
|
private int myOutBufferLength;
|
||||||
|
|
||||||
public NativeDeflatingDecompressor(MyBufferedInputStream inputStream, LocalFileHeader header) {
|
public NativeDeflatingDecompressor(MyBufferedInputStream inputStream, LocalFileHeader header) throws IOException {
|
||||||
super();
|
super();
|
||||||
reset(inputStream, header);
|
reset(inputStream, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(MyBufferedInputStream inputStream, LocalFileHeader header) {
|
void reset(MyBufferedInputStream inputStream, LocalFileHeader header) throws IOException {
|
||||||
endInflating();
|
endInflating();
|
||||||
|
|
||||||
myStream = inputStream;
|
myStream = inputStream;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class NoCompressionDecompressor extends Decompressor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int available() {
|
public int available() throws IOException {
|
||||||
return (myHeader.getUncompressedSize() - myCurrentPosition);
|
return (myHeader.getUncompressedSize() - myCurrentPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public final class ZipFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String PATH;
|
||||||
private final InputStreamHolder myStreamHolder;
|
private final InputStreamHolder myStreamHolder;
|
||||||
private final LinkedHashMap<String,LocalFileHeader> myFileHeaders = new LinkedHashMap<String,LocalFileHeader>();
|
private final LinkedHashMap<String,LocalFileHeader> myFileHeaders = new LinkedHashMap<String,LocalFileHeader>();
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ public final class ZipFile {
|
||||||
|
|
||||||
public ZipFile(String filePath) {
|
public ZipFile(String filePath) {
|
||||||
this(new FileInputStreamHolder(filePath));
|
this(new FileInputStreamHolder(filePath));
|
||||||
|
PATH = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZipFile(InputStreamHolder streamHolder) {
|
public ZipFile(InputStreamHolder streamHolder) {
|
||||||
|
@ -99,6 +101,7 @@ public final class ZipFile {
|
||||||
* Finds descriptor of the last header and installs sizes of files
|
* Finds descriptor of the last header and installs sizes of files
|
||||||
*/
|
*/
|
||||||
private void findAndReadDescriptor(MyBufferedInputStream baseStream, LocalFileHeader header) throws IOException {
|
private void findAndReadDescriptor(MyBufferedInputStream baseStream, LocalFileHeader header) throws IOException {
|
||||||
|
loop:
|
||||||
while (true) {
|
while (true) {
|
||||||
int signature = 0;
|
int signature = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -107,18 +110,30 @@ public final class ZipFile {
|
||||||
throw new ZipException(
|
throw new ZipException(
|
||||||
"readFileHeaders. Unexpected end of file when looking for DataDescriptor");
|
"readFileHeaders. Unexpected end of file when looking for DataDescriptor");
|
||||||
}
|
}
|
||||||
signature = ((signature << 8) & (0x0FFFFFFFF)) + (byte) nextByte;
|
signature = ((signature >> 8) & 0x0FFFFFF) | (nextByte << 24);
|
||||||
} while (signature != LocalFileHeader.DATA_DESCRIPTOR_SIGNATURE);
|
} while (
|
||||||
baseStream.skip(4);
|
signature != LocalFileHeader.FILE_HEADER_SIGNATURE &&
|
||||||
int compressedSize = baseStream.read4Bytes();
|
signature != LocalFileHeader.FOLDER_HEADER_SIGNATURE &&
|
||||||
int uncompressedSize = baseStream.read4Bytes();
|
signature != LocalFileHeader.DATA_DESCRIPTOR_SIGNATURE
|
||||||
if ((baseStream.offset() - header.OffsetOfLocalData - 16) == compressedSize) {
|
);
|
||||||
header.setSizes(compressedSize, uncompressedSize);
|
System.err.println(PATH + " : " + Integer.toHexString(signature));
|
||||||
break;
|
switch (signature) {
|
||||||
} else {
|
case LocalFileHeader.FILE_HEADER_SIGNATURE:
|
||||||
baseStream.backSkip(12);
|
break loop;
|
||||||
continue;
|
case LocalFileHeader.FOLDER_HEADER_SIGNATURE:
|
||||||
}
|
break loop;
|
||||||
|
case LocalFileHeader.DATA_DESCRIPTOR_SIGNATURE:
|
||||||
|
baseStream.skip(4);
|
||||||
|
int compressedSize = baseStream.read4Bytes();
|
||||||
|
int uncompressedSize = baseStream.read4Bytes();
|
||||||
|
if ((baseStream.offset() - header.OffsetOfLocalData - 16) == compressedSize) {
|
||||||
|
header.setSizes(compressedSize, uncompressedSize);
|
||||||
|
break loop;
|
||||||
|
} else {
|
||||||
|
baseStream.backSkip(12);
|
||||||
|
continue loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ZipInputStream extends InputStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int available() {
|
public int available() throws IOException {
|
||||||
return myDecompressor.available();
|
return myDecompressor.available();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
System.err.println("onCreate");
|
||||||
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler(this));
|
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler(this));
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
@ -73,6 +74,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
System.err.println("onStart");
|
||||||
switch (ourOrientation) {
|
switch (ourOrientation) {
|
||||||
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
|
||||||
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
|
case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
|
||||||
|
@ -88,9 +90,16 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
ZLApplication.Instance().onWindowClosing();
|
ZLApplication.Instance().onWindowClosing();
|
||||||
|
System.err.println("onPause");
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
System.err.println("onResume");
|
||||||
|
super.onResume();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewIntent(Intent intent) {
|
public void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
@ -148,6 +157,9 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration config) {
|
public void onConfigurationChanged(Configuration config) {
|
||||||
super.onConfigurationChanged(config);
|
super.onConfigurationChanged(config);
|
||||||
|
Configuration defaultConfig = new Configuration();
|
||||||
|
defaultConfig.setToDefaults();
|
||||||
|
System.err.println("config = " + config);
|
||||||
|
|
||||||
switch (getRequestedOrientation()) {
|
switch (getRequestedOrientation()) {
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue