Skip to content

Commit

Permalink
update version code
Browse files Browse the repository at this point in the history
  • Loading branch information
huzongyao committed Jan 10, 2019
1 parent cb2a3ae commit b301e60
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 92 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
![image](https://raw.githubusercontent.com/hzy3774/AndroidP7zip/master/misc/screenshot.gif)
Expand Down
12 changes: 9 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -30,6 +33,9 @@ android {
signingConfig signingConfigs.demokey
}
}
lintOptions {
abortOnError false
}
}

dependencies {
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
20 changes: 7 additions & 13 deletions app/src/main/java/com/hzy/p7zip/app/fragment/StorageFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<string name="folder_cant_extract">Folder Can Not Be Extracted!</string>

<string name="progress_title">Message</string>
<string name="progress_message">Please wait...</string>
<string name="progress_message">Please wait</string>
<string name="msg_ret_success">Success</string>
<string name="msg_ret_warning">Warning (Non fatal error(s))</string>
<string name="msg_ret_fault">Fatal error </string>
Expand Down
10 changes: 7 additions & 3 deletions libp7zip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -21,6 +21,7 @@ android {
debug {
externalNativeBuild {
cmake {
// log switch
cppFlags.add('-DNATIVE_LOG')
}
}
Expand All @@ -31,6 +32,9 @@ android {
path 'src/main/cpp/CMakeLists.txt'
}
}
lintOptions {
abortOnError false
}
}

dependencies {
Expand Down

This file was deleted.

13 changes: 1 addition & 12 deletions libp7zip/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.hzy.libp7zip">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
<manifest package="com.hzy.libp7zip" />
27 changes: 22 additions & 5 deletions libp7zip/src/main/cpp/ndkhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ extern "C" {
#endif

#include <jni.h>
#include <android/log.h>
#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 <android/log.h>

#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__)
Expand All @@ -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
}
Expand Down
7 changes: 2 additions & 5 deletions libp7zip/src/main/cpp/p7zip.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#include <ndkhelper.h>
#include <7zip/MyVersion.h>
#include <cmd/command.h>

#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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hzy.p7zip.app.command;
package com.hzy.libp7zip;

/**
* Created by huzongyao on 8/1/17.
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions libp7zip/src/main/java/com/hzy/libp7zip/P7ZipApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion libp7zip/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<resources>
<string name="app_name">libp7zip</string>
</resources>
17 changes: 0 additions & 17 deletions libp7zip/src/test/java/com/hzy/libp7zip/ExampleUnitTest.java

This file was deleted.

Binary file modified misc/wechat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b301e60

Please sign in to comment.