diff --git a/README.md b/README.md
index ff3959b..baa997b 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,33 @@ AndroidP7zip(P7Zip安卓)
An Android compress and extract library, P7Zip port for Android
### Details
+#### Get Started
-#### Begin To Use
-```gradle
+* Add gradle dependencie:
+``` gradle
dependencies {
- compile 'com.hzy:libp7zip:1.5.0'
+ implementation 'com.hzy:libp7zip:1.6.0'
}
```
+* Or just download the aar [here](https://jcenter.bintray.com/com/hzy/libp7zip/)
+
+* If you want to add some abi filters
+``` gradle
+android {
+ ...
+ defaultConfig {
+ ...
+ ndk {
+ abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
+ }
+ }
+}
+```
+
+* Simple interface
+``` java
+P7ZipApi.executeCommand(String command);
+```
### Screenshot

diff --git a/app/build.gradle b/app/build.gradle
index 3f0542a..60bddc2 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -15,8 +15,11 @@ android {
applicationId "com.hzy.p7zip.app"
minSdkVersion 15
targetSdkVersion 28
- versionCode 4
- versionName "1.5"
+ versionCode 6
+ versionName "1.6.0"
+ ndk {
+ abiFilters 'armeabi-v7a'
+ }
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -30,6 +33,9 @@ android {
signingConfig signingConfigs.demokey
}
}
+ lintOptions {
+ abortOnError false
+ }
}
dependencies {
@@ -39,7 +45,7 @@ dependencies {
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
- implementation 'com.blankj:utilcode:1.22.1'
+ implementation 'com.blankj:utilcode:1.22.9'
implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
diff --git a/app/src/main/java/com/hzy/p7zip/app/fragment/AboutFragment.java b/app/src/main/java/com/hzy/p7zip/app/fragment/AboutFragment.java
index 1ec3cc0..9f4218d 100644
--- a/app/src/main/java/com/hzy/p7zip/app/fragment/AboutFragment.java
+++ b/app/src/main/java/com/hzy/p7zip/app/fragment/AboutFragment.java
@@ -36,7 +36,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Nullable
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_about, null);
ButterKnife.bind(this, rootView);
mVersionInfo.setText(P7ZipApi.get7zVersionInfo());
diff --git a/app/src/main/java/com/hzy/p7zip/app/fragment/StorageFragment.java b/app/src/main/java/com/hzy/p7zip/app/fragment/StorageFragment.java
index d2fd932..d2166c0 100644
--- a/app/src/main/java/com/hzy/p7zip/app/fragment/StorageFragment.java
+++ b/app/src/main/java/com/hzy/p7zip/app/fragment/StorageFragment.java
@@ -16,10 +16,10 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Toast;
import com.afollestad.materialdialogs.MaterialDialog;
import com.blankj.utilcode.util.SnackbarUtils;
+import com.hzy.libp7zip.ExitCode;
import com.hzy.libp7zip.P7ZipApi;
import com.hzy.p7zip.app.R;
import com.hzy.p7zip.app.adapter.FileItemAdapter;
@@ -43,12 +43,6 @@
import io.reactivex.schedulers.Schedulers;
import static android.support.v7.widget.LinearLayoutManager.HORIZONTAL;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_CMD_ERROR;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_FATAL;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_MEMORY_ERROR;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_NOT_SUPPORT;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_OK;
-import static com.hzy.p7zip.app.command.ExitCode.EXIT_WARNING;
/**
* Created by huzongyao on 17-7-10.
@@ -273,22 +267,22 @@ private void dismissProgressDialog() {
private void showResult(int result) {
int retMsgId = R.string.msg_ret_success;
switch (result) {
- case EXIT_OK:
+ case ExitCode.EXIT_OK:
retMsgId = R.string.msg_ret_success;
break;
- case EXIT_WARNING:
+ case ExitCode.EXIT_WARNING:
retMsgId = R.string.msg_ret_warning;
break;
- case EXIT_FATAL:
+ case ExitCode.EXIT_FATAL:
retMsgId = R.string.msg_ret_fault;
break;
- case EXIT_CMD_ERROR:
+ case ExitCode.EXIT_CMD_ERROR:
retMsgId = R.string.msg_ret_command;
break;
- case EXIT_MEMORY_ERROR:
+ case ExitCode.EXIT_MEMORY_ERROR:
retMsgId = R.string.msg_ret_memmory;
break;
- case EXIT_NOT_SUPPORT:
+ case ExitCode.EXIT_NOT_SUPPORT:
retMsgId = R.string.msg_ret_user_stop;
break;
default:
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4652fcb..8a50a05 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -21,7 +21,7 @@
Folder Can Not Be Extracted!
Message
- Please wait...
+ Please wait…
Success
Warning (Non fatal error(s))
Fatal error
diff --git a/libp7zip/build.gradle b/libp7zip/build.gradle
index db693d7..6656322 100644
--- a/libp7zip/build.gradle
+++ b/libp7zip/build.gradle
@@ -6,10 +6,10 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
- versionCode 5
- versionName "1.5.0"
+ versionCode 6
+ versionName "1.6.0"
ndk {
- abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
+ abiFilters 'armeabi-v7a'//, 'arm64-v8a', 'x86'
}
externalNativeBuild {
cmake {
@@ -21,6 +21,7 @@ android {
debug {
externalNativeBuild {
cmake {
+ // log switch
cppFlags.add('-DNATIVE_LOG')
}
}
@@ -31,6 +32,9 @@ android {
path 'src/main/cpp/CMakeLists.txt'
}
}
+ lintOptions {
+ abortOnError false
+ }
}
dependencies {
diff --git a/libp7zip/src/androidTest/java/com/hzy/libp7zip/ExampleInstrumentedTest.java b/libp7zip/src/androidTest/java/com/hzy/libp7zip/ExampleInstrumentedTest.java
deleted file mode 100644
index 9543b25..0000000
--- a/libp7zip/src/androidTest/java/com/hzy/libp7zip/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.hzy.libp7zip;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumentation test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.hzy.libp7zip.test", appContext.getPackageName());
- }
-}
diff --git a/libp7zip/src/main/AndroidManifest.xml b/libp7zip/src/main/AndroidManifest.xml
index 29df7ce..de6c90b 100644
--- a/libp7zip/src/main/AndroidManifest.xml
+++ b/libp7zip/src/main/AndroidManifest.xml
@@ -1,12 +1 @@
-
-
-
-
-
-
-
+
diff --git a/libp7zip/src/main/cpp/ndkhelper.h b/libp7zip/src/main/cpp/ndkhelper.h
index 5f9a2b3..c13fb17 100644
--- a/libp7zip/src/main/cpp/ndkhelper.h
+++ b/libp7zip/src/main/cpp/ndkhelper.h
@@ -6,11 +6,13 @@ extern "C" {
#endif
#include
+#include
+#include <7zip/MyVersion.h>
+
+#define MY_P7ZIP_VERSION_INFO "P7Zip Version: "MY_VERSION"\n"MY_COPYRIGHT"\nDate: "MY_DATE
#ifdef NATIVE_LOG
#define LOG_TAG "NATIVE.LOG"
-#include
-
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
@@ -24,11 +26,26 @@ extern "C" {
#define LOGF(...) do{}while(0)
#endif
-JNIEXPORT jstring JNICALL
- Java_com_hzy_libp7zip_P7ZipApi_get7zVersionInfo(JNIEnv *env, jclass type);
+#define JNI_FUNC(X) Java_com_hzy_libp7zip_P7ZipApi_##X
+/**
+ * To Get lib p7zip version info
+ * @param env
+ * @param type
+ * @return
+ */
+JNIEXPORT jstring JNICALL
+JNI_FUNC(get7zVersionInfo)(JNIEnv *env, jclass type);
+
+/**
+ * To execute some command with p7zip
+ * @param env
+ * @param type
+ * @param command_
+ * @return
+ */
JNIEXPORT jint JNICALL
- Java_com_hzy_libp7zip_P7ZipApi_executeCommand(JNIEnv *env, jclass type, jstring command_);
+JNI_FUNC(executeCommand)(JNIEnv *env, jclass type, jstring command_);
#ifdef __cplusplus
}
diff --git a/libp7zip/src/main/cpp/p7zip.cpp b/libp7zip/src/main/cpp/p7zip.cpp
index df2711c..7cf01ed 100644
--- a/libp7zip/src/main/cpp/p7zip.cpp
+++ b/libp7zip/src/main/cpp/p7zip.cpp
@@ -1,16 +1,13 @@
#include
-#include <7zip/MyVersion.h>
#include
-#define MY_P7ZIP_VERSION_INFO "7zVersion: "MY_VERSION"\n"MY_COPYRIGHT"\nDate: "MY_DATE
-
JNIEXPORT jstring JNICALL
-Java_com_hzy_libp7zip_P7ZipApi_get7zVersionInfo(JNIEnv *env, jclass type) {
+JNI_FUNC(get7zVersionInfo)(JNIEnv *env, jclass type) {
return env->NewStringUTF(MY_P7ZIP_VERSION_INFO);
}
JNIEXPORT jint JNICALL
-Java_com_hzy_libp7zip_P7ZipApi_executeCommand(JNIEnv *env, jclass type, jstring command_) {
+JNI_FUNC(executeCommand)(JNIEnv *env, jclass type, jstring command_) {
const char *command = env->GetStringUTFChars(command_, 0);
LOGI("CMD:[%s]", command);
int ret = executeCommand(command);
diff --git a/app/src/main/java/com/hzy/p7zip/app/command/ExitCode.java b/libp7zip/src/main/java/com/hzy/libp7zip/ExitCode.java
similarity index 83%
rename from app/src/main/java/com/hzy/p7zip/app/command/ExitCode.java
rename to libp7zip/src/main/java/com/hzy/libp7zip/ExitCode.java
index d3c4b7c..acdf55d 100644
--- a/app/src/main/java/com/hzy/p7zip/app/command/ExitCode.java
+++ b/libp7zip/src/main/java/com/hzy/libp7zip/ExitCode.java
@@ -1,4 +1,4 @@
-package com.hzy.p7zip.app.command;
+package com.hzy.libp7zip;
/**
* Created by huzongyao on 8/1/17.
@@ -7,7 +7,8 @@
public class ExitCode {
/**
* 0 No error
- * 1 Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
+ * 1 Warning (Non fatal error(s)). For example, one or more files
+ * were locked by some other application, so they were not compressed.
* 2 Fatal error
* 7 Command line error
* 8 Not enough memory for operation
diff --git a/libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java b/libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java
index 69dbe4a..7b1600b 100644
--- a/libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java
+++ b/libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java
@@ -6,7 +6,18 @@
public class P7ZipApi {
+ /**
+ * Get P7zip version info
+ */
public static native String get7zVersionInfo();
+
+ /**
+ * Execute some p7zip command
+ *
+ * @param command command string
+ * @return exit code
+ * @see com.hzy.libp7zip.ExitCode
+ */
public static native int executeCommand(String command);
static {
diff --git a/libp7zip/src/main/res/values/strings.xml b/libp7zip/src/main/res/values/strings.xml
index a3eff4e..8542005 100644
--- a/libp7zip/src/main/res/values/strings.xml
+++ b/libp7zip/src/main/res/values/strings.xml
@@ -1,3 +1,2 @@
- libp7zip
diff --git a/libp7zip/src/test/java/com/hzy/libp7zip/ExampleUnitTest.java b/libp7zip/src/test/java/com/hzy/libp7zip/ExampleUnitTest.java
deleted file mode 100644
index 58b7e58..0000000
--- a/libp7zip/src/test/java/com/hzy/libp7zip/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.hzy.libp7zip;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/misc/wechat.png b/misc/wechat.png
index 574d109..820106a 100644
Binary files a/misc/wechat.png and b/misc/wechat.png differ