Skip to content

Commit b0022f3

Browse files
Added getEntry(String name)
1 parent fa2deba commit b0022f3

9 files changed

Lines changed: 45 additions & 37 deletions

File tree

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AndroidZip/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ plugins {
33
}
44

55
android {
6-
compileSdk 32
6+
compileSdk 33
77

88
defaultConfig {
99
minSdk 21
10-
targetSdk 32
10+
targetSdk 33
1111

1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
consumerProguardFiles "consumer-rules.pro"
@@ -23,14 +23,15 @@ android {
2323
sourceCompatibility JavaVersion.VERSION_1_8
2424
targetCompatibility JavaVersion.VERSION_1_8
2525
}
26+
namespace 'com.buggysofts.androidzip'
2627
}
2728

2829
dependencies {
2930

3031
implementation 'androidx.appcompat:appcompat:1.5.1'
3132
implementation 'com.google.android.material:material:1.6.1'
3233

33-
implementation 'com.github.buggysofts-com:StreamZip:v1.0.0'
34+
implementation 'com.github.buggysofts-com:StreamZip:v1.0.1'
3435

3536
testImplementation 'junit:junit:4.13.2'
3637
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest package="com.buggysofts.androidzip">
2+
<manifest>
33

44
</manifest>

AndroidZip/src/main/java/com/buggysofts/androidzip/AndroidZip.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,52 @@ public AndroidZip(@NonNull Context context, @NonNull DocumentFile documentFile)
2424
}
2525

2626
/**
27-
* Get number of available entries in this zip.
27+
* Get a particular entry.
28+
* */
29+
public ZipEntry getEntry(@NonNull String name){
30+
return super.getEntry(name);
31+
}
32+
33+
/**
34+
* Get a list of all the entries available in the zip file.
2835
*/
2936
@Override
30-
public int size() {
31-
return super.size();
37+
public List<ZipEntry> entries() {
38+
return super.entries();
3239
}
3340

3441
/**
35-
* Get global comment of the zip file.
42+
* Get input stream for a particular entry.
43+
*
44+
* @throws Exception If the input stream can not be opened due to unavailability,
45+
* or if the entry is a directory entry, or the zip has been closed.
3646
*/
3747
@Override
38-
public @Nullable String getComment() {
39-
return super.getComment();
48+
public InputStream getInputStream(@NonNull ZipEntry entry) throws Exception {
49+
return super.getInputStream(entry);
4050
}
4151

4252
/**
43-
* Close the zip file. After this you won't be able to call {@code getInputStream()}.
53+
* Get number of available entries in this zip.
4454
*/
4555
@Override
46-
public void close() throws IOException {
47-
super.close();
56+
public int size() {
57+
return super.size();
4858
}
4959

5060
/**
51-
* Get a list of all the entries available in the zip file.
61+
* Get global comment of the zip file.
5262
*/
5363
@Override
54-
public List<ZipEntry> entries() {
55-
return super.entries();
64+
public @Nullable String getComment() {
65+
return super.getComment();
5666
}
5767

5868
/**
59-
* Get input stream for a particular entry.
60-
*
61-
* @throws Exception If the input stream can not be opened due to unavailability,
62-
* or if the entry is a directory entry, or the zip has been closed.
69+
* Close the zip file. After this you won't be able to call {@code getInputStream()}.
6370
*/
6471
@Override
65-
public InputStream getInputStream(@NonNull ZipEntry entry) throws Exception {
66-
return super.getInputStream(entry);
72+
public void close() throws IOException {
73+
super.close();
6774
}
6875
}

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Finally, add these two dependencies to your app/module level build.gradle file
3333
3434
dependencies {
3535
...
36-
implementation 'com.github.buggysofts-com:StreamZip:v1.0.0'
37-
implementation 'com.github.buggysofts-com:AndroidZip:v1.0.0'
36+
implementation 'com.github.buggysofts-com:StreamZip:v1.0.1'
37+
implementation 'com.github.buggysofts-com:AndroidZip:v1.0.1'
3838
}
3939
```
4040
And you are done importing the library.
@@ -66,13 +66,12 @@ try {
6666
Then you can use different methods that are similar to the standard java ZipFile class. For example here are the
6767
publicly available methods.
6868

69+
- ```getEntry(String name)``` Returns the entry mapped with the specified name, or null if there is no entry mapped with that name.
70+
- ```entries()``` Returns all the available entries as a list of <b>ZipEntry</b>.
71+
- ```getInputStream(...)``` Opens(and returns) a bounded input stream currently positioning at the start of the requested entry's data block.
6972
- ```size()``` Returns the total number of available entries.
7073
- ```getComment()``` Returns the principal comment of the zip file.
71-
- ```entries()``` Returns all the available entries as a list of <b>ZipEntry</b>.
72-
- ```getInputStream(...)``` Opens(and returns) a bounded input stream currently positioning at the start of the
73-
requested entry's data block.
74-
- ```close()``` Closes the zip file, and any subsequent call to <b>getInputStream(...)</b> will throw an exception.
75-
However, other methods of the class that are saved in memory will still be available after call to <b>close()</b>.
74+
- ```close()``` Closes the zip file, and any subsequent call to <b>getInputStream(...)</b> will throw an exception. However, other methods of the class that are saved in memory will still be available after call to <b>close()</b>.
7675

7776
**Please Note**
7877

app/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdk 32
6+
compileSdk 33
77

88
defaultConfig {
99
applicationId "com.buggysofts.androidzipimpl"
1010
minSdk 21
11-
targetSdk 32
11+
targetSdk 33
1212
versionCode 1
1313
versionName "1.0.0"
1414

@@ -25,6 +25,7 @@ android {
2525
sourceCompatibility JavaVersion.VERSION_1_8
2626
targetCompatibility JavaVersion.VERSION_1_8
2727
}
28+
namespace 'com.buggysofts.androidzipimpl'
2829
}
2930

3031
dependencies {
@@ -34,7 +35,7 @@ dependencies {
3435
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
3536

3637
implementation project(':AndroidZip')
37-
implementation 'com.github.buggysofts-com:StreamZip:v1.0.0'
38+
implementation 'com.github.buggysofts-com:StreamZip:v1.0.1'
3839

3940
testImplementation 'junit:junit:4.13.2'
4041
androidTestImplementation 'androidx.test.ext:junit:1.1.3'

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="com.buggysofts.androidzipimpl">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<application
76
android:allowBackup="true"

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id 'com.android.application' version '7.2.1' apply false
4-
id 'com.android.library' version '7.2.1' apply false
3+
id 'com.android.application' version '7.3.0' apply false
4+
id 'com.android.library' version '7.3.0' apply false
55
}
66

77
task clean(type: Delete) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Aug 28 21:53:20 BDT 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)