diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..0f42a15
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,83 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ buildToolsVersion "30.0.3"
+ sourceSets {
+ main {
+ jniLibs.srcDirs = ['libs']
+ }
+ }
+
+// **兼容Android6.0系统所需,如果这句话报错,可在dependencies标签下使用compile 'cn.bmob.android:http-legacy:1.0'**
+ // useLibrary 'org.apache.http.legacy'
+
+ defaultConfig {
+ applicationId "com.bigbig.ding"
+ minSdkVersion 24
+ targetSdkVersion 28
+ versionCode 4
+ versionName "2.0.2"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
+ exclude group: 'com.android.support', module: 'support-annotations'
+ })
+ compile 'com.android.support:appcompat-v7:25.1.0'
+ compile 'com.android.support:design:25.1.0'
+ compile 'com.android.support.constraint:constraint-layout:1.0.2'
+ compile 'com.android.support:cardview-v7:25.1.0'
+ testCompile 'junit:junit:4.12'
+
+ // litePal 数据库框架 地址:https://github.com/LitePalFramework/LitePal
+ compile 'org.litepal.android:core:1.4.1'
+
+ // butterknife
+ compile 'com.jakewharton:butterknife:8.6.0'
+ annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
+
+ // BaseRecyclerViewAdapterHelper
+ compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.16'
+
+ // glide
+ compile 'com.github.bumptech.glide:glide:3.7.0'
+
+ // logger
+ compile 'com.orhanobut:logger:1.15'
+
+ //https://github.com/Blankj/AndroidUtilCode
+ compile 'com.blankj:utilcode:1.7.1'
+
+ //bmob-sdk:Bmob的android sdk包,包含了Bmob的数据存储、文件等服务,以下是最新的bmob-sdk:
+ //3.5.5:请务必查看下面注释[1]
+ compile 'cn.bmob.android:bmob-sdk:3.7.7'
+ //如果你想应用能够兼容Android6.0,请添加此依赖(org.apache.http.legacy.jar)
+// compile 'cn.bmob.android:http-legacy:1.0'
+ implementation "io.reactivex.rxjava2:rxjava:2.2.2"
+ implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
+ implementation 'com.squareup.okio:okio:2.1.0'
+ implementation 'com.google.code.gson:gson:2.8.5'
+ implementation 'com.squareup.okhttp3:okhttp:3.12.0'
+
+ implementation files('libs/MiPush_SDK_Client_3_6_19.jar')
+
+ // 以下是图片加载器
+ compile 'com.github.piasy:BigImageViewer:1.3.1'
+ // load with glide
+ // compile 'com.github.piasy:GlideImageLoader:1.3.1'
+ // load with fresco
+ compile 'com.github.piasy:FrescoImageLoader:1.3.1'
+
+ // photoView https://github.com/chrisbanes/PhotoView
+ compile 'com.github.chrisbanes:PhotoView:2.1.2'
+}
diff --git a/app/libs/MiPush_SDK_Client_3_6_19.jar b/app/libs/MiPush_SDK_Client_3_6_19.jar
new file mode 100644
index 0000000..b3449dd
Binary files /dev/null and b/app/libs/MiPush_SDK_Client_3_6_19.jar differ
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..dc42d0b
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,25 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in D:\ec\android sdk_4_5_6/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/release/output.json b/app/release/output.json
new file mode 100644
index 0000000..5d326f9
--- /dev/null
+++ b/app/release/output.json
@@ -0,0 +1 @@
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"2.0.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/bigbig/fadainote/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/bigbig/fadainote/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..bcc34a5
--- /dev/null
+++ b/app/src/androidTest/java/com/bigbig/fadainote/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.bigbig.fadainote;
+
+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.fadai.fadainote", appContext.getPackageName());
+ }
+}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..c9ec79c
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/litepal.xml b/app/src/main/assets/litepal.xml
new file mode 100644
index 0000000..040468b
--- /dev/null
+++ b/app/src/main/assets/litepal.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..d49e3b8
Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ
diff --git a/app/src/main/java/com/bigbig/ding/MainApplication.java b/app/src/main/java/com/bigbig/ding/MainApplication.java
new file mode 100644
index 0000000..f6fe00c
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/MainApplication.java
@@ -0,0 +1,120 @@
+package com.bigbig.ding;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.util.Log;
+
+import com.blankj.utilcode.util.Utils;
+import com.xiaomi.channel.commonutils.logger.LoggerInterface;
+import com.xiaomi.mipush.sdk.Logger;
+import com.xiaomi.mipush.sdk.MiPushClient;
+
+import org.litepal.LitePalApplication;
+import org.litepal.tablemanager.Connector;
+
+import java.util.List;
+
+import com.bigbig.ding.constants.CacheManager;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.FolderListConstans;
+import com.bigbig.ding.constants.NoteListConstans;
+import com.bigbig.ding.utils.PreferencesUtil;
+import cn.bmob.v3.Bmob;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/02
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class MainApplication extends LitePalApplication {
+
+ public static Context mContext;
+ public static String TAG = "com.bigbig.ding";
+ //小米消息推送APP_ID ,APP_KEY
+ private static final String APP_ID = "2882303761518023989";
+ private static final String APP_KEY = "5731802361989";
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ mContext = this;
+ init();
+ initBmob();
+ initXiaomiPush();
+ getCacheData();
+ setUpdateForVersionCode1();
+ }
+
+ private void init(){
+ Utils.init(getApplicationContext());
+ Connector.getDatabase();
+}
+
+ private void initBmob(){
+ Bmob.initialize(this,getResources().getString(R.string.bmob_app_id));
+ }
+
+ private void getCacheData(){
+ Constans.isFirst= PreferencesUtil.getBoolean(Constans.IS_FIRST,true);
+ Constans.currentFolder= PreferencesUtil.getInt(Constans.CURRENT_FOLDER, FolderListConstans.ITEM_ALL);
+ Constans.noteListShowMode=PreferencesUtil.getInt(Constans.NOTE_LIST_SHOW_MODE, NoteListConstans.STYLE_GRID);
+ Constans.theme=PreferencesUtil.getInt(Constans.THEME,Constans.theme);
+ Constans.isUseRecycleBin=PreferencesUtil.getBoolean(Constans.IS_USE_RECYCLE,Constans.isUseRecycleBin);
+ Constans.isLocked=PreferencesUtil.getBoolean(Constans.IS_LOCKED,Constans.isLocked);
+ Constans.lockPassword=PreferencesUtil.getString(Constans.LOCK_PASSWORD,"");
+ Constans.xmRegId=PreferencesUtil.getString(Constans.mRegId,"");
+ }
+ /**
+ * 初始化小米消息推送
+ **/
+ private void initXiaomiPush() {
+ // 注册push服务,注册成功后会向DemoMessageReceiver发送广播
+ // 可以从DemoMessageReceiver的onCommandResult方法中MiPushCommandMessage对象参数中获取注册信息
+ if (shouldInit()) {
+ MiPushClient.registerPush(this, APP_ID, APP_KEY);
+ }
+ }
+
+ private boolean shouldInit() {
+ ActivityManager am = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
+ List processInfos = am.getRunningAppProcesses();
+ String mainProcessName = getPackageName();
+ int myPid = android.os.Process.myPid();
+ for (ActivityManager.RunningAppProcessInfo info : processInfos) {
+ if (info.pid == myPid && mainProcessName.equals(info.processName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static void reInitPush(Context ctx) {
+ MiPushClient.registerPush(ctx.getApplicationContext(), APP_ID, APP_KEY);
+ }
+ // 为了兼容1.0.1版本,将其的缓存信息进行备份修改
+ private void setUpdateForVersionCode1(){
+ // 1.0.1版本使用的key值,如果是false,说明之前是V1.0.1版本
+ boolean isFirst= PreferencesUtil.getBoolean("isFirst",true);
+ if(!isFirst){
+ boolean isGrid= PreferencesUtil.getBoolean("is_grid",false);
+ boolean isUseRecycleBin=PreferencesUtil.getBoolean("recycle_bin",false);
+
+ CacheManager.setAndSaveIsFirst(false);
+ CacheManager.setAndSaveCurrentFolder(FolderListConstans.ITEM_ALL);
+ CacheManager.setAndSaveIsUseRecycleBin(isUseRecycleBin);
+ if(isGrid){
+ CacheManager.setAndSaveNoteListShowMode(NoteListConstans.MODE_GRID);
+ } else {
+ CacheManager.setAndSaveNoteListShowMode(NoteListConstans.MODE_LIST);
+ }
+ // isLock、lockPassword key值一样;主题key值不用修改。
+
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/adapter/NoteBottomSheetFolderAdapter.java b/app/src/main/java/com/bigbig/ding/adapter/NoteBottomSheetFolderAdapter.java
new file mode 100644
index 0000000..03b6165
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/adapter/NoteBottomSheetFolderAdapter.java
@@ -0,0 +1,31 @@
+package com.bigbig.ding.adapter;
+
+import com.bigbig.ding.R;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
+
+import com.bigbig.ding.bean.NoteFolder;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/27
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class NoteBottomSheetFolderAdapter extends BaseQuickAdapter {
+
+ public NoteBottomSheetFolderAdapter() {
+ super(R.layout.item_note_bottom_folder);
+ }
+
+ @Override
+ protected void convert(BaseViewHolder helper, NoteFolder item) {
+ helper.setText(R.id.tv_folder_title_bottom_sheet,item.getFolderName());
+ }
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/adapter/RvEditFolderAdapter.java b/app/src/main/java/com/bigbig/ding/adapter/RvEditFolderAdapter.java
new file mode 100644
index 0000000..9c10099
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/adapter/RvEditFolderAdapter.java
@@ -0,0 +1,136 @@
+package com.bigbig.ding.adapter;
+
+import android.content.Context;
+import android.support.annotation.IntRange;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.RelativeLayout;
+
+import com.bigbig.ding.R;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.EditFolderConstans;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class RvEditFolderAdapter extends BaseQuickAdapter {
+
+ public List mCheckList=new ArrayList<>();
+
+ public RvEditFolderAdapter(){
+ super(R.layout.item_edit_folder);
+ }
+
+ @Override
+ public void setNewData(@Nullable List data) {
+ super.setNewData(data);
+ mCheckList.clear();
+ for (int i=0;i
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/02
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class RvNoteFolderAdapter extends BaseQuickAdapter {
+
+ public RvNoteFolderAdapter() {
+ super(R.layout.item_folder);
+ }
+
+ @Override
+ protected void convert(BaseViewHolder helper, NoteFolder item) {
+ helper.setText(R.id.tv_folder_list_title, item.getFolderName())
+ .setText(R.id.tv_folder_list_count, item.getNoteCount() + "");
+
+
+ RelativeLayout rlItem=helper.getView(R.id.rl_folder_root);
+ TextView tvTitle=helper.getView(R.id.tv_folder_list_title);
+ TextView tvCount=helper.getView(R.id.tv_folder_list_count);
+ ImageView ivIcon=helper.getView(R.id.iv_folder_list_ic);
+
+ if(Constans.currentFolder == helper.getLayoutPosition()-getHeaderLayoutCount()){
+ rlItem.setSelected(true);
+ tvTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ tvCount.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ ivIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable( ThemeUtils.getColorPrimary(mContext)));
+ } else {
+ rlItem.setSelected(false);
+ tvTitle.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha87));
+ tvCount.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha54));
+ ivIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
+ }
+ }
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/adapter/RvNoteListAdapter.java b/app/src/main/java/com/bigbig/ding/adapter/RvNoteListAdapter.java
new file mode 100644
index 0000000..0b185f3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/adapter/RvNoteListAdapter.java
@@ -0,0 +1,345 @@
+package com.bigbig.ding.adapter;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.view.View;
+import android.widget.CheckBox;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+import com.blankj.utilcode.util.TimeUtils;
+import com.blankj.utilcode.util.Utils;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.BaseViewHolder;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.EditNoteConstans;
+import com.bigbig.ding.constants.FolderListConstans;
+import com.bigbig.ding.constants.NoteListConstans;
+import com.bigbig.ding.utils.DateUtils;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/02
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class RvNoteListAdapter extends BaseQuickAdapter {
+
+ public List mCheckList = new ArrayList<>();
+
+ public List mAllCheckList;
+ public List mAllDataList;
+
+ public void addData(@NonNull Collection extends Note> newData) {
+ addData(newData);
+ for (int i = 0; i < newData.size(); i++) {
+ mCheckList.add(false);
+ }
+ }
+
+ public void addData(@NonNull Note data) {
+ addData(0, data);
+ mCheckList.add(false);
+ notifyDataSetChanged();
+ }
+
+ public void setNewData(@Nullable List data) {
+ super.setNewData(data);
+ mCheckList.clear();
+ for (int i = 0; i < data.size(); i++) {
+ mCheckList.add(false);
+ }
+ }
+
+ public RvNoteListAdapter() {
+ super(R.layout.item_note);
+ }
+
+
+ @Override
+ protected void convert(BaseViewHolder helper, Note item) {
+ if (isLinearLayoutManager())
+ setLinearLayout(helper, item);
+ else if (isGridLayoutManager())
+ setGridLayout(helper, item);
+ }
+
+ /**
+ * 是否是线性布局
+ *
+ * @describe
+ */
+ private boolean isLinearLayoutManager() {
+ if (Constans.noteListShowMode == NoteListConstans.STYLE_LINEAR)
+ return true;
+ return false;
+ }
+
+ /**
+ * 是否是网格布局
+ *
+ * @describe
+ */
+ private boolean isGridLayoutManager() {
+ if (Constans.noteListShowMode == NoteListConstans.STYLE_GRID)
+ return true;
+ return false;
+ }
+
+ /**
+ * 设置网格布局
+ *
+ * @describe
+ */
+ private void setGridLayout(BaseViewHolder helper, Note item) {
+
+ helper.addOnClickListener(R.id.cv_note_list_grid);
+ helper.addOnLongClickListener(R.id.cv_note_list_grid);
+
+ helper.setVisible(R.id.ll_note_list_linear, false);
+ helper.setVisible(R.id.cv_note_list_grid, true);
+
+ TextView tvContent=helper.getView(R.id.tv_note_list_grid_content);
+ if(isPrivacyAndRecycle(item))
+ helper.setText(R.id.tv_note_list_grid_content,Utils.getContext().getResources().getString(R.string.note_privacy_and_recycle));
+ else
+ parseTextContent(tvContent,item.getNoteContent());
+
+ // 设置便签的时间显示
+ setNoteTime(helper, item.getModifiedTime());
+ // 设置多选按钮
+ setCheckBox(helper);
+ }
+
+ private boolean isPrivacyAndRecycle(Note note) {
+ if (Constans.currentFolder== FolderListConstans.ITEM_RECYCLE && note.getIsPrivacy() == 1 )
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 解析文本中的图片
+ */
+ private void parseTextContent(TextView textView, String content) {
+ // TODO: 2017/7/11 0011 后续可以找到图片后,显示在列表item上
+
+ textView.setText("");
+
+ Pattern p = Pattern.compile(EditNoteConstans.imageTabBefore+"([^<]*)"+EditNoteConstans.imageTabAfter);
+ Matcher m = p.matcher(content);
+ int tempIndex = 0;
+ List textList=new ArrayList<>();
+ while (m.find()) {
+
+ // 匹配到的数据中,第一个括号的中的内容(这里只有一个括号)
+ String temp = m.group(1);
+
+ // 查找图片标签的位置
+ int index = content.indexOf(EditNoteConstans.imageTabBefore, tempIndex);
+
+ // 将本次开始位置到图片标签间的图片储存起来
+ String text = content.substring(tempIndex, index);
+ textList.add(text);
+
+ // 将查询起始位置升级
+ int flagLength=EditNoteConstans.imageTabBefore.length()+EditNoteConstans.imageTabAfter.length();
+ tempIndex = index + flagLength + temp.length();
+ }
+
+ if(textList.size()!=0){
+ for (int i=0;i
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/02
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class Note extends DataSupport {
+ private int id;
+ private String noteId;
+ private long createdTime;
+ private long modifiedTime;
+ private String noteContent;
+ private int noteFolderId;
+ // 是否是私密便签 1是 0不是
+ private int isPrivacy;
+ // 是否是废纸篓中便签,1是,0不是
+ private int inRecycleBin;
+
+ public int getIsPrivacy() {
+ return isPrivacy;
+ }
+
+ public void setIsPrivacy(int isPrivacy) {
+ this.isPrivacy = isPrivacy;
+ }
+
+ public int getInRecycleBin() {
+ return inRecycleBin;
+ }
+
+ public void setInRecycleBin(int inRecycleBin) {
+ this.inRecycleBin = inRecycleBin;
+ }
+
+ public String getNoteId() {
+ return noteId;
+ }
+
+ public void setNoteId(String noteId) {
+ this.noteId = noteId;
+ }
+
+ public String getNoteContent() {
+ return noteContent;
+ }
+
+ public void setNoteContent(String noteContent) {
+ this.noteContent = noteContent;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getNoteFolderId() {
+ return noteFolderId;
+ }
+
+ public void setNoteFolderId(int noteFolderId) {
+ this.noteFolderId = noteFolderId;
+ }
+
+ public long getCreatedTime() {
+ return createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ public long getModifiedTime() {
+ return modifiedTime;
+ }
+
+ public void setModifiedTime(long modifiedTime) {
+ this.modifiedTime = modifiedTime;
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/bean/NoteFolder.java b/app/src/main/java/com/bigbig/ding/bean/NoteFolder.java
new file mode 100644
index 0000000..e045a25
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/bean/NoteFolder.java
@@ -0,0 +1,37 @@
+package com.bigbig.ding.bean;
+
+import org.litepal.crud.DataSupport;
+
+/**
+ * Created by miaoyongyong on 2017/1/4.
+ */
+
+public class NoteFolder extends DataSupport {
+ private int id;
+ private String folderName;
+ private int noteCount;
+
+ public String getFolderName() {
+ return folderName;
+ }
+
+ public void setFolderName(String folderName) {
+ this.folderName = folderName;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getNoteCount() {
+ return noteCount;
+ }
+
+ public void setNoteCount(int noteCount) {
+ this.noteCount = noteCount;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/bean/Point.java b/app/src/main/java/com/bigbig/ding/bean/Point.java
new file mode 100644
index 0000000..302ae80
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/bean/Point.java
@@ -0,0 +1,30 @@
+package com.bigbig.ding.bean;
+
+/**
+ * 点的bean
+ * Created by Administrator on 2015/9/21.
+ */
+public class Point {
+
+ public static final int STATE_NORMAL = 1;
+ public static final int STATE_PRESS = 2;
+ public static final int STATE_ERROR = 3;
+
+ public float x;
+ public float y;
+ public int state = STATE_NORMAL;
+
+ public Point(float x, float y){
+ this.x = x;
+ this.y = y;
+ }
+
+ /**
+ * 计算两点间的距离
+ * @param a 另外一个点
+ * @return
+ */
+ public float getInstance(Point a){
+ return (float) Math.sqrt((x-a.x)*(x-a.x) + (y-a.y)*(y-a.y));
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/bmob/Feedback.java b/app/src/main/java/com/bigbig/ding/bmob/Feedback.java
new file mode 100644
index 0000000..84ec950
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/bmob/Feedback.java
@@ -0,0 +1,46 @@
+package com.bigbig.ding.bmob;
+
+import cn.bmob.v3.BmobObject;
+
+/**
+ * Created by miaoyongyong on 2017/2/20.
+ */
+
+public class Feedback extends BmobObject{
+ private String contact=new String();
+ private String content=new String();
+ private int sdk;
+ private String version;
+
+ public String getContact() {
+ return contact;
+ }
+
+ public void setContact(String contact) {
+ this.contact = contact;
+ }
+
+ public int getSdk() {
+ return sdk;
+ }
+
+ public void setSdk(int sdk) {
+ this.sdk = sdk;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/CacheManager.java b/app/src/main/java/com/bigbig/ding/constants/CacheManager.java
new file mode 100644
index 0000000..c09efc3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/CacheManager.java
@@ -0,0 +1,64 @@
+package com.bigbig.ding.constants;
+
+import com.bigbig.ding.utils.PreferencesUtil;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/11
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class CacheManager {
+
+ /**
+ * 修改并保存 是否是第一次进入的缓存
+ */
+ public static void setAndSaveIsFirst(boolean isFirst){
+ Constans.isFirst=isFirst;
+ PreferencesUtil.saveBoolean(Constans.IS_FIRST,isFirst);
+ }
+
+ /**
+ * 修改并保存 当前便签夹
+ */
+ public static void setAndSaveCurrentFolder(int currentFolder){
+ Constans.currentFolder=currentFolder;
+ PreferencesUtil.saveInt(Constans.CURRENT_FOLDER,currentFolder);
+ }
+
+ /**
+ * 便签列表显示模式
+ */
+ public static void setAndSaveNoteListShowMode(int showMode){
+ Constans.noteListShowMode=showMode;
+ PreferencesUtil.saveInt(Constans.NOTE_LIST_SHOW_MODE,showMode);
+ }
+
+ /**
+ * 是否已启用废纸篓
+ */
+ public static void setAndSaveIsUseRecycleBin(boolean isUse){
+ Constans.isUseRecycleBin=isUse;
+ PreferencesUtil.saveBoolean(Constans.IS_USE_RECYCLE,isUse);
+ }
+
+ /**
+ * 是否设置了私密密码
+ */
+ public static void setAndSaveIsLocked(boolean isLocked){
+ Constans.isLocked=isLocked;
+ PreferencesUtil.saveBoolean(Constans.IS_LOCKED,isLocked);
+ }
+
+ /**
+ * 私密密码
+ */
+ public static void setAndSaveLockPassword(String lockPassword){
+ Constans.lockPassword=lockPassword;
+ PreferencesUtil.saveString(Constans.LOCK_PASSWORD,lockPassword);
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/Constans.java b/app/src/main/java/com/bigbig/ding/constants/Constans.java
new file mode 100644
index 0000000..d971149
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/Constans.java
@@ -0,0 +1,73 @@
+package com.bigbig.ding.constants;
+
+import android.os.Environment;
+
+import com.bigbig.ding.R;
+
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class Constans {
+
+ // 第一次使用应用
+ public static boolean isFirst = true;
+
+ // 主题
+ public static int theme = R.style.NoActionBar_Theme7;
+
+ // 当前选中的便签夹
+ public static int currentFolder = FolderListConstans.ITEM_ALL;
+
+ // 便签显示样式
+ public static int noteListShowMode = NoteListConstans.MODE_GRID;
+
+ // 是否已启用废纸篓
+ public static boolean isUseRecycleBin = true;
+
+ // 是否已设置隐私密码
+ public static boolean isLocked = false;
+
+ // 隐私密码
+ public static String lockPassword="";
+ // 小米推送设备id
+ public static String xmRegId="";
+
+
+
+ /*--------------以下是sharderPreference的储存的key值---------------------*/
+ // 为了兼容旧版本 一下key值命名风格可能不统一
+
+ public static final String IS_FIRST = "is_first";
+
+ public static final String THEME = "theme";
+
+ public static final String CURRENT_FOLDER = "current_folder";
+
+ public static final String NOTE_LIST_SHOW_MODE = "note_list_show_mode";
+
+ public static final String LOCK_PASSWORD = "lock_password";
+
+ public static final String IS_USE_RECYCLE = "is_use_recycle";
+
+ public static final String IS_LOCKED = "is_locked";
+
+ public static final String mRegId = "mRegId";
+
+
+ /*------------------------常量值------------------------------------*/
+
+ // 支付宝二维码内容
+ public static final String myAlipayQRContent = "HTTPS://QR.ALIPAY.COM/FKX02204SZGKIYYQSFPR54";
+
+ // 图片储存路径(另存为的路径)
+ public static final String imageSaveFolder = Environment.getExternalStorageDirectory().getPath() + "/SuperNote/image/";
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/EditFolderConstans.java b/app/src/main/java/com/bigbig/ding/constants/EditFolderConstans.java
new file mode 100644
index 0000000..278bd42
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/EditFolderConstans.java
@@ -0,0 +1,27 @@
+package com.bigbig.ding.constants;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class EditFolderConstans {
+
+ // 当前正在编辑的item是否是新item
+ public static boolean isNewFolder=false;
+
+ // 当前正在编辑的item
+ public static int selectedItem=-1;
+
+ // 已选择的便签夹
+ public static int selectedCount=0;
+
+
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/EditNoteConstans.java b/app/src/main/java/com/bigbig/ding/constants/EditNoteConstans.java
new file mode 100644
index 0000000..7a23afa
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/EditNoteConstans.java
@@ -0,0 +1,30 @@
+package com.bigbig.ding.constants;
+
+import android.graphics.Bitmap;
+
+import com.blankj.utilcode.util.SizeUtils;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/30
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class EditNoteConstans {
+
+ // 图片标记的前便签和后标签
+ public static String imageTabBefore="";
+ public static String imageTabAfter=" ";
+
+ // 图片距离左右的总距离
+ public static float imageMargin= SizeUtils.dp2px(32);
+
+ // 分享时的水印文字
+ public static String watermarkText="来自:叮咚";
+
+ public static Bitmap shareBitmap;
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/FolderListConstans.java b/app/src/main/java/com/bigbig/ding/constants/FolderListConstans.java
new file mode 100644
index 0000000..0eb18f3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/FolderListConstans.java
@@ -0,0 +1,22 @@
+package com.bigbig.ding.constants;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FolderListConstans {
+
+ public static final int ITEM_ALL=-1;
+ public static final int ITEM_PRIMARY=-2;
+ public static final int ITEM_RECYCLE=-3;
+
+ public static int noteFolderCount=0;
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/constants/NoteListConstans.java b/app/src/main/java/com/bigbig/ding/constants/NoteListConstans.java
new file mode 100644
index 0000000..18895e5
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/constants/NoteListConstans.java
@@ -0,0 +1,49 @@
+package com.bigbig.ding.constants;
+
+
+import com.bigbig.ding.R;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/07
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class NoteListConstans {
+
+ // 是否显示多选操作
+ public static boolean isShowMultiSelectAction = false;
+
+ // note的RecyclerView的显示布局样式
+ public static final int STYLE_LINEAR = 1; // 线性布局
+ public static final int STYLE_GRID = 2; // 网格布局
+
+ // 多选操作时,已选择的item数量
+ public static int selectedCount = 0;
+
+ // 已选择的便签夹名称
+ public static String selectedFolderName = "全部便签";
+
+ // 是否已全选
+ public static boolean isChoiceAll = false;
+
+ // 是否进入搜索模式
+ public static boolean isInSearch=false;
+
+ // 显示模式菜单的图标
+ public static final int MODE_LIST = R.drawable.ic_format_list_bulleted_white_24dp;
+ public static final int MODE_GRID = R.drawable.ic_border_all_white_24dp;
+
+ // 前往密码界面的requestCode
+ public static final int REQUEST_CODE_LOCK=1;
+ // 前往添加便签
+ public static final int REQUEST_CODE_ADD=2;
+ // 前往编辑便签
+ public static final int REQUEST_CODE_EDIT=3;
+ // 前往编辑便签夹
+ public static final int REQUEST_CODE_EDIT_FOLDER=4;
+}
diff --git a/app/src/main/java/com/bigbig/ding/local/table/MySqliteDBConnect.java b/app/src/main/java/com/bigbig/ding/local/table/MySqliteDBConnect.java
new file mode 100644
index 0000000..1baad45
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/local/table/MySqliteDBConnect.java
@@ -0,0 +1,34 @@
+package com.bigbig.ding.local.table;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+import com.orhanobut.logger.Logger;
+
+/**
+ * Created by miaoyongyong on 2016/12/5.
+ */
+
+public class MySqliteDBConnect extends SQLiteOpenHelper {
+ private String CREATE_NOTE="create table Note("
+ +"noteId Integer primary key autoincrement,"
+ +"createdTime Integer,"
+ +"modifiedTime Integer,"
+ +"noteContent text)";
+
+ public MySqliteDBConnect(Context context, String name, SQLiteDatabase.CursorFactory factory, int version){
+ super(context,name,factory,version);
+ }
+ @Override
+ public void onCreate(SQLiteDatabase sqLiteDatabase) {
+ Logger.d("MySqliteDBContent","before create");
+ sqLiteDatabase.execSQL(CREATE_NOTE);
+ Logger.d("MySqliteDBContent","数据库创建完毕");
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
+
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/model/INoteFolderModel.java b/app/src/main/java/com/bigbig/ding/model/INoteFolderModel.java
new file mode 100644
index 0000000..2dc5c6b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/model/INoteFolderModel.java
@@ -0,0 +1,32 @@
+package com.bigbig.ding.model;
+
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/05
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface INoteFolderModel {
+
+ int initNoteFolderAndGetFolderId();
+
+ void loadNoteFoldersList(LoadDataCallBack callBack);
+
+ void addNoteFolder(T noteFolder);
+
+ void deleteNoteFolder(NoteFolder folder);
+
+ void deleteNoteFolders();
+
+ void addNote2Folder(Note note, NoteFolder folder);
+
+ void addNote2Privacy(Note note,NoteFolder folder);
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/model/INoteModel.java b/app/src/main/java/com/bigbig/ding/model/INoteModel.java
new file mode 100644
index 0000000..12bbc82
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/model/INoteModel.java
@@ -0,0 +1,31 @@
+package com.bigbig.ding.model;
+
+import com.bigbig.ding.bean.Note;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/05
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface INoteModel {
+ void initNote(int folderId);
+
+ void loadAllNoteList(LoadDataCallBack callBack);
+
+ void loadPrivacyNoteList(LoadDataCallBack callBack);
+
+ void loadRecycleBinNoteList(LoadDataCallBack callBack);
+
+ void loadNormalNoteList(int folderId,LoadDataCallBack callBack);
+
+ void addNote(T note);
+
+ void deleteNote(Note note);
+
+ void deleteNotes();
+}
diff --git a/app/src/main/java/com/bigbig/ding/model/LoadDataCallBack.java b/app/src/main/java/com/bigbig/ding/model/LoadDataCallBack.java
new file mode 100644
index 0000000..e8cf6f6
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/model/LoadDataCallBack.java
@@ -0,0 +1,18 @@
+package com.bigbig.ding.model;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/05
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public abstract class LoadDataCallBack {
+ protected abstract void onSuccedd(List list);
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/model/NoteFolderModel.java b/app/src/main/java/com/bigbig/ding/model/NoteFolderModel.java
new file mode 100644
index 0000000..80cf948
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/model/NoteFolderModel.java
@@ -0,0 +1,91 @@
+package com.bigbig.ding.model;
+
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+
+import org.litepal.crud.DataSupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/05
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class NoteFolderModel implements INoteFolderModel {
+
+ private INoteModel mNoteModel=new NoteModel();
+
+ @Override
+ public int initNoteFolderAndGetFolderId() {
+
+ NoteFolder folder1 = new NoteFolder();
+ folder1.setFolderName("随手记");
+ folder1.setNoteCount(5);
+ addNoteFolder(folder1);
+
+ NoteFolder noteFolder2 = new NoteFolder();
+ noteFolder2.setFolderName("生活");
+ noteFolder2.setNoteCount(0);
+ addNoteFolder(noteFolder2);
+
+ NoteFolder noteFolder3 = new NoteFolder();
+ noteFolder3.setFolderName("工作");
+ addNoteFolder(noteFolder3);
+
+ NoteFolder folder=DataSupport.where("folderName = ? ","随手记").find(NoteFolder.class).get(0);
+ return folder.getId();
+ }
+
+ @Override
+ public void loadNoteFoldersList(LoadDataCallBack callBack) {
+ List list = DataSupport.findAll(NoteFolder.class);
+ callBack.onSuccedd(list);
+ }
+
+ @Override
+ public void addNoteFolder(NoteFolder folder) {
+ folder.save();
+ }
+
+ @Override
+ public void deleteNoteFolder(NoteFolder folder) {
+ int folderId=folder.getId();
+ List list=new ArrayList();
+ list= DataSupport.where("NoteFolderId = ? and inRecycleBin = ?",folderId+"","0").find(Note.class);
+ for(int i=0;i
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/05
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class NoteModel implements INoteModel {
+
+ @Override
+ public void initNote(int folderId) {
+
+ long years = (long)12 * 30 * 24 * 60 * 60 * 1000;
+ long month =(long) 24 * 60 * 60 * 1000 * 30;
+ long days = (long)24 * 60 * 60 * 1000;
+ long m=(long)60*1000;
+
+ long time = TimeUtils.getNowMills();
+
+
+ Note note2 = new Note();
+ note2.setCreatedTime(time-m-m-m-m);
+ note2.setModifiedTime(time-m-m-m-m);
+ note2.setNoteFolderId(folderId);
+ note2.setNoteContent(Utils.getContext().getResources().getString(R.string.database_content_three));
+ note2.setIsPrivacy(0);
+ note2.setInRecycleBin(0);
+ note2.setNoteId(UUID.randomUUID().toString());
+ note2.save();
+
+ Note note3 = new Note();
+ note3.setCreatedTime(time-m-m-m);
+ note3.setModifiedTime(time-m-m-m);
+ note3.setNoteFolderId(folderId);
+ note3.setNoteContent(Utils.getContext().getResources().getString(R.string.database_content_four));
+ note3.setIsPrivacy(0);
+ note3.setInRecycleBin(0);
+ note3.setNoteId(UUID.randomUUID().toString());
+ note3.save();
+
+ Note note4 = new Note();
+ note4.setCreatedTime(time-m-m);
+ note4.setModifiedTime(time -m-m);
+ note4.setNoteFolderId(folderId);
+ note4.setNoteContent(Utils.getContext().getResources().getString(R.string.database_content_five));
+ note4.setIsPrivacy(0);
+ note4.setInRecycleBin(0);
+ note4.setNoteId(UUID.randomUUID().toString());
+ note4.save();
+
+ Note note5 = new Note();
+ note5.setCreatedTime(time -m);
+ note5.setModifiedTime(time -m);
+ note5.setNoteContent(Utils.getContext().getResources().getString(R.string.database_content_one));
+ note5.setNoteFolderId(folderId);
+ note5.setIsPrivacy(0);
+ note5.setInRecycleBin(0);
+ note5.setNoteId(UUID.randomUUID().toString());
+ note5.save();
+
+ Note note1 = new Note();
+ note1.setCreatedTime(time );
+ note1.setModifiedTime(time );
+ note1.setNoteFolderId(folderId);
+ note1.setNoteContent(Utils.getContext().getResources().getString(R.string.database_content_two));
+ note1.setIsPrivacy(0);
+ note1.setInRecycleBin(0);
+ note1.setNoteId(UUID.randomUUID().toString());
+ note1.save();
+
+
+ }
+
+ @Override
+ public void loadAllNoteList(LoadDataCallBack callBack) {
+ List data = where("isPrivacy = ? and inRecycleBin = ?", "0", "0").order("createdTime desc").find(Note.class);
+ callBack.onSuccedd(data);
+ }
+
+ @Override
+ public void loadPrivacyNoteList(LoadDataCallBack callBack) {
+ List data = where("isPrivacy = ? and inRecycleBin = ?", "1", "0").order("createdTime desc").find(Note.class);
+ callBack.onSuccedd(data);
+ }
+
+ @Override
+ public void loadRecycleBinNoteList(LoadDataCallBack callBack) {
+ List data = DataSupport.where("inRecycleBin = ?", "1").order("createdTime desc").find(Note.class);
+ callBack.onSuccedd(data);
+ }
+
+ @Override
+ public void loadNormalNoteList(int folderId, LoadDataCallBack callBack) {
+ List data = where("noteFolderId = ? and isPrivacy = ? and inRecycleBin = ?", folderId + "", "0", "0").order("createdTime desc").find(Note.class);
+ callBack.onSuccedd(data);
+ }
+
+ @Override
+ public void addNote(Note note) {
+ note.save();
+ }
+
+ @Override
+ public void deleteNote(Note note) {
+ String noteId=note.getNoteId();
+ deleteNoteFile(noteId);
+ note.delete();
+ }
+
+ @Override
+ public void deleteNotes() {
+
+ }
+
+ private void deleteNoteFile(String noteId){
+ File file=Utils.getContext().getExternalFilesDir(noteId);
+ if(file.exists()){
+ FileUtils.deleteDir(file);
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/base/BaseActivity.java b/app/src/main/java/com/bigbig/ding/module/base/BaseActivity.java
new file mode 100644
index 0000000..a953463
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/base/BaseActivity.java
@@ -0,0 +1,152 @@
+package com.bigbig.ding.module.base;
+
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.Nullable;
+import android.support.design.widget.AppBarLayout;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.WindowManager;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.utils.ThemeUtils;
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/01
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public abstract class BaseActivity> extends AppCompatActivity {
+
+ public T mPresenter;
+
+ @BindView(R.id.toolbar)
+ public Toolbar mToolbar;
+
+ public Context mContext;
+
+ protected int theme;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setTheme();
+ mContext = this;
+ mPresenter = initPresenter();
+ initBeforeSetContentView();
+ setContentView(attachLayoutRes());
+ ButterKnife.bind(this);
+ setStatusBarBeforeApi19();
+ initToolbar();
+ initViews();
+ updateViews();
+ }
+
+ @Override
+ protected void onRestart() {
+ super.onRestart();
+ if (theme != Constans.theme)
+ recreate();
+ }
+
+ private void setTheme() {
+ theme = Constans.theme;
+ setTheme(theme);
+
+ }
+
+
+ private void setStatusBarBeforeApi19() {
+ if (Build.VERSION.SDK_INT < 21 && Build.VERSION.SDK_INT >= 19) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ AppBarLayout appBarLayout=(AppBarLayout)findViewById(R.id.app_bar);
+ // appBarLayout 用于有可折叠标题栏的界面
+ if (appBarLayout!=null) {
+ appBarLayout.setPadding(0, ThemeUtils.getStatusBarHeight(), 0, 0);
+ } else if (mToolbar != null) {
+ mToolbar.setPadding(0, ThemeUtils.getStatusBarHeight(), 0, 0);
+ }
+ }
+ }
+
+ /**
+ * 绑定布局文件
+ *
+ * @return 布局id
+ */
+ @LayoutRes
+ protected abstract int attachLayoutRes();
+
+ /**
+ * 初始化
+ *
+ * @describe
+ */
+ protected abstract T initPresenter();
+
+ /**
+ * 在setContentView之前调用,可不重写,需要时候再重写
+ *
+ * @describe
+ */
+ protected void initBeforeSetContentView() {
+ }
+
+ ;
+
+ /**
+ * 初始化视图控件
+ *
+ * @describe
+ */
+ protected abstract void initViews();
+
+ /**
+ * 更新视图控件
+ *
+ * @describe
+ */
+ protected abstract void updateViews();
+
+ @Override
+ protected void onDestroy() {
+ if (mPresenter != null) {
+ mPresenter.detach();
+ }
+ super.onDestroy();
+
+ }
+
+ /**
+ * 初始化Toolbar
+ *
+ * @describe
+ */
+ protected void initToolbar() {
+ if (mToolbar != null) {
+ setSupportActionBar(mToolbar);
+ }
+ }
+
+// /**
+// * 设置Toolbar title
+// *
+// * @describe
+// */
+// protected void setTitle(String title) {
+// if (mToolbar != null) {
+// mToolbar.setTitle(title);
+// }
+// }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/base/BaseFragment.java b/app/src/main/java/com/bigbig/ding/module/base/BaseFragment.java
new file mode 100644
index 0000000..786f668
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/base/BaseFragment.java
@@ -0,0 +1,96 @@
+package com.bigbig.ding.module.base;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import butterknife.ButterKnife;
+
+/**
+ * Created by long on 2016/5/31.
+ * 碎片基类
+ */
+public abstract class BaseFragment> extends Fragment {
+
+
+ protected T mPresenter;
+
+ protected Context mContext;
+ //缓存Fragment view
+ private View mRootView;
+ private boolean mIsMulti = false;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mContext = getActivity();
+ mPresenter = initPresenter();
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ if (mRootView == null) {
+ mRootView = inflater.inflate(attachLayoutRes(), container,false);
+ ButterKnife.bind(this, mRootView);
+ initViews();
+ }
+ ViewGroup parent = (ViewGroup) mRootView.getParent();
+ if (parent != null) {
+ parent.removeView(mRootView);
+ }
+ return mRootView;
+ }
+
+ @Override
+ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ if (getUserVisibleHint() && mRootView != null && !mIsMulti) {
+ mIsMulti = true;
+ updateViews(false);
+ }
+ }
+
+ /**
+ * 绑定布局文件
+ *
+ * @return 布局id
+ */
+ @LayoutRes
+ protected abstract int attachLayoutRes();
+
+ /**
+ * 初始化
+ *
+ * @describe
+ */
+ protected abstract T initPresenter();
+
+ /**
+ * 初始化视图控件
+ *
+ * @describe
+ */
+ protected abstract void initViews();
+
+ /**
+ * 更新视图控件
+ *
+ * @describe
+ */
+ protected abstract void updateViews(boolean isRefresh);
+
+
+
+
+
+
+
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/base/BasePresenter.java b/app/src/main/java/com/bigbig/ding/module/base/BasePresenter.java
new file mode 100644
index 0000000..a7ad5ac
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/base/BasePresenter.java
@@ -0,0 +1,37 @@
+package com.bigbig.ding.module.base;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/01
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public abstract class BasePresenter {
+
+ public T mView;
+
+ /**
+ * 绑定View 初始化时调用
+ *
+ * @param mView
+ * @describe
+ */
+ public void attch(T mView) {
+ this.mView = mView;
+ }
+
+ /**
+ * 分离view,View销毁时调用
+ *
+ * @describe
+ */
+ public void detach() {
+ mView = null;
+ }
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationPresenter.java b/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationPresenter.java
new file mode 100644
index 0000000..d55abaf
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationPresenter.java
@@ -0,0 +1,15 @@
+package com.bigbig.ding.module.lock.modification;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ILockModificationPresenter {
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationView.java b/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationView.java
new file mode 100644
index 0000000..815829f
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/modification/ILockModificationView.java
@@ -0,0 +1,15 @@
+package com.bigbig.ding.module.lock.modification;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ILockModificationView {
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationActivity.java b/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationActivity.java
new file mode 100644
index 0000000..7d57dc0
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationActivity.java
@@ -0,0 +1,180 @@
+package com.bigbig.ding.module.lock.modification;
+
+import android.content.Intent;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.Utils;
+
+import java.util.List;
+
+import com.bigbig.ding.constants.CacheManager;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.utils.MD5Util;
+import com.bigbig.ding.widget.LockView;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LockModificationActivity extends BaseActivity
+ implements ILockModificationView, LockView.OnDrawFinishedListener, View.OnClickListener {
+
+ @BindView(R.id.lockview_lock)
+ LockView mLickView;
+
+ @BindView(R.id.tv_lock_tip)
+ TextView mTvTip;
+
+ @BindView(R.id.ll_lock)
+ LinearLayout mLlRoot;
+
+ @BindView(R.id.btn_lock_ok)
+ Button mBtnOk;
+
+ @BindView(R.id.btn_lock_redraw)
+ Button mBtnReDraw;
+
+ private String mTitle, mPassword, mLastPassword;
+ private int mDrawTimes = 0; // 绘制次数
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_lock;
+ }
+
+ @Override
+ protected LockModificationPresenter initPresenter() {
+ mPresenter = new LockModificationPresenter();
+ mPresenter.attch(this);
+ return mPresenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ initData();
+ setTitle(mTitle);
+ mTvTip.setText("请设置隐私密码,至少连接四个点");
+ mLlRoot.setVisibility(View.GONE);
+
+ mLickView.setOnDrawFinishedListener(this);
+ mBtnOk.setOnClickListener(this);
+ mBtnReDraw.setOnClickListener(this);
+ }
+
+ private void initData() {
+ if (getIntent().getStringExtra("title") != null) {
+ mTitle = getIntent().getStringExtra("title");
+ } else {
+ mTitle = "设置密码";
+ }
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onDrawFinished(List passPositions) {
+ if (mDrawTimes == 0)
+ return firstDrawPass(passPositions);
+ else
+ return secondDrawPass(passPositions);
+ }
+
+ private boolean firstDrawPass(List passPositions) {
+ if (passPositions.size() < 4) {
+ mTvTip.setText("至少连接四个点,请重试");
+ return false;
+ } else {
+ mLastPassword = getStringForList(passPositions);
+ mTvTip.setText("已记录图案");
+ android.os.Handler handler = new android.os.Handler();
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ mLickView.resetPoints();
+ mDrawTimes++;
+ mTvTip.setText("再次绘制图案进行确认");
+ mLlRoot.setVisibility(View.VISIBLE);
+ mBtnOk.setClickable(false);
+ mBtnOk.setTextColor(Utils.getContext().getResources().getColor(R.color.colorBlackAlpha26));
+ }
+ }, 1 * 1000);
+ return true;
+ }
+ }
+
+ private boolean secondDrawPass(List passPositions) {
+ if (mLastPassword.equals(getStringForList(passPositions))) {
+ mTvTip.setText("请确认您的密码图案");
+ mBtnOk.setClickable(true);
+ mBtnOk.setTextColor(Utils.getContext().getResources().getColor(R.color.colorBlackAlpha87));
+ mLickView.setClickable(false);
+ mPassword = MD5Util.getMd5Value(mLastPassword);
+ return true;
+ } else {
+ mTvTip.setText("两次密码不一样,请重试");
+ mBtnOk.setClickable(false);
+ return false;
+ }
+ }
+
+ private String getStringForList(List passPositions) {
+ StringBuilder sb = new StringBuilder();
+ for (Integer i : passPositions) {
+ sb.append(i.intValue());
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.btn_lock_ok:
+ savePasswordAndResult();
+ break;
+ case R.id.btn_lock_redraw:
+ reDrawLock();
+ break;
+ }
+ }
+
+ private void savePasswordAndResult() {
+ CacheManager.setAndSaveIsLocked(true);
+ CacheManager.setAndSaveLockPassword(mPassword);
+ setResult(RESULT_OK, new Intent());
+ finish();
+ }
+
+ private void reDrawLock() {
+ mDrawTimes = 0;
+ mLlRoot.setVisibility(View.GONE);
+ mTvTip.setText("请设置隐私密码,至少连接四个点");
+ mLickView.setClickable(true);
+ mLickView.resetPoints();
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationPresenter.java b/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationPresenter.java
new file mode 100644
index 0000000..b9c48b6
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/modification/LockModificationPresenter.java
@@ -0,0 +1,18 @@
+package com.bigbig.ding.module.lock.modification;
+
+import com.bigbig.ding.module.base.BasePresenter;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LockModificationPresenter extends BasePresenter implements ILockModificationPresenter {
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockPresenter.java b/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockPresenter.java
new file mode 100644
index 0000000..89221ff
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockPresenter.java
@@ -0,0 +1,17 @@
+package com.bigbig.ding.module.lock.verification;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ILockPresenter {
+ boolean verifyPassword(List passPositions,String password);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockView.java b/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockView.java
new file mode 100644
index 0000000..aff84cd
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/verification/ILockView.java
@@ -0,0 +1,26 @@
+package com.bigbig.ding.module.lock.verification;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ILockView {
+
+ /**
+ * 错误
+ * @describe
+ */
+ void onError();
+
+ /**
+ * 正确
+ * @describe
+ */
+ void onSuccess();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/verification/LockActivity.java b/app/src/main/java/com/bigbig/ding/module/lock/verification/LockActivity.java
new file mode 100644
index 0000000..190a3f3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/verification/LockActivity.java
@@ -0,0 +1,160 @@
+package com.bigbig.ding.module.lock.verification;
+
+import android.animation.ObjectAnimator;
+import android.content.Intent;
+import android.os.Build;
+import android.transition.Transition;
+import android.transition.TransitionInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+
+import java.util.List;
+
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.module.setting.lock.LockSettingActivity;
+import com.bigbig.ding.widget.LockView;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LockActivity extends BaseActivity implements ILockView, LockView.OnDrawFinishedListener {
+
+ @BindView(R.id.lockview_lock)
+ LockView mLickView;
+
+ @BindView(R.id.tv_lock_tip)
+ TextView mTvTip;
+
+ @BindView(R.id.ll_lock)
+ LinearLayout mLlRoot;
+
+ @BindView(R.id.btn_lock_ok)
+ Button mBtnOk;
+
+ @BindView(R.id.btn_lock_redraw)
+ Button mBtnReDraw;
+
+ private String mTitle;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_lock;
+ }
+
+ @Override
+ protected LockPresenter initPresenter() {
+ mPresenter = new LockPresenter();
+ mPresenter.attch(this);
+
+ return mPresenter;
+ }
+
+ @Override
+ protected void initBeforeSetContentView() {
+ initPushInAnim();
+ }
+
+ private void initPushInAnim() {
+
+ Window window = getWindow();
+ window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
+
+ TransitionInflater inflater = TransitionInflater.from(mContext);
+ Transition pushDownIn = inflater.inflateTransition(R.transition.explode_in);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ window.setEnterTransition(pushDownIn); // 第一次进入时使用
+ window.setReenterTransition(pushDownIn); // 再次进入时使用
+ window.setExitTransition(pushDownIn);
+ }
+
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ initData();
+ setTitle(mTitle);
+ mTvTip.setText("请输入隐私密码");
+ mLlRoot.setVisibility(View.GONE);
+
+ mLickView.setOnDrawFinishedListener(this);
+ }
+
+ private void initData() {
+ if (getIntent().getStringExtra("title") != null) {
+ mTitle = getIntent().getStringExtra("title");
+ } else {
+ mTitle = "验证密码";
+ }
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public void onError() {
+ mTvTip.setText("请重试");
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mTvTip, "translationX", -SizeUtils.dp2px(8), SizeUtils.dp2px(8), 0);
+ animator.setDuration(200);
+ animator.start();
+ }
+
+ @Override
+ public void onSuccess() {
+ setResult(RESULT_OK, new Intent());
+ onBackPressed();
+ }
+
+ @Override
+ public boolean onDrawFinished(List passPositions) {
+ return mPresenter.verifyPassword(passPositions, Constans.lockPassword);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.menu_lock, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ switch (id) {
+ case R.id.menu_edit_lock:
+ toLockSetting();
+ break;
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+
+ private void toLockSetting() {
+ Intent intent = new Intent(mContext, LockSettingActivity.class);
+ startActivity(intent);
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/lock/verification/LockPresenter.java b/app/src/main/java/com/bigbig/ding/module/lock/verification/LockPresenter.java
new file mode 100644
index 0000000..e0004dc
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/lock/verification/LockPresenter.java
@@ -0,0 +1,35 @@
+package com.bigbig.ding.module.lock.verification;
+
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.utils.MD5Util;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/22
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LockPresenter extends BasePresenter implements ILockPresenter{
+
+ @Override
+ public boolean verifyPassword(List passPositions, String password) {
+ StringBuilder sb=new StringBuilder();
+ for (Integer i:passPositions){
+ sb.append(i.intValue());
+ }
+ String currentPassword= MD5Util.getMd5Value(sb.toString());
+ if(currentPassword.equals(password)){
+ mView.onSuccess();
+ return true;
+ } else{
+ mView.onError();
+ return false;
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/Image/IImagePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/Image/IImagePresenter.java
new file mode 100644
index 0000000..90e2ac5
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/Image/IImagePresenter.java
@@ -0,0 +1,29 @@
+package com.bigbig.ding.module.notes.Image;
+
+import android.app.Activity;
+import android.support.annotation.NonNull;
+
+import java.io.File;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/10
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IImagePresenter {
+
+ void getIntentData(Activity activity);
+
+ File getImageFile(Activity activity);
+
+ void saveImage(Activity activity);
+
+ void deleteImage(Activity activity);
+
+ void onRequestPermissionResult(Activity activity,int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/Image/IImageView.java b/app/src/main/java/com/bigbig/ding/module/notes/Image/IImageView.java
new file mode 100644
index 0000000..abddbcb
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/Image/IImageView.java
@@ -0,0 +1,23 @@
+package com.bigbig.ding.module.notes.Image;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/10
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IImageView {
+
+ void showLoading(String message);
+
+ void unShowLoading();
+
+ void showToAppSettingDialog();
+
+ void setResultAndFinish();
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/Image/ImageInfoActivity.java b/app/src/main/java/com/bigbig/ding/module/notes/Image/ImageInfoActivity.java
new file mode 100644
index 0000000..8c287a2
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/Image/ImageInfoActivity.java
@@ -0,0 +1,190 @@
+package com.bigbig.ding.module.notes.Image;
+
+import android.animation.ObjectAnimator;
+import android.content.DialogInterface;
+import android.support.annotation.NonNull;
+import android.support.design.widget.AppBarLayout;
+import android.support.v7.app.AlertDialog;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+import com.bumptech.glide.Glide;
+import com.github.chrisbanes.photoview.PhotoView;
+
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.utils.PermissionUtils;
+import com.bigbig.ding.utils.ProgressDialogUtils;
+import butterknife.BindView;
+
+/**
+ * Created by admin on 2017/3/3 0003.
+ */
+
+public class ImageInfoActivity extends BaseActivity implements IImageView, View.OnClickListener {
+
+ @BindView(R.id.iv_image)
+ PhotoView mIv;
+
+ @BindView(R.id.tv_image_down)
+ TextView mBtnSave;
+
+ @BindView(R.id.tv_image_del)
+ TextView mBtnDel;
+
+ @BindView(R.id.ll_image_bottom_bar)
+ LinearLayout mLlBottomBar;
+
+ @BindView(R.id.appBarLayout)
+ AppBarLayout mAppBarLayout;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_image;
+ }
+
+ @Override
+ protected ImagePresenter initPresenter() {
+ ImagePresenter imagePresenter = new ImagePresenter();
+ imagePresenter.attch(this);
+ return imagePresenter;
+ }
+
+ @Override
+ protected void initViews() {
+
+ mPresenter.getIntentData(this);
+
+ getSupportActionBar().setTitle("图片");
+ mToolbar.setNavigationIcon(R.drawable.ic_clear_white_24dp);
+ mBtnSave.setOnClickListener(this);
+ mBtnDel.setOnClickListener(this);
+
+ Glide.with(mContext)
+ .load(mPresenter.getImageFile(this))
+ .into(mIv);
+
+ mIv.setOnClickListener(this);
+
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.tv_image_down:
+ mPresenter.saveImage(this);
+ break;
+ case R.id.tv_image_del:
+ showDeleteDialog();
+ break;
+ case R.id.iv_image:
+ hideOrShowToolbarAndBottomBar();
+ break;
+ }
+ }
+
+ private void showDeleteDialog() {
+ new AlertDialog.Builder(mContext)
+ .setTitle("删除图片")
+ .setMessage("确定删除该图片吗?")
+ .setNegativeButton("取消", null)
+ .setPositiveButton("删除", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mPresenter.deleteImage(ImageInfoActivity.this);
+ }
+ })
+ .show();
+ }
+
+ private boolean mIsToolbarAndBottomBarHided = false;
+
+ private void hideOrShowToolbarAndBottomBar() {
+ if (mIsToolbarAndBottomBarHided) {
+ showToolbarAndBottomBar();
+ } else {
+ hideToolbarAndBottomBar();
+ }
+ }
+
+ private void showToolbarAndBottomBar() {
+ mIsToolbarAndBottomBarHided = false;
+
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mAppBarLayout, "translationY", -SizeUtils.dp2px(56), 0);
+ animator.setDuration(300);
+ animator.start();
+
+ ObjectAnimator animator1 = ObjectAnimator.ofFloat(mLlBottomBar, "translationY", SizeUtils.dp2px(56), 0);
+ animator1.setDuration(300);
+ animator1.start();
+ }
+
+ private void hideToolbarAndBottomBar() {
+ mIsToolbarAndBottomBarHided = true;
+
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mAppBarLayout, "translationY", 0, -SizeUtils.dp2px(56));
+ animator.setDuration(300);
+ animator.start();
+
+ ObjectAnimator animator1 = ObjectAnimator.ofFloat(mLlBottomBar, "translationY", 0, SizeUtils.dp2px(56));
+ animator1.setDuration(300);
+ animator1.start();
+ }
+
+ private ProgressDialogUtils mProgressDialog = new ProgressDialogUtils(this);
+
+ @Override
+ public void showLoading(String message) {
+ mProgressDialog.show(message);
+ }
+
+ @Override
+ public void unShowLoading() {
+ mProgressDialog.hide();
+ }
+
+ @Override
+ public void showToAppSettingDialog() {
+ new AlertDialog.Builder(mContext)
+ .setTitle("权限设置")
+ .setMessage("您已禁止应用的储存权限,请前往应用设置中开启")
+ .setPositiveButton("前往",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PermissionUtils.toAppSetting(mContext);
+ }
+ })
+ .setNegativeButton("取消", null)
+ .show();
+ }
+
+ @Override
+ public void setResultAndFinish() {
+ setResult(RESULT_OK);
+ onBackPressed();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/Image/ImagePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/Image/ImagePresenter.java
new file mode 100644
index 0000000..be9e375
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/Image/ImagePresenter.java
@@ -0,0 +1,188 @@
+package com.bigbig.ding.module.notes.Image;
+
+import android.Manifest;
+import android.app.Activity;
+import android.os.AsyncTask;
+import android.support.annotation.NonNull;
+
+import com.blankj.utilcode.util.FileUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.utils.PermissionUtils;
+
+import java.io.File;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/10
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class ImagePresenter extends BasePresenter implements IImagePresenter{
+
+ private final String PERMISSION_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
+
+ private final int REQUEST_PERMISSION_CODE_SAVE=1;
+ private final int REQUEST_PERMISSION_CODE_DEL=2;
+
+ private String mImageName;
+ private String mNoteId;
+
+ @Override
+ public void getIntentData(Activity activity) {
+ mImageName=activity.getIntent().getStringExtra("image_name");
+ mNoteId=activity.getIntent().getStringExtra("note_id");
+ }
+
+ @Override
+ public File getImageFile(Activity activity) {
+ String path=activity.getExternalFilesDir(mNoteId).getPath()+"/"+mImageName;
+ return new File(path);
+ }
+
+ @Override
+ public void saveImage(final Activity activity) {
+ PermissionUtils.checkPermission(activity, PERMISSION_STORAGE, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ copyFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ copyFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ PermissionUtils.requestPermission(activity,PERMISSION_STORAGE,REQUEST_PERMISSION_CODE_SAVE);
+ }
+ });
+ }
+
+ private void copyFile( final Activity activity){
+ new AsyncTask(){
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("保存中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ return FileUtils.copyFile(getImageFile(activity),
+ new File(Constans.imageSaveFolder+mImageName));
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ if(aBoolean){
+ ToastUtils.showLong("已保存至/SuperNote/image/中");
+ } else {
+ ToastUtils.showLong("保存失败,请查看图片是否已存在");
+ }
+ }
+ }.execute();
+ }
+
+ @Override
+ public void deleteImage(final Activity activity) {
+ PermissionUtils.checkPermission(activity, PERMISSION_STORAGE, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ deleteFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ deleteFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ PermissionUtils.requestPermission(activity,PERMISSION_STORAGE,REQUEST_PERMISSION_CODE_DEL);
+ }
+ });
+ }
+
+ @Override
+ public void onRequestPermissionResult(Activity activity,int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ switch (requestCode){
+ case REQUEST_PERMISSION_CODE_SAVE:
+ requestResultForSave(activity,grantResults);
+ break;
+ case REQUEST_PERMISSION_CODE_DEL:
+ requestResultForDel(activity,grantResults);
+ break;
+ }
+ }
+
+ private void requestResultForSave(final Activity activity, @NonNull int[] grantResults){
+ PermissionUtils.onRequestPermissionResult(activity, PERMISSION_STORAGE, grantResults, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ copyFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ ToastUtils.showShort("保存失败");
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ mView.showToAppSettingDialog();
+ }
+ });
+ }
+
+ private void requestResultForDel(final Activity activity, @NonNull int[] grantResults){
+ PermissionUtils.onRequestPermissionResult(activity, PERMISSION_STORAGE, grantResults, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ deleteFile(activity);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ ToastUtils.showShort("删除失败");
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ mView.showToAppSettingDialog();
+ }
+ });
+ }
+
+ private void deleteFile(final Activity activity){
+ new AsyncTask(){
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("删除中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ return FileUtils.deleteFile(getImageFile(activity));
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ if(aBoolean){
+ mView.setResultAndFinish();
+ } else {
+ ToastUtils.showShort("删除失败");
+ }
+ }
+ }.execute();
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNoteActivity.java b/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNoteActivity.java
new file mode 100644
index 0000000..0baf04e
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNoteActivity.java
@@ -0,0 +1,309 @@
+package com.bigbig.ding.module.notes.edit;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AlertDialog;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+
+import com.bigbig.ding.R;
+import com.orhanobut.logger.Logger;
+
+import com.bigbig.ding.bean.ImageEntity;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.utils.PermissionUtils;
+import com.bigbig.ding.utils.ProgressDialogUtils;
+import com.bigbig.ding.widget.MyEditText;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/30
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class EditNoteActivity extends BaseActivity implements IEditNoteView, View.OnClickListener {
+
+
+ @BindView(R.id.scroll_edit_note)
+ ScrollView mScrollView;
+
+ @BindView(R.id.et_edit_note_content)
+ MyEditText mEdContent;
+
+ @BindView(R.id.ll_edit_note_to_camera)
+ LinearLayout mLlToCamera;
+
+ @BindView(R.id.ll_edit_note_to_photo)
+ LinearLayout mLlToPhoto;
+
+ private ProgressDialogUtils mProgressDialogUtils = new ProgressDialogUtils(this);
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_edit_note;
+ }
+
+ @Override
+ protected EditNotePresenter initPresenter() {
+ EditNotePresenter presenter = new EditNotePresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ mEdContent.setMinHeight(mPresenter.getNoteEditNeedHeight());
+ mPresenter.initData();
+ mLlToCamera.setOnClickListener(this);
+ mLlToPhoto.setOnClickListener(this);
+ mEdContent.setOnClickListener(this);
+ }
+
+ private TextWatcher mTextWatcher = new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+// Logger.d("image:"+mEdContent.mImageList.get(0).getStart()+" "+mEdContent.mImageList.get(0).getEnd());
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ Logger.d("text change:" + s + " " + start + " " + count + " " + before);
+ for (int i = 0; i < mEdContent.mImageList.size(); i++) {
+ ImageEntity imageEntity = mEdContent.mImageList.get(i);
+ if (start == imageEntity.getEnd()) {
+ mEdContent.getEditableText().replace(imageEntity.getStart(), imageEntity.getEnd(), "");
+ mEdContent.mImageList.remove(i);
+ mEdContent.mDeleteImageList.add(imageEntity);
+ break;
+ }
+ }
+ mEdContent.setTextCountChange(start, before, count);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+
+ }
+ };
+
+
+ @Override
+ protected void updateViews() {
+ mPresenter.parseNoteContent();
+ mEdContent.setSelection(mEdContent.getText().length());
+ mEdContent.addTextChangedListener(mTextWatcher);
+ }
+
+ @Override
+ public Intent getActivityIntent() {
+ return getIntent();
+ }
+
+ @Override
+ public Activity getActivity() {
+ return this;
+ }
+
+ @Override
+ public void setTitle(String title) {
+ getSupportActionBar().setTitle(""); // 主标题为空
+ getSupportActionBar().setSubtitle(title); // 副标题
+ }
+
+ @Override
+ public void showNoteContent(String content) {
+ mEdContent.setText(content);
+ }
+
+ @Override
+ public void replaceImage(String imageName, Bitmap bitmap) {
+ mEdContent.replaceDrawable(bitmap, imageName);
+ }
+
+ @Override
+ public void insertImage(String imageName, Bitmap bitmap) {
+ mEdContent.insertDrawable(bitmap, imageName);
+ }
+
+ @Override
+ public void deleteImage(ImageEntity imageEntity) {
+ mEdContent.getEditableText().replace(imageEntity.getStart(), imageEntity.getEnd()+1, "");
+ }
+
+ @Override
+ public void setResultAndFinish(Intent intent) {
+ setResult(RESULT_OK, intent);
+ }
+
+ @Override
+ public void showLoading(String message) {
+ mProgressDialogUtils.show(message);
+ }
+
+ @Override
+ public void unShowLoading() {
+ mProgressDialogUtils.hide();
+ }
+
+ @Override
+ public void showToAppSettingDialog() {
+ new AlertDialog.Builder(mContext)
+ .setTitle("权限设置")
+ .setMessage("您已禁止应用的储存权限,请前往应用设置中开启")
+ .setPositiveButton("前往",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PermissionUtils.toAppSetting(mContext);
+ }
+ })
+ .setNegativeButton("取消", null)
+ .show();
+ }
+
+ @Override
+ public void showStatisticsDialog(int imageCount, int textCount) {
+ new AlertDialog.Builder(mContext)
+ .setMessage("文字数量:" + textCount + "\n" + "图片数量:" + imageCount)
+ .setPositiveButton("确定", null)
+ .show();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.ll_edit_note_to_camera:
+ mPresenter.checkPermissionAndToCamera(mContext);
+ break;
+ case R.id.ll_edit_note_to_photo:
+ mPresenter.checkPermissionAndToPhoto(mContext);
+ break;
+ case R.id.et_edit_note_content:
+ mPresenter.clickNoteEditText(mEdContent);
+ break;
+
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ mPresenter.onActivityResult(requestCode, resultCode, data);
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ mPresenter.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_note, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ case R.id.menu_note_statistics:
+ mPresenter.calculateContentAndImageCount(mEdContent);
+ break;
+ case R.id.menu_note_share:
+ showShareDialg();
+ break;
+ }
+ return true;
+ }
+
+ /**
+ * 显示分享Dialog
+ */
+ private void showShareDialg() {
+
+ if(mEdContent.getText().length()==0){
+ return;
+ }
+
+ setEditTextBeforeGetBitmap();
+ String items[];
+
+ // 没有图片时 添加:以文字形式分享的方法
+ if(mEdContent.mImageList.size()==0){
+ items=new String[]{"以图片形式分享","以文字形式分享"};
+ } else{
+ items=new String[]{"以图片形式分享"};
+ }
+
+ final AlertDialog.Builder builder=new AlertDialog.Builder(mContext);
+ builder.setTitle("分享")
+ .setItems(items, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which) {
+ case 0:
+ mPresenter.shareNoteWithImage(mEdContent);
+ break;
+ case 1:
+ shareText(mEdContent.getText().toString());
+ setEditTextAfterGetBitmap();
+ break;
+ }
+ }
+ })
+ .setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ setEditTextAfterGetBitmap();
+ }
+ })
+ .show();
+ }
+
+ public void shareText(String content){
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND);
+ intent.putExtra(Intent.EXTRA_TEXT, content);
+ intent.setType("text/plain");
+ intent = Intent.createChooser(intent, "分享");
+ startActivity(intent);
+ }
+
+ @Override
+ public void setEditTextBeforeGetBitmap(){
+ mPresenter.closeKeyboard(mEdContent);
+ mEdContent.setMinHeight(0);
+ mEdContent.setEnabled(false);
+ }
+
+ @Override
+ public void setEditTextAfterGetBitmap(){
+ mEdContent.setMinHeight(mPresenter.getNoteEditNeedHeight());
+ mEdContent.setEnabled(true);
+ }
+
+
+
+ @Override
+ public void onBackPressed() {
+ mPresenter.saveNote(mEdContent.getText().toString());
+ super.onBackPressed();
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNotePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNotePresenter.java
new file mode 100644
index 0000000..ec3de0c
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/edit/EditNotePresenter.java
@@ -0,0 +1,572 @@
+package com.bigbig.ding.module.notes.edit;
+
+import android.Manifest;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.ContentUris;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.provider.DocumentsContract;
+import android.provider.MediaStore;
+import android.support.annotation.NonNull;
+import android.support.v4.content.FileProvider;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.FileUtils;
+import com.blankj.utilcode.util.ImageUtils;
+import com.blankj.utilcode.util.ScreenUtils;
+import com.blankj.utilcode.util.SizeUtils;
+import com.blankj.utilcode.util.TimeUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.blankj.utilcode.util.Utils;
+import com.bumptech.glide.Glide;
+import com.bumptech.glide.Priority;
+import com.bumptech.glide.request.animation.GlideAnimation;
+import com.bumptech.glide.request.target.SimpleTarget;
+import com.orhanobut.logger.Logger;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.bigbig.ding.bean.ImageEntity;
+import com.bigbig.ding.constants.EditNoteConstans;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.module.notes.Image.ImageInfoActivity;
+import com.bigbig.ding.module.notes.share.ShareActivity;
+import com.bigbig.ding.utils.PermissionUtils;
+import com.bigbig.ding.utils.ThemeUtils;
+import com.bigbig.ding.widget.MyEditText;
+
+import static android.app.Activity.RESULT_OK;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/30
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class EditNotePresenter extends BasePresenter implements IEditNotePresenter {
+
+ public static final int REQUEST_CODE_TO_CAMERA = 1; //前往相机
+ public static final int REQUEST_CODE_TO_PHOTO = 2; //前往图库
+ public static final int REQUEST_CODE_TO_IMAGE_INFO = 3;
+
+ private final String PERMISSION_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
+
+ private final int REQUEST_PERMISSION_TO_CAMERA = 1; // 请求权限前往相机
+ private final int REQUEST_PERMISSION_TO_PHOTO = 2; // 请求权限前往图库
+
+ private boolean mIsAdd; // 是否是新增便签
+
+ private String mNoteId;
+ private long mModifiedTime;
+ private String mNoteContent;
+
+ private int mPosition = 0;
+
+ private String mImageName = new String();
+
+ private File mImageFolder;
+ private File mImageFile;
+
+ private ImageEntity mSelectedImageEntity;
+
+ @Override
+ public void initData() {
+ Intent intent = mView.getActivityIntent();
+ mIsAdd = intent.getBooleanExtra("is_add", false);
+ if (mIsAdd) {
+ mNoteId = UUID.randomUUID().toString();
+ mModifiedTime = TimeUtils.getNowMills();
+ mNoteContent = new String("");
+ } else {
+ mPosition = intent.getIntExtra("position", 0);
+ mNoteId = intent.getStringExtra("note_id");
+ mModifiedTime = intent.getLongExtra("modified_time", 0);
+ mNoteContent = intent.getStringExtra("note_content");
+ }
+ mView.setTitle(TimeUtils.millis2String(mModifiedTime));
+ }
+
+ @Override
+ public void setTextForNoteContent() {
+ mView.showNoteContent(mNoteContent);
+ }
+
+ @Override
+ public void parseNoteContent() {
+ if (mIsAdd)
+ return;
+ mView.showNoteContent(mNoteContent);
+ String flag = EditNoteConstans.imageTabBefore + "([^<]*)" + EditNoteConstans.imageTabAfter;
+
+ // 利用正则找出文档中的图片
+ Pattern p = Pattern.compile(flag);
+ Matcher m = p.matcher(mNoteContent);
+ List array = new ArrayList();
+ while (m.find()) {
+// 匹配到的数据中,第一个括号的中的内容(这里只有一个括号)
+ String temp = m.group(1);
+ array.add(temp);
+ }
+ for (int i = 0; i < array.size(); i++) {
+ final String imageName = array.get(i);
+ replaceImage(imageName);
+ }
+ }
+
+ private void replaceImage(final String imageName) {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true;
+
+ File imageFile = new File(mView.getActivity().getExternalFilesDir(mNoteId).getPath() + "/" + imageName);
+
+ BitmapFactory.decodeFile(imageFile.getPath(), options);
+
+ int imageRequestWidth = getRequestImeWidth();
+ int imageRequestHeight = setNeedHeight(options);
+
+
+ Glide.with(mView.getActivity())
+ .load(imageFile)
+ .asBitmap()
+ .override(imageRequestWidth, imageRequestHeight)
+ .fitCenter()
+ .priority(Priority.HIGH)
+ .into(new SimpleTarget() {
+ @Override
+ public void onResourceReady(Bitmap resource, GlideAnimation super Bitmap> glideAnimation) {
+ mView.replaceImage(imageName, resource);
+ }
+ });
+ }
+
+
+ private int setNeedHeight(BitmapFactory.Options options) {
+ int imageRequestHeight = getRequestImeHeight(options);
+ if (imageRequestHeight <= 0) {
+ return getNoteEditNeedHeight();
+ } else
+ return imageRequestHeight;
+ }
+
+ @Override
+ public void checkPermissionAndToCamera(final Context context) {
+ PermissionUtils.checkPermission(context, PERMISSION_STORAGE, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ toCamera((Activity) context);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ PermissionUtils.requestPermission(context, permission[0], REQUEST_PERMISSION_TO_CAMERA);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ PermissionUtils.requestPermission(context, permission[0], REQUEST_PERMISSION_TO_CAMERA);
+ }
+ });
+ }
+
+ @Override
+ public void checkPermissionAndToPhoto(final Context context) {
+ PermissionUtils.checkPermission(context, PERMISSION_STORAGE, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ toPhoto((Activity) context);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ PermissionUtils.requestPermission(context, permission[0], REQUEST_PERMISSION_TO_PHOTO);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ PermissionUtils.requestPermission(context, permission[0], REQUEST_PERMISSION_TO_PHOTO);
+ }
+ });
+ }
+
+ @Override
+ public void toCamera(Activity activity) {
+ try {
+ setFile(activity);
+ createImageFile();
+ Uri imageUri;
+ if (Build.VERSION.SDK_INT >= 24) {
+ imageUri = FileProvider.getUriForFile(activity, mView.getActivity().getPackageName()+".provider", mImageFile);
+ } else {
+ imageUri = Uri.fromFile(mImageFile);
+ }
+
+ Intent getImageByCamera = new Intent("android.media.action.IMAGE_CAPTURE");
+ getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
+ activity.startActivityForResult(getImageByCamera, REQUEST_CODE_TO_CAMERA);
+ } catch (Exception e) {
+ ToastUtils.showShort("打开相机失败");
+ }
+ }
+
+ private void setFile(Activity activity) throws IOException {
+ mImageName = TimeUtils.getNowString() + ".jpg";
+ mImageFolder = activity.getExternalFilesDir(mNoteId);
+ mImageFile = new File(mImageFolder, mImageName);
+
+ checkImageFolder();
+ }
+
+ private void checkImageFolder() throws IOException {
+ if (!mImageFolder.exists()) {
+ mImageFolder.createNewFile();
+ }
+ }
+
+ private void createImageFile() throws IOException {
+ mImageFile.createNewFile();
+ }
+
+ @Override
+ public void toPhoto(Activity activity) {
+ try {
+ setFile(activity);
+ Intent getImage = new Intent(Intent.ACTION_GET_CONTENT);
+ getImage.addCategory(Intent.CATEGORY_OPENABLE);
+ getImage.setType("image/*");
+ activity.startActivityForResult(getImage, REQUEST_CODE_TO_PHOTO);
+ } catch (IOException e) {
+ ToastUtils.showShort("打开图库失败");
+ }
+ }
+
+ private int getRequestImeWidth() {
+ return (int) (ScreenUtils.getScreenWidth() - EditNoteConstans.imageMargin);
+ }
+
+ @Override
+ public int getRequestImeHeight(BitmapFactory.Options option) {
+ float width = option.outWidth;
+ float height = option.outHeight;
+// 屏幕宽
+ float screenWidth = ScreenUtils.getScreenWidth();
+ //计算宽、高缩放率
+ float scanleWidth = (getRequestImeWidth()) / width;
+ return (int) (height * scanleWidth);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+ switch (requestCode) {
+ case REQUEST_CODE_TO_PHOTO:
+ if (resultCode == RESULT_OK) {
+ toPhotoResult(intent);
+ }
+ break;
+ case REQUEST_CODE_TO_CAMERA:
+ if (resultCode == RESULT_OK)
+ displayImage();
+ break;
+ case REQUEST_CODE_TO_IMAGE_INFO:
+ Logger.d("REQUEST_CODE_TO_IMAGE_INFO" + resultCode);
+ if (resultCode == RESULT_OK) {
+ mView.deleteImage(mSelectedImageEntity);
+ }
+ break;
+ }
+ }
+
+ private void toPhotoResult(Intent intent) {
+ if (Build.VERSION.SDK_INT >= 19) {
+ handleImageOnKitKat(intent);
+ } else {
+ handleImageBeforeKitKat(intent);
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ switch (requestCode) {
+ case REQUEST_PERMISSION_TO_CAMERA:
+ onRequestCameraResult(grantResults);
+ break;
+ case REQUEST_PERMISSION_TO_PHOTO:
+ onRequestPhotoResult(grantResults);
+ break;
+ }
+ }
+
+ private void onRequestCameraResult(int[] grantResults) {
+ PermissionUtils.onRequestPermissionResult(mView.getActivity(), PERMISSION_STORAGE, grantResults, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ toCamera(mView.getActivity());
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ ToastUtils.showShort("请允许读取储存权限");
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ mView.showToAppSettingDialog();
+ }
+ });
+ }
+
+ private void onRequestPhotoResult(int[] grantResults) {
+ PermissionUtils.onRequestPermissionResult(mView.getActivity(), PERMISSION_STORAGE, grantResults, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ toPhoto(mView.getActivity());
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ ToastUtils.showShort("请允许读取储存权限");
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ mView.showToAppSettingDialog();
+ }
+ });
+ }
+
+ @Override
+ public void saveNote(String content) {
+ Intent intent = mView.getActivityIntent();
+ // 内容改变时才保存
+ if (!mNoteContent.equals(content)) {
+ intent = mView.getActivityIntent();
+ intent.putExtra("note_id", mNoteId);
+ intent.putExtra("note_content", content);
+ intent.putExtra("modified_time", mModifiedTime);
+ intent.putExtra("position", mPosition);
+ mView.setResultAndFinish(intent);
+ }
+ }
+
+ @Override
+ public void calculateContentAndImageCount(MyEditText myEditText) {
+ int count = myEditText.getText().length();
+ int imageCount = myEditText.mImageList.size();
+ for (int i = 0; i < myEditText.mImageList.size(); i++) {
+ count = count - (myEditText.mImageList.get(i).getImageFlag().length());
+ // 再减去一个换行符
+ count = count - 1;
+ }
+ mView.showStatisticsDialog(imageCount, count);
+ }
+
+ @Override
+ public int getNoteEditNeedHeight() {
+ // 屏幕高度减去 状态栏高度、toolbar高度、底部工具栏高度
+ float height = ScreenUtils.getScreenHeight() - ThemeUtils.getStatusBarHeight()
+ - SizeUtils.dp2px(56) - SizeUtils.dp2px(48);
+ return (int) height;
+ }
+
+ @Override
+ public void clickNoteEditText(MyEditText editText) {
+ // 获取光标位置
+ int selectionAfter = editText.getSelectionStart();
+ Logger.d("光标位置:" + selectionAfter);
+
+ for (int i = 0; i < editText.mImageList.size(); i++) {
+
+ ImageEntity imageEntity = editText.mImageList.get(i);
+
+ if (selectionAfter >= imageEntity.getStart()
+ && selectionAfter <= imageEntity.getEnd()) { // 光标位置在照片的位置内
+ Logger.d("起点:" + imageEntity.getStart() + " 终点:" + imageEntity.getEnd());
+ // 隐藏键盘
+ InputMethodManager imm = (InputMethodManager) Utils.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
+ // 光标移到图片末尾的换行符后面
+ editText.setSelection(imageEntity.getEnd() + 1);
+ mSelectedImageEntity = imageEntity;
+ toImageInfoActivity();
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void shareNoteWithText() {
+
+ }
+
+ @Override
+ public void shareNoteWithImage(final View view) {
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("生成图片中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ Bitmap bitmap = getNoteShareBitmap(view);
+ EditNoteConstans.shareBitmap=bitmap;
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean b) {
+ mView.unShowLoading();
+ mView.setEditTextAfterGetBitmap();
+ toShareActivity();
+ }
+ }.execute();
+ }
+
+ private void toShareActivity() {
+ Intent intent = new Intent(mView.getActivity(), ShareActivity.class);
+ mView.getActivity().startActivity(intent);
+ }
+
+ @Override
+ public void closeKeyboard(View view) {
+ InputMethodManager manager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ if (manager.isActive()) {
+ manager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+ }
+
+ @Override
+ public Bitmap getNoteShareBitmap(View view) {
+ Bitmap bitmap = ImageUtils.view2Bitmap(view);
+ int x = bitmap.getWidth() - SizeUtils.sp2px(72);
+ int y = bitmap.getHeight() - SizeUtils.sp2px(16);
+ int textWaterMarkColor = Utils.getContext().getResources().getColor(R.color.colorBlackAlpha54);
+ bitmap = ImageUtils.addTextWatermark(bitmap, EditNoteConstans.watermarkText, 24, textWaterMarkColor, x, y);
+ return bitmap;
+ }
+
+ private void toImageInfoActivity() {
+ Intent intent = new Intent(mView.getActivity(), ImageInfoActivity.class);
+ intent.putExtra("image_name", mSelectedImageEntity.getImageName());
+ intent.putExtra("note_id", mNoteId);
+ mView.getActivity().startActivityForResult(intent, REQUEST_CODE_TO_IMAGE_INFO);
+ }
+
+ @TargetApi(19)
+ private void handleImageOnKitKat(Intent data) {
+ String imagePath = null;
+ Uri uri = data.getData();
+ if (DocumentsContract.isDocumentUri(mView.getActivity(), uri)) {
+// 如果是documentlent类型的URI,则通过docment id处理
+ String docId = DocumentsContract.getDocumentId(uri);
+ if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
+ String id = docId.split(":")[1];
+ String selection = MediaStore.Images.Media._ID + "=" + id;
+ imagePath = getImagePatch(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
+ } else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
+ Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
+ imagePath = getImagePatch(contentUri, null);
+ }
+ } else if ("content".equalsIgnoreCase(uri.getScheme())) {
+// 如果是content类型的uri的话,则使用普通方式处理
+ imagePath = getImagePatch(uri, null);
+ } else if ("file".equalsIgnoreCase(uri.getScheme())) {
+// 若果是file类型的uri,则直接获取图片路径
+ imagePath = uri.getPath();
+ }
+ copyFileInOtherThread(imagePath);
+ }
+
+ private String getImagePatch(Uri uri, String selection) {
+ String path = null;
+// 通过URi和selection 来获取真实的图片路径
+ Cursor cursor = mView.getActivity().getContentResolver().query(uri, null, selection, null, null);
+ if (cursor != null) {
+ if (cursor.moveToFirst()) {
+ path = cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media.DATA));
+ }
+ cursor.close();
+ }
+ return path;
+ }
+
+ // 新线程中对图片进行复制。
+ private void copyFileInOtherThread(String imagePath) {
+ final String imagePaths = imagePath;
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("加载中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ return FileUtils.copyFile(new File(imagePaths), mImageFile);
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ if (aBoolean) {
+ displayImage();
+ } else {
+ ToastUtils.showShort("图片读取失败");
+ }
+ }
+ }.execute();
+ }
+
+ private void handleImageBeforeKitKat(Intent data) {
+ Uri uri = data.getData();
+ String imagePath = getImagePatch(uri, null);
+ copyFileInOtherThread(imagePath);
+ }
+
+
+ private void displayImage() {
+
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true; // 对图片进行设置 但不形成示例,不耗费内存
+
+ BitmapFactory.decodeFile(mImageFile.getPath(), options);
+
+ int imageRequestWidth = getRequestImeWidth();
+ int imageRequestHeight = getRequestImeHeight(options);
+ Logger.d("width " + imageRequestWidth + " height:" + imageRequestHeight);
+ Logger.d("bitmap1 width " + options.outWidth + " height:" + options.outHeight);
+
+ Glide.with(mView.getActivity())
+ .load(mImageFile)
+ .asBitmap()
+ .override(imageRequestWidth, imageRequestHeight) // 设置大小
+ .fitCenter() // 不按照比例
+ .into(new SimpleTarget() {
+ @Override
+ public void onResourceReady(Bitmap resource, GlideAnimation super Bitmap> glideAnimation) {
+ //根据Bitmap对象创建ImageSpan对象
+ Logger.d("bitmap width:" + resource.getWidth() + " height:" + resource.getHeight());
+ mView.insertImage(mImageName, resource);
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNotePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNotePresenter.java
new file mode 100644
index 0000000..862c78f
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNotePresenter.java
@@ -0,0 +1,114 @@
+package com.bigbig.ding.module.notes.edit;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.support.annotation.NonNull;
+import android.view.View;
+
+import com.bigbig.ding.widget.MyEditText;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/30
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IEditNotePresenter {
+
+ /**
+ * 初始化数据
+ * @describe
+ */
+ void initData();
+
+ /**
+ * 设置内容
+ */
+ void setTextForNoteContent();
+
+ /**
+ * 解析便签内容(解析图片)
+ */
+ void parseNoteContent();
+
+ /**
+ * 检测权限并前往相机
+ */
+ void checkPermissionAndToCamera(Context context);
+
+ /**
+ * 检测权限并前往图库
+ */
+ void checkPermissionAndToPhoto(Context context);
+
+ /**
+ * 前往相机
+ */
+ void toCamera(Activity activity);
+
+ /**
+ * 前往图库
+ */
+ void toPhoto(Activity activity);
+
+ /**
+ * 获取需要的图片高度
+ */
+ int getRequestImeHeight(BitmapFactory.Options option);
+
+ /**
+ * Activity返回
+ */
+ void onActivityResult(int requestCode, int resultCode, Intent intent);
+
+ /**
+ * 请求权限返回
+ */
+ void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults);
+
+ /**
+ * 保存便签
+ */
+ void saveNote(String content);
+
+ /**
+ * 统计字数和图片数量
+ * @describe
+ */
+ void calculateContentAndImageCount(MyEditText myEditText);
+
+ /**
+ * 获取便签Edit需要的高度
+ */
+ int getNoteEditNeedHeight();
+
+ /**
+ * 点击便签EditText
+ */
+ void clickNoteEditText(MyEditText editText);
+
+ /**
+ * 分享便签 文字
+ */
+ void shareNoteWithText();
+
+ /**
+ * 分享便签 图片
+ */
+ void shareNoteWithImage(View view);
+
+ // 关闭键盘
+ void closeKeyboard(View view);
+
+ /**
+ * 获取便签分享的图片
+ */
+ Bitmap getNoteShareBitmap(View view);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNoteView.java b/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNoteView.java
new file mode 100644
index 0000000..d2b8827
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/edit/IEditNoteView.java
@@ -0,0 +1,70 @@
+package com.bigbig.ding.module.notes.edit;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.support.annotation.Nullable;
+
+import com.bigbig.ding.bean.ImageEntity;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/30
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IEditNoteView {
+
+ /**
+ * 获取Intent
+ * @describe
+ */
+ Intent getActivityIntent();
+
+ Activity getActivity();
+
+ void setTitle(String title);
+
+ void showNoteContent(String content);
+
+ void replaceImage(String imageName, Bitmap bitmap);
+
+ void insertImage(String imageName, Bitmap bitmap);
+
+ /**
+ * 删除图片
+ */
+ void deleteImage(ImageEntity imageEntity);
+
+ void setResultAndFinish(@Nullable Intent intent);
+
+ void showLoading(String message);
+
+ void unShowLoading();
+
+ /**
+ * 显示去往app设置页的dialog
+ */
+ void showToAppSettingDialog();
+
+ /**
+ * 显示统计Dialog
+ */
+ void showStatisticsDialog(int imageCount,int textCount);
+
+ /**
+ * 分享前 进行对EditText的调整:
+ * 以图片形式分享便签时,因需要将EditText转为Bitmap,
+ * 因此需要调整其大小,应:关闭键盘、不可便签(去除光标),设置minHeight为0
+ */
+ void setEditTextBeforeGetBitmap();
+
+ /**
+ * 分享后 调整回来
+ */
+ void setEditTextAfterGetBitmap();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderActivity.java b/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderActivity.java
new file mode 100644
index 0000000..333995d
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderActivity.java
@@ -0,0 +1,228 @@
+package com.bigbig.ding.module.notes.folder;
+
+import android.animation.ObjectAnimator;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.support.design.widget.FloatingActionButton;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+import com.blankj.utilcode.util.SnackbarUtils;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+
+import com.bigbig.ding.adapter.RvEditFolderAdapter;
+import com.bigbig.ding.constants.EditFolderConstans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.utils.ThemeUtils;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FolderActivity extends BaseActivity implements IFolderView, BaseQuickAdapter.OnItemChildClickListener, BaseQuickAdapter.OnItemClickListener, View.OnClickListener, View.OnTouchListener {
+
+ @BindView(R.id.rv_folder_folder)
+ RecyclerView mRvFolder;
+
+ @BindView(R.id.fab_folder_add)
+ FloatingActionButton mFabAdd;
+
+ private float mScrollLastY;
+ private float mTouchSlop;
+ private ProgressDialog mProgressDialog;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_edit_folder;
+ }
+
+ @Override
+ protected FolderPresenter initPresenter() {
+ FolderPresenter presenter=new FolderPresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+
+ mTouchSlop=ViewConfiguration.get(this).getScaledTouchSlop();
+
+ mPresenter.getIntentData(getIntent());
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle("编辑便签夹");
+
+ mRvFolder.setLayoutManager(new LinearLayoutManager(mContext));
+ mRvFolder.setOnTouchListener(this);
+
+ RvEditFolderAdapter adapter=new RvEditFolderAdapter();
+ adapter.setOnItemChildClickListener(this);
+ adapter.setOnItemClickListener(this);
+ adapter.bindToRecyclerView(mRvFolder);
+
+ mPresenter.setAdapter(adapter);
+
+ mFabAdd.setOnClickListener(this);
+ }
+
+ @Override
+ protected void updateViews() {
+ mPresenter.getData();
+ }
+
+ @Override
+ public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
+ mPresenter.editFolder(position);
+ }
+
+ @Override
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
+ mPresenter.choiceItem(position);
+ // 更新菜单
+ supportInvalidateOptionsMenu();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.fab_folder_add:
+ mPresenter.addFolder();
+ break;
+ }
+ }
+
+ @Override
+ public void hideAddBtn() {
+ ObjectAnimator animator= ObjectAnimator.ofFloat(mFabAdd,"translationY", SizeUtils.dp2px(80));
+ animator.setDuration(150);
+ animator.start();
+ }
+
+ @Override
+ public void showAddBtn() {
+ ObjectAnimator animator= ObjectAnimator.ofFloat(mFabAdd,"translationY", SizeUtils.dp2px(0));
+ animator.setDuration(150);
+ animator.start();
+ }
+
+ @Override
+ public void showSnackbar() {
+ SnackbarUtils.with(mRvFolder)
+ .setMessage("请选择要删除的便签夹")
+ .setBgColor( ThemeUtils.getColorPrimary(mContext))
+ .show();
+ }
+
+ @Override
+ public void scrollToItem(int position){
+ mRvFolder.scrollToPosition(position);
+ }
+
+ @Override
+ public void setActivityResultAndFinish(int resultCode,Intent intent) {
+ setResult(resultCode,intent);
+ }
+
+ @Override
+ public void onBackPressed() {
+ mPresenter.setResult();
+ super.onBackPressed();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_folder,menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem item=menu.findItem(R.id.menu_folder_delete);
+ mPresenter.setMenuAlpha(item);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ case R.id.menu_folder_delete:
+ mPresenter.judgeToDelete();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void showDeleteDialog(){
+ new AlertDialog.Builder(mContext)
+ .setTitle("删除便签夹")
+ .setMessage("确定删除选中的便签夹吗?")
+ .setPositiveButton("删除",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mPresenter.deleteMoreFolders();
+ }
+ })
+ .setNegativeButton("取消",null)
+ .show();
+ }
+
+ @Override
+ public void showLoading(String message) {
+ if(mProgressDialog==null){
+ mProgressDialog=new ProgressDialog(mContext);
+ }
+ mProgressDialog.setMessage(message);
+ mProgressDialog.show();
+ }
+
+ @Override
+ public void unShowLoading() {
+ if(mProgressDialog!=null)
+ mProgressDialog.cancel();
+ }
+
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ float rawY=event.getRawY();
+ switch (event.getAction()){
+ case MotionEvent.ACTION_DOWN:
+ mScrollLastY=rawY;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if(EditFolderConstans.selectedItem==-1){
+ if((rawY-mScrollLastY)>mTouchSlop){ // 手指向下滑动
+ showAddBtn();
+ } else if((mScrollLastY-rawY)>mTouchSlop){ // 手指向上滑动
+ hideAddBtn();
+ }
+ mScrollLastY=rawY;
+ }
+
+ break;
+ }
+ return false;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderPresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderPresenter.java
new file mode 100644
index 0000000..66c731d
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folder/FolderPresenter.java
@@ -0,0 +1,318 @@
+package com.bigbig.ding.module.notes.folder;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.support.design.widget.TextInputLayout;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+import com.bigbig.ding.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.bigbig.ding.adapter.RvEditFolderAdapter;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.EditFolderConstans;
+import com.bigbig.ding.model.INoteFolderModel;
+import com.bigbig.ding.model.LoadDataCallBack;
+import com.bigbig.ding.model.NoteFolderModel;
+import com.bigbig.ding.module.base.BasePresenter;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FolderPresenter extends BasePresenter implements IFolderPresenter {
+
+ // 当前已选中的便签夹
+ private int mCurrentFolderId;
+ // 当前已选中的便签夹是否已被删除
+ private boolean mIsCurrentFolderDeleted=false;
+ // 是否对便签夹做了修改
+ private int mResultCode= Activity.RESULT_CANCELED;
+
+ private RvEditFolderAdapter mAdapter;
+
+ private INoteFolderModel mNoteFolderModel = new NoteFolderModel();
+
+ @Override
+ public void setAdapter(RvEditFolderAdapter adapter) {
+ this.mAdapter = adapter;
+ }
+
+ @Override
+ public void getIntentData(Intent intent) {
+ mCurrentFolderId=intent.getIntExtra("current_folder_id",0);
+ }
+
+ @Override
+ public void getData() {
+ mNoteFolderModel.loadNoteFoldersList(new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ }
+ });
+ }
+
+ @Override
+ public void choiceItem(int position) {
+ boolean isChecked = mAdapter.mCheckList.get(position);
+ if (isChecked) {
+ EditFolderConstans.selectedCount--;
+ } else {
+ EditFolderConstans.selectedCount++;
+ }
+ mAdapter.mCheckList.set(position, !isChecked);
+ mAdapter.notifyItemChanged(position);
+ }
+
+ @Override
+ public void editFolder(int position) {
+ mResultCode=Activity.RESULT_OK;
+ if (EditFolderConstans.selectedItem == position) { // 如果当前item正在编辑
+ saveCurrentItem(position);
+ } else if(EditFolderConstans.selectedItem!=-1){ // 已有其他Item正在被编辑
+ cancelEditItem();
+ editItem(position);
+ } else{ // 无任何item正在被编辑
+ editItem(position);
+ }
+ }
+
+ private void saveCurrentItem(int position) {
+ EditText et = (EditText) mAdapter.getViewByPosition(position, R.id.et_edit_folder_name);
+ String newName = et.getText().toString();
+ verifyName(position,newName);
+ }
+
+ private void verifyName( int position,String newName) {
+
+ // 新名字为空
+ if (newName.isEmpty()){
+ setEditError(position,"便签夹名为空");
+ return ;
+ }
+
+ // 名字重复
+ for (int i = 0; i < mAdapter.getData().size(); i++) {
+ if (i != position && mAdapter.getData().get(i).getFolderName().equals(newName)) {
+ setEditError(position,"已存在");
+ return;
+ }
+ }
+
+ saveNewNameToFolder(position,newName);
+ }
+
+ private void setEditError(int position, String errorTip) {
+ TextInputLayout textInputLayout=(TextInputLayout)mAdapter.getViewByPosition(position,R.id.textinput_edit_folder_name);
+ textInputLayout.setErrorEnabled(true);
+ textInputLayout.setError(errorTip);
+ }
+
+ private void saveNewNameToFolder(int position,String newName){
+ NoteFolder folder = mAdapter.getData().get(position);
+ folder.setFolderName(newName);
+ folder.save();
+
+ EditFolderConstans.selectedItem=-1;
+ mAdapter.notifyItemChanged(position);
+ closeKeyboard(mAdapter.getViewByPosition(position,R.id.et_edit_folder_name));
+
+ mView.showAddBtn();
+ }
+
+ // 关闭键盘
+ public void closeKeyboard(View view){
+ InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ if(manager.isActive()){
+ manager.hideSoftInputFromWindow(view.getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
+ }
+ }
+
+ private void cancelEditItem(){
+ int i=EditFolderConstans.selectedItem;
+ EditFolderConstans.selectedItem=-1;
+ mAdapter.notifyItemChanged(i);
+ }
+
+
+ private void editItem(int position){
+ EditFolderConstans.selectedItem=position;
+ mAdapter.notifyItemChanged(position);
+
+ EditText editText=(EditText)mAdapter.getViewByPosition(position,R.id.et_edit_folder_name);
+ editText.selectAll();
+ setFoucus(editText);
+ mView.hideAddBtn();
+ }
+
+ // 获取焦点并弹出键盘
+ public void setFoucus(View view){
+// 获取 接受焦点的资格
+ view.setFocusable(true);
+// 获取 焦点可以响应点触的资格
+ view.setFocusableInTouchMode(true);
+// 请求焦点
+ view.requestFocus();
+// 弹出键盘
+ InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ manager.toggleSoftInput(0,0);
+ manager.showSoftInput(view,0);
+ }
+
+ @Override
+ public void addFolder() {
+ mResultCode=Activity.RESULT_OK;
+ mView.hideAddBtn();
+ NoteFolder folder=new NoteFolder();
+ // 已有item处于编辑状态,则让其恢复为正常状态
+ if(EditFolderConstans.selectedItem!=-1){
+ cancelEditItem();
+ }
+
+ String newName=getNewFolderName();
+ folder.setFolderName(newName);
+ folder.save();
+ mAdapter.addData(folder);
+ mView.scrollToItem(mAdapter.getData().size()-1);
+
+ // 新建便签夹的弹出键盘在Adapter中设置(因为RecyclerView的scrollToItem需要一定的时间)
+ EditFolderConstans.isNewFolder=true;
+ EditFolderConstans.selectedItem=mAdapter.getData().size()-1;
+ }
+
+ @Override
+ public void judgeToDelete() {
+ if(EditFolderConstans.selectedCount>0){
+ mView.showDeleteDialog();
+ } else {
+ mView.showSnackbar();
+ }
+ }
+
+ @Override
+ public void deleteMoreFolders() {
+
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mResultCode=Activity.RESULT_OK;
+ mView.showLoading("删除中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ // 当前正在编辑的便签夹是否被删除
+ boolean isSelectedDeleted=false;
+ for(int i=mAdapter.mCheckList.size()-1;i>=0;i--){
+ if(mAdapter.mCheckList.get(i)){
+ if(i==EditFolderConstans.selectedItem){
+ isSelectedDeleted=true;
+ }
+ deleteFolder(i);
+ }
+ }
+ return isSelectedDeleted;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ EditFolderConstans.selectedCount=0;
+
+ // 判断当前编辑的便签是否被删除
+ if(aBoolean){
+ mView.showAddBtn();
+ EditFolderConstans.selectedItem=-1;
+ }
+ mAdapter.notifyDataSetChanged();
+ }
+ }.execute();
+
+ }
+
+ @Override
+ public void setMenuAlpha(MenuItem menuItem) {
+ if(EditFolderConstans.selectedCount>0){
+ menuItem.getIcon().setAlpha(255);
+ } else {
+ menuItem.getIcon().setAlpha(85);
+ }
+ }
+
+ private void deleteFolder(int position){
+ NoteFolder folder=mAdapter.getData().get(position);
+
+ // 判断删除的是否是当前主页已选中的便签夹
+ if(folder.getId()==mCurrentFolderId)
+ mIsCurrentFolderDeleted=true;
+
+ mAdapter.getData().remove(position);
+ mAdapter.mCheckList.remove(position);
+ mNoteFolderModel.deleteNoteFolder(folder);
+ }
+
+ @Override
+ public void setResult() {
+ initConstans();
+
+ Intent intent=new Intent();
+ intent.putExtra("is_current_folder_deleted",mIsCurrentFolderDeleted);
+ mView.setActivityResultAndFinish(mResultCode,intent);
+ }
+
+ private void initConstans(){
+ EditFolderConstans.selectedCount=0;
+ EditFolderConstans.selectedItem=-1;
+ EditFolderConstans.isNewFolder=false;
+ }
+
+ private String getNewFolderName(){
+
+ List list=new ArrayList<>();
+
+ // 找出所有包含新建便签夹的名字
+ for(int i=0;i 新建便签夹2 依次尝试
+ int n=1;
+ while (true){
+ String newName;
+ if(n==1){
+ newName="新建便签夹";
+ } else {
+ newName="新建便签夹"+n;
+ }
+ int i;
+ for(i=0;i
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFolderPresenter {
+
+ void setAdapter(RvEditFolderAdapter adapter);
+
+ void getIntentData(Intent intent);
+
+ void getData();
+
+ void choiceItem(int position);
+
+ void editFolder(int position);
+
+ void addFolder();
+
+ void judgeToDelete();
+
+ void deleteMoreFolders();
+
+ void setMenuAlpha(MenuItem menuItem);
+
+ void setResult();
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folder/IFolderView.java b/app/src/main/java/com/bigbig/ding/module/notes/folder/IFolderView.java
new file mode 100644
index 0000000..7165514
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folder/IFolderView.java
@@ -0,0 +1,32 @@
+package com.bigbig.ding.module.notes.folder;
+
+import android.content.Intent;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/04
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFolderView {
+
+ void hideAddBtn();
+
+ void showAddBtn();
+
+ void showSnackbar();
+
+ void showDeleteDialog();
+
+ void showLoading(String message);
+
+ void unShowLoading();
+
+ void scrollToItem(int position);
+
+ void setActivityResultAndFinish(int resultCode,Intent intent);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListFragment.java b/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListFragment.java
new file mode 100644
index 0000000..44b658d
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListFragment.java
@@ -0,0 +1,305 @@
+package com.bigbig.ding.module.notes.folderList;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.provider.SyncStateContract;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.bigbig.ding.R;
+import com.bigbig.ding.constants.Constans;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+
+import java.util.List;
+
+import com.bigbig.ding.adapter.RvNoteFolderAdapter;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.FolderListConstans;
+import com.bigbig.ding.constants.NoteListConstans;
+import com.bigbig.ding.module.base.BaseFragment;
+import com.bigbig.ding.module.notes.folder.FolderActivity;
+import com.bigbig.ding.module.notes.main.NoteMainActivity;
+import com.bigbig.ding.module.setting.developer.DeveloperActivity;
+import com.bigbig.ding.module.setting.feedback.FeedbackActivity;
+import com.bigbig.ding.module.setting.main.SettingMainActivity;
+import com.bigbig.ding.utils.ThemeUtils;
+import com.bigbig.ding.widget.MyDrawable;
+import butterknife.BindView;
+
+import static cn.bmob.v3.Bmob.getApplicationContext;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FolderListFragment extends BaseFragment
+ implements IFolderListView> , View.OnClickListener{
+
+ @BindView(R.id.rv_note_list_folder)
+ RecyclerView mRvNoteFolder; // 便签夹列表
+
+ @BindView(R.id.ll_folder_list_setting)
+ LinearLayout mLlToSetting;
+
+ private View mHearderView1;
+
+ private View mHearderView2;
+ private RelativeLayout mRlAllFolder;
+ private ImageView mIvAllIcon;
+ private TextView mTvAllTitle;
+ private TextView mTvAllCount;
+
+ private View mFoolderView;
+ private RelativeLayout mRlPrimaryFolder;
+ private ImageView mIvPrimaryIcon;
+ private TextView mTvPrimaryTitle;
+
+ private RelativeLayout mRlRecycleFolder;
+ private ImageView mIvRecycleIcon;
+ private TextView mTvRecycleTitle;
+
+ public FolderListFragment( ){};
+
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.fragment_folder;
+ }
+
+ @Override
+ protected FolderListPresenter initPresenter() {
+ FolderListPresenter presenter = new FolderListPresenter();
+ presenter.attch(this);
+ NoteMainActivity activity=(NoteMainActivity)getActivity();
+ presenter.setActivityPresenter(activity.mPresenter);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+
+ RvNoteFolderAdapter mFolderAdapter = new RvNoteFolderAdapter();
+ mFolderAdapter.addHeaderView(getFolderHeaderView());
+ mFolderAdapter.addFooterView(getFolderFooterView());
+ mFolderAdapter.addHeaderView(getFolderHeaderView2());
+ mFolderAdapter.setOnItemClickListener(mNoteItemClickListener);
+
+ mRvNoteFolder.setLayoutManager(new LinearLayoutManager(mContext));
+ mRvNoteFolder.setAdapter(mFolderAdapter);
+
+ mPresenter.setAdapter(mFolderAdapter);
+
+ mLlToSetting.setOnClickListener(this);
+
+ }
+
+ /**
+ * 便签夹Rv点击事件
+ *
+ * @describe
+ */
+ private BaseQuickAdapter.OnItemClickListener mNoteItemClickListener = new BaseQuickAdapter.OnItemClickListener() {
+ @Override
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
+ mPresenter.choiceFolder(position,false);
+ }
+ };
+
+ @Override
+ protected void updateViews(boolean isRefresh) {
+
+ }
+
+ /**
+ * 获取FolderList的header
+ *
+ * @describe
+ */
+ private View getFolderHeaderView() {
+ mHearderView1 = LayoutInflater.from(mContext).inflate(R.layout.layout_folder_hearder, null, false);
+ TextView tvToCopy=(TextView)mHearderView1.findViewById(R.id.tv_folderlist_to_copy);
+ TextView tvToFeedback=(TextView)mHearderView1.findViewById(R.id.tv_folderlist_to_feedback);
+ TextView tvToDev=(TextView)mHearderView1.findViewById(R.id.tv_folderlist_to_developer);
+ tvToCopy.setOnClickListener(this);
+ tvToFeedback.setOnClickListener(this);
+ tvToDev.setOnClickListener(this);
+ return mHearderView1;
+ }
+ private View getFolderHeaderView2() {
+
+ mHearderView2= LayoutInflater.from(mContext).inflate(R.layout.layout_folder_hearder_2, null, false);
+
+ mRlAllFolder=(RelativeLayout)mHearderView2.findViewById(R.id.rl_folder_all);
+ mIvAllIcon=(ImageView)mHearderView2.findViewById(R.id.iv_folder_all_icon);
+ mTvAllTitle=(TextView)mHearderView2.findViewById(R.id.tv_folder_all_title);
+ mTvAllCount=(TextView)mHearderView2.findViewById(R.id.tv_folder_all_count);
+ TextView tvToEdit=(TextView)mHearderView2.findViewById(R.id.tv_folder_to_edit);
+
+ mRlAllFolder.setOnClickListener(this);
+ tvToEdit.setOnClickListener(this);
+
+ return mHearderView2;
+ }
+
+ /**
+ * 获取FolderList的footer
+ *
+ * @describe
+ */
+ private View getFolderFooterView() {
+
+ mFoolderView = LayoutInflater.from(mContext).inflate(R.layout.layout_folder_footer, null, false);
+
+ mRlPrimaryFolder=(RelativeLayout)mFoolderView.findViewById(R.id.rl_folder_privacy);
+ mIvPrimaryIcon=(ImageView)mFoolderView.findViewById(R.id.img_folder_privacy_icon);
+ mTvPrimaryTitle=(TextView)mFoolderView.findViewById(R.id.tv_folder_privacy_title);
+
+ mRlRecycleFolder=(RelativeLayout)mFoolderView.findViewById(R.id.rl_folder_recycle_bin);
+ mIvRecycleIcon=(ImageView)mFoolderView.findViewById(R.id.img_folder_recycle_bin_ic);
+ mTvRecycleTitle=(TextView)mFoolderView.findViewById(R.id.tv_folder_recycle_bin_title);
+
+ mRlPrimaryFolder.setOnClickListener(this);
+ mRlRecycleFolder.setOnClickListener(this);
+
+ return mFoolderView;
+ }
+
+ public void choiceItemAll(){
+
+ mRlAllFolder.setSelected(true);
+ mIvAllIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable( ThemeUtils.getColorPrimary(mContext)));
+ mTvAllTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ mTvAllCount.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ }
+
+ public void unChoiceItemAll(){
+ mRlAllFolder.setSelected(false);
+ mIvAllIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
+ mTvAllTitle.setTextColor(mContext.getResources().getColor(R.color.colorBlackAlpha87));
+ mTvAllCount.setTextColor(mContext.getResources().getColor(R.color.colorBlackAlpha54));
+ }
+
+ public void choiceItemPrimary(){
+ mRlPrimaryFolder.setSelected(true);
+ mIvPrimaryIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable(ThemeUtils.getColorPrimary(mContext)));
+ mTvPrimaryTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ }
+
+ public void unChoiceItemPrimary(){
+ mRlPrimaryFolder.setSelected(false);
+ mIvPrimaryIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
+ mTvPrimaryTitle.setTextColor(mContext.getResources().getColor(R.color.colorBlackAlpha87));
+ }
+
+ public void choiceItemRecycleBin(){
+ mRlRecycleFolder.setSelected(true);
+ mIvRecycleIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable(ThemeUtils.getColorPrimary(mContext)));
+ mTvRecycleTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
+ }
+
+ public void unChoiceItemRecycleBin(){
+ mRlRecycleFolder.setSelected(false);
+ mIvRecycleIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
+ mTvRecycleTitle.setTextColor(mContext.getResources().getColor(R.color.colorBlackAlpha87));
+ }
+
+ @Override
+ public void setAllNoteCount(int count) {
+ mTvAllCount.setText(count+"");
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.rl_folder_all:
+ mPresenter.choiceFolder(FolderListConstans.ITEM_ALL,false);
+ break;
+ case R.id.rl_folder_privacy:
+ mPresenter.choiceFolder(FolderListConstans.ITEM_PRIMARY,false);
+ break;
+ case R.id.rl_folder_recycle_bin:
+ mPresenter.choiceFolder(FolderListConstans.ITEM_RECYCLE,false);
+ break;
+ case R.id.ll_folder_list_setting:
+ toSettingActivity();
+ break;
+ case R.id.tv_folder_to_edit:
+ toEditFolderActivity();
+ break;
+ case R.id.tv_folderlist_to_developer:
+ toAboutDeveloper();
+ break;
+ case R.id.tv_folderlist_to_feedback:
+ toFeedbackActivity();
+ break;
+ case R.id.tv_folderlist_to_copy:
+ toCopyRegid();
+// Constans.mRegId
+ break;
+ }
+ }
+
+ private void toSettingActivity(){
+ Intent intent=new Intent(getActivity(), SettingMainActivity.class);
+ startActivity(intent);
+ }
+
+ private void toEditFolderActivity(){
+ Intent intent=new Intent(getActivity(), FolderActivity.class);
+ intent.putExtra("current_folder_id",mPresenter.getCurrentFolderId());
+ getActivity().startActivityForResult(intent, NoteListConstans.REQUEST_CODE_EDIT_FOLDER);
+ }
+
+ private void toAboutDeveloper() {
+ Intent intent=new Intent(getActivity(), DeveloperActivity.class);
+ getActivity().startActivity(intent);
+ }
+
+ private void toFeedbackActivity(){
+ Intent intent=new Intent(getActivity(), FeedbackActivity.class);
+ getActivity().startActivity(intent);
+ }
+ /**
+ * 复制内容到剪贴板
+ *
+ * @param content
+ * @param context
+ */
+ public void copyContentToClipboard(String content, Context context) {
+ //获取剪贴板管理器:
+ ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
+ // 创建普通字符型ClipData
+ ClipData mClipData = ClipData.newPlainText("Label", content);
+ // 将ClipData内容放到系统剪贴板里。
+ cm.setPrimaryClip(mClipData);
+ }
+
+ private void toCopyRegid(){
+ final String showText;
+ if (Constans.mRegId == null) {
+ showText="唯一值获取失败,请重新获取!";
+ } else {
+ //获取前台显示网址的控件
+ showText="https://service-mm0wgphf-1258509752.cd.apigw.tencentcs.com/release/APIService-mipushServer/dd/sendmsg?id=" + Constans.xmRegId + "&title=标题(可选值)&msg=测试提交数据";
+
+ }
+ copyContentToClipboard(showText,getApplicationContext());
+ Toast.makeText(getApplicationContext(), R.string.copy_to_clip, Toast.LENGTH_LONG).show();
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListPresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListPresenter.java
new file mode 100644
index 0000000..50264d5
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folderList/FolderListPresenter.java
@@ -0,0 +1,327 @@
+package com.bigbig.ding.module.notes.folderList;
+
+import android.util.Log;
+
+import com.bigbig.ding.MainApplication;
+import com.bigbig.ding.adapter.RvNoteFolderAdapter;
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.FolderListConstans;
+import com.bigbig.ding.constants.CacheManager;
+import com.bigbig.ding.model.INoteFolderModel;
+import com.bigbig.ding.model.LoadDataCallBack;
+import com.bigbig.ding.model.NoteFolderModel;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.module.notes.main.INoteMainPresenter;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FolderListPresenter extends BasePresenter implements IFolderListPresenter {
+
+ private INoteFolderModel mINoteFolderModel =new NoteFolderModel();
+
+ private INoteMainPresenter mNoteMainPresenter;
+
+ private RvNoteFolderAdapter mAdapter;
+
+
+ @Override
+ public void setActivityPresenter(INoteMainPresenter presenter) {
+ mNoteMainPresenter=presenter;
+ mNoteMainPresenter.setFolderPresenter(this);
+ }
+
+ @Override
+ public void setAdapter(RvNoteFolderAdapter adapter) {
+ this.mAdapter=adapter;
+ }
+
+ @Override
+ public int initDataBase() {
+ int folderId= mINoteFolderModel.initNoteFolderAndGetFolderId();
+ return folderId;
+ }
+
+ @Override
+ public void start() {
+ mNoteMainPresenter.start();
+ }
+
+ @Override
+ public void getFolders() {
+ mINoteFolderModel.loadNoteFoldersList(new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ setAllNoteCount(list);
+ }
+ });
+ }
+
+ @Override
+ public List getFoldersForAdapter() {
+ return mAdapter.getData();
+ }
+
+ @Override
+ public int getRealItemForAdapter(int position) {
+ return position+mAdapter.getHeaderLayoutCount();
+ }
+
+ private void setAllNoteCount(List list){
+ FolderListConstans.noteFolderCount=0;
+ for(int i=0;i data=mAdapter.getData();
+ if (data != null){
+ unChoiceFolder(Constans.currentFolder);
+ CacheManager.setAndSaveCurrentFolder(pos);
+ mAdapter.notifyItemChanged(mAdapter.getHeaderLayoutCount()+pos);
+ mNoteMainPresenter.showNormalNote(data.get(pos).getFolderName(), data.get(pos).getId());
+ }
+ break;
+ }
+ }
+
+ /**
+ * 检查当前Folder是否存在 如果不存在,则修改为全部便签
+ */
+ private int checkCurrentFolderIsExist(int pos){
+ switch (pos) {
+ case FolderListConstans.ITEM_ALL:
+ return pos;
+ case FolderListConstans.ITEM_PRIMARY:
+ return pos;
+ case FolderListConstans.ITEM_RECYCLE:
+ return pos;
+ default:
+ if(pos>=mAdapter.getData().size()){
+ return FolderListConstans.ITEM_ALL;
+ } else
+ return pos;
+ }
+ }
+
+ @Override
+ public void choicePrivacy() {
+ unChoiceFolder(Constans.currentFolder);
+ Constans.currentFolder=FolderListConstans.ITEM_PRIMARY;
+ mView.choiceItemPrimary();
+ }
+
+ public void unChoiceFolder(int pos) {
+ switch (pos) {
+ case FolderListConstans.ITEM_ALL:
+ mView.unChoiceItemAll();
+ break;
+ case FolderListConstans.ITEM_PRIMARY:
+ mView.unChoiceItemPrimary();
+ break;
+ case FolderListConstans.ITEM_RECYCLE:
+ mView.unChoiceItemRecycleBin();
+ break;
+ default:
+ mAdapter.notifyItemChanged(mAdapter.getHeaderLayoutCount()+pos);
+ break;
+ }
+ }
+
+
+ @Override
+ public void addNote2Folder(Note note) {
+ switch (Constans.currentFolder){
+ case FolderListConstans.ITEM_ALL:
+ addNote2ALL(note);
+ break;
+ case FolderListConstans.ITEM_PRIMARY:
+ addNote2Privacy(note);
+ break;
+ case FolderListConstans.ITEM_RECYCLE:
+ // 废纸篓不做添加便签操作
+ break;
+ default:
+ addNote2Normal(note);
+ break;
+ }
+ }
+
+ @Override
+ public void deleteNoteFromFolder(Note note) {
+
+ }
+
+ @Override
+ public int getCurrentFolderId() {
+ switch (Constans.currentFolder){
+ case FolderListConstans.ITEM_ALL:
+ return Constans.currentFolder;
+ case FolderListConstans.ITEM_PRIMARY:
+ return Constans.currentFolder;
+ case FolderListConstans.ITEM_RECYCLE:
+ return Constans.currentFolder;
+ default:
+ return mAdapter.getData().get(Constans.currentFolder).getId();
+ }
+ }
+
+ @Override
+ public void refreshFolderList() {
+ mAdapter.notifyDataSetChanged();
+ mView.setAllNoteCount(FolderListConstans.noteFolderCount);
+ }
+
+ private void addNote2ALL(Note note){
+ // 全部便签时,默认储存在随手记中
+ NoteFolder folder=mAdapter.getData().get(0);
+ mINoteFolderModel.addNote2Folder(note,folder);
+ mView.setAllNoteCount(++FolderListConstans.noteFolderCount);
+ mAdapter.notifyItemChanged(getRealItemForAdapter(0));
+ }
+
+ private void addNote2Privacy(Note note){
+ // 私密便签时,默认储存在随手记中
+ NoteFolder folder=mAdapter.getData().get(0);
+ mINoteFolderModel.addNote2Privacy(note,folder);
+ }
+
+ private void addNote2Normal(Note note){
+ NoteFolder folder=mAdapter.getData().get(Constans.currentFolder);
+ mINoteFolderModel.addNote2Folder(note,folder);
+ mView.setAllNoteCount(++FolderListConstans.noteFolderCount);
+ mAdapter.notifyItemChanged(getRealItemForAdapter(Constans.currentFolder));
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListPresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListPresenter.java
new file mode 100644
index 0000000..ba77bac
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListPresenter.java
@@ -0,0 +1,109 @@
+package com.bigbig.ding.module.notes.folderList;
+
+import com.bigbig.ding.adapter.RvNoteFolderAdapter;
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.module.notes.main.INoteMainPresenter;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFolderListPresenter {
+
+ void setActivityPresenter(INoteMainPresenter presenter);
+
+ void setAdapter(RvNoteFolderAdapter adapter);
+
+ /**
+ * 首次进入应用,初始化数据库
+ *
+ * @describe
+ */
+ int initDataBase();
+
+ void start() ;
+ /**
+ * 获取便签夹
+ *
+ * @describe
+ */
+ void getFolders();
+
+ /**
+ * 获取Adapter的dataList
+ * @describe
+ */
+ List getFoldersForAdapter();
+
+ /**
+ * 获取便签夹Rv的真实item
+ * @describe
+ */
+ int getRealItemForAdapter(int position);
+
+ /**
+ * 从当前已选中的便签夹中移除便签
+ * @describe
+ */
+ void removeNoteForFolder(Note note);
+
+ /**
+ * 移除私密
+ * @describe
+ */
+ void removePrivacyNote(Note note);
+
+ /**
+ * 移动便签到便签夹
+ * @describe
+ */
+ void moveNoteToFolder(Note note,NoteFolder noteFolder);
+
+ /**
+ * 恢复便签
+ * @describe
+ */
+ void recoverNote(Note note);
+
+ /**
+ * 选择便签夹
+ * @param isInit 是否是初始化时调用(初始化时,不判断是否已被选中)
+ */
+ void choiceFolder(int pos,boolean isInit);
+
+ /**
+ * 选中私密
+ * @describe
+ */
+ void choicePrivacy();
+
+ /**
+ * 取消选中便签夹
+ * @describe
+ */
+ void unChoiceFolder(int pos);
+
+ void addNote2Folder(Note note);
+
+ void deleteNoteFromFolder(Note note);
+
+ /**
+ * 获取当前便签夹ID
+ * @describe
+ */
+ int getCurrentFolderId();
+
+ /**
+ * 刷新FolderRv
+ */
+ void refreshFolderList();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListView.java b/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListView.java
new file mode 100644
index 0000000..172bfd9
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/folderList/IFolderListView.java
@@ -0,0 +1,30 @@
+package com.bigbig.ding.module.notes.folderList;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFolderListView {
+
+
+ public void choiceItemAll();
+
+ public void choiceItemPrimary();
+
+ public void choiceItemRecycleBin();
+
+ public void unChoiceItemAll();
+
+ public void unChoiceItemPrimary();
+
+ public void unChoiceItemRecycleBin();
+
+ void setAllNoteCount(int count);
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainPresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainPresenter.java
new file mode 100644
index 0000000..a9a369d
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainPresenter.java
@@ -0,0 +1,209 @@
+package com.bigbig.ding.module.notes.main;
+
+import android.content.Intent;
+import android.view.MenuItem;
+
+import com.bigbig.ding.adapter.RvNoteListAdapter;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.module.notes.folderList.IFolderListPresenter;
+
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/01
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface INoteMainPresenter {
+
+ void setFolderPresenter(IFolderListPresenter presenter);
+
+ void setAdapter(RvNoteListAdapter adapter);
+
+ /**
+ * 首次进入应用,初始化数据库
+ *
+ * @describe
+ */
+ void initDataBase();
+
+ /**
+ * 开始
+ * @describe
+ */
+ void start();
+
+ /**
+ * 显示便签
+ * @describe
+ */
+ void showNormalNote(String title,int folderId);
+
+ /**
+ * 显示全部便签
+ * @describe
+ */
+ void showAllNote();
+
+ /**
+ * 显示私密便签
+ * @describe
+ */
+ void showPrivacyNote(boolean isShow);
+
+ /**
+ * 显示废纸篓便签
+ * @describe
+ */
+ void showRecycleBinNote();
+
+ /**
+ * 添加便签
+ *
+ * @describe
+ */
+ void addNote(String noteId,String content,long modifiedTime);
+
+ /**
+ * 更新便签
+ * @describe
+ */
+ void updateNote(int position,String content,long modifiedTime);
+
+ /**
+ * 添加私密
+ * @describe
+ */
+ void putNoteToPrivacy();
+
+ /**
+ * 删除便签
+ *
+ * @describe
+ */
+ void deleteNotes();
+
+ /**
+ * 移动便签
+ *
+ * @describe
+ */
+ void moveNotes();
+
+ /**
+ * 恢复便签
+ * @describe
+ */
+ void recoverNote(int position);
+
+ /**
+ * 移动便签到Folder
+ * @describe
+ */
+ void moveNotesToFolder(NoteFolder noteFolder);
+
+ /**
+ * 获取便签夹List
+ * @describe
+ */
+ List getFolderDataList();
+
+ /**
+ * 如果当前便签已选中,则取消选中,反之亦然
+ */
+ void choiceNote(int position);
+
+ /**
+ * 获取并显示已选中的便签的数量
+ *
+ * @describe
+ */
+ void showSelectedNoteCount();
+
+ /**
+ * 获取并显示当前便签夹名称
+ *
+ * @describe
+ */
+ void showCurrentFolderName();
+
+ /**
+ * 便签列表点击事件
+ * @describe
+ */
+ void onNoteRvClick(int position);
+
+ /**
+ * 初始化便签Rv的布局
+ * @describe
+ */
+ void initNoteRvLayoutManager();
+
+ /**
+ * 初始化显示模式的菜单icon
+ * @describe
+ */
+ void initShowModeMenuIcon(MenuItem item);
+
+ /**
+ * 修改便签RecyclerView的layoutManager,并修改显示模式的菜单图标
+ *
+ * @describe
+ */
+ void changeNoteRvLayoutManagerAndMenuIcon(MenuItem item);
+
+ /**
+ * 执行多选操作
+ *
+ * @describe
+ */
+ void doMultiSelectActionAndChoiceThisItem(int position);
+
+ /**
+ * 取消多选操作
+ *
+ * @describe
+ */
+ void cancelMultiSelectAction();
+
+ /**
+ * 是否进入了多选操作中
+ *
+ * @describe
+ */
+ boolean isShowMultiSelectAction();
+
+
+ /**
+ * 执行全选操作
+ *
+ * @describe
+ */
+ void doChoiceAllNote();
+
+ /**
+ * 进入搜索
+ * @describe
+ */
+ void setInSearch();
+
+ /**
+ * 退出搜索
+ * @describe
+ */
+ void setOutSearch();
+
+ /**
+ * ActivityResult
+ * @describe
+ */
+ void onActivityResult(int requestCode, int resultCode, Intent data);
+
+ void logCheckList();
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainView.java b/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainView.java
new file mode 100644
index 0000000..1fc8148
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/main/INoteMainView.java
@@ -0,0 +1,169 @@
+package com.bigbig.ding.module.notes.main;
+
+import android.support.v7.widget.RecyclerView;
+
+import com.bigbig.ding.bean.Note;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/01
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface INoteMainView {
+
+ /**
+ * 便签移动到第一个
+ * @describe
+ */
+ void setRvScrollToFirst();
+ /**
+ * 设置Toolbar的title
+ *
+ * @describe
+ */
+ void showChoiceNotesCount(String title);
+
+ /**
+ * 显示当前选中的便签夹名字
+ *
+ * @describe
+ */
+ void showCurrentNoteFolderName(String title);
+
+ /**
+ * 更新toolbar的菜单
+ *
+ * @describe
+ */
+ void updateOptionMenu();
+
+ /**
+ * fab滑出
+ *
+ * @describe
+ */
+ void setAddFabOut();
+
+ /**
+ * fab滑入
+ *
+ * @describe
+ */
+ void setAddFabIn();
+
+ /**
+ * fab 显示
+ * @describe
+ */
+ void showAddFab();
+
+ /**
+ * fab 隐藏
+ * @describe
+ */
+ void hideAddFab();
+
+ /**
+ * 隐藏侧滑栏
+ * @describe
+ */
+ void hideDrawer();
+
+ /**
+ * 隐藏BottomBar
+ *
+ * @describe
+ */
+ void hideBottomBar();
+
+ /**
+ * 显示bottomBar
+ *
+ * @describe
+ */
+ void showBottomBar();
+
+ /**
+ * 底部的多选菜单可使用
+ * @describe
+ */
+ void setCheckMenuEnable();
+
+ /**
+ * 底部的多选菜单不可使用
+ * @describe
+ */
+ void setCheckMenuUnEnable();
+
+ /**
+ * 底部菜单For全部和普通便签
+ * @describe
+ */
+ void setCheckMenuForAllAndNormal();
+
+ /**
+ * 底部菜单For私密
+ * @describe
+ */
+ void setCheckMenuForPrivacy();
+
+ /**
+ * 底部菜单For废纸篓
+ * @describe
+ */
+ void setCheckMenuForRecycleBin();
+
+ /**
+ * 显示移动便签的bottom sheet
+ * @describe
+ */
+ void showMoveBottomSheet();
+
+ /**
+ * 显示便签恢复dialog
+ * @describe
+ */
+ void showNoteRecoverDialog(int position);
+
+ /**
+ * 设置便签列表的布局管理器
+ *
+ * @describe
+ */
+ void changeNoteRvLayoutManager(RecyclerView.LayoutManager manager);
+
+ /**
+ * 前往私密密码解锁界面
+ * @describe
+ */
+ void toLockActivity();
+
+ /**
+ * 前往编辑便签界面 For 添加
+ * @describe
+ */
+ void toEditNoteForAdd();
+
+ /**
+ * 前往编辑便签界面 For 编辑
+ * @describe
+ */
+ void toEditNoteForEdit(Note note,int position);
+
+ /**
+ * 显示进度条
+ */
+ void showLoading(String message);
+
+ /**
+ * 取消显示进度条
+ */
+ void unShowLoading();
+
+ void showSnackbar(String message);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainActivity.java b/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainActivity.java
new file mode 100644
index 0000000..1c4f28b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainActivity.java
@@ -0,0 +1,634 @@
+package com.bigbig.ding.module.notes.main;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
+import android.app.Activity;
+import android.app.ActivityOptions;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.annotation.StringRes;
+import android.support.design.widget.BottomSheetDialog;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.ActionBarDrawerToggle;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.SearchView;
+import android.support.v7.widget.Toolbar;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.orhanobut.logger.Logger;
+
+import java.util.List;
+
+import com.bigbig.ding.adapter.NoteBottomSheetFolderAdapter;
+import com.bigbig.ding.adapter.RvNoteListAdapter;
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.NoteListConstans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.module.lock.modification.LockModificationActivity;
+import com.bigbig.ding.module.lock.verification.LockActivity;
+import com.bigbig.ding.module.notes.edit.EditNoteActivity;
+import com.bigbig.ding.utils.ProgressDialogUtils;
+import butterknife.BindView;
+
+public class NoteMainActivity extends BaseActivity
+ implements INoteMainView>, View.OnClickListener, View.OnTouchListener {
+
+
+ @BindView(R.id.rv_note_list)
+ RecyclerView mRvNoteList; // 便签列表
+
+ @BindView(R.id.tv_note_list_to_privacy)
+ TextView mTvToPrivacy; // 设为私密
+
+ @BindView(R.id.tv_note_list_delete)
+ TextView mTvDelete; // 删除
+
+ @BindView(R.id.tv_note_list_move)
+ TextView mTvMove; // 移动
+
+ @BindView(R.id.fab_note_list_add)
+ FloatingActionButton mFabAdd; // 添加便签
+
+ @BindView(R.id.rl_note_list_bottom_bar)
+ RelativeLayout mRlBottomBar; // 多选操作的bottomBar
+
+ @BindView(R.id.drawer_layout)
+ DrawerLayout mDrawer;
+
+ private MenuItem mSearchMenu;
+ private MenuItem mShowModeMenu;
+ private MenuItem mCheckAllMenu;
+
+ private float mScrollLastY;
+ private float mTouchSlop;
+
+ private RvNoteListAdapter mAdapter = new RvNoteListAdapter();
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_main;
+ }
+
+ @Override
+ protected NoteMainPresenter initPresenter() {
+ NoteMainPresenter presenter = new NoteMainPresenter();
+ presenter.attch(this);
+ presenter.setAdapter(mAdapter);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+
+ mTouchSlop = ViewConfiguration.get(this).getScaledTouchSlop();
+
+ mPresenter.initDataBase();
+ initDrawer();
+ initAdapter();
+
+ mRvNoteList.setAdapter(mAdapter);
+ mRvNoteList.setOnTouchListener(this);
+
+ mPresenter.initNoteRvLayoutManager();
+ }
+
+ /**
+ * 初始化侧滑栏
+ */
+ public void initDrawer() {
+ ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
+ this, mDrawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
+ mDrawer.setDrawerListener(toggle);
+ toggle.syncState();
+ }
+
+ private void initAdapter() {
+ mAdapter.setOnItemChildClickListener(mOnRvClickListener);
+ mAdapter.setOnItemChildLongClickListener(mOnRvLongClickListener);
+ mAdapter.setEmptyView(getRvEmptyView());
+ }
+
+ /**
+ * 便签Rv点击事件
+ *
+ * @describe
+ */
+ BaseQuickAdapter.OnItemChildClickListener mOnRvClickListener = new BaseQuickAdapter.OnItemChildClickListener() {
+ @Override
+ public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
+ mPresenter.onNoteRvClick(position);
+ }
+ };
+
+ /**
+ * 便签Rv长按事件
+ *
+ * @describe
+ */
+ BaseQuickAdapter.OnItemChildLongClickListener mOnRvLongClickListener = new BaseQuickAdapter.OnItemChildLongClickListener() {
+ @Override
+ public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
+ Logger.d(NoteListConstans.isInSearch);
+ if (!NoteListConstans.isInSearch) { // 搜索模式下不允许长按事件
+ mPresenter.doMultiSelectActionAndChoiceThisItem(position);
+ }
+ return true;
+ }
+ };
+
+ private View getRvEmptyView() {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.layout_empty, null, false);
+ return view;
+ }
+
+ @Override
+ protected void updateViews() {
+ mPresenter.start();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.fab_note_list_add:
+ toEditNoteForAdd();
+ break;
+ case R.id.tv_note_list_delete:
+ showDeleteDialog();
+ break;
+ case R.id.tv_note_list_move:
+ mPresenter.moveNotes();
+ break;
+ case R.id.tv_note_list_to_privacy:
+ mPresenter.putNoteToPrivacy();
+ break;
+ }
+ }
+
+ // 显示dialog
+ private void showDeleteDialog() {
+ new AlertDialog.Builder(mContext)
+ .setTitle("删除便签")
+ .setMessage("确定删除选中的便签吗?")
+ .setPositiveButton("删除",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mPresenter.deleteNotes();
+ }
+ })
+ .setNegativeButton("取消", null)
+ .show();
+ }
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+
+ float rawY = event.getRawY();
+ switch (event.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mScrollLastY = rawY;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if ((rawY - mScrollLastY) > mTouchSlop) { // 手指向下滑动
+ setAddFabIn();
+ } else if ((mScrollLastY - rawY) > mTouchSlop) { // 手指向上滑动
+ setAddFabOut();
+ }
+ mScrollLastY = rawY;
+ break;
+ }
+ return false;
+ }
+
+
+ @Override
+ public void onBackPressed() {
+ if (mDrawer.isDrawerOpen(GravityCompat.START)) {// 侧滑菜单已打开
+ mDrawer.closeDrawer(GravityCompat.START);
+ } else if (mPresenter.isShowMultiSelectAction()) {// 已显示多选菜单
+ mPresenter.cancelMultiSelectAction();
+ } else { // 默认
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ initOptionMemu(menu);
+ return true;
+ }
+
+ /**
+ * 初始化toolbar menu
+ */
+ public void initOptionMemu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+
+ mSearchMenu = menu.findItem(R.id.menu_note_search);
+ initSearchMenu(mSearchMenu);
+
+ mShowModeMenu = menu.findItem(R.id.menu_note_show_mode);
+ mPresenter.initShowModeMenuIcon(mShowModeMenu);
+
+ mCheckAllMenu = menu.findItem(R.id.menu_note_check_all);
+ }
+
+ private void initSearchMenu(MenuItem searchItem) {
+ SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
+ // 搜索View的文字改变事件
+ searchView.setOnQueryTextListener(qreryTextListener);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+ MenuItemCompat.setOnActionExpandListener(searchItem,
+ new MenuItemCompat.OnActionExpandListener() {
+ @Override
+ public boolean onMenuItemActionExpand(MenuItem menuItem) {
+ return true;
+ }
+
+ @Override
+ public boolean onMenuItemActionCollapse(MenuItem menuItem) {
+ mPresenter.cancelFilter();
+ mPresenter.setOutSearch();
+ return true;
+ }
+ });
+ } else {
+ searchView.setOnCloseListener(new SearchView.OnCloseListener() {
+ @Override
+ public boolean onClose() {
+ mPresenter.setOutSearch();
+ mPresenter.cancelFilter();
+ return true;
+ }
+ });
+ }
+ }
+
+ /**
+ * toolbar的SearchView的文字改变事件
+ */
+ private SearchView.OnQueryTextListener qreryTextListener = new SearchView.OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ mPresenter.setFilter(newText);
+ return true;
+ }
+ };
+
+ /**
+ * 更新toolbar的menu
+ */
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ if (mPresenter.isShowMultiSelectAction()) {
+ setMenuForMulitiSelectionActionIsShow();
+ } else {
+ setMenuForMulitiSelectionActionIsNotShow();
+ }
+
+ return true;
+ }
+
+ private void setMenuForMulitiSelectionActionIsShow() {
+ mSearchMenu.setVisible(false);
+ mShowModeMenu.setVisible(false);
+ mCheckAllMenu.setVisible(true);
+ mToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
+ mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mPresenter.isShowMultiSelectAction()) {
+ mPresenter.cancelMultiSelectAction();
+ }
+ }
+ });
+ }
+
+ private void setMenuForMulitiSelectionActionIsNotShow() {
+ mSearchMenu.setVisible(true);
+ mShowModeMenu.setVisible(true);
+ mCheckAllMenu.setVisible(false);
+// 自定义的drawer打开关闭的事件
+ MyActionBarDrawerToggle toggle = new MyActionBarDrawerToggle(
+ this, mDrawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
+ mDrawer.addDrawerListener(toggle);
+ toggle.syncState();
+ }
+
+
+ // 继承系统定义的事件。重写drawer open的事件,如果多选菜单以显示,则关闭多选菜单.
+ class MyActionBarDrawerToggle extends ActionBarDrawerToggle {
+ public MyActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) {
+ super(activity, drawerLayout, toolbar, openDrawerContentDescRes, closeDrawerContentDescRes);
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ if (mPresenter.isShowMultiSelectAction()) {
+ mPresenter.cancelMultiSelectAction();
+ }
+// 滑动时,容易导致fab隐藏,所以让其显示
+ setAddFabIn();
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ switch (id) {
+ case R.id.menu_note_show_mode:
+ mPresenter.changeNoteRvLayoutManagerAndMenuIcon(item);
+ break;
+ case R.id.menu_note_check_all:
+ mPresenter.doChoiceAllNote();
+ break;
+ case R.id.menu_note_search:
+ mPresenter.setInSearch();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void setRvScrollToFirst() {
+ mRvNoteList.scrollToPosition(0);
+ }
+
+ @Override
+ public void showChoiceNotesCount(String title) {
+ setTitle(title);
+ }
+
+ @Override
+ public void showCurrentNoteFolderName(String title) {
+ setTitle(title);
+ }
+
+ @Override
+ public void updateOptionMenu() {
+ // 更新toolbar菜单,系统会去调用onPrepareOptionsMenu(MenuItem item)方法
+ supportInvalidateOptionsMenu();
+ }
+
+ @Override
+ public void setAddFabOut() {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mFabAdd, "translationY", SizeUtils.dp2px(80));
+ animator.setDuration(150);
+ animator.start();
+ }
+
+ @Override
+ public void setAddFabIn() {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mFabAdd, "translationY", SizeUtils.dp2px(0));
+ animator.setDuration(150);
+ animator.start();
+ }
+
+ @Override
+ public void showAddFab() {
+ mFabAdd.setVisibility(View.VISIBLE);
+ setAddFabIn();
+ }
+
+ @Override
+ public void hideAddFab() {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mFabAdd, "translationY", SizeUtils.dp2px(80));
+ animator.setDuration(150);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mFabAdd.setVisibility(View.GONE);
+ }
+ });
+ animator.start();
+ }
+
+ @Override
+ public void hideDrawer() {
+ mDrawer.closeDrawer(GravityCompat.START);
+ }
+
+ @Override
+ public void hideBottomBar() {
+ // 下移动画
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mRlBottomBar, "translationY", SizeUtils.dp2px(56));
+ animator.setDuration(300);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mRlBottomBar.setVisibility(View.GONE);
+ }
+ });
+ animator.start();
+ }
+
+ @Override
+ public void showBottomBar() {
+ mRlBottomBar.setVisibility(View.VISIBLE);
+ // bottombar进行一个上移的动画
+ ObjectAnimator animator = ObjectAnimator.ofFloat(mRlBottomBar, "translationY", SizeUtils.dp2px(56), 0);
+ animator.setDuration(300);
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ }
+ });
+ animator.start();
+ }
+
+ @Override
+ public void setCheckMenuEnable() {
+ setButtonEnabled(true, mTvDelete);
+ setButtonEnabled(true, mTvMove);
+ setButtonEnabled(true, mTvToPrivacy);
+ }
+
+ @Override
+ public void setCheckMenuUnEnable() {
+ setButtonEnabled(false, mTvDelete);
+ setButtonEnabled(false, mTvMove);
+ setButtonEnabled(false, mTvToPrivacy);
+ }
+
+ // 设置按钮的可使用性
+ private void setButtonEnabled(boolean enabled, TextView view) {
+ view.setEnabled(enabled);
+ if (enabled) {
+ view.setTextColor(getResources().getColor(R.color.white));
+ } else {
+ view.setTextColor(getResources().getColor(R.color.colorWhiteAlpha30));
+ }
+ }
+
+ @Override
+ public void setCheckMenuForAllAndNormal() {
+ mTvToPrivacy.setText("设为私密");
+ mTvDelete.setText("删除");
+ mTvMove.setText("移动");
+
+ mTvToPrivacy.setVisibility(View.VISIBLE);
+ mTvDelete.setVisibility(View.VISIBLE);
+ mTvMove.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void setCheckMenuForPrivacy() {
+ mTvToPrivacy.setText("移除私密");
+ mTvDelete.setText("删除");
+
+ mTvToPrivacy.setVisibility(View.VISIBLE);
+ mTvDelete.setVisibility(View.VISIBLE);
+ mTvMove.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void setCheckMenuForRecycleBin() {
+ mTvDelete.setText("删除");
+ mTvMove.setText("恢复");
+
+ mTvToPrivacy.setVisibility(View.GONE);
+ mTvDelete.setVisibility(View.VISIBLE);
+ mTvMove.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void showMoveBottomSheet() {
+ final BottomSheetDialog dialog = new BottomSheetDialog(mContext);
+// 获取contentView
+ ViewGroup contentView = (ViewGroup) ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
+ View root = LayoutInflater.from(mContext).inflate(R.layout.bottom_sheet_folder, contentView, false);
+ RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_bottom_sheet_folder);
+ recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
+ dialog.setContentView(root);
+
+ recyclerView.setAdapter(getBottomSheetRvAdapter(dialog));
+
+ dialog.show();
+ }
+
+ private NoteBottomSheetFolderAdapter getBottomSheetRvAdapter(final BottomSheetDialog dialog) {
+ final NoteBottomSheetFolderAdapter folderAdapter = new NoteBottomSheetFolderAdapter();
+ folderAdapter.setNewData(mPresenter.getFolderDataList());
+ folderAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
+ @Override
+ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
+ NoteFolder folder = folderAdapter.getData().get(position);
+ mPresenter.moveNotesToFolder(folder);
+ dialog.cancel();
+ }
+ });
+ return folderAdapter;
+ }
+
+ @Override
+ public void showNoteRecoverDialog(final int position) {
+ new AlertDialog.Builder(mContext)
+ .setMessage("无法直接打开便签,是否恢复至原有便签夹?")
+ .setPositiveButton("恢复",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mPresenter.recoverNote(position);
+ }
+ })
+ .setNegativeButton("取消", null)
+ .show();
+ }
+
+
+
+ @Override
+ public void changeNoteRvLayoutManager(RecyclerView.LayoutManager manager) {
+ mRvNoteList.setLayoutManager(manager);
+ mPresenter.refreshRv();
+ }
+
+ @Override
+ public void toLockActivity() {
+ Intent intent;
+ if (Constans.isLocked) {
+ intent = new Intent(mContext, LockActivity.class);
+ } else {
+ intent = new Intent(mContext, LockModificationActivity.class);
+ }
+
+ // 5.0及以上则使用Activity动画
+ if (Build.VERSION.SDK_INT >= 21) {
+ Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this).toBundle();
+ startActivityForResult(intent, NoteListConstans.REQUEST_CODE_LOCK, bundle);
+ } else {
+ startActivityForResult(intent, NoteListConstans.REQUEST_CODE_LOCK);
+ }
+ }
+
+ @Override
+ public void toEditNoteForAdd() {
+ Intent intent = new Intent(this, EditNoteActivity.class);
+ intent.putExtra("is_add", true);
+ startActivityForResult(intent, NoteListConstans.REQUEST_CODE_ADD);
+ }
+
+ @Override
+ public void toEditNoteForEdit(Note note, int position) {
+ Intent intent = new Intent(this, EditNoteActivity.class);
+ intent.putExtra("position", position);
+ intent.putExtra("is_add", false);
+ intent.putExtra("note_id", note.getNoteId());
+ intent.putExtra("note_content", note.getNoteContent());
+ intent.putExtra("modified_time", note.getModifiedTime());
+ startActivityForResult(intent, NoteListConstans.REQUEST_CODE_EDIT);
+ }
+
+ private ProgressDialogUtils mProgressDialog=new ProgressDialogUtils(this);
+
+ @Override
+ public void showLoading(String message) {
+ mProgressDialog.show(message);
+ }
+
+ @Override
+ public void unShowLoading() {
+ mProgressDialog.hide();
+ }
+
+ @Override
+ public void showSnackbar(String message) {
+ Snackbar.make(mFabAdd, message,
+ Snackbar.LENGTH_SHORT).setAction("Action", null).show();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ mPresenter.onActivityResult(requestCode, resultCode, data);
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainPresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainPresenter.java
new file mode 100644
index 0000000..9954223
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/main/NoteMainPresenter.java
@@ -0,0 +1,727 @@
+package com.bigbig.ding.module.notes.main;
+
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.StaggeredGridLayoutManager;
+import android.text.TextUtils;
+import android.view.MenuItem;
+
+import com.blankj.utilcode.util.FileUtils;
+import com.blankj.utilcode.util.Utils;
+import com.orhanobut.logger.Logger;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.bigbig.ding.MainApplication;
+import com.bigbig.ding.adapter.RvNoteListAdapter;
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.CacheManager;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.FolderListConstans;
+import com.bigbig.ding.constants.NoteListConstans;
+import com.bigbig.ding.model.INoteModel;
+import com.bigbig.ding.model.LoadDataCallBack;
+import com.bigbig.ding.model.NoteModel;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.module.notes.folderList.IFolderListPresenter;
+
+import static android.app.Activity.RESULT_OK;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/01
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class NoteMainPresenter extends BasePresenter implements INoteMainPresenter {
+
+ // Note Model
+ private INoteModel mINoteModel = new NoteModel();
+
+ private IFolderListPresenter mFolderListPresenter;
+
+ private RvNoteListAdapter mAdapter;
+
+ @Override
+ public void setFolderPresenter(IFolderListPresenter presenter) {
+ mFolderListPresenter = presenter;
+ }
+
+ @Override
+ public void setAdapter(RvNoteListAdapter adapter) {
+ this.mAdapter = adapter;
+
+ }
+
+ @Override
+
+ public void initDataBase() {
+ if (Constans.isFirst) {
+ int folderId = mFolderListPresenter.initDataBase();
+ mINoteModel.initNote(folderId);
+ CacheManager.setAndSaveIsFirst(false);
+ }
+ }
+
+ @Override
+ public void start() {
+ mFolderListPresenter.getFolders();
+ mFolderListPresenter.choiceFolder(Constans.currentFolder, true);
+ }
+
+ @Override
+ public void showNormalNote(String title, int folderId) {
+ mINoteModel.loadNormalNoteList(folderId, new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ }
+ });
+ mView.hideDrawer();
+ showFolderNameFotTitle(title);
+ mView.showAddFab();
+ }
+
+ @Override
+ public void showAllNote() {
+ mINoteModel.loadAllNoteList(new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ }
+ });
+ mView.hideDrawer();
+ showFolderNameFotTitle("全部");
+ mView.showAddFab();
+ }
+
+ @Override
+ public void showPrivacyNote(boolean isShow) {
+ if (isShow) {
+ mINoteModel.loadPrivacyNoteList(new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ }
+ });
+ showFolderNameFotTitle("私密");
+ mFolderListPresenter.choicePrivacy();
+ mView.showAddFab();
+ } else {
+ mView.toLockActivity();
+ }
+ mView.hideDrawer();
+ }
+
+ @Override
+ public void showRecycleBinNote() {
+ mINoteModel.loadRecycleBinNoteList(new LoadDataCallBack() {
+ @Override
+ protected void onSuccedd(List list) {
+ mAdapter.setNewData(list);
+ }
+ });
+ mView.hideDrawer();
+ showFolderNameFotTitle("废纸篓");
+ mView.hideAddFab();
+ }
+
+ private void showFolderNameFotTitle(String title) {
+ mView.showCurrentNoteFolderName(title);
+ NoteListConstans.selectedFolderName = title;
+ }
+
+ @Override
+ public void addNote(String noteId, String content, long modifiedTime) {
+ Note note = new Note();
+ note.setNoteId(noteId);
+ note.setNoteContent(content);
+ note.setCreatedTime(modifiedTime);
+ note.setModifiedTime(modifiedTime);
+ mINoteModel.addNote(note); // 保存便签
+ mFolderListPresenter.addNote2Folder(note); // 添加便签到便签夹
+ mAdapter.addData(note);
+ mView.setRvScrollToFirst();
+ }
+
+ @Override
+ public void updateNote(int position, String content, long modifiedTime) {
+ Note note = mAdapter.getData().get(position);
+
+ if (TextUtils.isEmpty(content)) {
+ removeNote(position);
+ deleteNote(note, true);
+ refreshRv();
+ } else {
+ note.setNoteContent(content);
+ note.setModifiedTime(modifiedTime);
+ note.save();
+ mAdapter.notifyItemChanged(position);
+ }
+ }
+
+ @Override
+ public void putNoteToPrivacy() {
+
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ // 如果当前便签夹是私密便签夹,则执行移除私密操作,否则,执行添加私密操作
+ if (Constans.currentFolder == FolderListConstans.ITEM_PRIMARY) {
+ mView.showLoading("移除中...");
+ } else {
+ mView.showLoading("添加中...");
+ }
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ for (int i = mAdapter.mCheckList.size() - 1; i >= 0; i--) {
+ if (mAdapter.mCheckList.get(i)) {
+ toPrivacy(i);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ refreshRv();
+ cancelMultiSelectAction();
+ }
+ }.execute();
+
+ }
+
+ private void toPrivacy(int position) {
+ Note note = mAdapter.getData().get(position);
+ if (mAdapter.mAllDataList != null) {
+ mAdapter.mAllDataList.remove(note);
+ }
+
+ mAdapter.getData().remove(position);
+ mAdapter.mCheckList.remove(position);
+
+ // 如果当前便签夹是私密便签夹,则执行移除私密操作,否则,执行添加私密操作
+ if (Constans.currentFolder == FolderListConstans.ITEM_PRIMARY) {
+ note.setIsPrivacy(0);
+ mFolderListPresenter.removePrivacyNote(note);
+ } else {
+ note.setIsPrivacy(1);
+ mFolderListPresenter.removeNoteForFolder(note);
+ }
+ note.save();
+ }
+
+ @Override
+ public void deleteNotes() {
+
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("删除中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ for (int i = mAdapter.mCheckList.size() - 1; i >= 0; i--) {
+ if (mAdapter.mCheckList.get(i)) {
+ Note note = mAdapter.getData().get(i);
+ removeNote(i);
+ deleteNote(note, false);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+
+ refreshRv();
+ cancelMultiSelectAction();
+ }
+ }.execute();
+
+ }
+
+ private void removeNote(int position) {
+ if (mAdapter.mAllDataList != null) { // 如果已进入搜索模式
+ mAdapter.mAllDataList.remove(mAdapter.getData().get(position));
+ }
+ Note note = mAdapter.getData().get(position);
+ mAdapter.getData().remove(position); // 从Adapter的数据中删除
+ mAdapter.mCheckList.remove(position);
+
+ mFolderListPresenter.removeNoteForFolder(note); // 从便签夹中移除
+ }
+
+ /**
+ * @param isRealDelete 是否是永久删除(不指定的话,根据便签夹进行判断)
+ * @describe
+ */
+ private void deleteNote(Note note, boolean isRealDelete) {
+
+ // 删除操作
+ if (isRealDelete || Constans.currentFolder == FolderListConstans.ITEM_RECYCLE) { // 当前便签夹是废纸篓,则直接永久删除
+ deleteFile(note.getNoteId());
+ note.delete();
+ } else {
+ if (Constans.isUseRecycleBin) { // 已启用废纸篓
+ toRecycleBin(note);
+ } else { // 已关闭废纸篓
+ note.delete();
+ deleteFile(note.getNoteId());
+ }
+ }
+ }
+
+ private void deleteFile(String mNoteId) {
+ File file = Utils.getContext().getExternalFilesDir(mNoteId);
+ if (file.exists()) {
+ FileUtils.deleteDir(file);
+ }
+ }
+
+ private void toRecycleBin(Note note) {
+ note.setInRecycleBin(1);
+ note.save();
+ }
+
+ @Override
+ public void moveNotes() {
+
+ // 如果是废纸篓,则执行恢复操作
+ if (Constans.currentFolder == FolderListConstans.ITEM_RECYCLE) {
+ recoverNotes();
+ } else {
+ mView.showMoveBottomSheet();
+ }
+ }
+
+ private void recoverNotes() {
+
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("恢复中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ for (int i = mAdapter.mCheckList.size() - 1; i >= 0; i--) {
+ if (mAdapter.mCheckList.get(i)) {
+ recoverNote(i);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ refreshRv();
+ cancelMultiSelectAction();
+ }
+ }.execute();
+
+ }
+
+ @Override
+ public void recoverNote(int position) {
+ Note note = mAdapter.getData().get(position);
+ if (mAdapter.mAllDataList != null) {
+ mAdapter.mAllDataList.remove(note);
+ }
+ mAdapter.getData().remove(position);
+ mAdapter.mCheckList.remove(position);
+ mFolderListPresenter.recoverNote(note);
+ }
+
+ @Override
+ public void moveNotesToFolder(final NoteFolder noteFolder) {
+
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoading("移动中...");
+ }
+
+ @Override
+ protected Boolean doInBackground(String... params) {
+ for (int i = mAdapter.mCheckList.size() - 1; i >= 0; i--) {
+ if (mAdapter.mCheckList.get(i)) {
+ moveNote(i, noteFolder);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean aBoolean) {
+ mView.unShowLoading();
+ int count = NoteListConstans.selectedCount;
+ cancelMultiSelectAction();
+ refreshRv();
+ mView.showSnackbar("已将" + count + "条便签移动到" + noteFolder.getFolderName());
+ }
+ }.execute();
+
+ }
+
+ private void moveNote(int notePos, NoteFolder noteFolder) {
+ Note note = mAdapter.getData().get(notePos);
+ // 如果当前便签为全部便签,则不用从当前NoteRv中移除
+ if (Constans.currentFolder == FolderListConstans.ITEM_ALL) {
+ mFolderListPresenter.moveNoteToFolder(note, noteFolder);
+ } else {
+ if (noteFolder.getId() != mFolderListPresenter.getCurrentFolderId()) {
+ if (mAdapter.mAllDataList != null) {
+ mAdapter.mAllDataList.remove(note);
+ }
+ mAdapter.getData().remove(notePos);
+ mAdapter.mCheckList.remove(notePos);
+
+ mFolderListPresenter.moveNoteToFolder(note, noteFolder);
+
+ }
+ }
+ }
+
+ @Override
+ public List getFolderDataList() {
+ return mFolderListPresenter.getFoldersForAdapter();
+ }
+
+ @Override
+ public void choiceNote(int position) {
+ boolean isChoice = mAdapter.mCheckList.get(position);
+ if (isChoice) {
+ setNoteSelectedCount(getNoteSelectedCount() - 1);
+ } else {
+ setNoteSelectedCount(getNoteSelectedCount() + 1);
+ }
+ mAdapter.mCheckList.set(position, !isChoice);
+ mAdapter.notifyItemChanged(position);
+ showSelectedNoteCount();
+ }
+
+
+ @Override
+ public void showSelectedNoteCount() {
+ mView.showChoiceNotesCount(NoteListConstans.selectedCount + "");
+ }
+
+ @Override
+ public void showCurrentFolderName() {
+ mView.showCurrentNoteFolderName(NoteListConstans.selectedFolderName);
+ }
+
+ @Override
+ public void onNoteRvClick(int position) {
+ if (isShowMultiSelectAction()) {
+ choiceNote(position);
+ } else {
+ if (Constans.currentFolder == FolderListConstans.ITEM_RECYCLE) {
+ mView.showNoteRecoverDialog(position);
+ } else {
+ mView.toEditNoteForEdit(mAdapter.getData().get(position), position);
+ }
+ }
+ }
+
+ @Override
+ public void initNoteRvLayoutManager() {
+ if (Constans.noteListShowMode == NoteListConstans.STYLE_LINEAR) {
+ mView.changeNoteRvLayoutManager(new LinearLayoutManager(MainApplication.mContext));
+ } else {
+ mView.changeNoteRvLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
+ }
+ }
+
+ @Override
+ public void initShowModeMenuIcon(MenuItem item) {
+ if (Constans.noteListShowMode == NoteListConstans.STYLE_LINEAR) {
+ item.setIcon(MainApplication.mContext.getResources().getDrawable(NoteListConstans.MODE_GRID));
+ } else {
+ item.setIcon(MainApplication.mContext.getResources().getDrawable(NoteListConstans.MODE_LIST));
+ }
+ }
+
+
+ @Override
+ public void changeNoteRvLayoutManagerAndMenuIcon(MenuItem item) {
+
+ if (Constans.noteListShowMode == NoteListConstans.STYLE_LINEAR) {
+ CacheManager.setAndSaveNoteListShowMode(NoteListConstans.STYLE_GRID);
+ mView.changeNoteRvLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
+ item.setIcon(MainApplication.mContext.getResources().getDrawable(NoteListConstans.MODE_LIST));
+ } else {
+ CacheManager.setAndSaveNoteListShowMode(NoteListConstans.STYLE_LINEAR);
+ mView.changeNoteRvLayoutManager(new LinearLayoutManager(MainApplication.mContext));
+ item.setIcon(MainApplication.mContext.getResources().getDrawable(NoteListConstans.MODE_GRID));
+ }
+ }
+
+ @Override
+ public void doMultiSelectActionAndChoiceThisItem(int position) {
+ if (!NoteListConstans.isShowMultiSelectAction) {
+ NoteListConstans.isShowMultiSelectAction = true;
+ // 更新toolbar菜单
+ mView.updateOptionMenu();
+ // 隐藏添加按钮
+ mView.hideAddFab();
+ // 显示BottomBar
+ mView.showBottomBar();
+ // 设置三个按钮的可使用性
+ mView.setCheckMenuEnable();
+ // 设置三个按钮
+ setCheckMenuForFolderType();
+ // 选中当前便签
+ choiceNote(position);
+ // 显示已选中的数量
+ mView.showChoiceNotesCount(NoteListConstans.selectedCount + "");
+ // 刷新便签RecyclerView
+ refreshRv();
+ }
+ }
+
+
+ private void setCheckMenuForFolderType() {
+ switch (Constans.currentFolder) {
+ case FolderListConstans.ITEM_PRIMARY:
+ mView.setCheckMenuForPrivacy();
+ break;
+ case FolderListConstans.ITEM_RECYCLE:
+ mView.setCheckMenuForRecycleBin();
+ break;
+ default:
+ mView.setCheckMenuForAllAndNormal();
+ break;
+ }
+ }
+
+ @Override
+ public void cancelMultiSelectAction() {
+ if (NoteListConstans.isShowMultiSelectAction) {
+ NoteListConstans.isShowMultiSelectAction = false;
+ // 更新toolbar菜单
+ mView.updateOptionMenu();
+ // 隐藏BottomBar
+ mView.hideBottomBar();
+ // 将所有便签的选中状态设为false
+ unChoiceAllNote();
+ // 显示已选中的便签夹名称
+ mView.showCurrentNoteFolderName(NoteListConstans.selectedFolderName);
+ // 刷新便签RecyclerView
+ refreshRv();
+ // 显示添加按钮
+ mView.showAddFab();
+ }
+ }
+
+ @Override
+ public boolean isShowMultiSelectAction() {
+ return NoteListConstans.isShowMultiSelectAction;
+ }
+
+ @Override
+ public void doChoiceAllNote() {
+ if (NoteListConstans.isChoiceAll) {
+ unChoiceAllNote();
+ } else {
+ choiceAllNote();
+ }
+ }
+
+ @Override
+ public void setInSearch() {
+ mView.hideAddFab();
+ NoteListConstans.isInSearch = true;
+ }
+
+ @Override
+ public void setOutSearch() {
+ mView.showAddFab();
+ NoteListConstans.isInSearch = false;
+ }
+
+ /*---------------------------------------------------------------------------------------*/
+
+ public void setFilter(String text) {
+ if (mAdapter.mAllDataList == null) {
+ mAdapter.mAllDataList = new ArrayList();
+ mAdapter.mAllDataList.addAll(mAdapter.getData());
+ }
+ if (mAdapter.mAllCheckList == null) {
+ mAdapter.mAllCheckList = new ArrayList();
+ mAdapter.mAllCheckList.addAll(mAdapter.mCheckList);
+ }
+
+ mAdapter.getData().clear();
+ mAdapter.mCheckList.clear();
+// 转换为小写
+ String lowerCaseQuery = text.toLowerCase();
+ // 此处使用倒叙进行检索,这样搜索出来的顺序是正序
+ for (int i = mAdapter.mAllDataList.size() - 1; i >= 0; i--) {
+ if (mAdapter.mAllDataList.get(i).getNoteContent().toLowerCase().contains(lowerCaseQuery)) {
+ mAdapter.addData(mAdapter.mAllDataList.get(i));
+ }
+ }
+ mAdapter.notifyDataSetChanged();
+ }
+
+ public void cancelFilter() {
+ NoteListConstans.isInSearch = false;
+ if (mAdapter.mAllDataList != null || mAdapter.mAllCheckList != null) {
+ mAdapter.getData().clear();
+ mAdapter.mCheckList.clear();
+ mAdapter.setNewData(mAdapter.mAllDataList);
+ for (int i = 0; i < mAdapter.mAllDataList.size(); i++) {
+ mAdapter.mCheckList.add(false);
+ }
+ mAdapter.mAllDataList = null;
+ mAdapter.mAllCheckList = null;
+ mAdapter.notifyDataSetChanged();
+ }
+ }
+
+ public int getNoteSelectedCount() {
+ return NoteListConstans.selectedCount;
+ }
+
+ public void setNoteSelectedCount(int count) {
+ NoteListConstans.selectedCount = count;
+ setChoiceAllState();
+ setBottomMenuEnable();
+ }
+
+ private void setChoiceAllState() {
+ if (NoteListConstans.selectedCount == mAdapter.getData().size()) {
+ NoteListConstans.isChoiceAll = true;
+ } else {
+ NoteListConstans.isChoiceAll = false;
+ }
+ }
+
+
+ private void setBottomMenuEnable() {
+ if (NoteListConstans.selectedCount > 0) {
+ mView.setCheckMenuEnable();
+ } else {
+ mView.setCheckMenuUnEnable();
+ }
+ }
+
+ public void choiceAllNote() {
+ NoteListConstans.isChoiceAll = true;
+ for (int i = 0; i < mAdapter.mCheckList.size(); i++) {
+ mAdapter.mCheckList.set(i, true);
+ }
+ setNoteSelectedCount(mAdapter.mCheckList.size());
+ mAdapter.notifyDataSetChanged();
+
+ showSelectedNoteCount();
+ }
+
+ public void unChoiceAllNote() {
+ NoteListConstans.isChoiceAll = false;
+ for (int i = 0; i < mAdapter.mCheckList.size(); i++) {
+ mAdapter.mCheckList.set(i, false);
+ }
+ setNoteSelectedCount(0);
+ mAdapter.notifyDataSetChanged();
+
+ showSelectedNoteCount();
+ }
+
+ public void uncertainChoiceNote(int position) {
+ boolean isChoice = mAdapter.mCheckList.get(position);
+ if (isChoice) {
+ setNoteSelectedCount(getNoteSelectedCount() - 1);
+ } else {
+ setNoteSelectedCount(getNoteSelectedCount() + 1);
+ }
+ mAdapter.mCheckList.set(position, !isChoice);
+ mAdapter.notifyItemChanged(position);
+ }
+
+ public void refreshRv() {
+ mAdapter.notifyDataSetChanged();
+ mFolderListPresenter.refreshFolderList();
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ com.orhanobut.logger.Logger.d("requestCode=" + requestCode + " resultCode=" + resultCode);
+ switch (requestCode) {
+ case NoteListConstans.REQUEST_CODE_LOCK:
+ resultForLock(resultCode);
+ break;
+ case NoteListConstans.REQUEST_CODE_ADD:
+ resultForAddNote(resultCode, data);
+ break;
+ case NoteListConstans.REQUEST_CODE_EDIT:
+ resultForEditNote(resultCode, data);
+ break;
+ case NoteListConstans.REQUEST_CODE_EDIT_FOLDER:
+ resultForEditFolder(resultCode, data);
+ break;
+ }
+ }
+
+ @Override
+ public void logCheckList() {
+ for (int i = mAdapter.mCheckList.size() - 1; i >= 0; i--) {
+ Logger.d("lllll" + mAdapter.mCheckList.get(i) + " " + i);
+
+ }
+ }
+
+ private void resultForLock(int resultCode) {
+ if (resultCode == RESULT_OK) {
+ showPrivacyNote(true);
+ }
+ }
+
+ private void resultForAddNote(int resultCode, Intent data) {
+ if (resultCode == RESULT_OK) {
+ String noteId = data.getStringExtra("note_id");
+ String content = data.getStringExtra("note_content");
+ long modifiedTime = data.getLongExtra("modified_time", 0);
+ addNote(noteId, content, modifiedTime);
+ }
+ }
+
+ private void resultForEditNote(int resultCode, Intent data) {
+ if (resultCode == RESULT_OK) {
+ int position = data.getIntExtra("position", 0);
+ String content = data.getStringExtra("note_content");
+ long modifiedTime = data.getLongExtra("modified_time", 0);
+ updateNote(position, content, modifiedTime);
+ }
+ }
+
+ private void resultForEditFolder(int resultCode, Intent data) {
+ if (resultCode == RESULT_OK) {
+ boolean isCurrentFolderDeleted = data.getBooleanExtra("is_current_folder_deleted", false);
+ if (isCurrentFolderDeleted) {
+ Constans.currentFolder = FolderListConstans.ITEM_ALL;
+ }
+ start();
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/share/ISharePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/share/ISharePresenter.java
new file mode 100644
index 0000000..04a5e6b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/share/ISharePresenter.java
@@ -0,0 +1,54 @@
+package com.bigbig.ding.module.notes.share;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ISharePresenter {
+
+ /**
+ * 获取图片
+ */
+ Bitmap getBitmap();
+
+ /**
+ * 分享图片
+ */
+ void sendBitmap();
+
+ /**
+ * 保存图片
+ */
+ void saveImage();
+
+ /**
+ * 保存图片 并获取Uri
+ */
+ Uri saveImageAndGetUri();
+
+ /**
+ * Activity 返回
+ */
+ void onActivityResult(int requestCode, int resultCode, Intent data);
+
+ /**
+ * 申请权限返回
+ */
+ void onRequestPermissionResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults);
+
+ /**
+ * 回收图片等操作
+ */
+ void onDestroy();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/share/IShareView.java b/app/src/main/java/com/bigbig/ding/module/notes/share/IShareView.java
new file mode 100644
index 0000000..5c2a7a0
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/share/IShareView.java
@@ -0,0 +1,33 @@
+package com.bigbig.ding.module.notes.share;
+
+import android.app.Activity;
+import android.net.Uri;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IShareView {
+
+ Activity getActivity();
+
+ /**
+ * 显示分享Dialog
+ */
+ void showShareDialog(Uri uri);
+
+ /**
+ * 前往应用设置Dialog
+ */
+ void showToAppSettingDialog();
+
+ void showLoadingDialog(String message);
+
+ void unShowLoadingDialog();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/share/ShareActivity.java b/app/src/main/java/com/bigbig/ding/module/notes/share/ShareActivity.java
new file mode 100644
index 0000000..d594571
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/share/ShareActivity.java
@@ -0,0 +1,141 @@
+package com.bigbig.ding.module.notes.share;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.support.v7.app.AlertDialog;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.bigbig.ding.R;
+import com.github.chrisbanes.photoview.PhotoView;
+
+import com.bigbig.ding.constants.EditNoteConstans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.utils.PermissionUtils;
+import com.bigbig.ding.utils.ProgressDialogUtils;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class ShareActivity extends BaseActivity implements IShareView {
+
+ @BindView(R.id.iv_share_preview)
+ PhotoView mIv;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_share;
+ }
+
+ @Override
+ protected SharePresenter initPresenter() {
+ SharePresenter presenter=new SharePresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle("预览");
+ mIv.setImageBitmap(mPresenter.getBitmap());
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_share, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ case R.id.menu_share_send:
+ mPresenter.sendBitmap();
+ break;
+ case R.id.menu_share_save:
+ mPresenter.saveImage();
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ mPresenter.onRequestPermissionResult(requestCode,permissions,grantResults);
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ @Override
+ public Activity getActivity() {
+ return this;
+ }
+
+ @Override
+ public void showShareDialog(Uri uri) {
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND);//设置分享行为
+ intent.setType("image/*");//设置分享内容的类型
+ intent.putExtra(Intent.EXTRA_STREAM, uri);
+ intent = Intent.createChooser(intent, "分享");
+ startActivity(intent);
+ }
+
+ @Override
+ public void showToAppSettingDialog() {
+ new AlertDialog.Builder(mContext)
+ .setTitle("权限设置")
+ .setMessage("您已禁止应用的储存权限,请前往应用设置中开启")
+ .setPositiveButton("前往",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ PermissionUtils.toAppSetting(mContext);
+ }
+ })
+ .setNegativeButton("取消", null)
+ .show();
+ }
+
+ private ProgressDialogUtils mProgressDialog=new ProgressDialogUtils(this);
+ @Override
+ public void showLoadingDialog(String message) {
+ mProgressDialog.show(message);
+ }
+
+ @Override
+ public void unShowLoadingDialog() {
+ mProgressDialog.hide();
+ }
+
+ @Override
+ protected void onDestroy() {
+ EditNoteConstans.shareBitmap.recycle();
+ EditNoteConstans.shareBitmap=null;
+ mPresenter.onDestroy();
+ super.onDestroy();
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/notes/share/SharePresenter.java b/app/src/main/java/com/bigbig/ding/module/notes/share/SharePresenter.java
new file mode 100644
index 0000000..678dc35
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/notes/share/SharePresenter.java
@@ -0,0 +1,145 @@
+package com.bigbig.ding.module.notes.share;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.support.annotation.NonNull;
+
+import com.blankj.utilcode.util.ImageUtils;
+import com.blankj.utilcode.util.TimeUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.constants.EditNoteConstans;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.utils.PermissionUtils;
+
+import java.io.File;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class SharePresenter extends BasePresenter implements ISharePresenter {
+
+ private final String PERMISSION_STORAGE = Manifest.permission.WRITE_EXTERNAL_STORAGE;
+
+ private final int REQUEST_PERMISSION_CODE_SAVE = 1;
+
+ private Bitmap mBitmap = EditNoteConstans.shareBitmap;
+
+ @Override
+ public Bitmap getBitmap() {
+ return mBitmap;
+ }
+
+ @Override
+ public void sendBitmap() {
+ shareBitmap();
+ }
+
+ private void shareBitmap(){
+ new AsyncTask() {
+
+ @Override
+ protected void onPreExecute() {
+ mView.showLoadingDialog("加载中...");
+ }
+
+ @Override
+ protected Uri doInBackground(String... params) {
+ Uri uri = saveImageAndGetUri();
+ return uri;
+ }
+
+ @Override
+ protected void onPostExecute(Uri uri) {
+ mView.unShowLoadingDialog();
+ mView.showShareDialog(uri);
+ }
+ }.execute();
+ }
+
+ @Override
+ public void saveImage() {
+ final Activity activity = mView.getActivity();
+ PermissionUtils.checkPermission(activity, PERMISSION_STORAGE, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ saveImageToLocation(mBitmap);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ saveImageToLocation(mBitmap);
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ PermissionUtils.requestPermission(activity, PERMISSION_STORAGE, REQUEST_PERMISSION_CODE_SAVE);
+ }
+ });
+ }
+
+ @Override
+ public Uri saveImageAndGetUri() {
+ String filePath = mView.getActivity().getExternalFilesDir("share").getPath() + "/" + TimeUtils.getNowMills() + ".jpg";
+ File file = new File(filePath);
+ ImageUtils.save(mBitmap, file, Bitmap.CompressFormat.JPEG);
+ return Uri.fromFile(file);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ }
+
+ @Override
+ public void onRequestPermissionResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ switch (requestCode) {
+ case REQUEST_PERMISSION_CODE_SAVE:
+ requestPermissionForSaveImageResult(grantResults);
+ break;
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+ mBitmap.recycle();
+ mBitmap = null;
+ }
+
+ private void requestPermissionForSaveImageResult(@NonNull int[] grantResults) {
+ final Activity activity = mView.getActivity();
+ PermissionUtils.onRequestPermissionResult(activity, PERMISSION_STORAGE, grantResults, new PermissionUtils.PermissionCheckCallBack() {
+ @Override
+ public void onHasPermission() {
+ saveImage();
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDown(String... permission) {
+ ToastUtils.showShort("保存失败");
+ }
+
+ @Override
+ public void onUserHasAlreadyTurnedDownAndDontAsk(String... permission) {
+ mView.showToAppSettingDialog();
+ }
+ });
+ }
+
+ private void saveImageToLocation(Bitmap bitmap) {
+ File file = new File(Constans.imageSaveFolder + "/" + TimeUtils.getNowMills() + ".jpg");
+ ImageUtils.save(bitmap, file, Bitmap.CompressFormat.JPEG);
+ ToastUtils.showLong("已保存至" + "/SuperNote/Image/" + "中");
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/about/AppAboutActivity.java b/app/src/main/java/com/bigbig/ding/module/setting/about/AppAboutActivity.java
new file mode 100644
index 0000000..e661405
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/about/AppAboutActivity.java
@@ -0,0 +1,128 @@
+package com.bigbig.ding.module.setting.about;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+import android.view.MenuItem;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.AppUtils;
+
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.utils.AliPayUtils;
+import butterknife.BindView;
+
+/**
+ * Created by miaoyongyong on 2017/2/19.
+ */
+
+public class AppAboutActivity extends BaseActivity {
+
+ @BindView(R.id.tv_about_versions)
+ TextView tvVersions;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_about;
+ }
+
+ @Override
+ protected BasePresenter initPresenter() {
+ return null;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setTitle("关于");
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getFragmentManager().beginTransaction().replace(R.id.frame_about_content, new AboutPreferenceFragment()).commit();
+ initVersions();
+ }
+
+ private void initVersions() {
+ String versions = AppUtils.getAppVersionName();
+ tvVersions.setText("V " + versions);
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+
+ public static class AboutPreferenceFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
+
+ private PreferenceScreen mToAlipay;
+ private PreferenceScreen mCheckVersion;
+ private PreferenceScreen mToMarket;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.pref_about);
+ initView();
+ }
+
+ private void initView() {
+ mCheckVersion = (PreferenceScreen) findPreference("check_version");
+ mToMarket = (PreferenceScreen) findPreference("to_market");
+
+ mCheckVersion.setOnPreferenceClickListener(this);
+ mToMarket.setOnPreferenceClickListener(this);
+ }
+
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ if (preference.getKey().equals(getString(R.string.about_key_to_alipay))) {
+ toAlipay();
+ } else if (preference.getKey().equals(getString(R.string.about_key_to_market))) {
+ toMarket();
+ } else if (preference.getKey().equals(getString(R.string.about_key_check_version))) {
+ checkVersion();
+ }
+ return true;
+ }
+
+ private void toAlipay() {
+ AliPayUtils.openAliPay2Pay(getActivity(), Constans.myAlipayQRContent);
+ }
+
+ private void toMarket() {
+ String uri = "market://details?id=" + getActivity().getPackageName();
+ openUri(getActivity(), uri);
+ }
+
+ private void checkVersion() {
+ toMarket();
+ }
+
+ /**
+ * 发送一个intent
+ *
+ * @param context
+ * @param s
+ */
+ private static void openUri(Context context, String s) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
+ context.startActivity(intent);
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperActivity.java b/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperActivity.java
new file mode 100644
index 0000000..aad0106
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperActivity.java
@@ -0,0 +1,120 @@
+package com.bigbig.ding.module.setting.developer;
+
+import android.app.Activity;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.module.base.BaseActivity;
+import butterknife.BindView;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class DeveloperActivity extends BaseActivity implements IDeveloperView, View.OnLongClickListener {
+
+ @BindView(R.id.ll_developer_github)
+ LinearLayout mLlToGitHub;
+
+ @BindView(R.id.ll_developer_blog)
+ LinearLayout mLlToBlog;
+
+// @BindView(R.id.ll_developer_jianshu)
+// LinearLayout mLlToJianShu;
+
+ @BindView(R.id.ll_developer_email)
+ LinearLayout mLlEmail;
+
+
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_developer;
+ }
+
+ @Override
+ protected DeveloperPresenter initPresenter() {
+ DeveloperPresenter presenter=new DeveloperPresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle("关于开发者");
+
+ mLlToGitHub.setOnLongClickListener(this);
+ mLlToBlog.setOnLongClickListener(this);
+// mLlToJianShu.setOnLongClickListener(this);
+ mLlEmail.setOnLongClickListener(this);
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ public void onClick(View view){
+ switch (view.getId()){
+ case R.id.ll_developer_github:
+ mPresenter.openGithub();
+ break;
+ case R.id.ll_developer_blog:
+ mPresenter.openBlog();
+ break;
+// case R.id.ll_developer_jianshu:
+// mPresenter.openJianShu();
+// break;
+ case R.id.ll_developer_email:
+ mPresenter.copyEmail();
+ break;
+ case R.id.ll_developer_to_alipay:
+ mPresenter.toAlipay();
+ break;
+ }
+ }
+
+ @Override
+ public boolean onLongClick(View v) {
+ switch (v.getId()){
+ case R.id.ll_developer_github:
+ mPresenter.copyGithub();
+ break;
+ case R.id.ll_developer_blog:
+ mPresenter.copyBlog();
+ break;
+// case R.id.ll_developer_jianshu:
+// mPresenter.copyJianShu();
+// break;
+ case R.id.ll_developer_email:
+ mPresenter.copyEmail();
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ public Activity getActivity() {
+ return this;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperPresenter.java
new file mode 100644
index 0000000..3cd2052
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/developer/DeveloperPresenter.java
@@ -0,0 +1,83 @@
+package com.bigbig.ding.module.setting.developer;
+
+import android.content.Intent;
+import android.net.Uri;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.ClipboardUtils;
+import com.blankj.utilcode.util.ToastUtils;
+
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.utils.AliPayUtils;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class DeveloperPresenter extends BasePresenter implements IDeveloperPresenter{
+ @Override
+ public void openGithub() {
+ String uri=mView.getActivity().getResources().getString(R.string.github);
+ openUri(uri);
+ }
+
+ private void openUri(String uri){
+ Intent intent = new Intent();
+ intent.setAction("android.intent.action.VIEW");
+ Uri content_url = Uri.parse(uri);
+ intent.setData(content_url);
+ mView.getActivity().startActivity(intent);
+ }
+
+ @Override
+ public void openBlog() {
+ String uri=mView.getActivity().getResources().getString(R.string.csdn);
+ openUri(uri);
+ }
+
+ @Override
+ public void openJianShu() {
+ String uri=mView.getActivity().getResources().getString(R.string.jian_shu);
+ openUri(uri);
+ }
+
+ @Override
+ public void toAlipay() {
+ String alipayQrCode=mView.getActivity().getResources().getString(R.string.alipay_qr_code);
+ AliPayUtils.openAliPay2Pay(mView.getActivity(),alipayQrCode);
+ }
+
+ @Override
+ public void copyGithub() {
+ String uri=mView.getActivity().getResources().getString(R.string.github);
+ ClipboardUtils.copyText(uri);
+ ToastUtils.showShort("已复制");
+ }
+
+ @Override
+ public void copyBlog() {
+ String uri=mView.getActivity().getResources().getString(R.string.csdn);
+ ClipboardUtils.copyText(uri);
+ ToastUtils.showShort("已复制");
+ }
+
+ @Override
+ public void copyJianShu() {
+ String uri=mView.getActivity().getResources().getString(R.string.jian_shu);
+ ClipboardUtils.copyText(uri);
+ ToastUtils.showShort("已复制");
+ }
+
+ @Override
+ public void copyEmail() {
+ String uri=mView.getActivity().getResources().getString(R.string.my_email);
+ ClipboardUtils.copyText(uri);
+ ToastUtils.showShort("已复制");
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperPresenter.java
new file mode 100644
index 0000000..d77cd4e
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperPresenter.java
@@ -0,0 +1,31 @@
+package com.bigbig.ding.module.setting.developer;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IDeveloperPresenter {
+
+ void openGithub();
+
+ void openBlog();
+
+ void openJianShu();
+
+ void toAlipay();
+
+ void copyGithub();
+
+ void copyBlog();
+
+ void copyJianShu();
+
+ void copyEmail();
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperView.java b/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperView.java
new file mode 100644
index 0000000..52bf31a
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/developer/IDeveloperView.java
@@ -0,0 +1,18 @@
+package com.bigbig.ding.module.setting.developer;
+
+import android.app.Activity;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IDeveloperView {
+
+ Activity getActivity();
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackActivity.java b/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackActivity.java
new file mode 100644
index 0000000..c9c347b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackActivity.java
@@ -0,0 +1,136 @@
+package com.bigbig.ding.module.setting.feedback;
+
+import android.app.ProgressDialog;
+import android.text.TextUtils;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.ClipboardUtils;
+import com.blankj.utilcode.util.SpanUtils;
+import com.blankj.utilcode.util.ToastUtils;
+
+import com.bigbig.ding.module.base.BaseActivity;
+import butterknife.BindView;
+
+
+/**
+ * Created by miaoyongyong on 2017/2/20.
+ */
+
+public class FeedbackActivity extends BaseActivity
+ implements IFeedbackView, View.OnClickListener {
+
+ @BindView(R.id.edit_feedback_content)
+ EditText mEtContent;
+
+ @BindView(R.id.edit_feedback_contact)
+ EditText mEtContact;
+
+ @BindView(R.id.tv_feedback_tip)
+ TextView mTvTip;
+
+ private ProgressDialog mProgressDialog;
+
+ @Override
+ protected void initBeforeSetContentView() {
+ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
+ }
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_feedback;
+ }
+
+ @Override
+ protected FeedbackPresenter initPresenter() {
+ FeedbackPresenter presenter=new FeedbackPresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle("反馈");
+
+ mTvTip.setText(new SpanUtils().append("你也可直接发邮件至")
+ .append(mContext.getResources().getString(R.string.my_email))
+ .setBold()
+ .append("(点击复制)")
+ .create());
+ mTvTip.setOnClickListener(this);
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.menu_feedback, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ case R.id.menu_feedback_commit:
+ submitFeedback();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void submitFeedback(){
+ if(TextUtils.isEmpty(mEtContent.getText())){
+ ToastUtils.showShort("请至少填写反馈内容");
+ }else {
+ sendFeedback();
+ }
+ }
+
+ private void sendFeedback(){
+ String content=mEtContent.getText().toString();
+ String contact=mEtContact.getText().toString();
+ mPresenter.sendFeedback(content,contact);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()){
+ case R.id.tv_feedback_tip:
+ copyEmail();
+ break;
+ }
+ }
+
+ private void copyEmail(){
+ ClipboardUtils.copyText(mContext.getResources().getString(R.string.my_email));
+ ToastUtils.showShort("已复制");
+ }
+
+ @Override
+ public void showLoading() {
+ if (mProgressDialog == null) {
+ mProgressDialog = new ProgressDialog(this);
+ }
+ mProgressDialog.setMessage("提交中...");
+ mProgressDialog.show();
+ }
+
+ @Override
+ public void cancleLoading() {
+ if (mProgressDialog != null) {
+ mProgressDialog.cancel();
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackPresenter.java
new file mode 100644
index 0000000..645af88
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/feedback/FeedbackPresenter.java
@@ -0,0 +1,69 @@
+package com.bigbig.ding.module.setting.feedback;
+
+import android.text.TextUtils;
+
+import com.blankj.utilcode.util.AppUtils;
+import com.blankj.utilcode.util.DeviceUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.bigbig.ding.bmob.Feedback;
+import com.bigbig.ding.module.base.BasePresenter;
+
+import cn.bmob.v3.exception.BmobException;
+import cn.bmob.v3.listener.SaveListener;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/29
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class FeedbackPresenter extends BasePresenter implements IFeedbackPresenter{
+
+ private String mLastContent="",mLastContact="";
+
+ @Override
+ public void sendFeedback(final String content, final String contact) {
+
+ if(TextUtils.isEmpty(content)){
+ ToastUtils.showShort("请至少填写反馈内容");
+ return;
+ }
+ if(content.equals(mLastContent) && contact.equals(mLastContact)){
+ ToastUtils.showShort("请不要重复提交");
+ return;
+ }
+
+ Feedback feedback=getFeedback(content,contact);
+ mView.showLoading();
+ feedback.save(new SaveListener() {
+ @Override
+ public void done(String s, BmobException e) {
+ sendBack(e,content,contact);
+ }
+ });
+ }
+
+ private Feedback getFeedback(String content,String contact){
+ Feedback feedback=new Feedback();
+ feedback.setContent(content);
+ feedback.setContact(contact);
+ feedback.setSdk(DeviceUtils.getSDKVersion());
+ feedback.setVersion(AppUtils.getAppVersionName());
+ return feedback;
+ }
+
+ private void sendBack(BmobException e,String content,String contact){
+ mView.cancleLoading();
+ if(e==null){
+ mLastContent=content;
+ mLastContact=contact;
+ ToastUtils.showShort("提交成功");
+ } else{
+ ToastUtils.showShort("提交失败");
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackPresenter.java
new file mode 100644
index 0000000..561d404
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackPresenter.java
@@ -0,0 +1,16 @@
+package com.bigbig.ding.module.setting.feedback;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/29
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFeedbackPresenter {
+
+ void sendFeedback(String content,String contact);
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackView.java b/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackView.java
new file mode 100644
index 0000000..bbc0031
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/feedback/IFeedbackView.java
@@ -0,0 +1,19 @@
+package com.bigbig.ding.module.setting.feedback;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/29
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface IFeedbackView {
+
+ void showLoading();
+
+ void cancleLoading();
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/lock/LockSettingActivity.java b/app/src/main/java/com/bigbig/ding/module/setting/lock/LockSettingActivity.java
new file mode 100644
index 0000000..1df946f
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/lock/LockSettingActivity.java
@@ -0,0 +1,122 @@
+package com.bigbig.ding.module.setting.lock;
+
+import android.app.ActivityOptions;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+import android.view.MenuItem;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.module.base.BasePresenter;
+import com.bigbig.ding.module.lock.modification.LockModificationActivity;
+import com.bigbig.ding.module.lock.verification.LockActivity;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/29
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LockSettingActivity extends BaseActivity {
+
+ public static final int REQUEST_TO_LOCK = 1;
+
+ public static final int REQUEST_TO_MODIFY_LOCK = 2;
+
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_lock_setting;
+ }
+
+ @Override
+ protected BasePresenter initPresenter() {
+ return null;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setTitle("隐私密码");
+ getFragmentManager().beginTransaction().replace(R.id.frame_lock_setting_content, new LockSettingFragment()).commit();
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ switch (id) {
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ switch (requestCode) {
+ case REQUEST_TO_LOCK:
+ if(resultCode==RESULT_OK){
+ Intent intent = new Intent();
+ intent.setClass(mContext, LockModificationActivity.class);
+ startActivity(intent);
+ }
+ break;
+
+ }
+ }
+
+ public static class LockSettingFragment extends PreferenceFragment implements Preference.OnPreferenceClickListener {
+
+ PreferenceScreen mPreLock;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.pref_lock);
+ mPreLock=(PreferenceScreen)findPreference("modify_lock");
+ mPreLock.setOnPreferenceClickListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ toLockActivity();
+ return true;
+ }
+
+ private void toLockActivity() {
+ Intent intent = new Intent();
+ if (Constans.isLocked) {
+ intent.setClass(getActivity(), LockActivity.class);
+ startActivityForAnim(intent,REQUEST_TO_LOCK);
+ } else {
+ intent.setClass(getActivity(), LockModificationActivity.class);
+ getActivity().startActivityForResult(intent, REQUEST_TO_MODIFY_LOCK);
+ }
+ }
+
+ private void startActivityForAnim(Intent intent,int requestCode){
+ // 5.0及以上则使用Activity动画
+ if(Build.VERSION.SDK_INT>=21){
+ Bundle bundle= ActivityOptions.makeSceneTransitionAnimation(getActivity()).toBundle();
+ getActivity().startActivityForResult(intent, requestCode, bundle);
+ } else {
+ getActivity().startActivityForResult(intent, requestCode);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainPresenter.java
new file mode 100644
index 0000000..8707af2
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainPresenter.java
@@ -0,0 +1,14 @@
+package com.bigbig.ding.module.setting.main;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ISettingMainPresenter {
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainView.java b/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainView.java
new file mode 100644
index 0000000..84751c3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/main/ISettingMainView.java
@@ -0,0 +1,14 @@
+package com.bigbig.ding.module.setting.main;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ISettingMainView {
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainActivity.java b/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainActivity.java
new file mode 100644
index 0000000..203d7a4
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainActivity.java
@@ -0,0 +1,54 @@
+package com.bigbig.ding.module.setting.main;
+
+import android.view.MenuItem;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.module.base.BaseActivity;
+import com.bigbig.ding.module.setting.setting.SettingFragment;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class SettingMainActivity extends BaseActivity implements ISettingMainView {
+ @Override
+ protected int attachLayoutRes() {
+ return R.layout.activity_setting;
+ }
+
+ @Override
+ protected SettingMainPresenter initPresenter() {
+ SettingMainPresenter presenter=new SettingMainPresenter();
+ presenter.attch(this);
+ return presenter;
+ }
+
+ @Override
+ protected void initViews() {
+ getSupportActionBar().setTitle("设置");
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getFragmentManager().beginTransaction().replace(R.id.frame_setting_content,new SettingFragment()).commit();
+ }
+
+ @Override
+ protected void updateViews() {
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()){
+ case android.R.id.home:
+ onBackPressed();
+ break;
+ }
+ return true;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainPresenter.java
new file mode 100644
index 0000000..8fa42a1
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/main/SettingMainPresenter.java
@@ -0,0 +1,16 @@
+package com.bigbig.ding.module.setting.main;
+
+import com.bigbig.ding.module.base.BasePresenter;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class SettingMainPresenter extends BasePresenter implements ISettingMainPresenter {
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingPresenter.java
new file mode 100644
index 0000000..c34dd8f
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingPresenter.java
@@ -0,0 +1,14 @@
+package com.bigbig.ding.module.setting.setting;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ISettingPresenter {
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingView.java b/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingView.java
new file mode 100644
index 0000000..57b5638
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/setting/ISettingView.java
@@ -0,0 +1,14 @@
+package com.bigbig.ding.module.setting.setting;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public interface ISettingView {
+}
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingFragment.java b/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingFragment.java
new file mode 100644
index 0000000..1abe642
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingFragment.java
@@ -0,0 +1,81 @@
+package com.bigbig.ding.module.setting.setting;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import android.widget.Toast;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.constants.Constans;
+import com.bigbig.ding.module.setting.main.SettingMainActivity;
+import com.bigbig.ding.utils.PreferencesUtil;
+import com.bigbig.ding.utils.ThemeUtils;
+
+import static cn.bmob.v3.Bmob.getApplicationContext;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class SettingFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
+
+ private SettingMainActivity mActivity;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.pref_settings);
+ mActivity = (SettingMainActivity) getActivity();
+ }
+
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
+ super.onDestroy();
+
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ switch (key){
+ case Constans.THEME:
+ changeTheme();
+ break;
+ case Constans.IS_USE_RECYCLE:
+ getIsUseRecycle();
+ break;
+ }
+ }
+
+ private void changeTheme(){
+ int newTheme = PreferencesUtil.getInt(Constans.THEME,Constans.theme);
+ if (newTheme != Constans.theme && mActivity != null) {
+ Constans.theme=newTheme;
+ mActivity.setTheme(newTheme);
+ ThemeUtils.resetToolbarColor(mActivity);
+ ThemeUtils.resetWindowStatusBarColor(mActivity);
+ this.onCreate(null);
+ }
+ }
+
+ private void getIsUseRecycle(){
+ Constans.isUseRecycleBin=PreferencesUtil.getBoolean(Constans.IS_USE_RECYCLE,true);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingPresenter.java b/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingPresenter.java
new file mode 100644
index 0000000..3042f11
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/module/setting/setting/SettingPresenter.java
@@ -0,0 +1,16 @@
+package com.bigbig.ding.module.setting.setting;
+
+import com.bigbig.ding.module.base.BasePresenter;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/28
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class SettingPresenter extends BasePresenter implements ISettingPresenter {
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/AliPayUtils.java b/app/src/main/java/com/bigbig/ding/utils/AliPayUtils.java
new file mode 100644
index 0000000..defeaec
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/AliPayUtils.java
@@ -0,0 +1,50 @@
+package com.bigbig.ding.utils;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.widget.Toast;
+
+import java.net.URLEncoder;
+
+/**
+ * Created by miaoyongyong on 2017/2/20.
+ */
+
+public class AliPayUtils {
+
+ /**
+ * 支付
+ *
+ */
+ public static void openAliPay2Pay(Context context,String qrContent) {
+ if (openAlipayPayPage(context,qrContent)) {
+ Toast.makeText(context, "跳转中...", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(context, "跳转失败", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ private static boolean openAlipayPayPage(Context context ,String qrContent) {
+ try {
+ String qrcode = URLEncoder.encode(qrContent, "utf-8");
+ final String alipayqr = "alipayqr://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=" + qrcode;
+ openUri(context, alipayqr + "%3F_s%3Dweb-other&_t=" + System.currentTimeMillis());
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * 发送一个intent
+ *
+ * @param context
+ * @param s
+ */
+ private static void openUri(Context context, String s) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(s));
+ context.startActivity(intent);
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/DateStyle.java b/app/src/main/java/com/bigbig/ding/utils/DateStyle.java
new file mode 100644
index 0000000..067c333
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/DateStyle.java
@@ -0,0 +1,42 @@
+package com.bigbig.ding.utils;
+
+public enum DateStyle {
+
+ MM_DD("MM-dd"),
+ YYYY_MM("yyyy-MM"),
+ YYYY_MM_DD("yyyy-MM-dd"),
+ MM_DD_HH_MM("MM-dd HH:mm"),
+ MM_DD_HH_MM_SS("MM-dd HH:mm:ss"),
+ YYYY_MM_DD_HH_MM("yyyy-MM-dd HH:mm"),
+ YYYY_MM_DD_HH_MM_SS("yyyy-MM-dd HH:mm:ss"),
+
+ MM_DD_EN("MM/dd"),
+ YYYY_MM_EN("yyyy/MM"),
+ YYYY_MM_DD_EN("yyyy/MM/dd"),
+ MM_DD_HH_MM_EN("MM/dd HH:mm"),
+ MM_DD_HH_MM_SS_EN("MM/dd HH:mm:ss"),
+ YYYY_MM_DD_HH_MM_EN("yyyy/MM/dd HH:mm"),
+ YYYY_MM_DD_HH_MM_SS_EN("yyyy/MM/dd HH:mm:ss"),
+
+ MM_DD_CN("MM月dd日"),
+ YYYY_MM_CN("yyyy年MM月"),
+ YYYY_MM_DD_CN("yyyy年MM月dd日"),
+ MM_DD_HH_MM_CN("MM月dd日 HH:mm"),
+ MM_DD_HH_MM_SS_CN("MM月dd日 HH:mm:ss"),
+ YYYY_MM_DD_HH_MM_CN("yyyy年MM月dd日 HH:mm"),
+ YYYY_MM_DD_HH_MM_SS_CN("yyyy年MM月dd日 HH:mm:ss"),
+
+ HH_MM("HH:mm"),
+ HH_MM_SS("HH:mm:ss");
+
+
+ private String value;
+
+ DateStyle(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/bigbig/ding/utils/DateUtils.java b/app/src/main/java/com/bigbig/ding/utils/DateUtils.java
new file mode 100644
index 0000000..8f2668b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/DateUtils.java
@@ -0,0 +1,758 @@
+package com.bigbig.ding.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DateUtils {
+
+ /**
+ * 获取SimpleDateFormat
+ *
+ * @param parttern 日期格式
+ * @return SimpleDateFormat对象
+ * @throws RuntimeException 异常:非法日期格式
+ */
+ private static SimpleDateFormat getDateFormat(String parttern) throws RuntimeException {
+ return new SimpleDateFormat(parttern);
+ }
+
+ /**
+ * 获取日期中的某数值。如获取月份
+ *
+ * @param date 日期
+ * @param dateType 日期格式
+ * @return 数值
+ */
+ private static int getInteger(Date date, int dateType) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar.get(dateType);
+ }
+
+ /**
+ * 增加日期中某类型的某数值。如增加日期
+ *
+ * @param date 日期字符串
+ * @param dateType 类型
+ * @param amount 数值
+ * @return 计算后日期字符串
+ */
+ private static String addInteger(String date, int dateType, int amount) {
+ String dateString = null;
+ DateStyle dateStyle = getDateStyle(date);
+ if (dateStyle != null) {
+ Date myDate = StringToDate(date, dateStyle);
+ myDate = addInteger(myDate, dateType, amount);
+ dateString = DateToString(myDate, dateStyle);
+ }
+ return dateString;
+ }
+
+ /**
+ * 增加日期中某类型的某数值。如增加日期
+ *
+ * @param date 日期
+ * @param dateType 类型
+ * @param amount 数值
+ * @return 计算后日期
+ */
+ private static Date addInteger(Date date, int dateType, int amount) {
+ Date myDate = null;
+ if (date != null) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.add(dateType, amount);
+ myDate = calendar.getTime();
+ }
+ return myDate;
+ }
+
+ /**
+ * 获取精确的日期
+ *
+ * @param timestamps 时间long集合
+ * @return 日期
+ */
+ private static Date getAccurateDate(List timestamps) {
+ Date date = null;
+ long timestamp = 0;
+ Map map = new HashMap();
+ List absoluteValues = new ArrayList();
+
+ if (timestamps != null && timestamps.size() > 0) {
+ if (timestamps.size() > 1) {
+ for (int i = 0; i < timestamps.size(); i++) {
+ for (int j = i + 1; j < timestamps.size(); j++) {
+ long absoluteValue = Math.abs(timestamps.get(i) - timestamps.get(j));
+ absoluteValues.add(absoluteValue);
+ long[] timestampTmp = {timestamps.get(i), timestamps.get(j)};
+ map.put(absoluteValue, timestampTmp);
+ }
+ }
+
+ // 有可能有相等的情况。如2012-11和2012-11-01。时间戳是相等的
+ long minAbsoluteValue = -1;
+ if (!absoluteValues.isEmpty()) {
+ // 如果timestamps的size为2,这是差值只有一个,因此要给默认值
+ minAbsoluteValue = absoluteValues.get(0);
+ }
+ for (int i = 0; i < absoluteValues.size(); i++) {
+ for (int j = i + 1; j < absoluteValues.size(); j++) {
+ if (absoluteValues.get(i) > absoluteValues.get(j)) {
+ minAbsoluteValue = absoluteValues.get(j);
+ } else {
+ minAbsoluteValue = absoluteValues.get(i);
+ }
+ }
+ }
+
+ if (minAbsoluteValue != -1) {
+ long[] timestampsLastTmp = map.get(minAbsoluteValue);
+ if (absoluteValues.size() > 1) {
+ timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
+ } else if (absoluteValues.size() == 1) {
+ // 当timestamps的size为2,需要与当前时间作为参照
+ long dateOne = timestampsLastTmp[0];
+ long dateTwo = timestampsLastTmp[1];
+ if ((Math.abs(dateOne - dateTwo)) < 100000000000L) {
+ timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
+ } else {
+ long now = new Date().getTime();
+ if (Math.abs(dateOne - now) <= Math.abs(dateTwo - now)) {
+ timestamp = dateOne;
+ } else {
+ timestamp = dateTwo;
+ }
+ }
+ }
+ }
+ } else {
+ timestamp = timestamps.get(0);
+ }
+ }
+
+ if (timestamp != 0) {
+ date = new Date(timestamp);
+ }
+ return date;
+ }
+
+ /**
+ * 判断字符串是否为日期字符串
+ *
+ * @param date 日期字符串
+ * @return true or false
+ */
+ public static boolean isDate(String date) {
+ boolean isDate = false;
+ if (date != null) {
+ if (StringToDate(date) != null) {
+ isDate = true;
+ }
+ }
+ return isDate;
+ }
+
+ /**
+ * 获取日期字符串的日期风格。失敗返回null。
+ *
+ * @param date 日期字符串
+ * @return 日期风格
+ */
+ public static DateStyle getDateStyle(String date) {
+ DateStyle dateStyle = null;
+ Map map = new HashMap();
+ List timestamps = new ArrayList();
+ for (DateStyle style : DateStyle.values()) {
+ Date dateTmp = StringToDate(date, style.getValue());
+ if (dateTmp != null) {
+ timestamps.add(dateTmp.getTime());
+ map.put(dateTmp.getTime(), style);
+ }
+ }
+ dateStyle = map.get(getAccurateDate(timestamps).getTime());
+ return dateStyle;
+ }
+
+ /**
+ * 将日期字符串转化为日期。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 日期
+ */
+ public static Date StringToDate(String date) {
+ DateStyle dateStyle = null;
+ return StringToDate(date, dateStyle);
+ }
+
+ /**
+ * 将日期字符串转化为日期。失败返回null。
+ *
+ * @param date 日期字符串
+ * @param parttern 日期格式
+ * @return 日期
+ */
+ public static Date StringToDate(String date, String parttern) {
+ Date myDate = null;
+ if (date != null) {
+ try {
+ myDate = getDateFormat(parttern).parse(date);
+ } catch (Exception e) {
+ }
+ }
+ return myDate;
+ }
+
+ /**
+ * 将日期字符串转化为日期。失败返回null。
+ *
+ * @param date 日期字符串
+ * @param dateStyle 日期风格
+ * @return 日期
+ */
+ public static Date StringToDate(String date, DateStyle dateStyle) {
+ Date myDate = null;
+ if (dateStyle == null) {
+ List timestamps = new ArrayList();
+ for (DateStyle style : DateStyle.values()) {
+ Date dateTmp = StringToDate(date, style.getValue());
+ if (dateTmp != null) {
+ timestamps.add(dateTmp.getTime());
+ }
+ }
+ myDate = getAccurateDate(timestamps);
+ } else {
+ myDate = StringToDate(date, dateStyle.getValue());
+ }
+ return myDate;
+ }
+
+ /**
+ * 将日期转化为日期字符串。失败返回null。
+ *
+ * @param date 日期
+ * @param parttern 日期格式
+ * @return 日期字符串
+ */
+ public static String DateToString(Date date, String parttern) {
+ String dateString = null;
+ if (date != null) {
+ try {
+ dateString = getDateFormat(parttern).format(date);
+ } catch (Exception e) {
+ }
+ }
+ return dateString;
+ }
+
+ /**
+ * 将日期转化为日期字符串。失败返回null。
+ *
+ * @param date 日期
+ * @param dateStyle 日期风格
+ * @return 日期字符串
+ */
+ public static String DateToString(Date date, DateStyle dateStyle) {
+ String dateString = null;
+ if (dateStyle != null) {
+ dateString = DateToString(date, dateStyle.getValue());
+ }
+ return dateString;
+ }
+
+ /**
+ * 将日期字符串转化为另一日期字符串。失败返回null。
+ *
+ * @param date 旧日期字符串
+ * @param parttern 新日期格式
+ * @return 新日期字符串
+ */
+ public static String StringToString(String date, String parttern) {
+ return StringToString(date, null, parttern);
+ }
+
+ /**
+ * 将日期字符串转化为另一日期字符串。失败返回null。
+ *
+ * @param date 旧日期字符串
+ * @param dateStyle 新日期风格
+ * @return 新日期字符串
+ */
+ public static String StringToString(String date, DateStyle dateStyle) {
+ return StringToString(date, null, dateStyle);
+ }
+
+ /**
+ * 将日期字符串转化为另一日期字符串。失败返回null。
+ *
+ * @param date 旧日期字符串
+ * @param olddParttern 旧日期格式
+ * @param newParttern 新日期格式
+ * @return 新日期字符串
+ */
+ public static String StringToString(String date, String olddParttern, String newParttern) {
+ String dateString = null;
+ if (olddParttern == null) {
+ DateStyle style = getDateStyle(date);
+ if (style != null) {
+ Date myDate = StringToDate(date, style.getValue());
+ dateString = DateToString(myDate, newParttern);
+ }
+ } else {
+ Date myDate = StringToDate(date, olddParttern);
+ dateString = DateToString(myDate, newParttern);
+ }
+ return dateString;
+ }
+
+ /**
+ * 将日期字符串转化为另一日期字符串。失败返回null。
+ *
+ * @param date 旧日期字符串
+ * @param olddDteStyle 旧日期风格
+ * @param newDateStyle 新日期风格
+ * @return 新日期字符串
+ */
+ public static String StringToString(String date, DateStyle olddDteStyle, DateStyle newDateStyle) {
+ String dateString = null;
+ if (olddDteStyle == null) {
+ DateStyle style = getDateStyle(date);
+ dateString = StringToString(date, style.getValue(), newDateStyle.getValue());
+ } else {
+ dateString = StringToString(date, olddDteStyle.getValue(), newDateStyle.getValue());
+ }
+ return dateString;
+ }
+
+ /**
+ * 增加日期的年份。失败返回null。
+ *
+ * @param date 日期
+ * @param yearAmount 增加数量。可为负数
+ * @return 增加年份后的日期字符串
+ */
+ public static String addYear(String date, int yearAmount) {
+ return addInteger(date, Calendar.YEAR, yearAmount);
+ }
+
+ /**
+ * 增加日期的年份。失败返回null。
+ *
+ * @param date 日期
+ * @param yearAmount 增加数量。可为负数
+ * @return 增加年份后的日期
+ */
+ public static Date addYear(Date date, int yearAmount) {
+ return addInteger(date, Calendar.YEAR, yearAmount);
+ }
+
+ /**
+ * 增加日期的月份。失败返回null。
+ *
+ * @param date 日期
+ * @param yearAmount 增加数量。可为负数
+ * @return 增加月份后的日期字符串
+ */
+ public static String addMonth(String date, int yearAmount) {
+ return addInteger(date, Calendar.MONTH, yearAmount);
+ }
+
+ /**
+ * 增加日期的月份。失败返回null。
+ *
+ * @param date 日期
+ * @param yearAmount 增加数量。可为负数
+ * @return 增加月份后的日期
+ */
+ public static Date addMonth(Date date, int yearAmount) {
+ return addInteger(date, Calendar.MONTH, yearAmount);
+ }
+
+ /**
+ * 增加日期的天数。失败返回null。
+ *
+ * @param date 日期字符串
+ * @param dayAmount 增加数量。可为负数
+ * @return 增加天数后的日期字符串
+ */
+ public static String addDay(String date, int dayAmount) {
+ return addInteger(date, Calendar.DATE, dayAmount);
+ }
+
+ /**
+ * 增加日期的天数。失败返回null。
+ *
+ * @param date 日期
+ * @param dayAmount 增加数量。可为负数
+ * @return 增加天数后的日期
+ */
+ public static Date addDay(Date date, int dayAmount) {
+ return addInteger(date, Calendar.DATE, dayAmount);
+ }
+
+ /**
+ * 增加日期的小时。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 增加小时后的日期字符串
+ */
+ public static String addHour(String date, int hourAmount) {
+ return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
+ }
+
+ /**
+ * 增加日期的小时。失败返回null。
+ *
+ * @param date 日期
+ * @return 增加小时后的日期
+ */
+ public static Date addHour(Date date, int hourAmount) {
+ return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
+ }
+
+ /**
+ * 增加日期的分钟。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 增加分钟后的日期字符串
+ */
+ public static String addMinute(String date, int hourAmount) {
+ return addInteger(date, Calendar.MINUTE, hourAmount);
+ }
+
+ /**
+ * 增加日期的分钟。失败返回null。
+ *
+ * @param date 日期
+ * @return 增加分钟后的日期
+ */
+ public static Date addMinute(Date date, int hourAmount) {
+ return addInteger(date, Calendar.MINUTE, hourAmount);
+ }
+
+ /**
+ * 增加日期的秒钟。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 增加秒钟后的日期字符串
+ */
+ public static String addSecond(String date, int hourAmount) {
+ return addInteger(date, Calendar.SECOND, hourAmount);
+ }
+
+ /**
+ * 增加日期的秒钟。失败返回null。
+ *
+ * @param date 日期
+ * @return 增加秒钟后的日期
+ */
+ public static Date addSecond(Date date, int hourAmount) {
+ return addInteger(date, Calendar.SECOND, hourAmount);
+ }
+
+ /**
+ * 获取日期的年份。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 年份
+ */
+ public static int getYear(String date) {
+ return getYear(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的年份。失败返回0。
+ *
+ * @param date 日期
+ * @return 年份
+ */
+ public static int getYear(Date date) {
+ return getInteger(date, Calendar.YEAR);
+ }
+
+ /**
+ * 获取日期的月份。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 月份
+ */
+ public static int getMonth(String date) {
+ return getMonth(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的月份。失败返回0。
+ *
+ * @param date 日期
+ * @return 月份
+ */
+ public static int getMonth(Date date) {
+ return getInteger(date, Calendar.MONTH);
+ }
+
+ /**
+ * 获取日期的天数。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 天
+ */
+ public static int getDay(String date) {
+ return getDay(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的天数。失败返回0。
+ *
+ * @param date 日期
+ * @return 天
+ */
+ public static int getDay(Date date) {
+ return getInteger(date, Calendar.DATE);
+ }
+
+ /**
+ * 获取日期的小时。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 小时
+ */
+ public static int getHour(String date) {
+ return getHour(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的小时。失败返回0。
+ *
+ * @param date 日期
+ * @return 小时
+ */
+ public static int getHour(Date date) {
+ return getInteger(date, Calendar.HOUR_OF_DAY);
+ }
+
+ /**
+ * 获取日期的分钟。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 分钟
+ */
+ public static int getMinute(String date) {
+ return getMinute(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的分钟。失败返回0。
+ *
+ * @param date 日期
+ * @return 分钟
+ */
+ public static int getMinute(Date date) {
+ return getInteger(date, Calendar.MINUTE);
+ }
+
+ /**
+ * 获取日期的秒钟。失败返回0。
+ *
+ * @param date 日期字符串
+ * @return 秒钟
+ */
+ public static int getSecond(String date) {
+ return getSecond(StringToDate(date));
+ }
+
+ /**
+ * 获取日期的秒钟。失败返回0。
+ *
+ * @param date 日期
+ * @return 秒钟
+ */
+ public static int getSecond(Date date) {
+ return getInteger(date, Calendar.SECOND);
+ }
+
+ /**
+ * 获取日期 。默认yyyy-MM-dd格式。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 日期
+ */
+ public static String getDate(String date) {
+ return StringToString(date, DateStyle.YYYY_MM_DD);
+ }
+
+ /**
+ * 获取日期。默认yyyy-MM-dd格式。失败返回null。
+ *
+ * @param date 日期
+ * @return 日期
+ */
+ public static String getDate(Date date) {
+ return DateToString(date, DateStyle.YYYY_MM_DD);
+ }
+
+ /**
+ * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 时间
+ */
+ public static String getTime(String date) {
+ return StringToString(date, DateStyle.HH_MM_SS);
+ }
+
+ /**
+ * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
+ *
+ * @param date 日期
+ * @return 时间
+ */
+ public static String getTime(Date date) {
+ return DateToString(date, DateStyle.HH_MM_SS);
+ }
+
+ /**
+ * 获取日期的星期。失败返回null。
+ *
+ * @param date 日期字符串
+ * @return 星期
+ */
+ public static Week getWeek(String date) {
+ Week week = null;
+ DateStyle dateStyle = getDateStyle(date);
+ if (dateStyle != null) {
+ Date myDate = StringToDate(date, dateStyle);
+ week = getWeek(myDate);
+ }
+ return week;
+ }
+
+ /**
+ * 获取日期的星期。失败返回null。
+ *
+ * @param date 日期
+ * @return 星期
+ */
+ public static Week getWeek(Date date) {
+ Week week = null;
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ int weekNumber = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+ switch (weekNumber) {
+ case 0:
+ week = Week.SUNDAY;
+ break;
+ case 1:
+ week = Week.MONDAY;
+ break;
+ case 2:
+ week = Week.TUESDAY;
+ break;
+ case 3:
+ week = Week.WEDNESDAY;
+ break;
+ case 4:
+ week = Week.THURSDAY;
+ break;
+ case 5:
+ week = Week.FRIDAY;
+ break;
+ case 6:
+ week = Week.SATURDAY;
+ break;
+ }
+ return week;
+ }
+
+ /**
+ * 获取两个日期相差的天数
+ *
+ * @param date 日期字符串
+ * @param otherDate 另一个日期字符串
+ * @return 相差天数
+ */
+ public static int getIntervalDays(String date, String otherDate) {
+ return getIntervalDays(StringToDate(date), StringToDate(otherDate));
+ }
+
+ /**
+ * @param date 日期
+ * @param otherDate 另一个日期
+ * @return 相差天数
+ */
+ public static int getIntervalDays(Date date, Date otherDate) {
+ date = DateUtils.StringToDate(DateUtils.getDate(date));
+ long time = Math.abs(date.getTime() - otherDate.getTime());
+ return (int) time / (24 * 60 * 60 * 1000);
+ }
+
+ /*____________________________________________________*/
+
+ /**
+ * 判断是否是同一年
+ *
+ * @param millis 第一个时间戳
+ * @param millis1 第二个时间戳
+ * @describe
+ */
+ public static boolean isInSameYear(long millis, long millis1) {
+ Date date1 = new Date(millis);
+ Date date2 = new Date(millis1);
+ int years1 = getYear(date1);
+ int years2 = getYear(date2);
+ if (years1 == years2)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 判断是否是同一月
+ *
+ * @param millis 第一个时间戳
+ * @param millis1 第二个时间戳
+ * @describe
+ */
+ public static boolean isInSameMonth(long millis, long millis1) {
+ Date date1 = new Date(millis);
+ Date date2 = new Date(millis1);
+
+ if (!isInSameYear(millis, millis1)) {
+ return false;
+ } else {
+ int month1 = getMonth(date1);
+ int month2 = getMonth(date2);
+ if (month1 == month2)
+ return true;
+ else
+ return false;
+ }
+
+
+ }
+
+ /**
+ * 判断是否是同一天
+ *
+ * @param millis 第一个时间戳
+ * @param millis1 第二个时间戳
+ * @describe
+ */
+ public static boolean isInSameDay(long millis, long millis1) {
+ Date date1 = new Date(millis);
+ Date date2 = new Date(millis1);
+ int day1 = getDay(date1);
+ int day2 = getDay(date2);
+
+ if (!isInSameMonth(millis, millis1)) {
+ return false;
+ } else if (day1 == day2)
+ return true;
+ else
+ return false;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/DemoMessageReceiver.java b/app/src/main/java/com/bigbig/ding/utils/DemoMessageReceiver.java
new file mode 100644
index 0000000..0b43a44
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/DemoMessageReceiver.java
@@ -0,0 +1,344 @@
+package com.bigbig.ding.utils;
+
+import android.annotation.SuppressLint;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.bigbig.ding.R;
+import com.bigbig.ding.bean.NoteFolder;
+import com.bigbig.ding.constants.Constans;
+import com.blankj.utilcode.util.TimeUtils;
+//import com.xiaomi.mipush.sdk.Constants;
+import com.blankj.utilcode.util.Utils;
+import com.xiaomi.mipush.sdk.ErrorCode;
+import com.xiaomi.mipush.sdk.MiPushClient;
+import com.xiaomi.mipush.sdk.MiPushCommandMessage;
+import com.xiaomi.mipush.sdk.MiPushMessage;
+import com.xiaomi.mipush.sdk.PushMessageReceiver;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import com.bigbig.ding.MainApplication;
+import com.bigbig.ding.bean.Note;
+import com.bigbig.ding.module.notes.main.NoteMainActivity;
+
+import org.litepal.crud.DataSupport;
+
+/**
+ * 1、PushMessageReceiver 是个抽象类,该类继承了 BroadcastReceiver。
+ * 2、需要将自定义的 DemoMessageReceiver 注册在 AndroidManifest.xml 文件中:
+ *
+ * {@code
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * }
+ * 3、DemoMessageReceiver 的 onReceivePassThroughMessage 方法用来接收服务器向客户端发送的透传消息。
+ * 4、DemoMessageReceiver 的 onNotificationMessageClicked 方法用来接收服务器向客户端发送的通知消息,
+ * 这个回调方法会在用户手动点击通知后触发。
+ * 5、DemoMessageReceiver 的 onNotificationMessageArrived 方法用来接收服务器向客户端发送的通知消息,
+ * 这个回调方法是在通知消息到达客户端时触发。另外应用在前台时不弹出通知的通知消息到达客户端也会触发这个回调函数。
+ * 6、DemoMessageReceiver 的 onCommandResult 方法用来接收客户端向服务器发送命令后的响应结果。
+ * 7、DemoMessageReceiver 的 onReceiveRegisterResult 方法用来接收客户端向服务器发送注册命令后的响应结果。
+ * 8、以上这些方法运行在非 UI 线程中。
+ *
+ * @author mayixiang
+ */
+public class DemoMessageReceiver extends PushMessageReceiver {
+
+ public static String mRegId;
+ private String mTopic;
+ private String mAlias;
+ private String mAccount;
+ private String mStartTime;
+ private String mEndTime;
+ long years = (long)12 * 30 * 24 * 60 * 60 * 1000;
+ long month =(long) 24 * 60 * 60 * 1000 * 30;
+ long days = (long)24 * 60 * 60 * 1000;
+ long m=(long)60*1000;
+
+ @Override
+ public void onReceivePassThroughMessage(Context context, MiPushMessage message) {
+ Log.v(MainApplication.TAG,
+ "onReceivePassThroughMessage is called. " + message.toString());
+ String log = context.getString(R.string.recv_passthrough_message, message.getContent());
+// MainActivity.logList.add(0, getSimpleDate() + " " + log);
+ //MainActivity.mLogView.setText("状态记录:\n\n"+message.getContent());
+ //保存到 Sqlite 数据库
+ Note note2 = new Note();
+ long time = TimeUtils.getNowMills();
+ note2.setCreatedTime(time-m-m-m-m);
+ note2.setModifiedTime(time-m-m-m-m);
+ note2.setNoteFolderId(1);
+ note2.setNoteContent(message.getExtra().get("md").replace("|||","\r\n"));
+ note2.setIsPrivacy(0);
+ note2.setInRecycleBin(0);
+ note2.setNoteId(UUID.randomUUID().toString());
+ note2.save();
+ Log.v(MainApplication.TAG,
+ "note message is . " + note2.toString());
+
+ if (!TextUtils.isEmpty(message.getTopic())) {
+ mTopic = message.getTopic();
+ } else if (!TextUtils.isEmpty(message.getAlias())) {
+ mAlias = message.getAlias();
+ }
+
+// Message msg = Message.obtain();
+// msg.obj = log;
+// MyApplication.getHandler().sendMessage(msg);
+ }
+
+ @Override
+ public void onNotificationMessageClicked(Context context, MiPushMessage message) {
+
+ /*
+ 此处是在任务栏点击推送消息后的通知
+ * */
+ Log.v(MainApplication.TAG,
+ "onNotificationMessageArrived is called. " + message.toString());
+ //String log = context.getString(R.string.arrive_notification_message)+message.getContent();
+ String log = "消息为:"+message.getDescription();
+// getNoteCount
+ NoteFolder folder= DataSupport.where("folderName = ? ","随手记").find(NoteFolder.class).get(0);
+ int folderid =folder.getId();
+ int noteCount=folder.getNoteCount();
+
+ Note note2 = new Note();
+ long time = TimeUtils.getNowMills();
+ note2.setCreatedTime(time-m-m-m-m);
+ note2.setModifiedTime(time-m-m-m-m);
+ note2.setNoteFolderId(folderid);
+ note2.setNoteContent(message.getExtra().get("md").replace("|||","\r\n"));
+ note2.setIsPrivacy(0);
+ note2.setInRecycleBin(0);
+ note2.setNoteId(UUID.randomUUID().toString());
+ note2.save();
+ noteCount+=1;
+ Log.v(MainApplication.TAG,
+ "nnoteCount is . " + noteCount);
+ folder.setNoteCount(noteCount);
+ folder.save();
+ Log.v(MainApplication.TAG,
+ "note message is . " + note2.getNoteContent());
+
+ if (!TextUtils.isEmpty(message.getTopic())) {
+ mTopic = message.getTopic();
+ } else if (!TextUtils.isEmpty(message.getAlias())) {
+ mAlias = message.getAlias();
+ }
+
+// Message msg = Message.obtain();
+// msg.obj = log;
+// MyApplication.getHandler().sendMessage(msg);
+ Intent intent =new Intent(context, NoteMainActivity.class);
+ context.startActivity(intent);
+ }
+
+ @Override
+ public void onNotificationMessageArrived(Context context, MiPushMessage message) {
+ Log.v(MainApplication.TAG,
+ "onNotificationMessageArrived is called. " + message.toString());
+ //String log = context.getString(R.string.arrive_notification_message)+message.getContent();
+ String log = "消息为:"+message.getDescription();
+ //保存到 Sqlite 数据库
+// Note note2 = new Note();
+// long time = TimeUtils.getNowMills();
+// note2.setCreatedTime(time-m-m-m-m);
+// note2.setModifiedTime(time-m-m-m-m);
+// note2.setNoteFolderId(1);
+// note2.setNoteContent(message.getExtra().get("md").replace("|||","\r\n"));
+// note2.setIsPrivacy(0);
+// note2.setInRecycleBin(0);
+// note2.setNoteId(UUID.randomUUID().toString());
+// note2.save();
+// Log.v(MainApplication.TAG,
+// "note message is . " + note2.getNoteFolderId());
+
+ if (!TextUtils.isEmpty(message.getTopic())) {
+ mTopic = message.getTopic();
+ } else if (!TextUtils.isEmpty(message.getAlias())) {
+ mAlias = message.getAlias();
+ }
+
+// Message msg = Message.obtain();
+// msg.obj = log;
+// MyApplication.getHandler().sendMessage(msg);
+ }
+
+ @Override
+ public void onCommandResult(Context context, MiPushCommandMessage message) {
+ Log.v(MainApplication.TAG,
+ "onCommandResult is called. " + message.toString());
+ String command = message.getCommand();
+ List arguments = message.getCommandArguments();
+ String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
+ String cmdArg2 = ((arguments != null && arguments.size() > 1) ? arguments.get(1) : null);
+ String log;
+ if (MiPushClient.COMMAND_REGISTER.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mRegId = cmdArg1;
+
+ log = context.getString(R.string.register_success);
+ } else {
+ log = context.getString(R.string.register_fail);
+ }
+ } else if (MiPushClient.COMMAND_SET_ALIAS.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mAlias = cmdArg1;
+ log = context.getString(R.string.set_alias_success, mAlias);
+ } else {
+ log = context.getString(R.string.set_alias_fail, message.getReason());
+ }
+ } else if (MiPushClient.COMMAND_UNSET_ALIAS.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mAlias = cmdArg1;
+ log = context.getString(R.string.unset_alias_success, mAlias);
+ } else {
+ log = context.getString(R.string.unset_alias_fail, message.getReason());
+ }
+ }
+ //此处是注册成功后的标志
+ else if (MiPushClient.COMMAND_SET_ACCOUNT.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mAccount = cmdArg1;
+ log = context.getString(R.string.set_account_success, mAccount);
+ } else {
+ log = context.getString(R.string.set_account_fail, message.getReason());
+ }
+ }
+ else if (MiPushClient.COMMAND_UNSET_ACCOUNT.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mAccount = cmdArg1;
+ log = context.getString(R.string.unset_account_success, mAccount);
+ } else {
+ log = context.getString(R.string.unset_account_fail, message.getReason());
+ }
+ } else if (MiPushClient.COMMAND_SUBSCRIBE_TOPIC.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mTopic = cmdArg1;
+ log = context.getString(R.string.subscribe_topic_success, mTopic);
+ } else {
+ log = context.getString(R.string.subscribe_topic_fail, message.getReason());
+ }
+ } else if (MiPushClient.COMMAND_UNSUBSCRIBE_TOPIC.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mTopic = cmdArg1;
+ log = context.getString(R.string.unsubscribe_topic_success, mTopic);
+ } else {
+ log = context.getString(R.string.unsubscribe_topic_fail, message.getReason());
+ }
+ } else if (MiPushClient.COMMAND_SET_ACCEPT_TIME.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mStartTime = cmdArg1;
+ mEndTime = cmdArg2;
+ log = context.getString(R.string.set_accept_time_success, mStartTime, mEndTime);
+ } else {
+ log = context.getString(R.string.set_accept_time_fail, message.getReason());
+ }
+ } else {
+ log = message.getReason();
+ }
+// MainActivity.logList.add(0, getSimpleDate() + " " + log);
+
+// Message msg = Message.obtain();
+// msg.obj = log;
+// MainApplication.getHandler().sendMessage(msg);
+ }
+
+ @Override
+ public void onReceiveRegisterResult(Context context, MiPushCommandMessage message) {
+ Log.v(MainApplication.TAG,
+ "onReceiveRegisterResult is called. " + message.toString());
+ String command = message.getCommand();
+ List arguments = message.getCommandArguments();
+ String cmdArg1 = ((arguments != null && arguments.size() > 0) ? arguments.get(0) : null);
+ String log;
+ Note note;
+ if (MiPushClient.COMMAND_REGISTER.equals(command)) {
+ if (message.getResultCode() == ErrorCode.SUCCESS) {
+ mRegId = cmdArg1;
+ PreferencesUtil.saveString(Constans.mRegId,mRegId);
+ Constans.xmRegId=PreferencesUtil.getString(Constans.mRegId,"");
+ NoteFolder folder= DataSupport.where("folderName = ? ","随手记").find(NoteFolder.class).get(0);
+ int folderid =folder.getId();
+ int noteCount=folder.getNoteCount();
+ //更新到笔记
+ List notelist= DataSupport.where("isPrivacy=0 and inRecycleBin=0 and noteContent like ? ","推送网址%").find(Note.class);
+ if (notelist.size() <1){
+ note=new Note();
+ long time = TimeUtils.getNowMills();
+ note.setCreatedTime(time-m-m);
+ note.setModifiedTime(time -m-m);
+ note.setNoteFolderId(folderid);
+ note.setIsPrivacy(0);
+ note.setInRecycleBin(0);
+ note.setNoteId(UUID.randomUUID().toString());
+ noteCount+=1;
+ folder.setNoteCount(noteCount);
+ folder.save();
+ }
+ else {
+ note=notelist.get(0);
+ }
+ String newContent=String.format(Utils.getContext().getResources().getString(R.string.database_content_five),mRegId);
+ Log.v(MainApplication.TAG,newContent);
+ note.setNoteContent(newContent);
+ note.save();
+
+ log = context.getString(R.string.register_success)+mRegId;
+ } else {
+ log = context.getString(R.string.register_fail);
+ }
+ } else {
+ log = message.getReason();
+ }
+ Log.d(MainApplication.TAG, log);
+ }
+
+ @Override
+ public void onRequirePermissions(Context context, String[] permissions) {
+ super.onRequirePermissions(context, permissions);
+ Log.e(MainApplication.TAG,
+ "onRequirePermissions is called. need permission" + arrayToString(permissions));
+
+ if (Build.VERSION.SDK_INT >= 23 && context.getApplicationInfo().targetSdkVersion >= 23) {
+ Intent intent = new Intent();
+ intent.putExtra("permissions", permissions);
+ intent.setComponent(new ComponentName(context.getPackageName(), PermissionActivity.class.getCanonicalName()));
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ context.startActivity(intent);
+ }
+ }
+
+ @SuppressLint("SimpleDateFormat")
+ private static String getSimpleDate() {
+ return new SimpleDateFormat("MM-dd hh:mm:ss").format(new Date());
+ }
+
+
+ public String arrayToString(String[] strings) {
+ String result = " ";
+ for (String str : strings) {
+ result = result + str + " ";
+ }
+ return result;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/LongImageUtils.java b/app/src/main/java/com/bigbig/ding/utils/LongImageUtils.java
new file mode 100644
index 0000000..b5f54cc
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/LongImageUtils.java
@@ -0,0 +1,40 @@
+package com.bigbig.ding.utils;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.widget.ScrollView;
+
+import com.blankj.utilcode.util.ScreenUtils;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/12
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class LongImageUtils {
+
+ /**
+ * 截取scrollview的屏幕
+ **/
+ public static Bitmap getScrollViewBitmap(ScrollView scrollView) {
+ int h = 0;
+ Bitmap bitmap;
+ for (int i = 0; i < scrollView.getChildCount(); i++) {
+ h += scrollView.getChildAt(i).getHeight();
+ }
+ // 创建对应大小的bitmap
+
+ bitmap = Bitmap.createBitmap(ScreenUtils.getScreenWidth(), h,
+ Bitmap.Config.ARGB_4444);
+ final Canvas canvas = new Canvas(bitmap);
+ canvas.drawColor(Color.parseColor("#f2f7fa"));
+ scrollView.draw(canvas);
+ return bitmap;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/MD5Util.java b/app/src/main/java/com/bigbig/ding/utils/MD5Util.java
new file mode 100644
index 0000000..a3d403b
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/MD5Util.java
@@ -0,0 +1,32 @@
+package com.bigbig.ding.utils;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Created by miaoyongyong on 2017/1/27.
+ */
+
+public class MD5Util {
+ public static String getMd5Value(String sSecret) {
+ try {
+ MessageDigest bmd5 = MessageDigest.getInstance("MD5");
+ bmd5.update(sSecret.getBytes());
+ int i;
+ StringBuffer buf = new StringBuffer();
+ byte[] b = bmd5.digest();// 加密
+ for (int offset = 0; offset < b.length; offset++) {
+ i = b[offset];
+ if (i < 0)
+ i += 256;
+ if (i < 16)
+ buf.append("0");
+ buf.append(Integer.toHexString(i));
+ }
+ return buf.toString();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/PermissionActivity.java b/app/src/main/java/com/bigbig/ding/utils/PermissionActivity.java
new file mode 100644
index 0000000..a7740af
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/PermissionActivity.java
@@ -0,0 +1,49 @@
+package com.bigbig.ding.utils;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+
+public class PermissionActivity extends Activity {
+ private static final int PERMISSION_REQUEST = 1;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (Build.VERSION.SDK_INT >= 23) {
+ Intent intent = getIntent();
+ String permissions[] = intent.getStringArrayExtra("permissions");
+ for (int i = 0; i < permissions.length; ++i) {
+ if (checkSelfPermission(permissions[i]) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(permissions, PERMISSION_REQUEST);
+ break;
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public void onRequestPermissionsResult (int requestCode,
+ String[] permissions,
+ int[] grantResults) {
+ if (requestCode == PERMISSION_REQUEST) {
+ boolean granted = false;
+ for (int i = 0; i < grantResults.length; ++i) {
+ if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+ granted = true;
+ }
+ }
+
+ if (granted) {
+ Log.w("PermissionActivity", "Permissions granted:");
+// MainApplication.reInitPush(this);
+ }
+ finish();
+ }
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/PermissionUtils.java b/app/src/main/java/com/bigbig/ding/utils/PermissionUtils.java
new file mode 100644
index 0000000..996c764
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/PermissionUtils.java
@@ -0,0 +1,274 @@
+package com.bigbig.ding.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Build;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/13
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class PermissionUtils {
+
+ /**
+ * 检测权限
+ *
+ * @return true:已授权; false:未授权;
+ */
+ public static boolean checkPermission(Context context, String permission) {
+ if (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 检测多个权限
+ *
+ * @return 未授权的权限
+ */
+ public static List checkMorePermissions(Context context, String[] permissions) {
+ List permissionList = new ArrayList<>();
+ for (int i = 0; i < permissions.length; i++) {
+ if (!checkPermission(context, permissions[i]))
+ permissionList.add(permissions[i]);
+ }
+ return permissionList;
+ }
+
+ /**
+ * 请求权限
+ */
+ public static void requestPermission(Context context, String permission, int requestCode) {
+ ActivityCompat.requestPermissions((Activity) context, new String[]{permission}, requestCode);
+ }
+
+ /**
+ * 请求多个权限
+ */
+ public static void requestMorePermissions(Context context, List permissionList, int requestCode) {
+ String[] permissions = (String[]) permissionList.toArray(new String[permissionList.size()]);
+ requestMorePermissions(context, permissions, requestCode);
+ }
+
+ /**
+ * 请求多个权限
+ */
+ public static void requestMorePermissions(Context context, String[] permissions, int requestCode) {
+ ActivityCompat.requestPermissions((Activity) context, permissions, requestCode);
+ }
+
+ /**
+ * 判断是否已拒绝过权限
+ *
+ * @return
+ * @describe :如果应用之前请求过此权限但用户拒绝,此方法将返回 true;
+ * -----------如果应用第一次请求权限或 用户在过去拒绝了权限请求,
+ * -----------并在权限请求系统对话框中选择了 Don't ask again 选项,此方法将返回 false。
+ */
+ public static boolean judgePermission(Context context, String permission) {
+ if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permission))
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 检测权限并请求权限:如果没有权限,则请求权限
+ */
+ public static void checkAndRequestPermission(Context context, String permission, int requestCode) {
+ if (!checkPermission(context, permission)) {
+ requestPermission(context, permission, requestCode);
+ }
+ }
+
+ /**
+ * 检测并请求多个权限
+ */
+ public static void checkAndRequestMorePermissions(Context context, String[] permissions, int requestCode) {
+ List permissionList = checkMorePermissions(context, permissions);
+ requestMorePermissions(context, permissionList, requestCode);
+ }
+
+
+ /**
+ * 检测权限
+ *
+ * @describe:具体实现由回调接口决定
+ */
+ public static void checkPermission(Context context, String permission, PermissionCheckCallBack callBack) {
+ if (checkPermission(context, permission)) { // 用户已授予权限
+ callBack.onHasPermission();
+ } else {
+ if (judgePermission(context, permission)) // 用户之前已拒绝过权限申请
+ callBack.onUserHasAlreadyTurnedDown(permission);
+ else // 用户之前已拒绝并勾选了不在询问、用户第一次申请权限。
+ callBack.onUserHasAlreadyTurnedDownAndDontAsk(permission);
+ }
+ }
+
+ /**
+ * 检测多个权限
+ *
+ * @describe:具体实现由回调接口决定
+ */
+ public static void checkMorePermissions(Context context, String[] permissions, PermissionCheckCallBack callBack) {
+ List permissionList = checkMorePermissions(context, permissions);
+ if (permissionList.size() == 0) { // 用户已授予权限
+ callBack.onHasPermission();
+ } else {
+ boolean isFirst = true;
+ for (int i = 0; i < permissionList.size(); i++) {
+ String permission = permissionList.get(i);
+ if (judgePermission(context, permission)) {
+ isFirst = false;
+ break;
+ }
+ }
+ String[] unauthorizedMorePermissions = (String[]) permissionList.toArray(new String[permissionList.size()]);
+ if (isFirst)// 用户之前已拒绝过权限申请
+ callBack.onUserHasAlreadyTurnedDownAndDontAsk(unauthorizedMorePermissions);
+ else // 用户之前已拒绝并勾选了不在询问、用户第一次申请权限。
+ callBack.onUserHasAlreadyTurnedDown(unauthorizedMorePermissions);
+
+ }
+ }
+
+
+ /**
+ * 检测并申请权限
+ */
+ public static void checkAndRequestPermission(Context context, String permission, int requestCode, PermissionRequestSuccessCallBack callBack) {
+ if (checkPermission(context, permission)) {// 用户已授予权限
+ callBack.onHasPermission();
+ } else {
+ requestPermission(context, permission, requestCode);
+ }
+ }
+
+ /**
+ * 检测并申请多个权限
+ */
+ public static void checkAndRequestMorePermissions(Context context, String[] permissions, int requestCode, PermissionRequestSuccessCallBack callBack) {
+ List permissionList = checkMorePermissions(context, permissions);
+ if (permissionList.size() == 0) { // 用户已授予权限
+ callBack.onHasPermission();
+ } else {
+ requestMorePermissions(context, permissionList, requestCode);
+ }
+ }
+
+ /**
+ * 判断权限是否申请成功
+ */
+ public static boolean isPermissionRequestSuccess(int[] grantResults) {
+ if (grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * 用户申请权限返回
+ */
+ public static void onRequestPermissionResult(Context context, String permission, int[] grantResults, PermissionCheckCallBack callback) {
+ if (PermissionUtils.isPermissionRequestSuccess(grantResults)) {
+ callback.onHasPermission();
+ } else {
+ if (PermissionUtils.judgePermission(context, permission)) {
+ callback.onUserHasAlreadyTurnedDown(permission);
+ } else {
+ callback.onUserHasAlreadyTurnedDownAndDontAsk(permission);
+ }
+ }
+ }
+
+ /**
+ * 用户申请多个权限返回
+ */
+ public static void onRequestMorePermissionsResult(Context context, String[] permissions, PermissionCheckCallBack callback) {
+ boolean isBannedPermission = false;
+ List permissionList = checkMorePermissions(context, permissions);
+ if (permissionList.size() == 0)
+ callback.onHasPermission();
+ else {
+ for (int i = 0; i < permissionList.size(); i++) {
+ if (!judgePermission(context, permissionList.get(i))) {
+ isBannedPermission = true;
+ break;
+ }
+ }
+ // 已禁止再次询问权限
+ if (isBannedPermission)
+ callback.onUserHasAlreadyTurnedDownAndDontAsk(permissions);
+ else // 拒绝权限
+ callback.onUserHasAlreadyTurnedDown(permissions);
+ }
+
+ }
+
+
+ /**
+ * 跳转到权限设置界面
+ */
+ public static void toAppSetting(Context context) {
+ Intent intent = new Intent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ if (Build.VERSION.SDK_INT >= 9) {
+ intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
+ intent.setData(Uri.fromParts("package", context.getPackageName(), null));
+ } else if (Build.VERSION.SDK_INT <= 8) {
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
+ intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
+ }
+ context.startActivity(intent);
+ }
+
+ public interface PermissionRequestSuccessCallBack {
+ /**
+ * 用户已授予权限
+ */
+ void onHasPermission();
+ }
+
+
+ public interface PermissionCheckCallBack {
+
+ /**
+ * 用户已授予权限
+ */
+ void onHasPermission();
+
+ /**
+ * 用户已拒绝过权限
+ *
+ * @param permission:被拒绝的权限
+ */
+ void onUserHasAlreadyTurnedDown(String... permission);
+
+ /**
+ * 用户已拒绝过并且已勾选不再询问选项、用户第一次申请权限;
+ *
+ * @param permission:被拒绝的权限
+ */
+ void onUserHasAlreadyTurnedDownAndDontAsk(String... permission);
+ }
+
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/PreferencesUtil.java b/app/src/main/java/com/bigbig/ding/utils/PreferencesUtil.java
new file mode 100644
index 0000000..6a019f3
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/PreferencesUtil.java
@@ -0,0 +1,49 @@
+package com.bigbig.ding.utils;
+
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+
+import com.blankj.utilcode.util.Utils;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/19
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class PreferencesUtil {
+ private static SharedPreferences mShare = PreferenceManager.getDefaultSharedPreferences(Utils.getContext());
+ private static SharedPreferences.Editor mEdit = mShare.edit();
+
+ public static void saveString(String key, String value) {
+ mEdit.putString(key, value);
+ mEdit.commit();
+ }
+
+ public static void saveInt(String key, int value) {
+ mEdit.putInt(key, value);
+ mEdit.commit();
+ }
+
+ public static void saveBoolean(String key, boolean value) {
+ mEdit.putBoolean(key, value);
+ mEdit.commit();
+ }
+
+
+ public static String getString(String key, String value) {
+ return mShare.getString(key, value);
+ }
+
+ public static boolean getBoolean(String key, boolean defalut) {
+ return mShare.getBoolean(key, defalut);
+ }
+
+ public static int getInt(String key, int defalut) {
+ return mShare.getInt(key, defalut);
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/ProgressDialogUtils.java b/app/src/main/java/com/bigbig/ding/utils/ProgressDialogUtils.java
new file mode 100644
index 0000000..9e78c28
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/ProgressDialogUtils.java
@@ -0,0 +1,36 @@
+package com.bigbig.ding.utils;
+
+import android.app.ProgressDialog;
+import android.content.Context;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/07
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class ProgressDialogUtils {
+
+ private ProgressDialog mProgressDialog;
+ private Context mContext;
+
+ public ProgressDialogUtils(Context context){
+ this.mContext=context;
+ }
+
+ public void show(String message){
+ if(mProgressDialog==null)
+ mProgressDialog=new ProgressDialog(mContext);
+ mProgressDialog.setMessage(message);
+ mProgressDialog.show();
+ }
+
+ public void hide(){
+ if(mProgressDialog!=null)
+ mProgressDialog.cancel();
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/ThemeUtils.java b/app/src/main/java/com/bigbig/ding/utils/ThemeUtils.java
new file mode 100644
index 0000000..c176a27
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/ThemeUtils.java
@@ -0,0 +1,103 @@
+package com.bigbig.ding.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.util.TypedValue;
+import android.view.Window;
+import android.view.WindowManager;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.Utils;
+
+import java.lang.reflect.Field;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/06/20
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class ThemeUtils {
+
+ private static TypedValue value=new TypedValue();
+
+ public static int getColorPrimary(Context context){
+ context.getTheme().resolveAttribute(R.attr.colorPrimary, value,true);
+ return value.data;
+ }
+
+ public static int getColorPrimaryDark(Context context){
+ context.getTheme().resolveAttribute(R.attr.colorPrimaryDark, value,true);
+ return value.data;
+ }
+
+ // 状态栏颜色
+ public static void setWindowStatusBarColor(Window window, int color){
+ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
+ window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+// 状态栏
+ window.setStatusBarColor(color);
+// 底部导航栏
+// window.setNavigationBarColor(color);
+ }
+ }
+
+ // Toolbar颜色
+ public static void setToolbarColor(ActionBar actionBar, int color){
+ actionBar.setBackgroundDrawable(new ColorDrawable(color));
+ }
+
+ public static void resetToolbarColor(Context context){
+ int color=getColorPrimary(context);
+ ActionBar actionBar=((AppCompatActivity)context).getSupportActionBar();
+ actionBar.setBackgroundDrawable(new ColorDrawable(color));
+ }
+
+ public static void resetWindowStatusBarColor(Context context){
+ int color=getColorPrimaryDark(context);
+ Window window=((Activity)context).getWindow();
+ setWindowStatusBarColor(window,color);
+ }
+
+ /**
+ * 获取状态栏高度
+ * @describe
+ */
+ public static int getStatusBarHeight() {
+ Class> c = null;
+
+ Object obj = null;
+
+ Field field = null;
+
+ int x = 0, sbar = 0;
+
+ try {
+
+ c = Class.forName("com.android.internal.R$dimen");
+
+ obj = c.newInstance();
+
+ field = c.getField("status_bar_height");
+
+ x = Integer.parseInt(field.get(obj).toString());
+
+ sbar = Utils.getContext().getResources().getDimensionPixelSize(x);
+
+ } catch (Exception e1) {
+
+ e1.printStackTrace();
+
+ }
+
+ return sbar;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/utils/Week.java b/app/src/main/java/com/bigbig/ding/utils/Week.java
new file mode 100644
index 0000000..adcb01f
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/utils/Week.java
@@ -0,0 +1,40 @@
+package com.bigbig.ding.utils;
+
+public enum Week {
+
+ MONDAY("星期一", "Monday", "Mon.", 1),
+ TUESDAY("星期二", "Tuesday", "Tues.", 2),
+ WEDNESDAY("星期三", "Wednesday", "Wed.", 3),
+ THURSDAY("星期四", "Thursday", "Thur.", 4),
+ FRIDAY("星期五", "Friday", "Fri.", 5),
+ SATURDAY("星期六", "Saturday", "Sat.", 6),
+ SUNDAY("星期日", "Sunday", "Sun.", 7);
+
+ String name_cn;
+ String name_en;
+ String name_enShort;
+ int number;
+
+ Week(String name_cn, String name_en, String name_enShort, int number) {
+ this.name_cn = name_cn;
+ this.name_en = name_en;
+ this.name_enShort = name_enShort;
+ this.number = number;
+ }
+
+ public String getChineseName() {
+ return name_cn;
+ }
+
+ public String getName() {
+ return name_en;
+ }
+
+ public String getShortName() {
+ return name_enShort;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/bigbig/ding/widget/LockView.java b/app/src/main/java/com/bigbig/ding/widget/LockView.java
new file mode 100644
index 0000000..de4632c
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/widget/LockView.java
@@ -0,0 +1,355 @@
+package com.bigbig.ding.widget;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.bigbig.ding.R;
+import com.blankj.utilcode.util.SizeUtils;
+import com.blankj.utilcode.util.Utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.bigbig.ding.bean.Point;
+
+/**
+ * 九宫格解锁控件
+ * Created by Jerry on 2015/9/21.
+ */
+public class LockView extends View {
+
+ private Bitmap mNormalBitmap;
+ private Bitmap mPressBitmap;
+ private Bitmap mErrorBitmap;
+ private float mPointRadius= SizeUtils.dp2px(3);
+
+ private int mNormalColor= Utils.getContext().getResources().getColor(R.color.grey500);
+ private int mPressColor=Utils.getContext().getResources().getColor(R.color.grey600);
+ private int mErrorColor=Utils.getContext().getResources().getColor(R.color.red600);
+
+
+
+ // 手指在屏幕上的位置
+ private float mX, mY;
+
+ // 标记当前是否在绘制状态
+ private boolean isDraw = false;
+
+ // 三种状态下的画笔
+ private Paint mPaint, mPressPaint, mErrorPaint;
+
+ // 九个点
+ private Point[][] mPoints = new Point[3][3];
+ // 被选中的点
+ private List mSelectedPoints = new ArrayList<>();
+ // 绘制正确的点位置
+ private List mPassPositions = new ArrayList<>();
+
+// 是否可以点击
+ private boolean mClickable=true;
+
+ private OnDrawFinishedListener mListener;
+
+ public LockView(Context context) {
+ this(context, null);
+ }
+
+ public LockView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public LockView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ super.onSizeChanged(w, h, oldw, oldh);
+ init();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ measureDimension(widthMeasureSpec,heightMeasureSpec);
+ }
+
+ private void measureDimension(int widthMeasureSpec,int heightMeasureSpec){
+// 测量的值
+ int measureWidth=0;
+ int measureHeight=0;
+// 默认值
+ int defaultSize=400;
+
+ int widthSpecMode= MeasureSpec.getMode(widthMeasureSpec);
+ int heightSpcMode= MeasureSpec.getMode(heightMeasureSpec);
+ int widthSpecSize= MeasureSpec.getSize(widthMeasureSpec);
+ int heightSpecSize= MeasureSpec.getSize(heightMeasureSpec);
+ switch (widthSpecMode){
+ case MeasureSpec.EXACTLY:
+ measureWidth=widthSpecSize;
+ break;
+ case MeasureSpec.UNSPECIFIED:
+ measureWidth=SizeUtils.dp2px(defaultSize);
+ break;
+ case MeasureSpec.AT_MOST:
+ measureWidth= Math.min(widthSpecSize,defaultSize);
+ break;
+ }
+ switch (heightSpcMode){
+ case MeasureSpec.EXACTLY:
+ measureHeight=heightSpecSize;
+ break;
+ case MeasureSpec.UNSPECIFIED:
+ measureHeight=SizeUtils.dp2px(defaultSize);
+ break;
+ case MeasureSpec.AT_MOST:
+// 为了让解锁界面为方形,让高的值和宽一样。
+ measureHeight=measureWidth;
+ break;
+ }
+ setMeasuredDimension(measureWidth,measureHeight);
+
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+
+ // 绘制点
+ drawPoints(canvas);
+
+ // 绘制连线
+ drawLines(canvas);
+ }
+
+ private void init() {
+
+ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mPressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mErrorPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ // 按下状态的画笔
+ mPressPaint.setColor(mPressColor);
+ mPressPaint.setAlpha(66);
+ mPressPaint.setStrokeWidth(mPointRadius*2);
+ // 错误状态的画笔
+ mErrorPaint.setColor(mErrorColor);
+ mErrorPaint.setAlpha(66);
+ mErrorPaint.setStrokeWidth(mPointRadius*2);
+
+ // 当前视图的大小
+ int width = getMeasuredWidth();
+ int height = getMeasuredHeight();
+ // 九宫格点的偏移量
+ int offSet = Math.abs(width - height) / 2;
+ // x、y轴上的偏移量
+ int offSetX = 0, offSetY = 0;
+ int pointItemWidth = 0; // 每个点所占用方格的宽度
+ if (width >= height){ // 横屏的时候
+ offSetX = offSet;
+ offSetY = 0;
+ pointItemWidth = height / 4;
+ }
+ if (width <= height){ // 竖屏的时候
+ offSetX = 0;
+ offSetY = offSet;
+ pointItemWidth = width / 4;
+ }
+
+ // 初始化九个点
+ mPoints[0][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth);
+ mPoints[0][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth);
+ mPoints[0][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth);
+
+ mPoints[1][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth * 2);
+ mPoints[1][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth * 2);
+ mPoints[1][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth * 2);
+
+ mPoints[2][0] = new Point(offSetX + pointItemWidth, offSetY + pointItemWidth * 3);
+ mPoints[2][1] = new Point(offSetX + pointItemWidth * 2, offSetY + pointItemWidth * 3);
+ mPoints[2][2] = new Point(offSetX + pointItemWidth * 3, offSetY + pointItemWidth * 3);
+ }
+
+ /**
+ * 绘制所有的点
+ * @param canvas
+ */
+ private void drawPoints(Canvas canvas){
+ for (int i = 0; i < mPoints.length; i++){
+ for (int j = 0; j < mPoints[i].length; j++){
+ Paint paint=new Paint(Paint.ANTI_ALIAS_FLAG);
+ Point point = mPoints[i][j];
+ // 不同状态绘制点
+ switch (point.state){
+ case Point.STATE_NORMAL:
+ paint.setColor(mNormalColor);
+ canvas.drawCircle(point.x, point.y,mPointRadius,paint);
+ break;
+ case Point.STATE_PRESS:
+ paint.setColor(mPressColor);
+ canvas.drawCircle(point.x , point.y ,mPointRadius,paint);
+ break;
+ case Point.STATE_ERROR:
+ paint.setColor(mErrorColor);
+ canvas.drawCircle(point.x, point.y,mPointRadius,paint);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * 绘制所有的线
+ * @param canvas
+ */
+ private void drawLines(Canvas canvas){
+ if (mSelectedPoints.size() > 0){
+ // 从第一个被选中的点开始绘制
+ Point a = mSelectedPoints.get(0);
+ for (int i = 1; i < mSelectedPoints.size(); i++){
+ Point b = mSelectedPoints.get(i);
+ drawLine(canvas, a, b); // 连接两个点
+ a = b; // 把下一个点作为下一次绘制的第一个点
+ }
+ if (isDraw){// 如果还在绘制状态,那就继续绘制连接线
+ drawLine(canvas, a, new Point(mX, mY));
+ }
+ }
+ }
+
+ /**
+ * 绘制两点之间的线
+ * @param canvas
+ * @param a
+ * @param b
+ */
+ private void drawLine(Canvas canvas, Point a, Point b){
+ if (a.state == Point.STATE_PRESS){
+ canvas.drawLine(a.x, a.y, b.x, b.y, mPressPaint);
+ }
+ if (a.state == Point.STATE_ERROR){
+ canvas.drawLine(a.x, a.y, b.x, b.y, mErrorPaint);
+ }
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ mX = event.getX();
+ mY = event.getY();
+ int[] position;
+ int i, j;
+ if(mClickable){
+ switch (event.getAction()){
+ case MotionEvent.ACTION_DOWN:
+ // 重置所有的点
+ resetPoints();
+ // 获取选择的点的位置
+ position = getSelectedPointPosition();
+ if (position != null){
+ isDraw = true; // 标记为绘制状态
+ i = position[0];
+ j = position[1];
+ mPoints[i][j].state = Point.STATE_PRESS;
+ // 被选择的点存入一个集合中
+ mSelectedPoints.add(mPoints[i][j]);
+ mPassPositions.add(i * 3 + j); // 把选中的点的路径转换成一位数组存储起来
+ }
+ break;
+ case MotionEvent.ACTION_MOVE:
+ if (isDraw){
+ position = getSelectedPointPosition();
+ if (position != null){
+ i = position[0];
+ j = position[1];
+ if (!mSelectedPoints.contains(mPoints[i][j])){
+ mPoints[i][j].state = Point.STATE_PRESS;
+ mSelectedPoints.add(mPoints[i][j]);
+ mPassPositions.add(i * 3 + j);
+ }
+ }
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ boolean valid = false;
+ if (mListener != null && isDraw){
+ // 获取绘制路径是否正确
+ valid = mListener.onDrawFinished(mPassPositions);
+ }
+ if (!valid) {// 判断绘制路径不正确的所有被选中的点的状态改为出错
+ for (Point p : mSelectedPoints) {
+ p.state = Point.STATE_ERROR;
+ }
+ android.os.Handler handler = new android.os.Handler();
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if(!isDraw){
+ resetPoints();
+ }
+ }
+ }, 1 * 1000);
+ }
+ isDraw = false;
+ break;
+ }
+ invalidate();
+ }
+ return true;
+ }
+
+ /**
+ * 获取选择的点的位置
+ * @return
+ */
+ private int[] getSelectedPointPosition(){
+ Point point = new Point(mX, mY);
+ for (int i = 0; i < mPoints.length; i++) {
+ for (int j = 0; j < mPoints[i].length; j++) {
+ // 判断触摸的点和遍历的当前点的距离是否小于48dp
+ if(mPoints[i][j].getInstance(point) passPositions);
+ }
+
+ /**
+ * 设置绘制完成监听接口
+ * @param listener
+ */
+ public void setOnDrawFinishedListener(OnDrawFinishedListener listener){
+ this.mListener = listener;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/bigbig/ding/widget/MyDrawable.java b/app/src/main/java/com/bigbig/ding/widget/MyDrawable.java
new file mode 100644
index 0000000..5141c63
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/widget/MyDrawable.java
@@ -0,0 +1,29 @@
+package com.bigbig.ding.widget;
+
+import android.graphics.drawable.GradientDrawable;
+
+import com.blankj.utilcode.util.SizeUtils;
+
+
+/**
+ * Created by miaoyongyong on 2017/2/23.
+ */
+
+public class MyDrawable {
+
+// 便签夹 图标 的样式
+ public static GradientDrawable getIcFolderSelectedDrawable( int color){
+ GradientDrawable gradientDrawable=new GradientDrawable();
+ gradientDrawable.setShape(GradientDrawable.OVAL);
+ gradientDrawable.setSize(SizeUtils.dp2px(24), SizeUtils.dp2px(24));
+ gradientDrawable.setBounds(0,0,SizeUtils.dp2px(24), SizeUtils.dp2px(24));
+ gradientDrawable.setColor(color);
+ return gradientDrawable;
+ }
+
+//// 反馈页面的提交按钮
+// public static StateListDrawable getFeedbackBtnDrawable(){
+//
+// }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/widget/MyEditText.java b/app/src/main/java/com/bigbig/ding/widget/MyEditText.java
new file mode 100644
index 0000000..9e0e345
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/widget/MyEditText.java
@@ -0,0 +1,129 @@
+package com.bigbig.ding.widget;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.text.Editable;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.ImageSpan;
+import android.util.AttributeSet;
+
+import com.bigbig.ding.bean.ImageEntity;
+import com.bigbig.ding.constants.EditNoteConstans;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Created by miaoyongyong on 2017/2/8.
+ */
+
+public class MyEditText extends android.support.v7.widget.AppCompatEditText {
+
+ // 已插入的图片
+ public List mImageList = new ArrayList();
+ // 已删除的图片 在保存便签时应从储存中删除
+ public List mDeleteImageList=new ArrayList<>();
+
+ private Editable mEditable = getEditableText();
+
+ public MyEditText(Context context) {
+ super(context);
+ }
+
+ public MyEditText(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ /**
+ * 将文本中已有的imageName转换为Bitmap
+ */
+ public void replaceDrawable(Bitmap bitmap, String imageName) {
+ mEditable=getEditableText();
+
+ String imageFlag = getImageFlag(imageName);
+
+ SpannableString spannableString = getSpannableString(imageFlag, bitmap);
+
+
+ String content = mEditable.toString();
+ int start = content.indexOf(imageFlag);
+ int end = start + imageFlag.length();
+ mEditable.replace(start, end, spannableString);
+ addImage2List(start, end, imageFlag, imageName);
+ }
+
+ private SpannableString getSpannableString(String imageFlag, Bitmap bitmap) {
+ ImageSpan imageSpan = new ImageSpan(getContext(), bitmap);
+ SpannableString spannableString = new SpannableString(imageFlag);
+
+ spannableString.setSpan(imageSpan, 0, imageFlag.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return spannableString;
+ }
+
+ private String getImageFlag(String imageName) {
+ return EditNoteConstans.imageTabBefore + imageName + EditNoteConstans.imageTabAfter;
+ }
+
+ /**
+ * 插入图片到光标处
+ */
+ public void insertDrawable(Bitmap bitmap, String imageName) {
+
+ int index = getSelectionStart(); //获取光标所在位置
+ mEditable = getEditableText();
+
+ if (index != 0) {
+ String str = mEditable.toString().substring(index - 1, index);
+ if (!str.equals("\n") && !str.equals("\r")) { // 如果前一项不是换行符,则先添加换行符
+ mEditable.insert(index, "\n");
+ insertImageAndOneLine(bitmap, imageName, index + 1);
+ } else {
+ insertImageAndOneLine(bitmap, imageName, index);
+ }
+ } else {
+ insertImageAndOneLine(bitmap, imageName, index);
+ }
+ }
+
+ private void insertImageAndOneLine(Bitmap bitmap, String imageName, int index) {
+
+ String imageFlag = getImageFlag(imageName);
+ SpannableString spannableString = getSpannableString(imageFlag, bitmap);
+
+ mEditable.insert(index, spannableString);
+ mEditable.insert(index + imageFlag.length(), "\n"); // 后面再添加一行
+ addImage2List(index, index + imageFlag.length(), imageFlag, imageName);
+
+ }
+
+ private void addImage2List(int start, int end, String imageFlag, String imageName) {
+ ImageEntity imageEntity = new ImageEntity();
+ imageEntity.setStart(start);
+ imageEntity.setEnd(end);
+ imageEntity.setImageFlag(imageFlag);
+ imageEntity.setImageName(imageName);
+ mImageList.add(imageEntity);
+ }
+
+ /**
+ * 文字改变后,应更新图片列表中的位置参数
+ */
+ public void setTextCountChange(int start, int before, int count) {
+ for (int i = 0; i < mImageList.size(); i++) {
+ ImageEntity imageEntity = mImageList.get(i);
+ int imageStart = imageEntity.getStart();
+ int imageEnd = imageEntity.getEnd();
+ int changeCount = count - before;
+ // 如果图片在已改变文本的后面
+ if (start < imageStart) {
+ imageStart = imageStart + changeCount;
+ imageEnd = imageEnd + changeCount;
+ mImageList.get(i).setStart(imageStart);
+ mImageList.get(i).setEnd(imageEnd);
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/bigbig/ding/widget/MyScrollView.java b/app/src/main/java/com/bigbig/ding/widget/MyScrollView.java
new file mode 100644
index 0000000..f92ad40
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/widget/MyScrollView.java
@@ -0,0 +1,75 @@
+package com.bigbig.ding.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+import android.widget.ScrollView;
+
+import com.orhanobut.logger.Logger;
+
+import com.bigbig.ding.MainApplication;
+
+/**
+ *
+ * author : FaDai
+ * e-mail : i_fadai@163.com
+ * time : 2017/07/10
+ * desc : xxxx描述
+ * version: 1.0
+ *
+ */
+
+public class MyScrollView extends ScrollView {
+
+
+ final ViewConfiguration configuration = ViewConfiguration.get(MainApplication.mContext);
+ private float mTouchSlop = configuration.getScaledTouchSlop();
+
+ public MyScrollView(Context context) {
+ super(context);
+ }
+
+ public MyScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ boolean ret = super.dispatchTouchEvent(ev);
+ Logger.d("scrollView dispatchTouchEvent:" + ret);
+ return ret;
+ }
+
+ private float lastY;
+//
+// @Override
+// public boolean onInterceptTouchEvent(MotionEvent ev) {
+//// boolean ret=super.onInterceptTouchEvent(ev);
+//// Logger.d("scrollView onInterceptTouchEvent:"+ret);
+//// return ret;
+// switch (ev.getAction()) {
+// case MotionEvent.ACTION_DOWN:
+// lastY = ev.getY();
+// return false;
+// case MotionEvent.ACTION_MOVE:
+// if (Math.abs(lastY - ev.getY()) > mTouchSlop)
+// return true;
+// else super.onInterceptTouchEvent(ev);
+// default:
+// return super.onInterceptTouchEvent(ev);
+// }
+// }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ boolean ret = super.onTouchEvent(ev);
+ Logger.d("scrollView onTouchEvent:" + ret);
+ return ret;
+ }
+}
diff --git a/app/src/main/java/com/bigbig/ding/widget/ThemeChoicePreference.java b/app/src/main/java/com/bigbig/ding/widget/ThemeChoicePreference.java
new file mode 100644
index 0000000..de1c9a6
--- /dev/null
+++ b/app/src/main/java/com/bigbig/ding/widget/ThemeChoicePreference.java
@@ -0,0 +1,146 @@
+package com.bigbig.ding.widget;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.preference.DialogPreference;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+
+import com.bigbig.ding.R;
+
+import com.bigbig.ding.constants.Constans;
+
+/**
+ * Created by miaoyongyong on 2016/12/26.
+ */
+
+public class ThemeChoicePreference extends DialogPreference {
+
+ private Context mContext;
+
+
+ private int mCurrentValue; // 现在的value
+ private int mNewValue;// 新的value
+
+ private RadioGroup mGroup1;
+ private RadioGroup mGroup2;
+ private RadioGroup mGroup3;
+ private RadioGroup mGroup4;
+
+ // style文件中的所有theme
+ private int[] mThemes=new int[]{R.style.NoActionBar_Theme1,R.style.NoActionBar_Theme2,R.style.NoActionBar_Theme3
+ ,R.style.NoActionBar_Theme4,R.style.NoActionBar_Theme5,R.style.NoActionBar_Theme6
+ ,R.style.NoActionBar_Theme7,R.style.NoActionBar_Theme8,R.style.NoActionBar_Theme9
+ ,R.style.NoActionBar_Theme10,R.style.NoActionBar_Theme11,R.style.NoActionBar_Theme12
+ ,R.style.NoActionBar_Theme13,R.style.NoActionBar_Theme14,R.style.NoActionBar_Theme15
+ ,R.style.NoActionBar_Theme16,R.style.NoActionBar_Theme17,R.style.NoActionBar_Theme18
+ ,R.style.NoActionBar_Theme19};
+
+ // 所有的radioButton
+ private int[] mRdoBtns=new int[]{R.id.rdobtn_1,R.id.rdobtn_2,R.id.rdobtn_3,R.id.rdobtn_4,R.id.rdobtn_5
+ ,R.id.rdobtn_6,R.id.rdobtn_7,R.id.rdobtn_8,R.id.rdobtn_9,R.id.rdobtn_10
+ ,R.id.rdobtn_11,R.id.rdobtn_12,R.id.rdobtn_13,R.id.rdobtn_14,R.id.rdobtn_15
+ ,R.id.rdobtn_16,R.id.rdobtn_17,R.id.rdobtn_18,R.id.rdobtn_19};
+
+
+ public ThemeChoicePreference(final Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext=context;
+ }
+
+ @Override
+ protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
+ super.onPrepareDialogBuilder(builder);
+
+ View view= LayoutInflater.from(mContext).inflate(R.layout.dialog_theme_choice,null);
+
+ initRadioGroup(view);
+
+ builder.setView(view)
+ .setTitle("主题更换")
+ .setNegativeButton("", null)
+ .setPositiveButton("", null);
+
+ initSelectedRadioBtn(view);
+ }
+
+ private void initSelectedRadioBtn(View view){
+ for(int i=0;i
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/btn_folder_edit_pressed.xml b/app/src/main/res/drawable-v21/btn_folder_edit_pressed.xml
new file mode 100644
index 0000000..dce6533
--- /dev/null
+++ b/app/src/main/res/drawable-v21/btn_folder_edit_pressed.xml
@@ -0,0 +1,20 @@
+
+
+ -
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/cursor_drawable.xml b/app/src/main/res/drawable-v21/cursor_drawable.xml
new file mode 100644
index 0000000..6707235
--- /dev/null
+++ b/app/src/main/res/drawable-v21/cursor_drawable.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-v21/ic_menu_camera.xml
new file mode 100644
index 0000000..0d9ea10
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_camera.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/app/src/main/res/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-v21/ic_menu_gallery.xml
new file mode 100644
index 0000000..f6872c4
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_gallery.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-v21/ic_menu_manage.xml
new file mode 100644
index 0000000..c1be60b
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_manage.xml
@@ -0,0 +1,9 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-v21/ic_menu_send.xml
new file mode 100644
index 0000000..00c668c
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_send.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-v21/ic_menu_share.xml
new file mode 100644
index 0000000..a28fb9e
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_share.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml
new file mode 100644
index 0000000..209aa64
--- /dev/null
+++ b/app/src/main/res/drawable-v21/ic_menu_slideshow.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-v21/img_current_theme.xml b/app/src/main/res/drawable-v21/img_current_theme.xml
new file mode 100644
index 0000000..d3b6c0d
--- /dev/null
+++ b/app/src/main/res/drawable-v21/img_current_theme.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/rl_folder_bg.xml b/app/src/main/res/drawable-v21/rl_folder_bg.xml
new file mode 100644
index 0000000..c6ead9a
--- /dev/null
+++ b/app/src/main/res/drawable-v21/rl_folder_bg.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/rl_folder_selected_bg.xml b/app/src/main/res/drawable-v21/rl_folder_selected_bg.xml
new file mode 100644
index 0000000..94520f0
--- /dev/null
+++ b/app/src/main/res/drawable-v21/rl_folder_selected_bg.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_camera.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_camera.xml
new file mode 100644
index 0000000..0d9ea10
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_camera.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_gallery.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_gallery.xml
new file mode 100644
index 0000000..f6872c4
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_gallery.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_manage.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_manage.xml
new file mode 100644
index 0000000..c1be60b
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_manage.xml
@@ -0,0 +1,9 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_send.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_send.xml
new file mode 100644
index 0000000..00c668c
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_send.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_share.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_share.xml
new file mode 100644
index 0000000..a28fb9e
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_share.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_slideshow.xml b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_slideshow.xml
new file mode 100644
index 0000000..209aa64
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable-v21/ic_menu_slideshow.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable-xhdpi/drawable/side_nav_bar.xml b/app/src/main/res/drawable-xhdpi/drawable/side_nav_bar.xml
new file mode 100644
index 0000000..458b4b0
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/drawable/side_nav_bar.xml
@@ -0,0 +1,9 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_alipay.png b/app/src/main/res/drawable-xhdpi/ic_action_alipay.png
new file mode 100644
index 0000000..a4e2407
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_alipay.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_blog.png b/app/src/main/res/drawable-xhdpi/ic_action_blog.png
new file mode 100644
index 0000000..f44ce63
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_blog.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_email.png b/app/src/main/res/drawable-xhdpi/ic_action_email.png
new file mode 100644
index 0000000..8b30508
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_email.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_github.png b/app/src/main/res/drawable-xhdpi/ic_action_github.png
new file mode 100644
index 0000000..aaccfd5
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_github.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_action_jianshu.png b/app/src/main/res/drawable-xhdpi/ic_action_jianshu.png
new file mode 100644
index 0000000..98663af
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_jianshu.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..67bb598
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png
new file mode 100644
index 0000000..ce5b878
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_arrow_back_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_border_all_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_border_all_white_24dp.png
new file mode 100644
index 0000000..1235c87
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_border_all_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_check_box_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_check_box_white_24dp.png
new file mode 100644
index 0000000..d159855
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_check_box_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_check_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_check_white_24dp.png
new file mode 100644
index 0000000..3b2b65d
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_check_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_clear_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_clear_white_24dp.png
new file mode 100644
index 0000000..b7c7ffd
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_clear_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_cloud_download_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_cloud_download_black_24dp.png
new file mode 100644
index 0000000..c324cd5
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_cloud_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_create_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_create_black_24dp.png
new file mode 100644
index 0000000..87f8de1
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_create_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png
new file mode 100644
index 0000000..796ccd2
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_white_18dp.png
new file mode 100644
index 0000000..4a9f769
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png
new file mode 100644
index 0000000..388b5b0
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_delete_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_done_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_done_black_24dp.png
new file mode 100644
index 0000000..64a4944
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_done_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_extension_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_extension_white_18dp.png
new file mode 100644
index 0000000..5f9217f
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_extension_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_file_download_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_file_download_black_24dp.png
new file mode 100644
index 0000000..f5afb24
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_file_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_file_download_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_file_download_white_18dp.png
new file mode 100644
index 0000000..c8a2039
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_file_download_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_folder_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_folder_black_24dp.png
new file mode 100644
index 0000000..49272b0
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_folder_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_folder_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_folder_white_18dp.png
new file mode 100644
index 0000000..02ea533
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_folder_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_format_list_bulleted_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_format_list_bulleted_white_24dp.png
new file mode 100644
index 0000000..d8d86c2
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_format_list_bulleted_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_lock_open_white_48dp.png b/app/src/main/res/drawable-xhdpi/ic_lock_open_white_48dp.png
new file mode 100644
index 0000000..8ab4107
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_lock_open_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_lock_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_lock_white_18dp.png
new file mode 100644
index 0000000..cd4f04a
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_lock_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_mood_bad_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_mood_bad_black_24dp.png
new file mode 100644
index 0000000..8b9ce5e
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_mood_bad_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_mood_bad_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_mood_bad_white_24dp.png
new file mode 100644
index 0000000..ced5032
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_mood_bad_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_mood_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_mood_white_24dp.png
new file mode 100644
index 0000000..c97abc4
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_mood_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_open_with_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_open_with_white_18dp.png
new file mode 100644
index 0000000..da103f1
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_open_with_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_photo_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_photo_black_24dp.png
new file mode 100644
index 0000000..6b7cd78
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_photo_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_photo_camera_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_photo_camera_black_24dp.png
new file mode 100644
index 0000000..d83d658
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_photo_camera_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_save_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_save_black_24dp.png
new file mode 100644
index 0000000..eca2d92
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_save_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png
new file mode 100644
index 0000000..bfc3e39
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_search_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_settings_white_18dp.png b/app/src/main/res/drawable-xhdpi/ic_settings_white_18dp.png
new file mode 100644
index 0000000..97ded33
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_settings_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/side_nav_bar.xml b/app/src/main/res/drawable-xhdpi/side_nav_bar.xml
new file mode 100644
index 0000000..58a144e
--- /dev/null
+++ b/app/src/main/res/drawable-xhdpi/side_nav_bar.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_alipay.png b/app/src/main/res/drawable-xxhdpi/ic_action_alipay.png
new file mode 100644
index 0000000..2cf4101
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_alipay.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_blog.png b/app/src/main/res/drawable-xxhdpi/ic_action_blog.png
new file mode 100644
index 0000000..8cedbc3
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_blog.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_email.png b/app/src/main/res/drawable-xxhdpi/ic_action_email.png
new file mode 100644
index 0000000..861b95a
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_email.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_github.png b/app/src/main/res/drawable-xxhdpi/ic_action_github.png
new file mode 100644
index 0000000..120f762
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_github.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_jianshu.png b/app/src/main/res/drawable-xxhdpi/ic_action_jianshu.png
new file mode 100644
index 0000000..da00147
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_jianshu.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..0fdced8
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png
new file mode 100644
index 0000000..746d775
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_arrow_back_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_border_all_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_border_all_white_24dp.png
new file mode 100644
index 0000000..146d47c
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_border_all_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_check_box_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_check_box_white_24dp.png
new file mode 100644
index 0000000..3287ddf
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_check_box_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_check_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_check_white_24dp.png
new file mode 100644
index 0000000..2c2ad77
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_check_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_clear_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_clear_white_24dp.png
new file mode 100644
index 0000000..6b717e0
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_clear_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_cloud_download_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_cloud_download_black_24dp.png
new file mode 100644
index 0000000..254c20f
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_cloud_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_create_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_create_black_24dp.png
new file mode 100644
index 0000000..4af4ae6
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_create_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png
new file mode 100644
index 0000000..6d7cb81
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_16dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_16dp.png
new file mode 100644
index 0000000..388b5b0
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_white_16dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_18dp.png
new file mode 100644
index 0000000..c836e39
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png
new file mode 100644
index 0000000..3fcdfdb
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_delete_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_done_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_done_black_24dp.png
new file mode 100644
index 0000000..c9c0174
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_done_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_extension_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_extension_white_18dp.png
new file mode 100644
index 0000000..22bf741
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_extension_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_file_download_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_file_download_black_24dp.png
new file mode 100644
index 0000000..ce97c85
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_file_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_file_download_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_file_download_white_18dp.png
new file mode 100644
index 0000000..fa3ebbb
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_file_download_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_folder_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_folder_black_24dp.png
new file mode 100644
index 0000000..5c4360a
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_folder_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_folder_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_folder_white_18dp.png
new file mode 100644
index 0000000..ebb23d1
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_folder_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_format_list_bulleted_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_format_list_bulleted_white_24dp.png
new file mode 100644
index 0000000..138bd06
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_format_list_bulleted_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_lock_open_white_48dp.png b/app/src/main/res/drawable-xxhdpi/ic_lock_open_white_48dp.png
new file mode 100644
index 0000000..57d6a6f
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_lock_open_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_lock_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_lock_white_18dp.png
new file mode 100644
index 0000000..47bd641
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_lock_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_mood_bad_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_mood_bad_black_24dp.png
new file mode 100644
index 0000000..5068675
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_mood_bad_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_mood_bad_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_mood_bad_white_24dp.png
new file mode 100644
index 0000000..0104e02
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_mood_bad_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_mood_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_mood_white_24dp.png
new file mode 100644
index 0000000..4bfd751
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_mood_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_open_with_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_open_with_white_18dp.png
new file mode 100644
index 0000000..f94079d
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_open_with_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_photo_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_photo_black_24dp.png
new file mode 100644
index 0000000..7297bd5
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_photo_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_photo_camera_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_photo_camera_black_24dp.png
new file mode 100644
index 0000000..6125fa2
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_photo_camera_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_save_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_save_black_24dp.png
new file mode 100644
index 0000000..871291b
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_save_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png
new file mode 100644
index 0000000..abbb989
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_search_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_settings_white_18dp.png b/app/src/main/res/drawable-xxhdpi/ic_settings_white_18dp.png
new file mode 100644
index 0000000..64f77e1
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_settings_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_alipay.png b/app/src/main/res/drawable-xxxhdpi/ic_action_alipay.png
new file mode 100644
index 0000000..4c8f304
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_alipay.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_blog.png b/app/src/main/res/drawable-xxxhdpi/ic_action_blog.png
new file mode 100644
index 0000000..723f59a
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_blog.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_email.png b/app/src/main/res/drawable-xxxhdpi/ic_action_email.png
new file mode 100644
index 0000000..994046c
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_email.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_github.png b/app/src/main/res/drawable-xxxhdpi/ic_action_github.png
new file mode 100644
index 0000000..a91f482
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_github.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_jianshu.png b/app/src/main/res/drawable-xxxhdpi/ic_action_jianshu.png
new file mode 100644
index 0000000..be65adb
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_jianshu.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png
new file mode 100644
index 0000000..d64c22e
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png
new file mode 100644
index 0000000..fb06e1d
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_arrow_back_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_border_all_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_border_all_white_24dp.png
new file mode 100644
index 0000000..b54b794
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_border_all_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_check_box_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_check_box_white_24dp.png
new file mode 100644
index 0000000..769210e
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_check_box_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_check_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_check_white_24dp.png
new file mode 100644
index 0000000..d670618
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_check_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_clear_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_clear_white_24dp.png
new file mode 100644
index 0000000..3964192
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_clear_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_cloud_download_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_cloud_download_black_24dp.png
new file mode 100644
index 0000000..04ae376
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_cloud_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_create_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_create_black_24dp.png
new file mode 100644
index 0000000..d6761ba
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_create_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png
new file mode 100644
index 0000000..f2b75c3
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_18dp.png
new file mode 100644
index 0000000..3fcdfdb
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png
new file mode 100644
index 0000000..8d322aa
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_delete_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png
new file mode 100644
index 0000000..2f6d638
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_done_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_extension_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_extension_white_18dp.png
new file mode 100644
index 0000000..58c7e5a
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_extension_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_file_download_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_file_download_black_24dp.png
new file mode 100644
index 0000000..8c83bff
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_file_download_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_file_download_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_file_download_white_18dp.png
new file mode 100644
index 0000000..671e0b3
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_file_download_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_folder_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_folder_black_24dp.png
new file mode 100644
index 0000000..073d853
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_folder_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_folder_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_folder_white_18dp.png
new file mode 100644
index 0000000..b93d5a1
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_folder_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_format_list_bulleted_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_format_list_bulleted_white_24dp.png
new file mode 100644
index 0000000..7cebd0c
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_format_list_bulleted_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_lock_open_white_48dp.png b/app/src/main/res/drawable-xxxhdpi/ic_lock_open_white_48dp.png
new file mode 100644
index 0000000..d14df9f
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_lock_open_white_48dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_lock_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_lock_white_18dp.png
new file mode 100644
index 0000000..0e52c7c
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_lock_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_black_24dp.png
new file mode 100644
index 0000000..2e03d28
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_white_24dp.png
new file mode 100644
index 0000000..b0381dc
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_mood_bad_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_mood_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_mood_white_24dp.png
new file mode 100644
index 0000000..319a13a
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_mood_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_open_with_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_open_with_white_18dp.png
new file mode 100644
index 0000000..3ee4d4b
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_open_with_white_18dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_photo_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_photo_black_24dp.png
new file mode 100644
index 0000000..ebe206f
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_photo_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_photo_camera_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_photo_camera_black_24dp.png
new file mode 100644
index 0000000..6df33ed
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_photo_camera_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_save_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_save_black_24dp.png
new file mode 100644
index 0000000..ba00183
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_save_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_search_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_search_white_24dp.png
new file mode 100644
index 0000000..dd5adfc
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_search_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_settings_white_18dp.png b/app/src/main/res/drawable-xxxhdpi/ic_settings_white_18dp.png
new file mode 100644
index 0000000..eabb0a2
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_settings_white_18dp.png differ
diff --git a/app/src/main/res/drawable/bg_main_folder.xml b/app/src/main/res/drawable/bg_main_folder.xml
new file mode 100644
index 0000000..0284602
--- /dev/null
+++ b/app/src/main/res/drawable/bg_main_folder.xml
@@ -0,0 +1,7 @@
+
+
+ -
+
+ -
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/btn_dialog_pressed.xml b/app/src/main/res/drawable/btn_dialog_pressed.xml
new file mode 100644
index 0000000..18abadb
--- /dev/null
+++ b/app/src/main/res/drawable/btn_dialog_pressed.xml
@@ -0,0 +1,13 @@
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/btn_feedback_pressed.xml b/app/src/main/res/drawable/btn_feedback_pressed.xml
new file mode 100644
index 0000000..6a0226a
--- /dev/null
+++ b/app/src/main/res/drawable/btn_feedback_pressed.xml
@@ -0,0 +1,38 @@
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/btn_folder_edit_pressed.xml b/app/src/main/res/drawable/btn_folder_edit_pressed.xml
new file mode 100644
index 0000000..02b1fa4
--- /dev/null
+++ b/app/src/main/res/drawable/btn_folder_edit_pressed.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/cursor_drawable.xml b/app/src/main/res/drawable/cursor_drawable.xml
new file mode 100644
index 0000000..f160dfc
--- /dev/null
+++ b/app/src/main/res/drawable/cursor_drawable.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_folder_delete_focused.xml b/app/src/main/res/drawable/ic_folder_delete_focused.xml
new file mode 100644
index 0000000..d36085e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_folder_delete_focused.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_folder_selsected.xml b/app/src/main/res/drawable/ic_folder_selsected.xml
new file mode 100644
index 0000000..efac9fd
--- /dev/null
+++ b/app/src/main/res/drawable/ic_folder_selsected.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_folder_un_selected.xml b/app/src/main/res/drawable/ic_folder_un_selected.xml
new file mode 100644
index 0000000..28fff31
--- /dev/null
+++ b/app/src/main/res/drawable/ic_folder_un_selected.xml
@@ -0,0 +1,14 @@
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/note_item_bg.xml b/app/src/main/res/drawable/note_item_bg.xml
new file mode 100644
index 0000000..77da91c
--- /dev/null
+++ b/app/src/main/res/drawable/note_item_bg.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/rdo_btn_theme_transparent.xml b/app/src/main/res/drawable/rdo_btn_theme_transparent.xml
new file mode 100644
index 0000000..490a6d5
--- /dev/null
+++ b/app/src/main/res/drawable/rdo_btn_theme_transparent.xml
@@ -0,0 +1,25 @@
+
+
+ -
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/rl_folder_bg.xml b/app/src/main/res/drawable/rl_folder_bg.xml
new file mode 100644
index 0000000..c35f460
--- /dev/null
+++ b/app/src/main/res/drawable/rl_folder_bg.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/rl_folder_item_selected.xml b/app/src/main/res/drawable/rl_folder_item_selected.xml
new file mode 100644
index 0000000..b0ca566
--- /dev/null
+++ b/app/src/main/res/drawable/rl_folder_item_selected.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/rl_folder_selected_bg.xml b/app/src/main/res/drawable/rl_folder_selected_bg.xml
new file mode 100644
index 0000000..5789b00
--- /dev/null
+++ b/app/src/main/res/drawable/rl_folder_selected_bg.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/side_nav_bar.xml b/app/src/main/res/drawable/side_nav_bar.xml
new file mode 100644
index 0000000..f033617
--- /dev/null
+++ b/app/src/main/res/drawable/side_nav_bar.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tv_delete_pressed.xml b/app/src/main/res/drawable/tv_delete_pressed.xml
new file mode 100644
index 0000000..a83e3d3
--- /dev/null
+++ b/app/src/main/res/drawable/tv_delete_pressed.xml
@@ -0,0 +1,64 @@
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tv_down_pressed.xml b/app/src/main/res/drawable/tv_down_pressed.xml
new file mode 100644
index 0000000..98847da
--- /dev/null
+++ b/app/src/main/res/drawable/tv_down_pressed.xml
@@ -0,0 +1,64 @@
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tv_move_pressed.xml b/app/src/main/res/drawable/tv_move_pressed.xml
new file mode 100644
index 0000000..7367b5a
--- /dev/null
+++ b/app/src/main/res/drawable/tv_move_pressed.xml
@@ -0,0 +1,64 @@
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/tv_privacy_pressed.xml b/app/src/main/res/drawable/tv_privacy_pressed.xml
new file mode 100644
index 0000000..f7334f9
--- /dev/null
+++ b/app/src/main/res/drawable/tv_privacy_pressed.xml
@@ -0,0 +1,64 @@
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-v21/preference_theme_change.xml b/app/src/main/res/layout-v21/preference_theme_change.xml
new file mode 100644
index 0000000..04831e7
--- /dev/null
+++ b/app/src/main/res/layout-v21/preference_theme_change.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml
new file mode 100644
index 0000000..34408f3
--- /dev/null
+++ b/app/src/main/res/layout/activity_about.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_developer.xml b/app/src/main/res/layout/activity_developer.xml
new file mode 100644
index 0000000..0846fb5
--- /dev/null
+++ b/app/src/main/res/layout/activity_developer.xml
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_folder.xml b/app/src/main/res/layout/activity_edit_folder.xml
new file mode 100644
index 0000000..31bd3ad
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_folder.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_edit_note.xml b/app/src/main/res/layout/activity_edit_note.xml
new file mode 100644
index 0000000..2497354
--- /dev/null
+++ b/app/src/main/res/layout/activity_edit_note.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_feedback.xml b/app/src/main/res/layout/activity_feedback.xml
new file mode 100644
index 0000000..39324f6
--- /dev/null
+++ b/app/src/main/res/layout/activity_feedback.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_image.xml b/app/src/main/res/layout/activity_image.xml
new file mode 100644
index 0000000..b10133c
--- /dev/null
+++ b/app/src/main/res/layout/activity_image.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_lock.xml b/app/src/main/res/layout/activity_lock.xml
new file mode 100644
index 0000000..b6dc1f8
--- /dev/null
+++ b/app/src/main/res/layout/activity_lock.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_lock_setting.xml b/app/src/main/res/layout/activity_lock_setting.xml
new file mode 100644
index 0000000..f0bc75d
--- /dev/null
+++ b/app/src/main/res/layout/activity_lock_setting.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..77902d5
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml
new file mode 100644
index 0000000..5b49b94
--- /dev/null
+++ b/app/src/main/res/layout/activity_setting.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_share.xml b/app/src/main/res/layout/activity_share.xml
new file mode 100644
index 0000000..337d737
--- /dev/null
+++ b/app/src/main/res/layout/activity_share.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_test.xml b/app/src/main/res/layout/activity_test.xml
new file mode 100644
index 0000000..aebd847
--- /dev/null
+++ b/app/src/main/res/layout/activity_test.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml
new file mode 100644
index 0000000..3f9d32e
--- /dev/null
+++ b/app/src/main/res/layout/app_bar_main.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/bottom_sheet_folder.xml b/app/src/main/res/layout/bottom_sheet_folder.xml
new file mode 100644
index 0000000..b3ce9f2
--- /dev/null
+++ b/app/src/main/res/layout/bottom_sheet_folder.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/content_main.xml b/app/src/main/res/layout/content_main.xml
new file mode 100644
index 0000000..fd50995
--- /dev/null
+++ b/app/src/main/res/layout/content_main.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/dialog_theme_choice.xml b/app/src/main/res/layout/dialog_theme_choice.xml
new file mode 100644
index 0000000..203bdb0
--- /dev/null
+++ b/app/src/main/res/layout/dialog_theme_choice.xml
@@ -0,0 +1,225 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_folder.xml b/app/src/main/res/layout/fragment_folder.xml
new file mode 100644
index 0000000..3573422
--- /dev/null
+++ b/app/src/main/res/layout/fragment_folder.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/include_collapsing_toolbar_layout.xml b/app/src/main/res/layout/include_collapsing_toolbar_layout.xml
new file mode 100644
index 0000000..e79474b
--- /dev/null
+++ b/app/src/main/res/layout/include_collapsing_toolbar_layout.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/include_toolbar.xml b/app/src/main/res/layout/include_toolbar.xml
new file mode 100644
index 0000000..7431a66
--- /dev/null
+++ b/app/src/main/res/layout/include_toolbar.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_edit_folder.xml b/app/src/main/res/layout/item_edit_folder.xml
new file mode 100644
index 0000000..34b2124
--- /dev/null
+++ b/app/src/main/res/layout/item_edit_folder.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_folder.xml b/app/src/main/res/layout/item_folder.xml
new file mode 100644
index 0000000..e53d7bc
--- /dev/null
+++ b/app/src/main/res/layout/item_folder.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_note.xml b/app/src/main/res/layout/item_note.xml
new file mode 100644
index 0000000..d2bbd6c
--- /dev/null
+++ b/app/src/main/res/layout/item_note.xml
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_note_bottom_folder.xml b/app/src/main/res/layout/item_note_bottom_folder.xml
new file mode 100644
index 0000000..5182c17
--- /dev/null
+++ b/app/src/main/res/layout/item_note_bottom_folder.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_empty.xml b/app/src/main/res/layout/layout_empty.xml
new file mode 100644
index 0000000..63b5c9e
--- /dev/null
+++ b/app/src/main/res/layout/layout_empty.xml
@@ -0,0 +1,18 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_folder_footer.xml b/app/src/main/res/layout/layout_folder_footer.xml
new file mode 100644
index 0000000..4bb55a0
--- /dev/null
+++ b/app/src/main/res/layout/layout_folder_footer.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_folder_hearder.xml b/app/src/main/res/layout/layout_folder_hearder.xml
new file mode 100644
index 0000000..2fcaffc
--- /dev/null
+++ b/app/src/main/res/layout/layout_folder_hearder.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/layout_folder_hearder_2.xml b/app/src/main/res/layout/layout_folder_hearder_2.xml
new file mode 100644
index 0000000..e095ffa
--- /dev/null
+++ b/app/src/main/res/layout/layout_folder_hearder_2.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_notelist_bottom_bar.xml b/app/src/main/res/layout/layout_notelist_bottom_bar.xml
new file mode 100644
index 0000000..3cf4958
--- /dev/null
+++ b/app/src/main/res/layout/layout_notelist_bottom_bar.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/preference_theme_change.xml b/app/src/main/res/layout/preference_theme_change.xml
new file mode 100644
index 0000000..0ad93d0
--- /dev/null
+++ b/app/src/main/res/layout/preference_theme_change.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml
new file mode 100644
index 0000000..40491cf
--- /dev/null
+++ b/app/src/main/res/menu/main.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/menu_feedback.xml b/app/src/main/res/menu/menu_feedback.xml
new file mode 100644
index 0000000..cf0873b
--- /dev/null
+++ b/app/src/main/res/menu/menu_feedback.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_folder.xml b/app/src/main/res/menu/menu_folder.xml
new file mode 100644
index 0000000..365316e
--- /dev/null
+++ b/app/src/main/res/menu/menu_folder.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_lock.xml b/app/src/main/res/menu/menu_lock.xml
new file mode 100644
index 0000000..34f7379
--- /dev/null
+++ b/app/src/main/res/menu/menu_lock.xml
@@ -0,0 +1,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_note.xml b/app/src/main/res/menu/menu_note.xml
new file mode 100644
index 0000000..52cff36
--- /dev/null
+++ b/app/src/main/res/menu/menu_note.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_share.xml b/app/src/main/res/menu/menu_share.xml
new file mode 100644
index 0000000..4cb6d26
--- /dev/null
+++ b/app/src/main/res/menu/menu_share.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..036d09b
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..036d09b
--- /dev/null
+++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..18806a5
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_alpha.png b/app/src/main/res/mipmap-hdpi/ic_launcher_alpha.png
new file mode 100644
index 0000000..be60bfb
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_alpha.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_circle.png b/app/src/main/res/mipmap-hdpi/ic_launcher_circle.png
new file mode 100644
index 0000000..f7439d6
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_circle.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..693668a
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..49e023c
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-hdpi/icon_alpha.png b/app/src/main/res/mipmap-hdpi/icon_alpha.png
new file mode 100644
index 0000000..0e6cb57
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/icon_alpha.png differ
diff --git a/app/src/main/res/mipmap-hdpi/icon_launcher.png b/app/src/main/res/mipmap-hdpi/icon_launcher.png
new file mode 100644
index 0000000..3e60840
Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/icon_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..7ef5aae
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_alpha.png b/app/src/main/res/mipmap-mdpi/ic_launcher_alpha.png
new file mode 100644
index 0000000..f6157c2
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_alpha.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_circle.png b/app/src/main/res/mipmap-mdpi/ic_launcher_circle.png
new file mode 100644
index 0000000..7ecccfd
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_circle.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..95d375a
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..734a56c
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-mdpi/icon_alpha.png b/app/src/main/res/mipmap-mdpi/icon_alpha.png
new file mode 100644
index 0000000..ac9ee09
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/icon_alpha.png differ
diff --git a/app/src/main/res/mipmap-mdpi/icon_launcher.png b/app/src/main/res/mipmap-mdpi/icon_launcher.png
new file mode 100644
index 0000000..cfc8763
Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/icon_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..5ea66d2
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_alpha.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_alpha.png
new file mode 100644
index 0000000..36cb298
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_alpha.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_circle.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_circle.png
new file mode 100644
index 0000000..1559827
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_circle.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..d9f4540
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..7bb59b6
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/icon_alpha.png b/app/src/main/res/mipmap-xhdpi/icon_alpha.png
new file mode 100644
index 0000000..2a7cbe6
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_alpha.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/icon_launcher.png b/app/src/main/res/mipmap-xhdpi/icon_launcher.png
new file mode 100644
index 0000000..6160113
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/icon_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..78fb797
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_alpha.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_alpha.png
new file mode 100644
index 0000000..b869912
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_alpha.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_circle.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_circle.png
new file mode 100644
index 0000000..f892c0d
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_circle.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..8deb640
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..715f085
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/icon_alpha.png b/app/src/main/res/mipmap-xxhdpi/icon_alpha.png
new file mode 100644
index 0000000..a2bbc91
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/icon_alpha.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/icon_launcher.png b/app/src/main/res/mipmap-xxhdpi/icon_launcher.png
new file mode 100644
index 0000000..271785a
Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/icon_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..732eac7
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_alpha.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_alpha.png
new file mode 100644
index 0000000..6a4cc03
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_alpha.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_circle.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_circle.png
new file mode 100644
index 0000000..db4b3f3
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_circle.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
new file mode 100644
index 0000000..c4df70a
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..fe44f7f
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/icon_alpha.png b/app/src/main/res/mipmap-xxxhdpi/icon_alpha.png
new file mode 100644
index 0000000..b840a88
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/icon_alpha.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/icon_launcher.png b/app/src/main/res/mipmap-xxxhdpi/icon_launcher.png
new file mode 100644
index 0000000..d167181
Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/icon_launcher.png differ
diff --git a/app/src/main/res/transition/explode_in.xml b/app/src/main/res/transition/explode_in.xml
new file mode 100644
index 0000000..d02b8c7
--- /dev/null
+++ b/app/src/main/res/transition/explode_in.xml
@@ -0,0 +1,3 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/transition/push_down_in.xml b/app/src/main/res/transition/push_down_in.xml
new file mode 100644
index 0000000..bea7380
--- /dev/null
+++ b/app/src/main/res/transition/push_down_in.xml
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/transition/push_down_out.xml b/app/src/main/res/transition/push_down_out.xml
new file mode 100644
index 0000000..7c6c6ce
--- /dev/null
+++ b/app/src/main/res/transition/push_down_out.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..8c213e3
--- /dev/null
+++ b/app/src/main/res/values/attrs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..f4c3c34
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,320 @@
+
+
+ #1E000000
+ #42000000
+ #89000000
+ #DD000000
+ #FF000000
+
+ #00000000
+
+
+
+ #1EFFFFFF
+ #4CFFFFFF
+ #B2FFFFFF
+ #FFFFFF
+
+ #19999999
+ #33999999
+ #66999999
+
+ #CED1D1
+ #6D6D6D
+ ?attr/colorPrimary
+ ?attr/colorPrimaryDark
+ ?attr/colorAccent
+ #F7F7F7
+ #F2F2F2
+ #E6E6E6
+ #EEEEEE
+ #E0E0E0
+ #EFA71C
+
+
+ #795548
+ #5d4037
+ #d7ccc8
+
+ #607d8b
+ #455a64
+ #cfd8dc
+
+ #9e9e9e
+ #616161
+ #f5f5f5
+
+ #fde0dc
+ #f9bdbb
+ #f69988
+ #f36c60
+ #e84e40
+ #e51c23
+ #dd191d
+ #d01716
+ #c41411
+ #b0120a
+ #ff7997
+ #ff5177
+ #ff2d6f
+ #e00032
+
+ #fce4ec
+ #f8bbd0
+ #f48fb1
+ #f06292
+ #ec407a
+ #e91e63
+ #d81b60
+ #c2185b
+ #ad1457
+ #880e4f
+ #ff80ab
+ #ff4081
+ #f50057
+ #c51162
+
+ #f3e5f5
+ #e1bee7
+ #ce93d8
+ #ba68c8
+ #ab47bc
+ #9c27b0
+ #8e24aa
+ #7b1fa2
+ #6a1b9a
+ #4a148c
+ #ea80fc
+ #e040fb
+ #d500f9
+ #aa00ff
+
+ #ede7f6
+ #d1c4e9
+ #b39ddb
+ #9575cd
+ #7e57c2
+ #673ab7
+ #5e35b1
+ #512da8
+ #4527a0
+ #311b92
+ #b388ff
+ #7c4dff
+ #651fff
+ #6200ea
+
+ #e8eaf6
+ #c5cae9
+ #9fa8da
+ #7986cb
+ #5c6bc0
+ #3f51b5
+ #3949ab
+ #303f9f
+ #283593
+ #1a237e
+ #8c9eff
+ #536dfe
+ #3d5afe
+ #304ffe
+
+ #e7e9fd
+ #d0d9ff
+ #afbfff
+ #91a7ff
+ #738ffe
+ #5677fc
+ #4e6cef
+ #455ede
+ #3b50ce
+ #2a36b1
+ #a6baff
+ #6889ff
+ #4d73ff
+ #4d69ff
+
+ #e1f5fe
+ #b3e5fc
+ #81d4fa
+ #4fc3f7
+ #29b6f6
+ #03a9f4
+ #039be5
+ #0288d1
+ #0277bd
+ #01579b
+ #80d8ff
+ #40c4ff
+ #00b0ff
+ #0091ea
+
+ #e0f7fa
+ #b2ebf2
+ #80deea
+ #4dd0e1
+ #26c6da
+ #00bcd4
+ #00acc1
+ #0097a7
+ #00838f
+ #006064
+ #84ffff
+ #18ffff
+ #00e5ff
+ #00b8d4
+
+ #e0f2f1
+ #b2dfdb
+ #80cbc4
+ #4db6ac
+ #26a69a
+ #009688
+ #00897b
+ #00796b
+ #00695c
+ #004d40
+ #a7ffeb
+ #64ffda
+ #1de9b6
+ #00bfa5
+
+ #d0f8ce
+ #a3e9a4
+ #72d572
+ #42bd41
+ #2baf2b
+ #259b24
+ #0a8f08
+ #0a7e07
+ #056f00
+ #0d5302
+ #a2f78d
+ #5af158
+ #14e715
+ #12c700
+
+ #f1f8e9
+ #dcedc8
+ #c5e1a5
+ #aed581
+ #9ccc65
+ #8bc34a
+ #7cb342
+ #689f38
+ #558b2f
+ #33691e
+ #ccff90
+ #b2ff59
+ #76ff03
+ #64dd17
+
+ #f9fbe7
+ #f0f4c3
+ #e6ee9c
+ #dce775
+ #d4e157
+ #cddc39
+ #c0ca33
+ #afb42b
+ #9e9d24
+ #827717
+ #f4ff81
+ #eeff41
+ #c6ff00
+ #aeea00
+
+ #fffde7
+ #fff9c4
+ #fff59d
+ #fff176
+ #ffee58
+ #ffeb3b
+ #fdd835
+ #fbc02d
+ #f9a825
+ #f57f17
+ #ffff8d
+ #ffff00
+ #ffea00
+ #ffd600
+
+ #fff8e1
+ #ffecb3
+ #ffe082
+ #ffd54f
+ #ffca28
+ #ffc107
+ #ffb300
+ #ffa000
+ #ff8f00
+ #ff6f00
+ #ffe57f
+ #ffd740
+ #ffc400
+ #ffab00
+
+ #fff3e0
+ #ffe0b2
+ #ffcc80
+ #ffb74d
+ #ffa726
+ #ff9800
+ #fb8c00
+ #f57c00
+ #ef6c00
+ #e65100
+ #ffd180
+ #ffab40
+ #ff9100
+ #ff6d00
+
+ #fbe9e7
+ #ffccbc
+ #ffab91
+ #ff8a65
+ #ff7043
+ #ff5722
+ #f4511e
+ #e64a19
+ #d84315
+ #bf360c
+ #ff9e80
+ #ff6e40
+ #ff3d00
+ #dd2c00
+
+ #efebe9
+ #d7ccc8
+ #bcaaa4
+ #a1887f
+ #8d6e63
+ #795548
+ #6d4c41
+ #5d4037
+ #4e342e
+ #3e2723
+
+ #fafafa
+ #f5f5f5
+ #eeeeee
+ #e0e0e0
+ #bdbdbd
+ #9e9e9e
+ #757575
+ #616161
+ #424242
+ #212121
+ #000000
+
+ #eceff1
+ #cfd8dc
+ #b0bec5
+ #90a4ae
+ #78909c
+ #607d8b
+ #546e7a
+ #455a64
+ #37474f
+ #263238
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..8f830ee
--- /dev/null
+++ b/app/src/main/res/values/dimens.xml
@@ -0,0 +1,8 @@
+
+
+ 16dp
+ 16dp
+ 16dp
+ 160dp
+ 16dp
+
diff --git a/app/src/main/res/values/drawables.xml b/app/src/main/res/values/drawables.xml
new file mode 100644
index 0000000..52c6a6c
--- /dev/null
+++ b/app/src/main/res/values/drawables.xml
@@ -0,0 +1,8 @@
+
+ - @android:drawable/ic_menu_camera
+ - @android:drawable/ic_menu_gallery
+ - @android:drawable/ic_menu_slideshow
+ - @android:drawable/ic_menu_manage
+ - @android:drawable/ic_menu_share
+ - @android:drawable/ic_menu_send
+
diff --git a/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml
new file mode 100644
index 0000000..538c206
--- /dev/null
+++ b/app/src/main/res/values/ic_launcher_background.xml
@@ -0,0 +1,4 @@
+
+
+ #4170C6
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..724bfb3
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,79 @@
+
+ 叮咚便签
+ Open navigation drawer
+ Close navigation drawer
+ 叮咚消息
+ 叮咚,你有消息请及时查看
+ Navigation header
+ Settings
+
+ 最新消息
+ 消息管理
+ 标签管理
+ Share
+ Send
+ 确认
+ 取消
+ 设置别名
+ 撤销别名
+ 设置帐号
+ 撤销帐号
+ 订阅标签
+ 撤销标签
+ 设置时间
+ 暂停推送
+ 恢复推送
+ 开始时间
+ 结束时间
+ 点击复制
+ 已复制到剪贴板
+ 推送注册成功
+ 推送注册失败
+ 接收传递消息。内容是: \"%1$s\"
+ 点击推送消息. 内容是: \"%1$s\"
+ 收到开心通知消息
+ 设置别名 \"%1$s\" success.
+ 设置别名失败 %1$s.
+ 取消设置别名 \"%1$s\" success.
+ 取消设置别名失败 %1$s.
+ 设置帐户 \"%1$s\" success.
+ 设置帐户失败 %1$s.
+ Unset account \"%1$s\" success.
+ Unset account fail for %1$s.
+ Subscribe topic \"%1$s\" success.
+ Subscribe topic fail for %1$s.
+ Unsubscribe topic \"%1$s\" success.
+ Unsubscribe topic fail for %1$s.
+ 设置接受时间 %1$s - %2$s success.
+ 设置接受时间失败 %1$s.
+ 导出
+ 消息导出
+
+
+ 私密便签无法直接预览,请先恢复!
+
+ 点击右上角,可以切换视图样式!
+ 长按便签,可以进行批量操作!
+ 在设置中,可以切换主题颜色!
+ 点击右下角,创建新的便签!
+
+ 推送网址,点此复制网址!请求该网址就可以开始推送啦!\n https://service-mm0wgphf-1258509752.cd.apigw.tencentcs.com/release/APIService-mipushServer/dd/sendmsg?id=%1$s&title=标题(可选值)&msg=测试提交数据
+
+
+
+
+ to_alipay
+ about_dev
+ to_market
+ check_version
+ to_feekback
+
+ HTTPS://QR.ALIPAY.COM/A6X03615MGHZ2Y1ZH0X7YE9
+ bigbigsman@163.com
+ https://github.com/import
+ http://www.jianshu.com/u/707e22330793
+ https://blog.csdn.net/weixin_50878488
+ 本软件基于开源项目,地址:https://github.com/ifadai/SuperNote
+ 6f0681b70098f23f9d2b32f027545961
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..37b01ab
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/xml/file_paths.xml b/app/src/main/res/xml/file_paths.xml
new file mode 100644
index 0000000..63edd74
--- /dev/null
+++ b/app/src/main/res/xml/file_paths.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_about.xml b/app/src/main/res/xml/pref_about.xml
new file mode 100644
index 0000000..957c22a
--- /dev/null
+++ b/app/src/main/res/xml/pref_about.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_lock.xml b/app/src/main/res/xml/pref_lock.xml
new file mode 100644
index 0000000..47e8999
--- /dev/null
+++ b/app/src/main/res/xml/pref_lock.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/xml/pref_settings.xml b/app/src/main/res/xml/pref_settings.xml
new file mode 100644
index 0000000..7911002
--- /dev/null
+++ b/app/src/main/res/xml/pref_settings.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/test/java/com/bigbig/fadainote/ExampleUnitTest.java b/app/src/test/java/com/bigbig/fadainote/ExampleUnitTest.java
new file mode 100644
index 0000000..9c3f968
--- /dev/null
+++ b/app/src/test/java/com/bigbig/fadainote/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.bigbig.fadainote;
+
+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/build.gradle b/build.gradle
new file mode 100644
index 0000000..4343f92
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,39 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ maven { url 'https://maven.aliyun.com/repository/google' }
+ maven{ url 'https://maven.aliyun.com/repository/jcenter'}
+ jcenter()
+ maven {
+ url 'https://maven.google.com/'
+ name 'Google'
+ }
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.4.1'
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ jcenter()
+ maven { url "https://jitpack.io" }
+ mavenCentral()
+ //Bmob的maven仓库地址--必填
+ maven { url "https://dl.bintray.com/chaozhouzhang/maven" }
+ maven {
+ url "http://dl.bintray.com/piasy/maven"
+ }
+ maven { url "https://jitpack.io" }
+ maven { url 'https://maven.aliyun.com/repository/google' }
+ maven{ url 'https://maven.aliyun.com/repository/jcenter'}
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..aac7c9b
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,17 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx1536m
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..7d4a636
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Apr 27 12:56:00 CST 2021
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..9d82f78
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pushserver.py b/pushserver.py
new file mode 100644
index 0000000..d736bad
--- /dev/null
+++ b/pushserver.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+
+import sys
+import logging
+import json
+import requests
+
+logging.basicConfig(level=logging.INFO, stream=sys.stdout)
+logger = logging.getLogger()
+logger.setLevel(level=logging.INFO)
+logger.info('Loading function')
+TOKEN_STRING='小米推送AppSecret'
+
+class dingDong(object):
+ """docstring for dingDong"""
+ def __init__(self,regid):
+ super(dingDong, self).__init__()
+ self.token_string = TOKEN_STRING
+ self.headers = {"Authorization":"key={}".format(TOKEN_STRING)}
+ self.regid=regid
+ def sendBigmsg(self,title,mddata):
+ '''
+ 大单条消息
+ '''
+ data={"description":mddata[:50],
+ "payload":title,
+ "restricted_package_name":"com.bigbig.ding",
+ "title":title,
+ "notify_type":"2",
+ "time_to_live":"1000",
+ "pass_through":"0",
+ "registration_id":self.regid,
+ "extra.notification_style_type":'1',
+ "extra.notification_large_icon_uri":"http://t3.market.xiaomi.com/thumcrop/webp/h120/MiPass/0ba0443bd8603fe44a9857385b11d76932541b094/icon.webp?crop=l276r600",
+ "extra.md":mddata
+ }
+ r = requests.post("https://api.xmpush.xiaomi.com/v3/message/regid", headers=self.headers,data=data)
+ result=r.json()
+ if result.get('code')==0:
+ logger.info('发送成功')
+ return True
+ else:
+ logger.info('发送失败')
+ logger.info(result)
+ return False
+
+def main_handler(event,content):
+ if "requestContext" not in event.keys():
+ return {"errorCode":410,"errorMsg":"event is not come from api gateway"}
+ if event["path"] != "/APIService-mipushServer/dd/sendmsg":
+ return {"errorCode":411,"errorMsg":"request is not from setting api path"}
+ if event["path"] == "/APIService-mipushServer/dd/sendmsg" and event["httpMethod"] in ["GET","POST"]: #获取文章列表
+ try:
+ regid = event["queryString"]["id"]
+ if not regid:
+ return {"errorCode":412,"errorMsg":"regid is null"}
+ title = event["queryString"]["title"]
+ msg = event["queryString"]["msg"]
+ dd=dingDong(regid)
+ dd.sendBigmsg(title,msg[:800])
+ except Exception as e:
+ logger.info(e)
+ return {"errorCode":412,"errorMsg":"error is happend"}
+
+ return {"errorCode":200,"errorMsg":'regid:{} is send'.format(regid)}
+ return {"errorCode":411,"errorMsg":"request is not work"}
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..e7b4def
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':app'