Skip to content

Commit

Permalink
Merge pull request #2 from ihewro/3.1
Browse files Browse the repository at this point in the history
3.1
  • Loading branch information
ihewro authored Aug 14, 2018
2 parents f117dd6 + 443ba58 commit 695147a
Show file tree
Hide file tree
Showing 42 changed files with 1,039 additions and 41 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

4 changes: 2 additions & 2 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 201807121
versionName "3.1"
versionCode 201808101
versionName "3.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
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":"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"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[{"filterType":"ABI","value":"x86"}],"versionCode":201808101},"path":"app-x86-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}},{"outputType":{"type":"APK"},"apkInfo":{"type":"FULL_SPLIT","splits":[],"versionCode":201808101},"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":"armeabi-v7a"}],"versionCode":201808101},"path":"app-armeabi-v7a-release.apk","properties":{"packageId":"com.ihewro.android_expression_package","split":"","minSdkVersion":"19"}}]
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,41 @@
*/
public class MyDataBase {



/**
* 把一个表情信息加入到数据库
* @param expression
* @return
*/
public static boolean addExpressionRecord(Expression expression,File source){

byte[] bytes = fileToCompressedBytes(source);
if (bytes == null){
return false;
}else {
return addExpressionRecord(expression,bytes);
}
}

private static byte[] fileToCompressedBytes(File source){
//先进行图片压缩,避免数据太大,导致读取问题
File compressToFile = null;
File compressToFile;
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;
return null;
}else {
//因为compressToFile 和 source是同一个文件,所以先判断下,再决定是否删除
if (compressToFile.exists() && !Objects.equals(compressToFile.getAbsolutePath(), source.getAbsolutePath())){
compressToFile.delete();
}
return addExpressionRecord(expression,bytes);
return 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ protected void onCreate(Bundle savedInstanceState) {

initListener();

Animation rotateAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
imageView.setAnimation(rotateAnimation);
imageView.startAnimation(rotateAnimation);


imageView.setOnClickListener(new View.OnClickListener() {
Expand All @@ -89,6 +86,9 @@ public void onClick(View v) {
if (clickTimes > 3 && !isPlayed){
isPlayed = true;
Toasty.info(AboutActivity.this,"准备为您播放彩蛋音乐", Toast.LENGTH_LONG).show();
Animation rotateAnimation = AnimationUtils.loadAnimation(AboutActivity.this, R.anim.rotate);
imageView.setAnimation(rotateAnimation);
imageView.startAnimation(rotateAnimation);
String dataSource = "https://www.ihewro.com/little.mp3";
ALog.d("播放地址为" + dataSource);

Expand All @@ -102,7 +102,7 @@ public void onClick(View v) {
e.printStackTrace();
}
}else if (isPlayed){
Toasty.info(AboutActivity.this,"已经为你播放过啦~",Toast.LENGTH_LONG).show();
//Toasty.info(AboutActivity.this,"已经为你播放过啦~",Toast.LENGTH_LONG).show();
}
}else {
lastClickTime = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.ihewro.android_expression_package.activity;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -16,6 +18,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.blankj.ALog;
import com.chad.library.adapter.base.BaseQuickAdapter;
Expand All @@ -25,10 +28,17 @@
import com.ihewro.android_expression_package.adapter.ExpressionListAdapter;
import com.ihewro.android_expression_package.bean.EventMessage;
import com.ihewro.android_expression_package.bean.Expression;
import com.ihewro.android_expression_package.bean.ExpressionFolder;
import com.ihewro.android_expression_package.callback.GetExpListListener;
import com.ihewro.android_expression_package.callback.SaveImageToGalleryListener;
import com.ihewro.android_expression_package.callback.TaskListener;
import com.ihewro.android_expression_package.task.DeleteExpFolderTask;
import com.ihewro.android_expression_package.task.DeleteImageTask;
import com.ihewro.android_expression_package.task.EditExpFolderNameTask;
import com.ihewro.android_expression_package.task.GetExpListTask;
import com.ihewro.android_expression_package.task.SaveFolderToLocalTask;
import com.ihewro.android_expression_package.task.SaveImageToGalleryTask;
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 com.ihewro.android_expression_package.view.ExpImageDialog;
Expand All @@ -43,6 +53,7 @@
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.litepal.LitePal;
import org.litepal.crud.DataSupport;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -377,7 +388,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.re_add) {
//
//添加新的表情
Matisse.from(ExpLocalFolderDetailActivity.this)
.choose(MimeType.ofAll(), false)
.countable(true)
Expand All @@ -387,6 +398,63 @@ public boolean onOptionsItemSelected(MenuItem item) {
.theme(R.style.Matisse_Dracula)
.imageEngine(new MyGlideEngine())
.forResult(1998);
}else if (item.getItemId() == R.id.re_edit){
//修改表情包名称
new MaterialDialog.Builder(this)
.title("输入修改后的表情包名称")
.content("具有一点分类意义的名字哦,方便查找")
.inputType(InputType.TYPE_CLASS_TEXT)
.input("任意文字", dirName, new MaterialDialog.InputCallback() {
@Override
public void onInput(final MaterialDialog dialog, CharSequence input) {
List<ExpressionFolder> temExpFolderList = LitePal.where("name = ?",dialog.getInputEditText().getText().toString()).find(ExpressionFolder.class);
if (temExpFolderList.size()>0){
Toasty.error(ExpLocalFolderDetailActivity.this,"表情包名称已存在,请更换",Toast.LENGTH_SHORT).show();
}else {
//修改数据库的目录名称
new EditExpFolderNameTask(ExpLocalFolderDetailActivity.this, expressionList.size(), dirName, dialog.getInputEditText().getText().toString(), new SaveImageToGalleryListener() {
@Override
public void onFinish(Boolean result) {
//修改本地表情包目录名称
File dir = new File(GlobalConfig.appDirPath + dirName);
if (dir.exists()){
dir.renameTo(new File(GlobalConfig.appDirPath + dialog.getInputEditText().getText().toString()));
}
toolbar.setTitle(dialog.getInputEditText().getText().toString());
}
}).execute(expressionList);
}
}
}).show();
}else if (item.getItemId() == R.id.all_download){
//下载到手机
new MaterialDialog.Builder(this)
.title("下载提示")
.content("从[表情商店]下载的图片以二进制存储在本地数据库中,不[下载到本地]仍然可以离线使用,无需流量。\n\n [下载到手机]表示将图片以文件形式存在在手机存储卡中")
.negativeText("那就不下载了")
.positiveText("给我下载")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new SaveFolderToLocalTask(ExpLocalFolderDetailActivity.this,expressionList.size(),dirName).execute(expressionList);
}
})
.show();

}else if (item.getItemId() == R.id.all_delete){
//删除本地文件
new MaterialDialog.Builder(this)
.title("删除提示")
.content("该操作会删除表情包在手机存储卡中的文件。\n\n删除后,表情仍然以二进制保留在数据库,可以离线使用。")
.negativeText("取消")
.positiveText("给我删除")
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
new DeleteExpFolderTask(dirName,ExpLocalFolderDetailActivity.this).execute();
}
})
.show();
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
import com.ihewro.android_expression_package.bean.ExpressionFolder;
import com.ihewro.android_expression_package.bean.OneDetail;
import com.ihewro.android_expression_package.bean.OneDetailList;
import com.ihewro.android_expression_package.callback.GestureListener;
import com.ihewro.android_expression_package.callback.RemoveCacheListener;
import com.ihewro.android_expression_package.callback.GetMainExpListener;
import com.ihewro.android_expression_package.callback.TaskListener;
import com.ihewro.android_expression_package.fragment.ExpressionContentFragment;
import com.ihewro.android_expression_package.http.HttpUtil;
import com.ihewro.android_expression_package.task.CheckUpdateTask;
import com.ihewro.android_expression_package.task.GenerateScreenshotTask;
import com.ihewro.android_expression_package.task.RecoverDataTask;
import com.ihewro.android_expression_package.task.RemoveCacheTask;
import com.ihewro.android_expression_package.task.GetExpFolderTask;
Expand Down Expand Up @@ -528,6 +530,10 @@ public void onClickedGuideView() {

private void initListener() {

//监听图片的左右滑动
topImage.setLongClickable(true);
topImage.setOnTouchListener(new MyGestureListener(this));

fabSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -686,13 +692,26 @@ public void onLoadFailed(@Nullable Drawable errorDrawable) {
topImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Expression expression = new Expression(2, oneDetailLists.getDate().substring(0, 10) + (currentItem) + ".jpg", oneDetailList.get(currentItem).getImgUrl(), "头图");
ExpImageDialog expImageDialog = new ExpImageDialog.Builder(MainActivity.this)
//生成截图
final Expression expression = new Expression(3, oneDetailLists.getDate().substring(0, 10) + (currentItem) + ".jpg", oneDetailList.get(currentItem).getImgUrl(), "头图");
final ExpImageDialog expImageDialog = new ExpImageDialog.Builder(MainActivity.this)
.setContext(MainActivity.this, null,3)
.build();
expImageDialog.setImageData(expression);
expImageDialog.show();

//判断是否已经生成过了
File file = new File(GlobalConfig.appDirPath + expression.getFolderName() + "/" + expression.getName());
if (file.exists()){
expImageDialog.show();
}else {
new GenerateScreenshotTask(MainActivity.this, oneText.getText().toString(), expression, new TaskListener() {
@Override
public void onFinish(Boolean result) {
expImageDialog.show();
}
}).execute();
}

}
});
}
Expand Down Expand Up @@ -881,4 +900,28 @@ public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File fil
public void onFileChooserDismissed(@NonNull FileChooserDialog dialog) {

}

/**
* 继承GestureListener,重写left和right方法
*/
private class MyGestureListener extends GestureListener {
public MyGestureListener(Context context) {
super(context);
}

@Override
public boolean left() {
Toasty.info(MainActivity.this,"点击顶部风车按钮切换图片文字哦").show();
return super.left();
}

@Override
public boolean right() {
Toasty.info(MainActivity.this,"点击顶部风车按钮切换图片文字哦").show();
return super.right();
}
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
@Override
public void onFinished() {
updateLoadingDialog.setContent("终于同步完成");
updateLoadingDialog.dismiss();
Toasty.success(MyActivity.this,"同步完成", Toast.LENGTH_SHORT).show();
//更新RecyclerView 布局
initData();
Expand All @@ -244,7 +245,6 @@ public void onProgress(int progress,int max) {
if (!updateLoadingDialog.isShowing()){
updateLoadingDialog.setMaxProgress(max);
updateLoadingDialog.show();
ALog.d("有点问题");
}

if (progress > 0){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class Expression extends LitePalSupport{

private int id;//主键
private int status;//标志位,图片来源:~~-1 apk内置图片~~ 1 sd卡图片 2 网络图片
private int status;//标志位,图片来源:~~-1 apk内置图片~~ 1 数据库图片 2 网络图片 3 本机图片(数据库中没有存,头图分享卡片就是这种类型)
private String name;//图片名称
private String url;//图片路径或者图片地址
private String folderName;//目录的名称
Expand Down
Loading

0 comments on commit 695147a

Please sign in to comment.