Compare commits
1 Commits
master
...
feature-20
Author | SHA1 | Date |
---|---|---|
zengfantian | 95f5bdb930 |
|
@ -173,6 +173,7 @@ dependencies {
|
||||||
// 模板定制-动态页面(可选)
|
// 模板定制-动态页面(可选)
|
||||||
compile project(':modules:bm_dynamic-page')
|
compile project(':modules:bm_dynamic-page')
|
||||||
|
|
||||||
|
compile("com.squareup.okhttp3:okhttp:3.12.1")
|
||||||
|
|
||||||
// // 基础资源(必须)
|
// // 基础资源(必须)
|
||||||
// compile 'com.zftlive.android.library:common-resource:1.0.0'
|
// compile 'com.zftlive.android.library:common-resource:1.0.0'
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
package com.zftlive.android;
|
package com.zftlive.android;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -29,6 +33,9 @@ import com.zftlive.android.library.Logger;
|
||||||
import com.zftlive.android.library.base.ui.CommonActivity;
|
import com.zftlive.android.library.base.ui.CommonActivity;
|
||||||
import com.zftlive.android.sample.MainActivity;
|
import com.zftlive.android.sample.MainActivity;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 程序启动界面
|
* 程序启动界面
|
||||||
* @author 曾繁添,曾宪明
|
* @author 曾繁添,曾宪明
|
||||||
|
@ -37,6 +44,15 @@ import com.zftlive.android.sample.MainActivity;
|
||||||
*/
|
*/
|
||||||
public class Launcher extends CommonActivity {
|
public class Launcher extends CommonActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
|
||||||
|
boolean result = fixOrientation();
|
||||||
|
// XLog.i(XLog.BASE, "onCreate fixOrientation when Oreo, result = " + result);
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int bindLayout() {
|
public int bindLayout() {
|
||||||
return R.layout.activity_launcher;
|
return R.layout.activity_launcher;
|
||||||
|
@ -94,4 +110,43 @@ public class Launcher extends CommonActivity {
|
||||||
});
|
});
|
||||||
view.setAnimation(animation);
|
view.setAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRequestedOrientation(int requestedOrientation) {
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
|
||||||
|
// XLog.i(XLog.BASE, "avoid calling setRequestedOrientation when Oreo.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.setRequestedOrientation(requestedOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTranslucentOrFloating() {
|
||||||
|
boolean isTranslucentOrFloating = false;
|
||||||
|
try {
|
||||||
|
int[] styleableRes =
|
||||||
|
(int[]) Class.forName("com.android.internal.R$styleable").getField("Window").get(null);
|
||||||
|
final TypedArray ta = obtainStyledAttributes(styleableRes);
|
||||||
|
Method m = ActivityInfo.class.getMethod("isTranslucentOrFloating", TypedArray.class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
isTranslucentOrFloating = (boolean) m.invoke(null, ta);
|
||||||
|
m.setAccessible(false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return isTranslucentOrFloating;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fixOrientation() {
|
||||||
|
try {
|
||||||
|
Field field = Activity.class.getDeclaredField("mActivityInfo");
|
||||||
|
field.setAccessible(true);
|
||||||
|
ActivityInfo o = (ActivityInfo) field.get(this);
|
||||||
|
o.screenOrientation = -1;
|
||||||
|
field.setAccessible(false);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,7 +22,10 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
@ -45,6 +48,8 @@ import com.zftlive.android.library.base.bean.AdapterModelBean;
|
||||||
import com.zftlive.android.library.base.ui.CommonActivity;
|
import com.zftlive.android.library.base.ui.CommonActivity;
|
||||||
import com.zftlive.android.library.tools.ToolPhone;
|
import com.zftlive.android.library.tools.ToolPhone;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -66,6 +71,16 @@ public class MainActivity extends CommonActivity {
|
||||||
private ListView mListView;
|
private ListView mListView;
|
||||||
public final static String SAMPLE_CODE = "com.zftlive.android.SAMPLE_CODE";
|
public final static String SAMPLE_CODE = "com.zftlive.android.SAMPLE_CODE";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
|
||||||
|
boolean result = fixOrientation();
|
||||||
|
// XLog.i(XLog.BASE, "onCreate fixOrientation when Oreo, result = " + result);
|
||||||
|
}
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void config(Bundle savedInstanceState) {
|
public void config(Bundle savedInstanceState) {
|
||||||
super.config(savedInstanceState);
|
super.config(savedInstanceState);
|
||||||
|
@ -256,4 +271,43 @@ public class MainActivity extends CommonActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRequestedOrientation(int requestedOrientation) {
|
||||||
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O && isTranslucentOrFloating()) {
|
||||||
|
// XLog.i(XLog.BASE, "avoid calling setRequestedOrientation when Oreo.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.setRequestedOrientation(requestedOrientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTranslucentOrFloating() {
|
||||||
|
boolean isTranslucentOrFloating = false;
|
||||||
|
try {
|
||||||
|
int[] styleableRes =
|
||||||
|
(int[]) Class.forName("com.android.internal.R$styleable").getField("Window").get(null);
|
||||||
|
final TypedArray ta = obtainStyledAttributes(styleableRes);
|
||||||
|
Method m = ActivityInfo.class.getMethod("isTranslucentOrFloating", TypedArray.class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
isTranslucentOrFloating = (boolean) m.invoke(null, ta);
|
||||||
|
m.setAccessible(false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return isTranslucentOrFloating;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fixOrientation() {
|
||||||
|
try {
|
||||||
|
Field field = Activity.class.getDeclaredField("mActivityInfo");
|
||||||
|
field.setAccessible(true);
|
||||||
|
ActivityInfo o = (ActivityInfo) field.get(this);
|
||||||
|
o.screenOrientation = -1;
|
||||||
|
field.setAccessible(false);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
package com.zftlive.android.sample.http;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by wanglingsheng on 2018/5/29.
|
||||||
|
* 文件下载工具类(单例模式)
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class DownloadUtil {
|
||||||
|
|
||||||
|
private static DownloadUtil downloadUtil;
|
||||||
|
private final OkHttpClient okHttpClient;
|
||||||
|
|
||||||
|
public static DownloadUtil get() {
|
||||||
|
if (downloadUtil == null) {
|
||||||
|
downloadUtil = new DownloadUtil();
|
||||||
|
}
|
||||||
|
return downloadUtil;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DownloadUtil() {
|
||||||
|
okHttpClient = new OkHttpClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param url 下载连接
|
||||||
|
* @param destFileDir 下载的文件储存目录
|
||||||
|
* @param destFileName 下载文件名称
|
||||||
|
* @param listener 下载监听
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void download(final String url, final String destFileDir, final String destFileName, final OnDownloadListener listener) {
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build();
|
||||||
|
//异步请求
|
||||||
|
okHttpClient.newCall(request).enqueue(new Callback() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call call, IOException e) {
|
||||||
|
// 下载失败监听回调
|
||||||
|
listener.onDownloadFailed(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call call, Response response) throws IOException {
|
||||||
|
|
||||||
|
InputStream is = null;
|
||||||
|
byte[] buf = new byte[2048];
|
||||||
|
int len = 0;
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
|
||||||
|
//储存下载文件的目录
|
||||||
|
File dir = new File(destFileDir);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
File file = new File(dir, destFileName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
is = response.body().byteStream();
|
||||||
|
long total = response.body().contentLength();
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
long sum = 0;
|
||||||
|
while ((len = is.read(buf)) != -1) {
|
||||||
|
fos.write(buf, 0, len);
|
||||||
|
sum += len;
|
||||||
|
int progress = (int) (sum * 1.0f / total * 100);
|
||||||
|
//下载中更新进度条
|
||||||
|
listener.onDownloading(progress);
|
||||||
|
}
|
||||||
|
fos.flush();
|
||||||
|
//下载完成
|
||||||
|
listener.onDownloadSuccess(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
listener.onDownloadFailed(e);
|
||||||
|
}finally {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (is != null) {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
if (fos != null) {
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface OnDownloadListener{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载成功之后的文件
|
||||||
|
*/
|
||||||
|
void onDownloadSuccess(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载进度
|
||||||
|
*/
|
||||||
|
void onDownloading(int progress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载异常信息
|
||||||
|
*/
|
||||||
|
|
||||||
|
void onDownloadFailed(Exception e);
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,17 +20,19 @@ package com.zftlive.android.sample.http;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import com.loopj.android.http.BinaryHttpResponseHandler;
|
|
||||||
import com.loopj.android.http.JsonHttpResponseHandler;
|
import com.loopj.android.http.JsonHttpResponseHandler;
|
||||||
import com.loopj.android.http.RequestParams;
|
import com.loopj.android.http.RequestParams;
|
||||||
import com.loopj.android.http.ResponseHandlerInterface;
|
import com.loopj.android.http.ResponseHandlerInterface;
|
||||||
import com.zftlive.android.R;
|
import com.zftlive.android.R;
|
||||||
import com.zftlive.android.library.Alert;
|
import com.zftlive.android.library.Alert;
|
||||||
|
import com.zftlive.android.library.Logger;
|
||||||
import com.zftlive.android.library.base.ui.CommonActivity;
|
import com.zftlive.android.library.base.ui.CommonActivity;
|
||||||
import com.zftlive.android.library.network.ToolHTTP;
|
import com.zftlive.android.library.network.ToolHTTP;
|
||||||
import com.zftlive.android.library.tools.ToolDateTime;
|
import com.zftlive.android.library.tools.ToolDateTime;
|
||||||
|
@ -64,6 +66,10 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
public final static String DOWNLOAD_FILE_PATH = "http://zftlive-images.qiniudn.com/avatar.png";
|
public final static String DOWNLOAD_FILE_PATH = "http://zftlive-images.qiniudn.com/avatar.png";
|
||||||
public final static String UPLOAD_FILE = "http://10.45.255.90:8080/AjavaWeb/cn/com/ajava/servlet/ServletUploadFile";
|
public final static String UPLOAD_FILE = "http://10.45.255.90:8080/AjavaWeb/cn/com/ajava/servlet/ServletUploadFile";
|
||||||
|
|
||||||
|
private final static String apk = "https://125.39.12.5/downapp/JDJR-release-20191203T1741.apk";
|
||||||
|
|
||||||
|
private Handler mHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int bindLayout() {
|
public int bindLayout() {
|
||||||
return R.layout.activity_file_upload_download;
|
return R.layout.activity_file_upload_download;
|
||||||
|
@ -71,7 +77,18 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initParams(Bundle parms) {
|
public void initParams(Bundle parms) {
|
||||||
|
mHandler = new Handler(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if(msg.what == 11){
|
||||||
|
Alert.updateProgressText(String.valueOf(msg.obj));
|
||||||
|
}else{
|
||||||
|
Alert.closeLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,6 +101,7 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
|
|
||||||
et_downfile_path = (EditText) findViewById(R.id.et_downfile_path);
|
et_downfile_path = (EditText) findViewById(R.id.et_downfile_path);
|
||||||
et_downfile_path.setText(DOWNLOAD_FILE_PATH);
|
et_downfile_path.setText(DOWNLOAD_FILE_PATH);
|
||||||
|
et_downfile_path.setText(apk);
|
||||||
et_upload_file_path = (EditText) findViewById(R.id.et_upload_file_path);
|
et_upload_file_path = (EditText) findViewById(R.id.et_upload_file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +119,10 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
|
|
||||||
case R.id.btn_download:
|
case R.id.btn_download:
|
||||||
Alert.loading(getContext(), "准备下载");
|
Alert.loading(getContext(), "准备下载");
|
||||||
|
|
||||||
|
downFile(et_downfile_path.getText().toString().trim());
|
||||||
|
|
||||||
|
/**
|
||||||
String[] allowType = {".*"};
|
String[] allowType = {".*"};
|
||||||
|
|
||||||
ToolHTTP.get(DOWNLOAD_FILE_PATH, new BinaryHttpResponseHandler(allowType) {
|
ToolHTTP.get(DOWNLOAD_FILE_PATH, new BinaryHttpResponseHandler(allowType) {
|
||||||
|
@ -136,6 +158,7 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
Alert.closeLoading();
|
Alert.closeLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
**/
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case R.id.btn_upload:
|
case R.id.btn_upload:
|
||||||
|
@ -205,4 +228,41 @@ public class FileDownloadUploadActivity extends CommonActivity implements OnClic
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件下载
|
||||||
|
*/
|
||||||
|
private void downFile(String url) {
|
||||||
|
|
||||||
|
DownloadUtil.get().download(url, ToolFile.gainSDCardPath()+"/ajava_download/", ToolDateTime.gainCurrentDate("yyyyMMddHHmmss")+".apk",
|
||||||
|
new DownloadUtil.OnDownloadListener() {
|
||||||
|
@Override
|
||||||
|
public void onDownloadSuccess(File file) {
|
||||||
|
//下载完成进行相关逻辑操作
|
||||||
|
Message msg = mHandler.obtainMessage();
|
||||||
|
msg.what = 0;
|
||||||
|
mHandler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDownloading(int progress) {
|
||||||
|
Message msg = mHandler.obtainMessage();
|
||||||
|
msg.what = 11;
|
||||||
|
msg.obj = progress;
|
||||||
|
mHandler.sendMessage(msg);
|
||||||
|
Logger.d(TAG,"当前下载进度:"+progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDownloadFailed(Exception e) {
|
||||||
|
//下载异常进行相关提示操作
|
||||||
|
Message msg = mHandler.obtainMessage();
|
||||||
|
msg.what = 1;
|
||||||
|
msg.obj = e;
|
||||||
|
mHandler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,93 +1,93 @@
|
||||||
/*
|
///*
|
||||||
* Android基础开发个人积累、沉淀、封装、整理共通
|
// * Android基础开发个人积累、沉淀、封装、整理共通
|
||||||
* Copyright (c) 2016. 曾繁添 <zftlive@163.com>
|
// * Copyright (c) 2016. 曾繁添 <zftlive@163.com>
|
||||||
* Github:https://github.com/zengfantian || http://git.oschina.net/zftlive
|
// * Github:https://github.com/zengfantian || http://git.oschina.net/zftlive
|
||||||
*
|
// *
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
// * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
// * you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
// * You may obtain a copy of the License at
|
||||||
*
|
// *
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
// * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
// *
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
// * Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
// * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
// * See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
// * limitations under the License.
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
package com.zftlive.android.tests;
|
//package com.zftlive.android.tests;
|
||||||
|
//
|
||||||
import java.io.UnsupportedEncodingException;
|
//import android.test.AndroidTestCase;
|
||||||
|
//import android.util.Log;
|
||||||
import android.test.AndroidTestCase;
|
//
|
||||||
import android.util.Log;
|
//import com.zftlive.android.library.tools.security.Base64;
|
||||||
|
//import com.zftlive.android.library.tools.security.DES;
|
||||||
import com.zftlive.android.library.tools.security.Base64;
|
//import com.zftlive.android.library.tools.security.MD5;
|
||||||
import com.zftlive.android.library.tools.security.DES;
|
//
|
||||||
import com.zftlive.android.library.tools.security.MD5;
|
//import java.io.UnsupportedEncodingException;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 安全加密测试用例
|
// * 安全加密测试用例
|
||||||
* @author 曾繁添
|
// * @author 曾繁添
|
||||||
* @version 1.0
|
// * @version 1.0
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
public class TestSecurity extends AndroidTestCase {
|
//public class TestSecurity extends AndroidTestCase {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 加密Key(可以用官方的签名指纹作为加密key,只要官方签名文件不泄露,加密则是安全的)
|
// * 加密Key(可以用官方的签名指纹作为加密key,只要官方签名文件不泄露,加密则是安全的)
|
||||||
*/
|
// */
|
||||||
String key = "ajavagongchengshi";
|
// String key = "ajavagongchengshi";
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 加密明文
|
// * 加密明文
|
||||||
*/
|
// */
|
||||||
String encrypt = "Ajava工程师";
|
// String encrypt = "Ajava工程师";
|
||||||
|
//
|
||||||
String TAG = "Test";
|
// String TAG = "Test";
|
||||||
|
//
|
||||||
public void testBase64EnDecrypt(){
|
// public void testBase64EnDecrypt(){
|
||||||
try {
|
// try {
|
||||||
String encodeResult = Base64.encode(encrypt.getBytes());
|
// String encodeResult = Base64.encode(encrypt.getBytes());
|
||||||
Log.e(TAG, "testBase64EnDecrypt.encodeResult-->"+encodeResult);
|
// Log.e(TAG, "testBase64EnDecrypt.encodeResult-->"+encodeResult);
|
||||||
|
//
|
||||||
String decodeResult = new String(Base64.decode(encodeResult),"UTF-8");
|
// String decodeResult = new String(Base64.decode(encodeResult),"UTF-8");
|
||||||
Log.e(TAG, "testDESEnDecrypt.decodeResult-->"+decodeResult);
|
// Log.e(TAG, "testDESEnDecrypt.decodeResult-->"+decodeResult);
|
||||||
|
//
|
||||||
} catch (UnsupportedEncodingException e) {
|
// } catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试DES加密/解密
|
// * 测试DES加密/解密
|
||||||
*/
|
// */
|
||||||
public void testDESEnDecrypt(){
|
// public void testDESEnDecrypt(){
|
||||||
try {
|
// try {
|
||||||
String encodeResult = DES.encrypt(key, encrypt);
|
// String encodeResult = DES.encrypt(key, encrypt);
|
||||||
Log.e(TAG, "testDESEnDecrypt.encodeResult-->"+encodeResult);
|
// Log.e(TAG, "testDESEnDecrypt.encodeResult-->"+encodeResult);
|
||||||
|
//
|
||||||
String decodeResult = DES.decrypt(key, encodeResult);
|
// String decodeResult = DES.decrypt(key, encodeResult);
|
||||||
Log.e(TAG, "testDESEnDecrypt.decodeResult-->"+decodeResult);
|
// Log.e(TAG, "testDESEnDecrypt.decodeResult-->"+decodeResult);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* MD5加密
|
// * MD5加密
|
||||||
*/
|
// */
|
||||||
public void testMD5EnDecrypt(){
|
// public void testMD5EnDecrypt(){
|
||||||
try {
|
// try {
|
||||||
String encodeResult1 = MD5.encrypt16byte(encrypt);
|
// String encodeResult1 = MD5.encrypt16byte(encrypt);
|
||||||
Log.e(TAG, "testMD5EnDecrypt.encrypt16byte-->"+encodeResult1);
|
// Log.e(TAG, "testMD5EnDecrypt.encrypt16byte-->"+encodeResult1);
|
||||||
|
//
|
||||||
String encodeResult2 = MD5.encrypt32byte(encrypt);
|
// String encodeResult2 = MD5.encrypt32byte(encrypt);
|
||||||
Log.e(TAG, "testMD5EnDecrypt.encrypt32byte-->"+encodeResult2);
|
// Log.e(TAG, "testMD5EnDecrypt.encrypt32byte-->"+encodeResult2);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
14
build.gradle
14
build.gradle
|
@ -21,10 +21,16 @@ buildscript {
|
||||||
//统一编译环境
|
//统一编译环境
|
||||||
//minSdkVersion <= targetSdkVersion <= compileSdkVersion
|
//minSdkVersion <= targetSdkVersion <= compileSdkVersion
|
||||||
ext {
|
ext {
|
||||||
compileSdkVersion = 23 //编译SDK版本
|
// compileSdkVersion = 23 //编译SDK版本
|
||||||
buildToolsVersion = "25.0.3"//编译SDK工具版本
|
// buildToolsVersion = "25.0.3"//编译SDK工具版本
|
||||||
minSdkVersion = 9 //兼容最低版本
|
// minSdkVersion = 9 //兼容最低版本
|
||||||
targetSdkVersion = 22 //23需要特殊处理动态授权
|
// targetSdkVersion = 22 //23需要特殊处理动态授权
|
||||||
|
compileSdkVersion = 28
|
||||||
|
//24+版本解决[too many classes in –main-dex-list, main dex capacity exceeded] v4.2.0 20170704
|
||||||
|
buildToolsVersion = "28.0.3"
|
||||||
|
minSdkVersion = 16
|
||||||
|
//23需要特殊处理动态授权
|
||||||
|
targetSdkVersion = 28
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* ext自定义[App全局环境变量配置]属性
|
||||||
|
*
|
||||||
|
* @author 曾繁添
|
||||||
|
* @version 1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
def jdjr_repo_snapshots = '';
|
||||||
|
def jdjr_repo_release = '';
|
||||||
|
|
||||||
|
|
||||||
|
ext {
|
||||||
|
//app配置
|
||||||
|
app = [
|
||||||
|
applicationId : "com.zftlive.android",
|
||||||
|
versionCode : 3,
|
||||||
|
versionName : "1.2",
|
||||||
|
releaseVersion: "0"
|
||||||
|
]
|
||||||
|
|
||||||
|
//编译环境配置
|
||||||
|
android = [
|
||||||
|
compileSdkVersion: 28,
|
||||||
|
buildToolsVersion: "28.0.3",
|
||||||
|
minSdkVersion : 16,
|
||||||
|
targetSdkVersion : 28
|
||||||
|
]
|
||||||
|
|
||||||
|
//maven发布相关配置
|
||||||
|
maven = [
|
||||||
|
repo_snapshots : jdjr_repo_snapshots,
|
||||||
|
repo_release : jdjr_repo_release,
|
||||||
|
|
||||||
|
bintrayRepo : 'android',
|
||||||
|
publishedGroupIdForBm : "com.zftlive.android.bm",
|
||||||
|
publishedGroupIdForBmc: "com.zftlive.android.bm.common",
|
||||||
|
publishedGroupIdForLib: "com.zftlive.android.library",
|
||||||
|
publishedGroupIdForSDK: "com.zftlive.android.sdk",
|
||||||
|
|
||||||
|
developerId : 'zengfantian',
|
||||||
|
developerName : '曾繁添',
|
||||||
|
developerEmail : 'zftlive@163.com',
|
||||||
|
|
||||||
|
allLicenses : '["Apache-2.0"]',
|
||||||
|
licenseName : 'The Apache Software License, Version 2.0',
|
||||||
|
licenseUrl : 'http://www.apache.com/'
|
||||||
|
]
|
||||||
|
|
||||||
|
//谷歌官方基础配置
|
||||||
|
basicDependencies = [
|
||||||
|
support_v4 : 'com.android.support:support-v4:28.0.0',
|
||||||
|
support_v7 : 'com.android.support:appcompat-v7:28.0.0',
|
||||||
|
support_annotations : 'com.android.support:support-annotations:28.0.0',
|
||||||
|
support_exif : 'com.android.support:exifinterface:28.0.0',
|
||||||
|
recyclerview : 'com.android.support:recyclerview-v7:28.0.0',
|
||||||
|
cardview_v7 : 'com.android.support:cardview-v7:28.0.0',
|
||||||
|
spring_animation : 'com.android.support:support-dynamic-animation:28.0.0',
|
||||||
|
constraint : 'com.android.support.constraint:constraint-layout:1.1.0',
|
||||||
|
percent : 'com.android.support:percent:28.0.0',
|
||||||
|
design : 'com.android.support:design:28.0.0',
|
||||||
|
multidex : 'com.android.support:multidex:1.0.3',
|
||||||
|
multidex_instrumentation: 'com.android.support:multidex-instrumentation:1.0.3',
|
||||||
|
junit : 'junit:junit:4.12',
|
||||||
|
gson : 'com.google.code.gson:gson:2.8.5',
|
||||||
|
fastjson : 'com.alibaba:fastjson:1.2.7',
|
||||||
|
nineoldandroids : 'com.nineoldandroids:library:2.4.0',
|
||||||
|
wheelpicker : 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2',
|
||||||
|
greendao : 'org.greenrobot:greendao:3.2.2',
|
||||||
|
flexbox : 'com.google.android:flexbox:1.0.0',
|
||||||
|
countdownview : 'com.github.iwgang:countdownview:2.1.6',
|
||||||
|
eventbus : 'org.greenrobot:eventbus:3.0.0',
|
||||||
|
okhttp3 : 'com.squareup.okhttp3:okhttp:3.6.0',
|
||||||
|
lifecycle_runtime : 'android.arch.lifecycle:runtime:1.0.3',
|
||||||
|
wechatopen : 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:5.1.4',
|
||||||
|
flexbox : 'com.google.android:flexbox:1.0.0',
|
||||||
|
countdownview : 'com.github.iwgang:countdownview:2.1.6',
|
||||||
|
okio : 'com.squareup.okio:okio:1.13.0',
|
||||||
|
retrofit : 'com.squareup.retrofit2:retrofit:2.2.0',
|
||||||
|
eventbus : 'org.greenrobot:eventbus:3.0.0',
|
||||||
|
lottie : 'com.airbnb.android:lottie:2.3.1',
|
||||||
|
walle : 'com.meituan.android.walle:library:1.1.6'
|
||||||
|
]
|
||||||
|
}
|
|
@ -961,7 +961,8 @@ public class ToolPicture extends ToolBase {
|
||||||
cv.drawBitmap(markBMP, srcBMP.getWidth() - markBMP.getWidth() + 5,
|
cv.drawBitmap(markBMP, srcBMP.getWidth() - markBMP.getWidth() + 5,
|
||||||
srcBMP.getHeight() - markBMP.getHeight() + 5, null);
|
srcBMP.getHeight() - markBMP.getHeight() + 5, null);
|
||||||
// 保存
|
// 保存
|
||||||
cv.save(Canvas.ALL_SAVE_FLAG);
|
// cv.save(Canvas.ALL_SAVE_FLAG);
|
||||||
|
cv.save();
|
||||||
// 存储
|
// 存储
|
||||||
cv.restore();
|
cv.restore();
|
||||||
|
|
||||||
|
@ -1129,7 +1130,8 @@ public class ToolPicture extends ToolBase {
|
||||||
drawLine(c, paint);
|
drawLine(c, paint);
|
||||||
}
|
}
|
||||||
// 保存
|
// 保存
|
||||||
c.save(Canvas.ALL_SAVE_FLAG);
|
// c.save(Canvas.ALL_SAVE_FLAG);
|
||||||
|
c.save();
|
||||||
c.restore();
|
c.restore();
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
|
|
Loading…
Reference in New Issue