Skip to content

Commit 884fbb8

Browse files
Soumya Kanti KarSoumya Kanti Kar
Soumya Kanti Kar
authored and
Soumya Kanti Kar
committed
Update to Kotlin. Android code updated.
1 parent cd38f51 commit 884fbb8

28 files changed

+525
-505
lines changed

.idea/compiler.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetDropDown.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/migrations.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

-13
This file was deleted.

app/build.gradle

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'org.jetbrains.kotlin.android'
23

34
android {
4-
compileSdkVersion 30
5+
compileSdk 33
56
defaultConfig {
67
applicationId "com.wwdablu.soumya.wzipsample"
7-
minSdkVersion 22
8-
targetSdkVersion 30
8+
minSdk 27
9+
targetSdk 27
910
versionCode 1
1011
versionName "1.0"
1112
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -17,14 +18,16 @@ android {
1718
}
1819
}
1920
compileOptions {
20-
sourceCompatibility JavaVersion.VERSION_1_8
21-
targetCompatibility JavaVersion.VERSION_1_8
21+
sourceCompatibility JavaVersion.VERSION_17
22+
targetCompatibility JavaVersion.VERSION_17
2223
}
24+
namespace 'com.wwdablu.soumya.wzipsample'
2325
}
2426

2527
dependencies {
2628
implementation fileTree(dir: 'libs', include: ['*.jar'])
2729
implementation "androidx.appcompat:appcompat:1.3.0"
30+
implementation 'androidx.core:core-ktx:1.10.0'
2831
testImplementation 'junit:junit:4.12'
2932
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3033
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

app/src/main/AndroidManifest.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.wwdablu.soumya.wzipsample">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
65
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@@ -12,7 +11,8 @@
1211
android:roundIcon="@mipmap/ic_launcher_round"
1312
android:supportsRtl="true"
1413
android:theme="@style/AppTheme">
15-
<activity android:name=".MainActivity">
14+
<activity android:name=".MainActivity"
15+
android:exported="true">
1616
<intent-filter>
1717
<action android:name="android.intent.action.MAIN" />
1818

app/src/main/java/com/wwdablu/soumya/wzipsample/MainActivity.java

+47-43
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
public class MainActivity extends AppCompatActivity implements WZipCallback {
2525

26+
private static final String TAG = MainActivity.class.getSimpleName();
27+
2628
@Override
2729
protected void onCreate(Bundle savedInstanceState) {
2830
super.onCreate(savedInstanceState);
@@ -74,53 +76,12 @@ private void prepare() {
7476
}
7577

7678
//Perform the zip operation
77-
WZip wZip = new WZip();
78-
wZip.zip(fileList,
79+
WZip.zip(fileList,
7980
new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "misdir" + File.separator + "test.zip"),
80-
"zip",
81+
"Zipper",
8182
this);
8283
}
8384

84-
@Override
85-
public void onStarted(String identifier) {
86-
Log.d(MainActivity.class.getSimpleName(), "Started: " + identifier);
87-
}
88-
89-
@Override
90-
public void onZipCompleted(File zipFile, String identifier) {
91-
Log.d(MainActivity.class.getSimpleName(), "Zip ops completed for identifier " + identifier);
92-
93-
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
94-
File[] files = file.listFiles();
95-
for (File f : files) {
96-
97-
if(f.getName().contains("test_") && f.getName().endsWith(".txt")) {
98-
f.delete();
99-
}
100-
}
101-
102-
//Wait for 1500 msec to test unzip ops
103-
new Handler(MainActivity.this.getMainLooper()).postDelayed(() -> {
104-
WZip wZip = new WZip();
105-
Log.d(MainActivity.class.getSimpleName(), "File count: " + wZip.getFilesInfoFromZip(zipFile).size());
106-
wZip.unzip(zipFile,
107-
new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "misdirunzip"),
108-
"unzip",
109-
MainActivity.this);
110-
}, 1500);
111-
}
112-
113-
@Override
114-
public void onUnzipCompleted(String identifier) {
115-
Log.d(MainActivity.class.getSimpleName(), "Unzip ops completed for " + identifier);
116-
}
117-
118-
@Override
119-
public void onError(Throwable throwable, String identifier) {
120-
showToast(throwable.getMessage());
121-
Log.e(MainActivity.class.getSimpleName(), throwable.getMessage(), throwable);
122-
}
123-
12485
private void showToast(String text) {
12586
runOnUiThread(() -> Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show());
12687
}
@@ -135,6 +96,8 @@ private void createDummyFiles() {
13596
File dummyFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
13697
+ File.separator + "misdir" + File.separator + "test_" + fileIndex + ".txt");
13798

99+
String s = dummyFile.getParent();
100+
138101
boolean r = new File(dummyFile.getParent()).mkdirs();
139102
r = dummyFile.createNewFile();
140103

@@ -155,4 +118,45 @@ private void createDummyFiles() {
155118
fileIndex++;
156119
}
157120
}
121+
122+
@Override
123+
public void onStart(@NonNull String worker, @NonNull Mode mode) {
124+
Log.d(TAG, "onStart: " + mode.name() + " has been started for " + worker);
125+
}
126+
127+
@Override
128+
public void onZipComplete(@NonNull String worker, @NonNull File zipFile) {
129+
130+
Log.d(MainActivity.class.getSimpleName(), "Zip ops completed for identifier " + worker);
131+
showToast("Zip ops completed for identifier " + worker);
132+
133+
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath());
134+
File[] files = file.listFiles();
135+
for (File f : files) {
136+
137+
if(f.getName().contains("test_") && f.getName().endsWith(".txt")) {
138+
f.delete();
139+
}
140+
}
141+
142+
Log.d(MainActivity.class.getSimpleName(), "File count: " + WZip.getFilesInfoFromZip(zipFile).size());
143+
WZip.unzip(zipFile,
144+
new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "misdirunzip"),
145+
"Unzipper",
146+
MainActivity.this);
147+
148+
showToast("Extracting files");
149+
}
150+
151+
@Override
152+
public void onUnzipComplete(@NonNull String worker, @NonNull File extractedFolder) {
153+
Log.d(TAG, "onUnzipComplete: " + worker + " has done unzip at " + extractedFolder.getAbsolutePath());
154+
showToast(worker + " has done unzip at " + extractedFolder.getAbsolutePath());
155+
}
156+
157+
@Override
158+
public void onError(@NonNull String worker, @NonNull Exception e, @NonNull Mode mode) {
159+
Log.d(TAG, "onError: " + worker + " has encountered an exception " + e.getMessage() +
160+
" during " + mode.name());
161+
}
158162
}

build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4+
ext {
5+
kotlin_version = '1.9.22'
6+
}
47
repositories {
58
google()
69
mavenCentral()
710
}
811
dependencies {
9-
classpath 'com.android.tools.build:gradle:4.2.1'
10-
12+
classpath 'com.android.tools.build:gradle:8.2.0'
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
1115
// NOTE: Do not place your application dependencies here; they belong
1216
// in the individual module build.gradle files
1317
}

gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ org.gradle.jvmargs=-Xmx1536m
1313
# org.gradle.parallel=true
1414
android.useAndroidX=true
1515
android.enableJetifier=true
16+
android.defaults.buildfeatures.buildconfig=true
17+
android.nonTransitiveRClass=false
18+
android.nonFinalResIds=false
1619

gradle/wrapper/gradle-wrapper.jar

5.08 KB
Binary file not shown.
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Sat Jun 15 14:57:33 EDT 2019
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 commit comments

Comments
 (0)