Skip to content

Commit

Permalink
Merge pull request #1 from ihewro/3.1
Browse files Browse the repository at this point in the history
3.1
  • Loading branch information
ihewro authored Jul 17, 2018
2 parents fd94df9 + a23cb50 commit f117dd6
Show file tree
Hide file tree
Showing 72 changed files with 2,444 additions and 854 deletions.
46 changes: 46 additions & 0 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
23 changes: 13 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.ihewro.android_expression_package"
minSdkVersion 19
targetSdkVersion 26
versionCode 201807101
versionName "2.4"
versionCode 201807121
versionName "3.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down Expand Up @@ -54,10 +54,11 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'


compile 'com.android.support:cardview-v7:26.+'

//百度文字识别
compile files('libs/ocr-sdk.jar')

//侧边栏
implementation("com.mikepenz:materialdrawer:6.0.7@aar") {
transitive = true
Expand All @@ -66,7 +67,6 @@ dependencies {
//recyclerView
implementation "com.android.support:recyclerview-v7:26.1.0"


//简单修改状态栏,使其沉浸
compile 'com.jaeger.statusbarutil:library:1.5.0'

Expand All @@ -85,9 +85,10 @@ dependencies {
implementation "com.mikepenz:iconics-views:3.0.3@aar"
compile 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar' //Google Material Icons


//dialog
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'


//图片加载框架
implementation 'com.github.bumptech.glide:glide:4.6.1'
Expand All @@ -99,15 +100,12 @@ dependencies {
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'//打印请求信息
compile 'com.squareup.retrofit2:converter-jackson:2.3.0'


//toast
implementation 'com.github.GrenderG:Toasty:1.3.0'


//简化运行时申请权限的代码
compile 'pub.devrel:easypermissions:1.0.1'


//滚动布局的第三方框架
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.36'
//下拉刷新
Expand All @@ -124,7 +122,6 @@ dependencies {
compile 'com.canking.minipay:minipay:1.0.5'
compile 'cn.gavinliu.android.lib:ShapedImageView:0.8.5'


//全局错误异常捕捉
compile 'cat.ereza:customactivityoncrash:2.2.0'

Expand All @@ -133,5 +130,11 @@ dependencies {

compile 'org.greenrobot:eventbus:3.1.1'

//图片选择器
compile 'com.zhihu.android:matisse:0.5.1'

//图片压缩
compile 'id.zelory:compressor:2.1.0'


}
Binary file added app/libs/ocr-sdk.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
-keep class .R
-keep class **.R$* {
<fields>;
}
}

-dontwarn com.squareup.picasso.**
Binary file modified app/release/app-universal-release.apk
Binary file not shown.
Binary file modified app/release/app-x86-release.apk
Binary file not shown.
Binary file modified app/release/baby.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[{"filterType":"ABI","value":"armeabi-v7a"}],"versionCode":201807101},"path":"app-armeabi-v7a-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}},{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[],"versionCode":201807101},"path":"app-universal-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}},{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[{"filterType":"ABI","value":"x86"}],"versionCode":201807101},"path":"app-x86-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[{"filterType":"ABI","value":"x86"}],"versionCode":201807121},"path":"app-x86-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}},{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[{"filterType":"ABI","value":"armeabi-v7a"}],"versionCode":201807121},"path":"app-armeabi-v7a-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}},{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[],"versionCode":201807121},"path":"app-universal-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}}]
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity">
</activity>
<activity android:name=".activity.MainActivity"></activity>
<activity
android:name=".activity.BaseActivity"
android:label="@string/title_activity_base"
Expand Down Expand Up @@ -53,6 +52,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -62,6 +62,7 @@
android:name=".activity.ErrorActivity"
android:label="抱歉,出错了"
android:process=":error_activity" />
<activity android:name=".activity.ResultActivity"></activity>
</application>

</manifest>
2 changes: 1 addition & 1 deletion app/src/main/assets/litepal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
For example:
<version value="1" />
-->
<version value="5" />
<version value="8" />

<!--
Define your models in the list with mapping tag, LitePal will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public class GlobalConfig {
public static final String serverUrl = "https://www.ihewro.com/exp/";
public static final String getDirListUrl = serverUrl + "expFolderList.php";
public static final String getDirDetailUrl = serverUrl + "expFolderDetail.php";
public static final String appShareOrSavePath = appDirPath + "应用默认文件夹/";//文件夹名称为

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
import android.widget.Toast;

import com.blankj.ALog;
import com.ihewro.android_expression_package.activity.ExpLocalFolderDetailActivity;
import com.ihewro.android_expression_package.bean.Expression;
import com.ihewro.android_expression_package.bean.ExpressionFolder;
import com.ihewro.android_expression_package.bean.OneDetailList;
import com.ihewro.android_expression_package.callback.UpdateDatabaseListener;
import com.ihewro.android_expression_package.util.DateUtil;
import com.ihewro.android_expression_package.util.FileUtil;
import com.ihewro.android_expression_package.util.UIUtil;

import org.litepal.LitePal;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import es.dmoral.toasty.Toasty;
import id.zelory.compressor.Compressor;

/**
* <pre>
Expand All @@ -28,22 +36,47 @@
*/
public class MyDataBase {



/**
* 把一个表情信息加入到数据库
* @param expression
* @return
*/
public static boolean addExpressionRecord(Expression expression){
public static boolean addExpressionRecord(Expression expression,File source){
//先进行图片压缩,避免数据太大,导致读取问题
File compressToFile = null;
compressToFile = FileUtil.returnCompressExp(source);
ALog.d("压缩后的路径" + compressToFile.getAbsolutePath() + "大小" + compressToFile.length());
byte[] bytes = FileUtil.fileToBytes(compressToFile);
ALog.d("文件大小为" + bytes.length);
if (bytes.length>2060826){
return false;
}else {
//因为compressToFile 和 source是同一个文件,所以先判断下,再决定是否删除
if (compressToFile.exists() && !Objects.equals(compressToFile.getAbsolutePath(), source.getAbsolutePath())){
compressToFile.delete();
}
return addExpressionRecord(expression,bytes);
}

}

public static boolean addExpressionRecord(Expression expression,byte[] source) {
//1. 检查有没有表情对应的目录
List<ExpressionFolder> expressionFolderList = LitePal.where("name = ? and exist = ?",expression.getFolderName(), String.valueOf(1)).find(ExpressionFolder.class,true);
ExpressionFolder expressionFolder = null;//当前表情的目录的持久化对象
List<ExpressionFolder> expressionFolderList = LitePal.where("name = ? and exist = ?",expression.getFolderName(), String.valueOf(1)).find(ExpressionFolder.class);
ExpressionFolder expressionFolder;//当前表情的目录的持久化对象

Expression currentExpression;//当前表情的持久化对象

//2. 检查该目录中有没有该表情名称
if (expressionFolderList.size () == 1){
expressionFolder = expressionFolderList.get(0);
List<Expression> expressionList = LitePal.where("name = ?",expression.getName()).find(Expression.class);
List<Expression> expressionList = queryExpListByNameAndFolderName(false,expression.getName(),expression.getFolderName());
if (expressionList.size() >0){//有该表情的信息就不用管了
currentExpression = expressionList.get(0);
currentExpression.setExpressionFolder(expressionFolder);
saveExpImage(currentExpression,source,false);
return true;
}
ALog.d("目录存在,但是表情不存在");
Expand All @@ -54,9 +87,13 @@ public static boolean addExpressionRecord(Expression expression){
} else {
return false;//这种错误几乎不会发生,除非数据库的错误严重错乱
}

//3. 把表情的信息存储进去,执行这里的时候有两种情况,一种是目录和表情都没有的。一种目录存在,但是表情不存在。
currentExpression = new Expression(1,expression.getName(),GlobalConfig.appDirPath + expression.getFolderName() + "/" + expression.getName(),expression.getFolderName(),expressionFolder);
currentExpression.save();
saveExpImage(currentExpression,source,false);



expressionFolder.setCount(expressionFolder.getCount() + 1);

Expand All @@ -71,12 +108,12 @@ public static boolean addExpressionRecord(Expression expression){
}
expressionFolder.save();



return true;
}




public static boolean isNeedGetOnes(){
//获取one数据库信息
List<OneDetailList> oneDetailListList = LitePal.findAll(OneDetailList.class);
Expand All @@ -94,4 +131,36 @@ public static boolean isNeedGetOnes(){
}
return flag;
}

public static void saveExpImage(Expression expression,File file, boolean isForce) {
byte[] bytes = FileUtil.fileToBytes(file);
saveExpImage(expression,bytes,isForce);
}

/**
* 把图片存储到数据库的二进制中
* @param expression
* @param bytes
* @param isForce
*/
public static void saveExpImage(Expression expression,byte[] bytes, boolean isForce){
if (expression.isSaved()){
if (isForce || (expression.getImage() == null || expression.getImage().length == 0)){
expression.setImage(bytes);
ALog.d(bytes);
expression.save();
}
}else {
ALog.d("expression 不是持久化对象");
}
}

public static List<Expression> queryExpListByNameAndFolderName(boolean isImage,String name,String folderName){
if (isImage){
return LitePal.where("name = ? and foldername = ?",name,folderName).find(Expression.class);
}else {
return LitePal.select("id","name","foldername","status","url","expressionfolder_id","desstatus","description").where("name = ? and foldername = ?",name,folderName).find(Expression.class);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.afollestad.materialdialogs.MaterialDialog;
import com.ihewro.android_expression_package.R;
import com.ihewro.android_expression_package.callback.UpdateDatabaseListener;
import com.ihewro.android_expression_package.task.RecoverDataTask;
import com.ihewro.android_expression_package.task.UpdateDatabaseTask;

import butterknife.BindView;
Expand All @@ -22,21 +23,23 @@ public class ErrorActivity extends AppCompatActivity {
Button restart;
@BindView(R.id.button6)
Button update;
@BindView(R.id.button)
Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_error);
ButterKnife.bind(this);

updateDatabase();
// updateDatabase();

initListener();
}


private void updateDatabase() {
UpdateDatabaseTask task = new UpdateDatabaseTask(new UpdateDatabaseListener() {
UpdateDatabaseTask task = new UpdateDatabaseTask(this, new UpdateDatabaseListener() {

private MaterialDialog updateLoadingDialog;

Expand Down Expand Up @@ -75,6 +78,13 @@ public void onStart() {
}

private void initListener() {

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new RecoverDataTask(ErrorActivity.this).execute();
}
});
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Loading

0 comments on commit f117dd6

Please sign in to comment.