├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── rair │ │ └── diary │ │ ├── adapter │ │ ├── CommentRvAdapter.java │ │ ├── DiaryRvAdapter.java │ │ ├── FindXrvAdapter.java │ │ └── LoginPagerAdapter.java │ │ ├── base │ │ └── RairApp.java │ │ ├── bean │ │ ├── Comment.java │ │ ├── Diary.java │ │ ├── DiaryBean.java │ │ ├── FeedBack.java │ │ └── User.java │ │ ├── config │ │ ├── Cockroach.java │ │ └── QuitCockroachException.java │ │ ├── constant │ │ └── Constants.java │ │ ├── db │ │ ├── DataBaseHelper.java │ │ └── DiaryDao.java │ │ ├── receiver │ │ └── RairReceiver.java │ │ ├── service │ │ └── RemindService.java │ │ ├── ui │ │ ├── MainActivity.java │ │ ├── SplashActivity.java │ │ ├── diary │ │ │ ├── DiaryFragment.java │ │ │ ├── add │ │ │ │ └── AddDiaryActivity.java │ │ │ └── detail │ │ │ │ └── DiaryDetailActivity.java │ │ ├── find │ │ │ ├── FindDetailActivity.java │ │ │ └── FindFragment.java │ │ └── setting │ │ │ ├── SetFragment.java │ │ │ ├── about │ │ │ └── AboutActivity.java │ │ │ ├── export │ │ │ └── ExportActivity.java │ │ │ ├── feedback │ │ │ └── FeedBackActivity.java │ │ │ ├── recover │ │ │ └── RecoverActivity.java │ │ │ ├── remind │ │ │ └── NotifyActivity.java │ │ │ ├── secret │ │ │ └── SecretActivity.java │ │ │ └── user │ │ │ ├── LoginActivity.java │ │ │ ├── LoginFragment.java │ │ │ ├── RegisterFragment.java │ │ │ └── UserActivity.java │ │ ├── utils │ │ ├── RairUtils.java │ │ ├── SPUtils.java │ │ └── Utils.java │ │ └── view │ │ ├── BounceScrollView.java │ │ ├── CircleImageView.java │ │ ├── CustomLayoutManager.java │ │ ├── EditTextWithDel.java │ │ ├── LinedEditText.java │ │ ├── LockPattern.java │ │ └── RippleView.java │ └── res │ ├── color │ └── text_color_select.xml │ ├── drawable │ ├── base_shape.xml │ ├── editor_shape.xml │ ├── sex_choice_selector.xml │ └── textview_bg_select.xml │ ├── layout │ ├── activity_about.xml │ ├── activity_add_diary.xml │ ├── activity_diary_detail.xml │ ├── activity_export.xml │ ├── activity_feed_back.xml │ ├── activity_find_detail.xml │ ├── activity_login.xml │ ├── activity_main.xml │ ├── activity_notify.xml │ ├── activity_recover.xml │ ├── activity_secret.xml │ ├── activity_splash.xml │ ├── activity_user.xml │ ├── fragment_diary.xml │ ├── fragment_find.xml │ ├── fragment_login.xml │ ├── fragment_register.xml │ ├── fragment_set.xml │ ├── view_comment_item.xml │ ├── view_diary_item.xml │ ├── view_edit_sign_dialog.xml │ ├── view_find_item.xml │ ├── view_number_pwd_dialog.xml │ ├── view_number_unlock_dialog.xml │ ├── view_pattern_pwd_dialog.xml │ ├── view_pattern_unlock_dialog.xml │ ├── view_rv_footer.xml │ └── view_rv_header.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ ├── delete.png │ ├── female.png │ ├── ic_add.png │ ├── ic_back.png │ ├── ic_bg.png │ ├── ic_delete.png │ ├── ic_diary.png │ ├── ic_diary_sel.png │ ├── ic_edit.png │ ├── ic_export.png │ ├── ic_feedback.png │ ├── ic_find.png │ ├── ic_find_sel.png │ ├── ic_head.png │ ├── ic_info.png │ ├── ic_launcher.png │ ├── ic_next.png │ ├── ic_notify.png │ ├── ic_option.png │ ├── ic_photo.png │ ├── ic_recover.png │ ├── ic_right.png │ ├── ic_save.png │ ├── ic_secret.png │ ├── ic_setting.png │ ├── ic_setting_sel.png │ ├── ic_sex_female.png │ ├── ic_sex_male.png │ ├── ic_user_email.png │ ├── ic_user_name.png │ ├── ic_user_pwd.png │ ├── ic_weather_leiyu.png │ ├── ic_weather_qing.png │ ├── ic_weather_xue.png │ ├── ic_weather_yin.png │ ├── ic_weather_yu.png │ └── male.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-night │ └── colors.xml │ ├── values │ ├── attrs.xml │ ├── colors.xml │ ├── strings.xml │ └── styles.xml │ └── xml │ └── file_path.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── Screenshot1.jpg ├── Screenshot2.png └── Screenshot3.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Rair 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Diary时光记 2 | 3 | App已上线酷安市场 4 | 5 | https://www.coolapk.com/apk/com.rair.diary 6 | 7 | 可下载体验。 8 | 9 | ### 设计 10 | MVC架构 11 | 12 | APP_ID:Bmob key 13 | 14 | QQ_KEY:QQ群加群组件key 15 | 16 | 后端使用的Bmob,请自行注册. 17 | 18 | ### 截图 19 | ![1] 20 | ![2] 21 | ![3] 22 | 23 | ### 功能 24 | 纯粹的一个日记本应用 25 | * -提醒:设置提醒时间,每天提醒写日记 26 | * -隐私密码:密码保护,不用当心内容被别人看到(其实也并没什么卵用) 27 | * -备份:将数据备份到云端 28 | * -导出:将数据导出到sdcard(.txt/.db) 29 | * -夜间模式 30 | * -发现:把单条日记发布到广场 31 | 32 | 因为我一直有写日记的习惯,就简单的写了一个写日记的应用。 33 | 34 | 因为在多台pc上写的,所以结构比较乱。 35 | 36 | 欢迎您联系反馈,rairmmd@qq.com 37 | 38 | [1]:https://github.com/Rairmmd/Diary/blob/master/screenshots/Screenshot1.jpg 39 | 40 | [2]:https://github.com/Rairmmd/Diary/blob/master/screenshots/Screenshot2.png 41 | 42 | [3]:https://github.com/Rairmmd/Diary/blob/master/screenshots/Screenshot3.jpg 43 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | buildToolsVersion "28.0.3" 6 | useLibrary 'org.apache.http.legacy' 7 | 8 | defaultConfig { 9 | applicationId "com.rair.diary" 10 | minSdkVersion 19 11 | targetSdkVersion 28 12 | versionCode 3 13 | versionName "2.0.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled true 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | compileOptions { 22 | sourceCompatibility = '1.8' 23 | targetCompatibility = '1.8' 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(include: ['*.jar'], dir: 'libs') 29 | compile 'com.android.support:appcompat-v7:28.0.0' 30 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 31 | compile 'com.jakewharton:butterknife:8.8.1' 32 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 33 | compile 'com.android.support:support-v4:28.0.0' 34 | compile 'com.jpeng:JPTabBar:1.3.3' 35 | compile 'com.android.support:design:28.0.0' 36 | compile 'com.android.support:cardview-v7:28.0.0' 37 | compile 'cn.bmob.android:bmob-sdk:3.5.5' 38 | compile 'cn.bmob.android:http-legacy:1.0' 39 | compile 'com.jcodecraeer:xrecyclerview:1.3.2' 40 | compile 'com.squareup.picasso:picasso:2.5.2' 41 | compile 'com.github.lovetuzitong:MultiImageSelector:1.2' 42 | compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.34' 43 | 44 | } 45 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontoptimize 3 | -dontpreverify 4 | -ignorewarnings 5 | -keepattributes Signature,*Annotation* 6 | 7 | #四大组件不能混淆 8 | -keep public class * extends android.content.BroadcastReceiver 9 | -dontwarn android.support.v4.** 10 | -keep class android.support.v4.app.** { *; } 11 | -keep interface android.support.v4.app.** { *; } 12 | -keep class android.support.v4.** { *; } 13 | -keep public class * extends android.app.Application 14 | 15 | -dontwarn android.support.v7.** 16 | -keep class android.support.v7.internal.** { *; } 17 | -keep interface android.support.v7.internal.** { *; } 18 | -keep class android.support.v7.** { *; } 19 | 20 | -keep public class * extends android.app.** 21 | -keep public class * extends android.content.** 22 | -keep public class * extends android.preference.Preference 23 | 24 | # support design 25 | -dontwarn android.support.design.** 26 | -keep class android.support.design.** { *; } 27 | -keep interface android.support.design.** { *; } 28 | -keep public class android.support.design.R$* { *; } 29 | 30 | #release版不打印log 31 | -assumenosideeffects class android.util.Log { 32 | public static *** d(...); 33 | public static *** v(...); 34 | public static *** i(...); 35 | public static *** e(...); 36 | public static *** w(...); 37 | } 38 | 39 | #保持枚举enum类不被混淆 40 | -keepclassmembers enum * { 41 | public static **[] values(); 42 | public static ** valueOf(java.lang.String); 43 | } 44 | #自定义View 45 | -keep public class * extends android.view.View{ 46 | *** get*(); 47 | void set*(***); 48 | public (android.content.Context); 49 | public (android.content.Context, android.util.AttributeSet); 50 | public (android.content.Context, android.util.AttributeSet, int); 51 | } 52 | 53 | # keep BmobSDK 54 | -dontwarn cn.bmob.v3.** 55 | -keep class cn.bmob.v3.** {*;} 56 | 57 | # 确保JavaBean不被混淆-否则gson将无法将数据解析成具体对象 58 | -keep class * extends cn.bmob.v3.BmobObject { 59 | *; 60 | } 61 | -keep class com.rair.diary.bean.** { *; } 62 | 63 | # keep okhttp3、okio 64 | -dontwarn okhttp3.** 65 | -keep class okhttp3.** { *;} 66 | -keep interface okhttp3.** { *; } 67 | -dontwarn okio.** 68 | 69 | # 如果你需要兼容6.0系统,请不要混淆org.apache.http.legacy.jar 70 | -dontwarn android.net.compatibility.** 71 | -dontwarn android.net.http.** 72 | -dontwarn com.android.internal.http.multipart.** 73 | -dontwarn org.apache.commons.** 74 | -dontwarn org.apache.http.** 75 | -keep class android.net.compatibility.**{*;} 76 | -keep class android.net.http.**{*;} 77 | -keep class com.android.internal.http.multipart.**{*;} 78 | -keep class org.apache.commons.**{*;} 79 | -keep class org.apache.http.**{*;} 80 | 81 | # keep rx 82 | -dontwarn sun.misc.** 83 | -keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 84 | long producerIndex; 85 | long consumerIndex; 86 | } 87 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 88 | rx.internal.util.atomic.LinkedQueueNode producerNode; 89 | } 90 | -keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { 91 | rx.internal.util.atomic.LinkedQueueNode consumerNode; 92 | } 93 | 94 | #Gson 95 | -keep class com.google.gson.** {*;} 96 | -keep class com.google.**{*;} 97 | -keep class sun.misc.Unsafe { *; } 98 | -keep class com.google.gson.stream.** { *; } 99 | -keep class com.google.gson.examples.android.model.** { *; } 100 | 101 | -keepclassmembers class * implements java.io.Serializable { 102 | static final long serialVersionUID; 103 | private static final java.io.ObjectStreamField[] serialPersistentFields; 104 | private void writeObject(java.io.ObjectOutputStream); 105 | private void readObject(java.io.ObjectInputStream); 106 | java.lang.Object writeReplace(); 107 | java.lang.Object readResolve(); 108 | } 109 | -keep public class * implements java.io.Serializable {*;} 110 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 71 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/adapter/CommentRvAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.widget.ImageView; 6 | 7 | import com.chad.library.adapter.base.BaseQuickAdapter; 8 | import com.chad.library.adapter.base.BaseViewHolder; 9 | import com.rair.diary.R; 10 | import com.rair.diary.bean.Comment; 11 | import com.rair.diary.bean.User; 12 | import com.squareup.picasso.Picasso; 13 | 14 | import java.util.List; 15 | 16 | import cn.bmob.v3.datatype.BmobFile; 17 | 18 | /** 19 | * Created by Rair on 2017/6/25. 20 | * Email:rairmmd@gmail.com 21 | * Author:Rair 22 | */ 23 | 24 | public class CommentRvAdapter extends BaseQuickAdapter { 25 | 26 | private Context context; 27 | 28 | public CommentRvAdapter(Context context, int layoutResId, @Nullable List data) { 29 | super(layoutResId, data); 30 | this.context = context; 31 | } 32 | 33 | @Override 34 | protected void convert(BaseViewHolder helper, Comment item) { 35 | User user = item.getUser(); 36 | ImageView sexView = helper.getView(R.id.comment_item_iv_sex); 37 | if (user.getSex() != null) { 38 | if (user.getSex() == 0) { 39 | Picasso.with(context).load(R.mipmap.male).into(sexView); 40 | } else { 41 | Picasso.with(context).load(R.mipmap.female).into(sexView); 42 | } 43 | } 44 | ImageView headView = helper.getView(R.id.comment_item_civ_head); 45 | if (user.getHeadFile() != null) { 46 | BmobFile headFileFile = user.getHeadFile(); 47 | Picasso.with(context).load(headFileFile.getFileUrl()).into(headView); 48 | } else { 49 | Picasso.with(context).load(R.mipmap.ic_head).into(headView); 50 | } 51 | helper.setText(R.id.comment_item_tv_name, user.getNickName()); 52 | helper.setText(R.id.comment_item_tv_time, item.getCommentTime()); 53 | helper.setText(R.id.comment_item_tv_content, item.getContent()); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/adapter/DiaryRvAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.graphics.Color; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ImageView; 12 | import android.widget.TextView; 13 | 14 | import com.rair.diary.R; 15 | import com.rair.diary.bean.DiaryBean; 16 | import com.rair.diary.constant.Constants; 17 | 18 | import java.io.File; 19 | import java.util.ArrayList; 20 | import java.util.Random; 21 | 22 | /** 23 | * Created by mzaiy on 2017/6/1. 24 | */ 25 | 26 | public class DiaryRvAdapter extends RecyclerView.Adapter { 27 | 28 | private Context context; 29 | private ArrayList datas; 30 | private OnRvItemClickListener onRvItemClickListener; 31 | 32 | public interface OnRvItemClickListener { 33 | void OnItemClick(int position); 34 | 35 | void OnOptionClick(int position); 36 | } 37 | 38 | public void setOnRvItemClickListener(OnRvItemClickListener onRvItemClickListener) { 39 | this.onRvItemClickListener = onRvItemClickListener; 40 | } 41 | 42 | public DiaryRvAdapter(Context context, ArrayList datas) { 43 | this.context = context; 44 | this.datas = datas; 45 | } 46 | 47 | @Override 48 | public DiaryHolder onCreateViewHolder(ViewGroup parent, int viewType) { 49 | View view = LayoutInflater.from(context).inflate(R.layout.view_diary_item, parent, false); 50 | return new DiaryHolder(view); 51 | } 52 | 53 | @Override 54 | public void onBindViewHolder(DiaryHolder holder, int position) { 55 | setColor(holder); 56 | DiaryBean diaryBean = datas.get(position); 57 | holder.tvTitle.setText(diaryBean.getTitle()); 58 | holder.tvContent.setText(diaryBean.getContent()); 59 | String image = diaryBean.getImage(); 60 | if (!image.equals("n")) { 61 | File file = new File(image); 62 | if (file.exists()) { 63 | holder.ivShow.setVisibility(View.VISIBLE); 64 | Bitmap bitmap = BitmapFactory.decodeFile(image); 65 | holder.ivShow.setImageBitmap(bitmap); 66 | } else { 67 | holder.ivShow.setVisibility(View.GONE); 68 | } 69 | } 70 | holder.tvDate.setText(String.format(Constants.FORMAT, diaryBean.getDate(), diaryBean.getWeek(), diaryBean.getWeather())); 71 | final int mPosition = position; 72 | holder.itemView.setOnClickListener(new View.OnClickListener() { 73 | @Override 74 | public void onClick(View v) { 75 | if (onRvItemClickListener != null) 76 | onRvItemClickListener.OnItemClick(mPosition); 77 | } 78 | }); 79 | holder.ivOption.setOnClickListener(new View.OnClickListener() { 80 | @Override 81 | public void onClick(View v) { 82 | if (onRvItemClickListener != null) 83 | onRvItemClickListener.OnOptionClick(mPosition); 84 | } 85 | }); 86 | } 87 | 88 | private void setColor(DiaryHolder holder) { 89 | int random = new Random().nextInt(9); 90 | switch (random) { 91 | case 0: 92 | holder.viewColor.setBackgroundColor(Color.rgb(255, 82, 82)); 93 | break; 94 | case 1: 95 | holder.viewColor.setBackgroundColor(Color.rgb(76, 175, 80)); 96 | break; 97 | case 2: 98 | holder.viewColor.setBackgroundColor(Color.rgb(255, 64, 129)); 99 | break; 100 | case 3: 101 | holder.viewColor.setBackgroundColor(Color.rgb(68, 138, 255)); 102 | break; 103 | case 4: 104 | holder.viewColor.setBackgroundColor(Color.rgb(255, 255, 0)); 105 | break; 106 | case 5: 107 | holder.viewColor.setBackgroundColor(Color.rgb(224, 64, 251)); 108 | break; 109 | case 6: 110 | holder.viewColor.setBackgroundColor(Color.rgb(24, 255, 255)); 111 | break; 112 | case 7: 113 | holder.viewColor.setBackgroundColor(Color.rgb(97, 97, 97)); 114 | break; 115 | case 8: 116 | holder.viewColor.setBackgroundColor(Color.rgb(255, 171, 64)); 117 | break; 118 | 119 | } 120 | } 121 | 122 | @Override 123 | public int getItemCount() { 124 | return datas.size(); 125 | } 126 | 127 | class DiaryHolder extends RecyclerView.ViewHolder { 128 | 129 | private TextView tvTitle, tvContent, tvDate; 130 | private View viewColor; 131 | private ImageView ivOption, ivShow; 132 | 133 | DiaryHolder(View itemView) { 134 | super(itemView); 135 | tvTitle = (TextView) itemView.findViewById(R.id.diary_item_tv_title); 136 | tvContent = (TextView) itemView.findViewById(R.id.diary_item_tv_content); 137 | tvDate = (TextView) itemView.findViewById(R.id.diary_item_tv_date); 138 | viewColor = itemView.findViewById(R.id.diary_item_view_color); 139 | ivOption = (ImageView) itemView.findViewById(R.id.diary_item_iv_option); 140 | ivShow = (ImageView) itemView.findViewById(R.id.diary_item_iv_show); 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/adapter/FindXrvAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.widget.ImageView; 6 | 7 | import com.chad.library.adapter.base.BaseQuickAdapter; 8 | import com.chad.library.adapter.base.BaseViewHolder; 9 | import com.rair.diary.R; 10 | import com.rair.diary.bean.Diary; 11 | import com.rair.diary.bean.User; 12 | import com.rair.diary.view.CircleImageView; 13 | import com.squareup.picasso.Picasso; 14 | 15 | import java.util.List; 16 | 17 | import cn.bmob.v3.datatype.BmobFile; 18 | 19 | /** 20 | * Created by Rair on 2017/6/12. 21 | * Email:rairmmd@gmail.com 22 | * Author:Rair 23 | */ 24 | public class FindXrvAdapter extends BaseQuickAdapter { 25 | 26 | private Context context; 27 | 28 | public FindXrvAdapter(Context context, int layoutResId, @Nullable List data) { 29 | super(layoutResId, data); 30 | this.context = context; 31 | } 32 | 33 | @Override 34 | protected void convert(BaseViewHolder helper, Diary item) { 35 | User user = item.getUser(); 36 | ImageView ivSex = helper.getView(R.id.find_item_iv_sex); 37 | CircleImageView civHead = helper.getView(R.id.find_item_civ_head); 38 | if (user.getSex() == 0) { 39 | Picasso.with(context).load(R.mipmap.male).into(ivSex); 40 | } else { 41 | Picasso.with(context).load(R.mipmap.female).into(ivSex); 42 | } 43 | if (user.getHeadFile() != null) { 44 | BmobFile headFileFile = user.getHeadFile(); 45 | Picasso.with(context).load(headFileFile.getFileUrl()).into(civHead); 46 | } else { 47 | Picasso.with(context).load(R.mipmap.ic_head).into(civHead); 48 | } 49 | helper.setText(R.id.find_item_tv_name, item.getName()); 50 | helper.setText(R.id.find_item_tv_time, item.getCreateTime()); 51 | helper.setText(R.id.find_item_tv_content, item.getContent()); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/adapter/LoginPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | /** 8 | * Created by Rair on 2017/6/12. 9 | * Email:rairmmd@gmail.com 10 | * Author:Rair 11 | */ 12 | public class LoginPagerAdapter extends FragmentPagerAdapter { 13 | 14 | private String[] titles; 15 | private Fragment[] fragments; 16 | 17 | public LoginPagerAdapter(FragmentManager fm, String[] titles, Fragment[] fragments) { 18 | super(fm); 19 | this.titles = titles; 20 | this.fragments = fragments; 21 | } 22 | 23 | @Override 24 | public CharSequence getPageTitle(int position) { 25 | return titles[position]; 26 | } 27 | 28 | @Override 29 | public Fragment getItem(int position) { 30 | return fragments[position]; 31 | } 32 | 33 | @Override 34 | public int getCount() { 35 | return fragments.length; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/base/RairApp.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.base; 2 | 3 | import android.app.Application; 4 | import android.os.Environment; 5 | import android.support.v7.app.AppCompatDelegate; 6 | import android.util.Log; 7 | 8 | import com.rair.diary.config.Cockroach; 9 | import com.rair.diary.constant.Constants; 10 | import com.rair.diary.utils.SPUtils; 11 | import com.rair.diary.utils.Utils; 12 | 13 | import java.io.File; 14 | 15 | import cn.bmob.v3.Bmob; 16 | 17 | /** 18 | * Created by mzaiy on 2017/6/5. 19 | */ 20 | 21 | public class RairApp extends Application { 22 | 23 | private static RairApp rairApp; 24 | private SPUtils spUtils; 25 | 26 | @Override 27 | public void onCreate() { 28 | super.onCreate(); 29 | rairApp = this; 30 | Utils.init(this); 31 | spUtils = new SPUtils(Constants.SP_NAME); 32 | Bmob.initialize(this, Constants.APP_ID); 33 | // Cockroach.install(exceptionHandler); 34 | configTheme(); 35 | } 36 | 37 | public void configTheme() { 38 | boolean isNight = spUtils.getBoolean("isNight", false); 39 | if (isNight) { 40 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); 41 | } else { 42 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); 43 | } 44 | } 45 | 46 | Cockroach.ExceptionHandler exceptionHandler = new Cockroach.ExceptionHandler() { 47 | @Override 48 | public void handlerException(Thread thread, Throwable throwable) { 49 | Log.e("TAG", "handlerException: " + throwable); 50 | } 51 | }; 52 | 53 | public static RairApp getRairApp() { 54 | return rairApp; 55 | } 56 | 57 | public SPUtils getSpUtils() { 58 | return spUtils; 59 | } 60 | 61 | public File getRairPath() { 62 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { 63 | File storageDirectory = Environment.getExternalStorageDirectory(); 64 | File rairFile = new File(storageDirectory, Constants.RAIR_PATH); 65 | if (!rairFile.exists()) { 66 | rairFile.mkdirs(); 67 | } 68 | return rairFile; 69 | } 70 | return getCacheDir(); 71 | } 72 | 73 | @Override 74 | public void onTerminate() { 75 | super.onTerminate(); 76 | Cockroach.uninstall(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/bean/Comment.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.bean; 2 | 3 | import cn.bmob.v3.BmobObject; 4 | 5 | /** 6 | * Created by Rair on 2017/6/12. 7 | * Email:rairmmd@gmail.com 8 | * Author:Rair 9 | */ 10 | public class Comment extends BmobObject { 11 | 12 | //评论内容 13 | private String content; 14 | //用户 15 | private User user; 16 | //评论 17 | private Diary diary; 18 | 19 | //评论时间 20 | private String commentTime; 21 | 22 | public String getContent() { 23 | return content; 24 | } 25 | 26 | public void setContent(String content) { 27 | this.content = content; 28 | } 29 | 30 | public User getUser() { 31 | return user; 32 | } 33 | 34 | public void setUser(User user) { 35 | this.user = user; 36 | } 37 | 38 | public Diary getDiary() { 39 | return diary; 40 | } 41 | 42 | public void setDiary(Diary diary) { 43 | this.diary = diary; 44 | } 45 | 46 | public String getCommentTime() { 47 | return commentTime; 48 | } 49 | 50 | public void setCommentTime(String commentTime) { 51 | this.commentTime = commentTime; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/bean/Diary.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.bean; 2 | 3 | import cn.bmob.v3.BmobObject; 4 | import cn.bmob.v3.datatype.BmobFile; 5 | import cn.bmob.v3.datatype.BmobRelation; 6 | 7 | /** 8 | * Created by Rair on 2017/6/12. 9 | * Email:rairmmd@gmail.com 10 | * Author:Rair 11 | */ 12 | public class Diary extends BmobObject { 13 | 14 | //发布者 15 | private User user; 16 | //昵称 17 | private String name; 18 | //标题 19 | private String title; 20 | //内容 21 | private String content; 22 | //图片 23 | private BmobFile image; 24 | //天气 25 | private String weather; 26 | //日期 27 | private String date; 28 | //星期 29 | private String week; 30 | //评论 31 | private BmobRelation comment; 32 | //发布时间 33 | private String createTime; 34 | //点赞总数 35 | private Integer likes; 36 | //点赞的人 37 | private BmobRelation likers; 38 | //评论总数 39 | private Integer comments; 40 | 41 | public User getUser() { 42 | return user; 43 | } 44 | 45 | public void setUser(User user) { 46 | this.user = user; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public String getTitle() { 58 | return title; 59 | } 60 | 61 | public void setTitle(String title) { 62 | this.title = title; 63 | } 64 | 65 | public String getContent() { 66 | return content; 67 | } 68 | 69 | public void setContent(String content) { 70 | this.content = content; 71 | } 72 | 73 | public BmobFile getImage() { 74 | return image; 75 | } 76 | 77 | public void setImage(BmobFile image) { 78 | this.image = image; 79 | } 80 | 81 | public String getWeather() { 82 | return weather; 83 | } 84 | 85 | public void setWeather(String weather) { 86 | this.weather = weather; 87 | } 88 | 89 | public String getDate() { 90 | return date; 91 | } 92 | 93 | public void setDate(String date) { 94 | this.date = date; 95 | } 96 | 97 | public String getWeek() { 98 | return week; 99 | } 100 | 101 | public void setWeek(String week) { 102 | this.week = week; 103 | } 104 | 105 | public BmobRelation getComment() { 106 | return comment; 107 | } 108 | 109 | public void setComment(BmobRelation comment) { 110 | this.comment = comment; 111 | } 112 | 113 | public String getCreateTime() { 114 | return createTime; 115 | } 116 | 117 | public void setCreateTime(String createTime) { 118 | this.createTime = createTime; 119 | } 120 | 121 | public Integer getLikes() { 122 | return likes; 123 | } 124 | 125 | public void setLikes(Integer likes) { 126 | this.likes = likes; 127 | } 128 | 129 | public BmobRelation getLikers() { 130 | return likers; 131 | } 132 | 133 | public void setLikers(BmobRelation likers) { 134 | this.likers = likers; 135 | } 136 | 137 | public Integer getComments() { 138 | return comments; 139 | } 140 | 141 | public void setComments(Integer comments) { 142 | this.comments = comments; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/bean/DiaryBean.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.bean; 2 | 3 | /** 4 | * Created by mzaiy on 2017/6/1. 5 | */ 6 | 7 | public class DiaryBean { 8 | 9 | private String title; 10 | private String content; 11 | private String image; 12 | private String weather; 13 | private String date; 14 | private String week; 15 | private long id; 16 | 17 | public String getTitle() { 18 | return title; 19 | } 20 | 21 | public void setTitle(String title) { 22 | this.title = title; 23 | } 24 | 25 | public String getContent() { 26 | return content; 27 | } 28 | 29 | public void setContent(String content) { 30 | this.content = content; 31 | } 32 | 33 | public String getImage() { 34 | return image; 35 | } 36 | 37 | public void setImage(String image) { 38 | this.image = image; 39 | } 40 | 41 | public String getWeather() { 42 | return weather; 43 | } 44 | 45 | public void setWeather(String weather) { 46 | this.weather = weather; 47 | } 48 | 49 | public String getDate() { 50 | return date; 51 | } 52 | 53 | public void setDate(String date) { 54 | this.date = date; 55 | } 56 | 57 | public String getWeek() { 58 | return week; 59 | } 60 | 61 | public void setWeek(String week) { 62 | this.week = week; 63 | } 64 | 65 | public long getId() { 66 | return id; 67 | } 68 | 69 | public void setId(long id) { 70 | this.id = id; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/bean/FeedBack.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.bean; 2 | 3 | import cn.bmob.v3.BmobObject; 4 | 5 | /** 6 | * Created by mzaiy on 2017/6/6. 7 | */ 8 | 9 | public class FeedBack extends BmobObject { 10 | 11 | private String content; 12 | private String contact; 13 | 14 | public FeedBack() { 15 | } 16 | 17 | public FeedBack(String content, String contact) { 18 | this.content = content; 19 | this.contact = contact; 20 | } 21 | 22 | public String getContent() { 23 | return content; 24 | } 25 | 26 | public void setContent(String content) { 27 | this.content = content; 28 | } 29 | 30 | public String getContact() { 31 | return contact; 32 | } 33 | 34 | public void setContact(String contact) { 35 | this.contact = contact; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/bean/User.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.bean; 2 | 3 | import cn.bmob.v3.BmobUser; 4 | import cn.bmob.v3.datatype.BmobFile; 5 | import cn.bmob.v3.datatype.BmobRelation; 6 | 7 | /** 8 | * Created by mzaiy on 2017/6/9. 9 | */ 10 | 11 | public class User extends BmobUser { 12 | 13 | //头像 14 | private BmobFile headFile; 15 | //个性签名 16 | private String sign; 17 | //昵称 18 | private String nickName; 19 | //性别 20 | private Integer sex; 21 | //数据 22 | private BmobFile dbFile; 23 | //数据下载链接 24 | private String dbUrl; 25 | //粉丝 26 | private BmobRelation fans; 27 | //关注 28 | private BmobRelation focus; 29 | //评论 30 | private BmobRelation comment; 31 | //日记 32 | private BmobRelation diary; 33 | //是否Vip 34 | private Boolean isVip; 35 | 36 | public BmobFile getHeadFile() { 37 | return headFile; 38 | } 39 | 40 | public void setHeadFile(BmobFile headFile) { 41 | this.headFile = headFile; 42 | } 43 | 44 | public String getSign() { 45 | return sign; 46 | } 47 | 48 | public void setSign(String sign) { 49 | this.sign = sign; 50 | } 51 | 52 | public String getNickName() { 53 | return nickName; 54 | } 55 | 56 | public void setNickName(String nickName) { 57 | this.nickName = nickName; 58 | } 59 | 60 | public Integer getSex() { 61 | return sex; 62 | } 63 | 64 | public void setSex(Integer sex) { 65 | this.sex = sex; 66 | } 67 | 68 | public BmobFile getDbFile() { 69 | return dbFile; 70 | } 71 | 72 | public void setDbFile(BmobFile dbFile) { 73 | this.dbFile = dbFile; 74 | } 75 | 76 | public String getDbUrl() { 77 | return dbUrl; 78 | } 79 | 80 | public void setDbUrl(String dbUrl) { 81 | this.dbUrl = dbUrl; 82 | } 83 | 84 | public BmobRelation getFans() { 85 | return fans; 86 | } 87 | 88 | public void setFans(BmobRelation fans) { 89 | this.fans = fans; 90 | } 91 | 92 | public BmobRelation getFocus() { 93 | return focus; 94 | } 95 | 96 | public void setFocus(BmobRelation focus) { 97 | this.focus = focus; 98 | } 99 | 100 | public BmobRelation getComment() { 101 | return comment; 102 | } 103 | 104 | public void setComment(BmobRelation comment) { 105 | this.comment = comment; 106 | } 107 | 108 | public BmobRelation getDiary() { 109 | return diary; 110 | } 111 | 112 | public void setDiary(BmobRelation diary) { 113 | this.diary = diary; 114 | } 115 | 116 | public Boolean getVip() { 117 | return isVip; 118 | } 119 | 120 | public void setVip(Boolean vip) { 121 | isVip = vip; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/config/Cockroach.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.config; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | 6 | /** 7 | * Created by wanjian on 2017/2/14. 8 | */ 9 | 10 | public final class Cockroach { 11 | 12 | public interface ExceptionHandler { 13 | void handlerException(Thread thread, Throwable throwable); 14 | } 15 | 16 | private Cockroach() { 17 | } 18 | 19 | private static ExceptionHandler sExceptionHandler; 20 | private static Thread.UncaughtExceptionHandler sUncaughtExceptionHandler; 21 | private static boolean sInstalled = false;//标记位,避免重复安装卸载 22 | 23 | /** 24 | * 当主线程或子线程抛出异常时会调用exceptionHandler.handlerException(Thread thread, Throwable throwable) 25 | *

26 | * exceptionHandler.handlerException可能运行在非UI线程中。 27 | *

28 | * 若设置了Thread.setDefaultUncaughtExceptionHandler则可能无法捕获子线程异常。 29 | * 30 | * @param exceptionHandler 31 | */ 32 | public static synchronized void install(ExceptionHandler exceptionHandler) { 33 | if (sInstalled) { 34 | return; 35 | } 36 | sInstalled = true; 37 | sExceptionHandler = exceptionHandler; 38 | 39 | new Handler(Looper.getMainLooper()).post(new Runnable() { 40 | @Override 41 | public void run() { 42 | while (true) { 43 | try { 44 | Looper.loop(); 45 | } catch (Throwable e) { 46 | // Binder.clearCallingIdentity(); 47 | if (e instanceof QuitCockroachException) { 48 | return; 49 | } 50 | if (sExceptionHandler != null) { 51 | sExceptionHandler.handlerException(Looper.getMainLooper().getThread(), e); 52 | } 53 | } 54 | } 55 | } 56 | }); 57 | 58 | sUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); 59 | Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { 60 | @Override 61 | public void uncaughtException(Thread t, Throwable e) { 62 | if (sExceptionHandler != null) { 63 | sExceptionHandler.handlerException(t, e); 64 | } 65 | } 66 | }); 67 | 68 | } 69 | 70 | public static synchronized void uninstall() { 71 | if (!sInstalled) { 72 | return; 73 | } 74 | sInstalled = false; 75 | sExceptionHandler = null; 76 | //卸载后恢复默认的异常处理逻辑,否则主线程再次抛出异常后将导致ANR,并且无法捕获到异常位置 77 | Thread.setDefaultUncaughtExceptionHandler(sUncaughtExceptionHandler); 78 | new Handler(Looper.getMainLooper()).post(new Runnable() { 79 | @Override 80 | public void run() { 81 | throw new QuitCockroachException("Quit Cockroach.....");//主线程抛出异常,迫使 while (true) {}结束 82 | } 83 | }); 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/config/QuitCockroachException.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.config; 2 | 3 | /** 4 | * Created by wanjian on 2017/2/15. 5 | */ 6 | 7 | final class QuitCockroachException extends RuntimeException { 8 | public QuitCockroachException(String message) { 9 | super(message); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/constant/Constants.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.constant; 2 | 3 | /** 4 | * Created by mzaiy on 2017/6/5. 5 | */ 6 | 7 | public class Constants { 8 | //DB 9 | public static final String DB_NAME = "diary.db"; 10 | public static final int DB_VERSION = 2; 11 | //RairPath 12 | public static final String RAIR_PATH = "RairDiary"; 13 | // public static final String PDF_NAME = "我的日记.pdf"; 14 | public static final String TXT_NAME = "我的日记.txt"; 15 | public static final String BACKUP_NAME = "Backup.db"; 16 | public static final String Export_NAME = "我的日记.db"; 17 | public static final String HEAD_IMAGE = "head.jpg"; 18 | public static final String FORMAT = "%s(%s)%s"; 19 | //SharedPreferences 20 | public static final String SP_NAME = "rair"; 21 | public static final String RECREATE = "isRecreate"; 22 | //设置提醒时间 23 | public static final String SET_RECEIVER = "com.rair.set"; 24 | //提醒广播 25 | public static final String REMIND_RECEIVER = "com.rair.time"; 26 | //加群key 27 | public static final String QQ_KEY = "J_-"; 28 | //Bmob 29 | public static final String APP_ID = ""; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/db/DataBaseHelper.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.db; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | 7 | import com.rair.diary.constant.Constants; 8 | 9 | public class DataBaseHelper extends SQLiteOpenHelper { 10 | 11 | public DataBaseHelper(Context context) { 12 | super(context, Constants.DB_NAME, null, Constants.DB_VERSION); 13 | } 14 | 15 | public DataBaseHelper(Context context, int version) { 16 | super(context, Constants.DB_NAME, null, version); 17 | } 18 | 19 | /** 20 | * 该函数是子啊第一次创建数据库的时候执行,实际上是第一次 21 | * 得到SQLiteDatabase对象的时候才会被调用 22 | */ 23 | @Override 24 | public void onCreate(SQLiteDatabase db) { 25 | db.execSQL("create table DIARY (date TEXT,week TEXT,weather TEXT,title TEXT,content TEXT,image TEXT,id INTEGER PRIMARY KEY AUTOINCREMENT)"); 26 | } 27 | 28 | @Override 29 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 30 | switch (newVersion) { 31 | case 2: 32 | db.execSQL("ALTER TABLE DIARY ADD image TEXT"); 33 | break; 34 | default: 35 | db.execSQL("DROP TABLE IF EXISTS DIARY"); 36 | onCreate(db); 37 | break; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/db/DiaryDao.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.db; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | 8 | import com.rair.diary.bean.DiaryBean; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | public class DiaryDao { 14 | 15 | private DataBaseHelper helper; 16 | 17 | public DiaryDao(Context context) { 18 | helper = new DataBaseHelper(context); 19 | } 20 | 21 | /** 22 | * 插入数据 23 | * 24 | * @param diary 25 | */ 26 | public void insert(DiaryBean diary) { 27 | SQLiteDatabase db = helper.getWritableDatabase(); 28 | ContentValues values = new ContentValues(); 29 | values.put("date", diary.getDate()); 30 | values.put("week", diary.getWeek()); 31 | values.put("weather", diary.getWeather()); 32 | values.put("title", diary.getTitle()); 33 | values.put("content", diary.getContent()); 34 | values.put("image", diary.getImage()); 35 | db.insert("DIARY", null, values); 36 | db.close(); 37 | } 38 | 39 | /** 40 | * 根据id删除 41 | * 42 | * @param id 43 | */ 44 | public void delete(long id) { 45 | SQLiteDatabase db = helper.getWritableDatabase(); 46 | db.execSQL("delete from DIARY where id = " + id); 47 | db.close(); 48 | } 49 | 50 | /** 51 | * 更新 52 | * 53 | * @param title 标题 54 | * @param content 内容 55 | * @param id id 56 | */ 57 | public void update(String title, String content, long id) { 58 | SQLiteDatabase db = helper.getWritableDatabase(); 59 | db.execSQL("update DIARY set title = \" " + title + " \", content = \" " + content + "\" where id = " + id); 60 | db.close(); 61 | } 62 | 63 | /** 64 | * 查询 65 | * 66 | * @param diaries 67 | */ 68 | public void query(ArrayList diaries) { 69 | SQLiteDatabase db = helper.getReadableDatabase(); 70 | Cursor cursor = db.query("DIARY", null, null, null, null, null, "id desc"); 71 | diaries.clear(); 72 | while (cursor.moveToNext()) { 73 | DiaryBean diary = new DiaryBean(); 74 | String title = cursor.getString(cursor.getColumnIndex("title")); 75 | String content = cursor.getString(cursor.getColumnIndex("content")); 76 | String image = cursor.getString(cursor.getColumnIndex("image")); 77 | String date = cursor.getString(cursor.getColumnIndex("date")); 78 | String week = cursor.getString(cursor.getColumnIndex("week")); 79 | String weather = cursor.getString(cursor.getColumnIndex("weather")); 80 | int id = cursor.getInt(cursor.getColumnIndex("id")); 81 | diary.setDate(date); 82 | diary.setWeek(week); 83 | diary.setWeather(weather); 84 | diary.setTitle(title); 85 | diary.setContent(content); 86 | diary.setImage(image); 87 | diary.setId(id); 88 | diaries.add(diary); 89 | } 90 | cursor.close(); 91 | db.close(); 92 | } 93 | 94 | public void deleteAll() { 95 | String delete_sql = "delete from DIARY"; 96 | SQLiteDatabase db = helper.getWritableDatabase(); 97 | db.execSQL(delete_sql); 98 | db.close(); 99 | } 100 | 101 | public void dimSearch(String query, List diaries) { 102 | SQLiteDatabase db = helper.getReadableDatabase(); 103 | Cursor cursor = db.query("DIARY", null, "content like '%" + query + "%' " + " OR title like '%" + query + "%'", null, null, null, "id desc"); 104 | diaries.clear(); 105 | while (cursor.moveToNext()) { 106 | DiaryBean diary = new DiaryBean(); 107 | String date = cursor.getString(cursor.getColumnIndex("date")); 108 | String week = cursor.getString(cursor.getColumnIndex("week")); 109 | String weather = cursor.getString(cursor.getColumnIndex("weather")); 110 | String image = cursor.getString(cursor.getColumnIndex("image")); 111 | String content = cursor.getString(cursor.getColumnIndex("content")); 112 | String title = cursor.getString(cursor.getColumnIndex("title")); 113 | int id = cursor.getInt(cursor.getColumnIndex("id")); 114 | diary.setDate(date); 115 | diary.setWeek(week); 116 | diary.setWeather(weather); 117 | diary.setImage(image); 118 | diary.setContent(content); 119 | diary.setTitle(title); 120 | diary.setId(id); 121 | diaries.add(diary); 122 | } 123 | cursor.close(); 124 | db.close(); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/receiver/RairReceiver.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.receiver; 2 | 3 | import android.annotation.TargetApi; 4 | import android.app.Notification; 5 | import android.app.NotificationManager; 6 | import android.app.PendingIntent; 7 | import android.content.BroadcastReceiver; 8 | import android.content.Context; 9 | import android.content.Intent; 10 | import android.os.Build; 11 | import android.support.annotation.RequiresApi; 12 | 13 | import com.rair.diary.R; 14 | import com.rair.diary.utils.RairUtils; 15 | import com.rair.diary.base.RairApp; 16 | import com.rair.diary.constant.Constants; 17 | import com.rair.diary.ui.MainActivity; 18 | 19 | import java.util.Calendar; 20 | 21 | /** 22 | * Created by mzaiy on 2017/6/5. 23 | */ 24 | 25 | public class RairReceiver extends BroadcastReceiver { 26 | 27 | private Calendar calendar = Calendar.getInstance(); 28 | 29 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 30 | @Override 31 | public void onReceive(Context context, Intent intent) { 32 | if (intent.getAction().equals(Constants.REMIND_RECEIVER)) { 33 | calendar.setTimeInMillis(System.currentTimeMillis()); 34 | int h = calendar.get(Calendar.HOUR_OF_DAY); 35 | int m = calendar.get(Calendar.MINUTE); 36 | String setTime = RairApp.getRairApp().getSpUtils().getString("setTime"); 37 | if ((RairUtils.format(h) + RairUtils.format(m)).equals(setTime)) { 38 | showNotification(context); 39 | return; 40 | } 41 | } 42 | } 43 | 44 | @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN) 45 | private void showNotification(Context context) { 46 | NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 47 | Intent notificationIntent = new Intent(context, MainActivity.class); 48 | PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 49 | Notification notification = new Notification.Builder(context) 50 | .setContentTitle("提醒") 51 | .setContentText("时间到了,该写日记了哦,亲!O(∩_∩)O~") 52 | .setSmallIcon(R.mipmap.ic_launcher) 53 | .setContentIntent(contentIntent) 54 | .build(); 55 | // 指定通知可以清除 56 | notification.flags |= Notification.FLAG_AUTO_CANCEL; 57 | // 指定通知不能清除 58 | // notification.flags |= Notification.FLAG_NO_CLEAR; 59 | // 通知显示的时候播放默认声音 60 | notification.flags |= Notification.FLAG_SHOW_LIGHTS; 61 | //设置声音 62 | notification.defaults |= Notification.DEFAULT_SOUND; 63 | //设置LED灯 64 | notification.defaults |= Notification.DEFAULT_LIGHTS; 65 | manager.notify(1, notification); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/service/RemindService.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.service; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | import android.support.annotation.Nullable; 7 | 8 | import com.rair.diary.constant.Constants; 9 | 10 | /** 11 | * Created by mzaiy on 2017/6/5. 12 | */ 13 | 14 | public class RemindService extends Service { 15 | 16 | private static RemindService remindService; 17 | 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | remindService = this; 22 | } 23 | 24 | @Nullable 25 | @Override 26 | public IBinder onBind(Intent intent) { 27 | return null; 28 | } 29 | 30 | @Override 31 | public int onStartCommand(Intent intent, int flags, int startId) { 32 | sendBroadcast(new Intent(Constants.SET_RECEIVER)); 33 | new Thread(new Runnable() { 34 | 35 | @Override 36 | public void run() { 37 | while (true) { 38 | try { 39 | Thread.sleep(60000); 40 | sendBroadcast(new Intent(Constants.REMIND_RECEIVER)); 41 | } catch (Exception e) { 42 | } 43 | } 44 | } 45 | }).start(); 46 | return super.onStartCommand(intent, flags, startId); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.widget.TextView; 8 | 9 | import com.rair.diary.R; 10 | 11 | import java.util.Random; 12 | 13 | import butterknife.BindView; 14 | import butterknife.ButterKnife; 15 | import butterknife.Unbinder; 16 | 17 | public class SplashActivity extends AppCompatActivity { 18 | 19 | @BindView(R.id.splash_tv_tip) 20 | TextView splashTvTip; 21 | private Unbinder bind; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_splash); 27 | bind = ButterKnife.bind(this); 28 | initView(); 29 | } 30 | 31 | private void initView() { 32 | String[] tips = { 33 | "日记,不光是庄稼,是粮食,也是一剂疗养生命疼痛的良药。", 34 | "坚持写日记可以培养一个人的真诚感。", 35 | "写日记,要有恒,几十年如一日。记下个人的成绩,也记下个人的得失。", 36 | "最自然、最活泼、最不摆架子而又最精练的文学作品,莫过于日记。", 37 | "日记的价值不仅表现在写的当时,更表现在若干时间之后。", 38 | "为了不忘昨天,为了憧憬明天,应该写日记。", 39 | "每天写日记之前,都应该静下心来回忆一下全天的生活。", 40 | "我敞开心扉向它(日记)倾诉,请它为我挽住时间的足迹。", 41 | "日记是向自己讲述故事的忠实伙伴;日记,是催人反省的香醇美酒。", 42 | "我觉得坚持写日记更主要的好处是帮助自己,养成勤于动脑的习惯。" 43 | }; 44 | int random = new Random().nextInt(tips.length); 45 | splashTvTip.setText(tips[random]); 46 | new Handler().postDelayed(new Runnable() { 47 | @Override 48 | public void run() { 49 | startActivity(new Intent(SplashActivity.this, MainActivity.class)); 50 | SplashActivity.this.finish(); 51 | } 52 | }, 2000); 53 | } 54 | 55 | @Override 56 | protected void onDestroy() { 57 | super.onDestroy(); 58 | bind.unbind(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/diary/detail/DiaryDetailActivity.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.diary.detail; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.os.Bundle; 9 | import android.support.design.widget.FloatingActionButton; 10 | import android.support.v7.app.AppCompatActivity; 11 | import android.text.TextUtils; 12 | import android.view.View; 13 | import android.widget.EditText; 14 | import android.widget.ImageView; 15 | import android.widget.LinearLayout; 16 | import android.widget.TextView; 17 | import android.widget.Toast; 18 | 19 | import com.rair.diary.R; 20 | import com.rair.diary.constant.Constants; 21 | import com.rair.diary.db.DiaryDao; 22 | import com.rair.diary.utils.RairUtils; 23 | import com.rair.diary.view.LinedEditText; 24 | 25 | import java.io.File; 26 | 27 | import butterknife.BindView; 28 | import butterknife.ButterKnife; 29 | import butterknife.OnClick; 30 | import butterknife.Unbinder; 31 | 32 | public class DiaryDetailActivity extends AppCompatActivity { 33 | 34 | @BindView(R.id.detail_iv_back) 35 | ImageView detailIvBack; 36 | @BindView(R.id.detail_iv_save) 37 | ImageView detailIvSave; 38 | @BindView(R.id.detail_et_title) 39 | EditText detailEtTitle; 40 | @BindView(R.id.detail_et_content) 41 | LinedEditText detailEtContent; 42 | @BindView(R.id.detail_fab_edit) 43 | FloatingActionButton detailFabEdit; 44 | @BindView(R.id.detail_fab_delete) 45 | FloatingActionButton detailFabDelete; 46 | @BindView(R.id.detail_ll_option) 47 | LinearLayout detailLlOption; 48 | @BindView(R.id.detail_iv_show) 49 | ImageView detailIvShow; 50 | @BindView(R.id.detail_tv_tite) 51 | TextView detailTvTite; 52 | private Unbinder bind; 53 | private DiaryDao diaryDao; 54 | private long id; 55 | 56 | @Override 57 | protected void onCreate(Bundle savedInstanceState) { 58 | super.onCreate(savedInstanceState); 59 | setContentView(R.layout.activity_diary_detail); 60 | bind = ButterKnife.bind(this); 61 | initView(); 62 | } 63 | 64 | private void initView() { 65 | diaryDao = new DiaryDao(this); 66 | Intent intent = getIntent(); 67 | String title = intent.getStringExtra("title"); 68 | String content = intent.getStringExtra("content"); 69 | String image = intent.getStringExtra("image"); 70 | String date = intent.getStringExtra("date"); 71 | String week = intent.getStringExtra("week"); 72 | String weather = intent.getStringExtra("weather"); 73 | id = intent.getLongExtra("id", 0); 74 | detailEtTitle.setText(title); 75 | detailEtContent.setText(content); 76 | detailTvTite.setText(String.format(Constants.FORMAT, date, week, weather)); 77 | if (image != null || !image.equals("n") || !TextUtils.isEmpty(image)) { 78 | File file = new File(image); 79 | if (file.exists()) { 80 | detailIvShow.setVisibility(View.VISIBLE); 81 | Bitmap bitmap = BitmapFactory.decodeFile(image); 82 | detailIvShow.setImageBitmap(bitmap); 83 | } else { 84 | detailIvShow.setVisibility(View.GONE); 85 | } 86 | } 87 | } 88 | 89 | @OnClick({R.id.detail_iv_back, R.id.detail_iv_save, R.id.detail_fab_edit, R.id.detail_fab_delete}) 90 | public void onViewClicked(View view) { 91 | switch (view.getId()) { 92 | case R.id.detail_iv_back: 93 | this.finish(); 94 | break; 95 | case R.id.detail_iv_save: 96 | doSave(); 97 | break; 98 | case R.id.detail_fab_edit: 99 | detailEtTitle.setEnabled(true); 100 | detailEtContent.setEnabled(true); 101 | detailIvSave.setVisibility(View.VISIBLE); 102 | detailLlOption.setVisibility(View.GONE); 103 | break; 104 | case R.id.detail_fab_delete: 105 | doDelete(); 106 | break; 107 | } 108 | } 109 | 110 | /** 111 | * 保存的方法 112 | */ 113 | private void doSave() { 114 | String title = detailEtTitle.getText().toString().trim(); 115 | String content = detailEtContent.getText().toString().trim(); 116 | if (TextUtils.isEmpty(title)) { 117 | title = "无标题"; 118 | } 119 | if (TextUtils.isEmpty(content)) { 120 | content = "无内容"; 121 | } 122 | diaryDao.update(title, content, id); 123 | this.finish(); 124 | RairUtils.showSnackar(detailEtContent, "保存成功"); 125 | RairUtils.hideInput(this); 126 | } 127 | 128 | /** 129 | * 删除的方法 130 | */ 131 | private void doDelete() { 132 | AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.DialogStyle); 133 | builder.setMessage(getString(R.string.delete_sure)); 134 | builder.setTitle(getString(R.string.delete)); 135 | builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { 136 | @Override 137 | public void onClick(DialogInterface dialog, int which) { 138 | diaryDao.delete(id); 139 | dialog.dismiss(); 140 | DiaryDetailActivity.this.finish(); 141 | Toast.makeText(DiaryDetailActivity.this, getString(R.string.delete_over), Toast.LENGTH_SHORT).show(); 142 | } 143 | }); 144 | builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { 145 | @Override 146 | public void onClick(DialogInterface dialog, int which) { 147 | dialog.dismiss(); 148 | } 149 | }); 150 | builder.create().show(); 151 | } 152 | 153 | @Override 154 | protected void onDestroy() { 155 | super.onDestroy(); 156 | bind.unbind(); 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/find/FindFragment.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.find; 2 | 3 | 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.view.LayoutInflater; 11 | import android.view.View; 12 | import android.view.ViewGroup; 13 | import android.widget.TextView; 14 | 15 | import com.chad.library.adapter.base.BaseQuickAdapter; 16 | import com.rair.diary.R; 17 | import com.rair.diary.adapter.FindXrvAdapter; 18 | import com.rair.diary.bean.Diary; 19 | import com.rair.diary.bean.User; 20 | import com.rair.diary.utils.RairUtils; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import butterknife.BindView; 26 | import butterknife.ButterKnife; 27 | import butterknife.Unbinder; 28 | import cn.bmob.v3.BmobQuery; 29 | import cn.bmob.v3.exception.BmobException; 30 | import cn.bmob.v3.listener.FindListener; 31 | 32 | /** 33 | * A simple {@link Fragment} subclass. 34 | */ 35 | public class FindFragment extends Fragment implements BaseQuickAdapter.OnItemClickListener { 36 | 37 | @BindView(R.id.find_rv_list) 38 | RecyclerView findrvList; 39 | Unbinder unbinder; 40 | @BindView(R.id.find_tv_tip) 41 | TextView findTvTip; 42 | private ArrayList datas; 43 | //当前页 44 | private int pageNum = 0; 45 | private FindXrvAdapter findXrvAdapter; 46 | 47 | public static FindFragment newInstance() { 48 | FindFragment findFragment = new FindFragment(); 49 | return findFragment; 50 | } 51 | 52 | @Override 53 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 54 | Bundle savedInstanceState) { 55 | return inflater.inflate(R.layout.fragment_find, container, false); 56 | } 57 | 58 | @Override 59 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 60 | super.onViewCreated(view, savedInstanceState); 61 | unbinder = ButterKnife.bind(this, view); 62 | initView(); 63 | } 64 | 65 | private void initView() { 66 | datas = new ArrayList<>(); 67 | findrvList.setLayoutManager(new LinearLayoutManager(getContext())); 68 | findXrvAdapter = new FindXrvAdapter(getContext(), R.layout.view_find_item, datas); 69 | findrvList.setAdapter(findXrvAdapter); 70 | findXrvAdapter.setOnItemClickListener(this); 71 | loadDiary(); 72 | } 73 | 74 | /** 75 | * 加载日记 76 | */ 77 | private void loadDiary() { 78 | BmobQuery query = new BmobQuery<>(); 79 | query.order("-createdAt"); 80 | query.setLimit(20); 81 | query.setSkip(20 * (pageNum++)); 82 | query.include("user"); 83 | query.findObjects(new FindListener() { 84 | @Override 85 | public void done(List list, BmobException e) { 86 | if (e == null) { 87 | findXrvAdapter.notifyDataSetChanged(); 88 | datas.addAll(list); 89 | if (datas.size() == 0) { 90 | findTvTip.setVisibility(View.VISIBLE); 91 | } else { 92 | findTvTip.setVisibility(View.GONE); 93 | } 94 | findXrvAdapter.notifyDataSetChanged(); 95 | } else { 96 | RairUtils.showSnackar(findrvList, "加载失败,请稍后重试。"); 97 | } 98 | } 99 | }); 100 | } 101 | 102 | @Override 103 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) { 104 | Diary diary = datas.get(position); 105 | User user = diary.getUser(); 106 | Intent intent = new Intent(getContext(), FindDetailActivity.class); 107 | intent.putExtra("title", diary.getTitle()); 108 | intent.putExtra("content", diary.getContent()); 109 | if (diary.getImage() != null) 110 | intent.putExtra("image", diary.getImage().getFileUrl()); 111 | intent.putExtra("date", diary.getDate()); 112 | intent.putExtra("week", diary.getWeek()); 113 | intent.putExtra("weather", diary.getWeather()); 114 | if (user.getHeadFile() != null) 115 | intent.putExtra("head", user.getHeadFile().getFileUrl()); 116 | intent.putExtra("name", diary.getName()); 117 | intent.putExtra("sex", user.getSex()); 118 | intent.putExtra("sign", user.getSign()); 119 | intent.putExtra("publish", diary.getCreateTime()); 120 | intent.putExtra("diary", diary); 121 | startActivity(intent); 122 | } 123 | 124 | // @Override 125 | // public void onRefresh() { 126 | // datas.clear(); 127 | // pageNum = 0; 128 | // loadDiary(); 129 | // } 130 | 131 | @Override 132 | public void onHiddenChanged(boolean hidden) { 133 | super.onHiddenChanged(hidden); 134 | if (!hidden) loadDiary(); 135 | } 136 | 137 | @Override 138 | public void onDestroyView() { 139 | super.onDestroyView(); 140 | unbinder.unbind(); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/setting/about/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.setting.about; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.rair.diary.R; 12 | import com.rair.diary.constant.Constants; 13 | 14 | import butterknife.BindView; 15 | import butterknife.ButterKnife; 16 | import butterknife.OnClick; 17 | import butterknife.Unbinder; 18 | 19 | public class AboutActivity extends AppCompatActivity { 20 | 21 | @BindView(R.id.about_iv_back) 22 | ImageView aboutIvBack; 23 | @BindView(R.id.about_tv_join) 24 | TextView aboutTvJoin; 25 | @BindView(R.id.about_tv_version) 26 | TextView aboutTvVersion; 27 | @BindView(R.id.about_tv_support) 28 | TextView aboutTvSupport; 29 | private Unbinder unbinder; 30 | 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_about); 35 | unbinder = ButterKnife.bind(this); 36 | } 37 | 38 | @OnClick({R.id.about_iv_back, R.id.about_tv_join, R.id.about_tv_version, R.id.about_tv_support}) 39 | public void onViewClicked(View view) { 40 | switch (view.getId()) { 41 | case R.id.about_iv_back: 42 | this.finish(); 43 | break; 44 | case R.id.about_tv_join: 45 | joinQQGroup(Constants.QQ_KEY); 46 | break; 47 | case R.id.about_tv_version: 48 | break; 49 | case R.id.about_tv_support: 50 | break; 51 | } 52 | } 53 | 54 | /**************** 55 | * 56 | * 发起添加群流程。群号:Rair修仙开发交流(650494950) 的 key 为: J_-56inXPgycIyUIF9tPW19bfUFZul9m 57 | * 调用 joinQQGroup(J_-56inXPgycIyUIF9tPW19bfUFZul9m) 即可发起手Q客户端申请加群 Rair修仙开发交流(650494950) 58 | * 59 | * @param key 由官网生成的key 60 | * @return 返回true表示呼起手Q成功,返回fals表示呼起失败 61 | ******************/ 62 | public boolean joinQQGroup(String key) { 63 | Intent intent = new Intent(); 64 | intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key)); 65 | // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 66 | try { 67 | startActivity(intent); 68 | return true; 69 | } catch (Exception e) { 70 | // 未安装手Q或安装的版本不支持 71 | return false; 72 | } 73 | } 74 | 75 | @Override 76 | protected void onDestroy() { 77 | super.onDestroy(); 78 | unbinder.unbind(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/setting/feedback/FeedBackActivity.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.setting.feedback; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.text.TextUtils; 6 | import android.view.View; 7 | import android.widget.EditText; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.rair.diary.R; 12 | import com.rair.diary.bean.FeedBack; 13 | import com.rair.diary.utils.RairUtils; 14 | import com.rair.diary.view.LinedEditText; 15 | 16 | import butterknife.BindView; 17 | import butterknife.ButterKnife; 18 | import butterknife.OnClick; 19 | import butterknife.Unbinder; 20 | import cn.bmob.v3.exception.BmobException; 21 | import cn.bmob.v3.listener.SaveListener; 22 | 23 | public class FeedBackActivity extends AppCompatActivity { 24 | 25 | @BindView(R.id.feedback_iv_back) 26 | ImageView feedbackIvBack; 27 | @BindView(R.id.feedback_et_content) 28 | LinedEditText feedbackEtContent; 29 | @BindView(R.id.feedback_et_contact) 30 | EditText feedbackEtContact; 31 | @BindView(R.id.feedback_tv_commit) 32 | TextView feedbackTvCommit; 33 | private Unbinder unbinder; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_feed_back); 39 | unbinder = ButterKnife.bind(this); 40 | } 41 | 42 | @OnClick({R.id.feedback_iv_back, R.id.feedback_tv_commit}) 43 | public void onViewClicked(View view) { 44 | switch (view.getId()) { 45 | case R.id.feedback_iv_back: 46 | this.finish(); 47 | break; 48 | case R.id.feedback_tv_commit: 49 | doCommit(); 50 | break; 51 | } 52 | } 53 | 54 | /** 55 | * 提交 56 | */ 57 | private void doCommit() { 58 | String content = feedbackEtContent.getText().toString().trim(); 59 | String contact = feedbackEtContact.getText().toString().trim(); 60 | if (TextUtils.isEmpty(content)) { 61 | RairUtils.showSnackar(feedbackTvCommit, "请输入反馈内容"); 62 | } else if (TextUtils.isEmpty(contact)) { 63 | RairUtils.showSnackar(feedbackTvCommit, "请输入联系方式"); 64 | } else { 65 | FeedBack feedBack = new FeedBack(content, contact); 66 | feedBack.save(new SaveListener() { 67 | @Override 68 | public void done(String s, BmobException e) { 69 | if (e == null) { 70 | FeedBackActivity.this.finish(); 71 | RairUtils.showSnackar(feedbackTvCommit, "提交成功"); 72 | } else { 73 | RairUtils.showSnackar(feedbackTvCommit, "提交失败"); 74 | } 75 | } 76 | }); 77 | } 78 | } 79 | 80 | @Override 81 | protected void onDestroy() { 82 | super.onDestroy(); 83 | unbinder.unbind(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/setting/user/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.setting.user; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.TabLayout; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.view.ViewPager; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.widget.ImageView; 10 | 11 | import com.rair.diary.R; 12 | import com.rair.diary.adapter.LoginPagerAdapter; 13 | 14 | import butterknife.BindView; 15 | import butterknife.ButterKnife; 16 | import butterknife.OnClick; 17 | import butterknife.Unbinder; 18 | 19 | public class LoginActivity extends AppCompatActivity { 20 | 21 | @BindView(R.id.login_iv_back) 22 | ImageView loginIvBack; 23 | @BindView(R.id.login_tabs) 24 | TabLayout loginTabs; 25 | @BindView(R.id.login_pagers) 26 | ViewPager loginPagers; 27 | private Unbinder unbinder; 28 | 29 | @Override 30 | protected void onCreate(Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_login); 33 | unbinder = ButterKnife.bind(this); 34 | initView(); 35 | } 36 | 37 | private void initView() { 38 | FragmentManager fragmentManager = getSupportFragmentManager(); 39 | String[] titles = {getString(R.string.login), getString(R.string.register)}; 40 | Fragment[] fragments = {LoginFragment.newInstance(), RegisterFragment.newInstance()}; 41 | LoginPagerAdapter pagerAdapter = new LoginPagerAdapter(fragmentManager, titles, fragments); 42 | loginPagers.setAdapter(pagerAdapter); 43 | loginTabs.setupWithViewPager(loginPagers); 44 | } 45 | 46 | @OnClick(R.id.login_iv_back) 47 | public void onViewClicked() { 48 | this.finish(); 49 | } 50 | 51 | @Override 52 | protected void onDestroy() { 53 | super.onDestroy(); 54 | unbinder.unbind(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/setting/user/LoginFragment.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.setting.user; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.text.TextUtils; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | import com.rair.diary.R; 14 | import com.rair.diary.base.RairApp; 15 | import com.rair.diary.bean.User; 16 | import com.rair.diary.utils.RairUtils; 17 | import com.rair.diary.utils.SPUtils; 18 | import com.rair.diary.view.EditTextWithDel; 19 | 20 | import butterknife.BindView; 21 | import butterknife.ButterKnife; 22 | import butterknife.OnClick; 23 | import butterknife.Unbinder; 24 | import cn.bmob.v3.exception.BmobException; 25 | import cn.bmob.v3.listener.SaveListener; 26 | 27 | /** 28 | * A simple {@link Fragment} subclass. 29 | */ 30 | public class LoginFragment extends Fragment { 31 | 32 | @BindView(R.id.login_et_name) 33 | EditTextWithDel loginEtName; 34 | @BindView(R.id.login_et_pwd) 35 | EditTextWithDel loginEtPwd; 36 | @BindView(R.id.login_tv_login) 37 | TextView loginTvLogin; 38 | @BindView(R.id.login_tv_forget) 39 | TextView loginTvForget; 40 | Unbinder unbinder; 41 | private SPUtils spUtils; 42 | 43 | public static LoginFragment newInstance() { 44 | LoginFragment loginFragment = new LoginFragment(); 45 | return loginFragment; 46 | } 47 | 48 | @Override 49 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 50 | Bundle savedInstanceState) { 51 | return inflater.inflate(R.layout.fragment_login, container, false); 52 | } 53 | 54 | @Override 55 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 56 | super.onViewCreated(view, savedInstanceState); 57 | unbinder = ButterKnife.bind(this, view); 58 | spUtils = RairApp.getRairApp().getSpUtils(); 59 | } 60 | 61 | @OnClick({R.id.login_tv_login, R.id.login_tv_forget}) 62 | public void onViewClicked(View view) { 63 | switch (view.getId()) { 64 | case R.id.login_tv_login: 65 | doLogin(); 66 | break; 67 | case R.id.login_tv_forget: 68 | break; 69 | } 70 | } 71 | 72 | /** 73 | * 登录操作 74 | */ 75 | private void doLogin() { 76 | String userName = loginEtName.getText().toString(); 77 | String userPwd = loginEtPwd.getText().toString(); 78 | if (TextUtils.isEmpty(userName)) { 79 | RairUtils.showSnackar(loginTvLogin, "请输入用户名/邮箱"); 80 | return; 81 | } 82 | if (TextUtils.isEmpty(userPwd)) { 83 | RairUtils.showSnackar(loginTvLogin, "请输入密码"); 84 | return; 85 | } 86 | User user = new User(); 87 | user.setUsername(userName); 88 | user.setNickName(userName); 89 | user.setPassword(userPwd); 90 | user.login(new SaveListener() { 91 | @Override 92 | public void done(User user, BmobException e) { 93 | if (e == null) { 94 | RairUtils.showSnackar(loginTvLogin, "登陆成功"); 95 | getActivity().finish(); 96 | } else { 97 | switch (e.getErrorCode()) { 98 | case 101: 99 | RairUtils.showSnackar(loginTvLogin, "登陆失败,用户不存在或密码错误"); 100 | break; 101 | default: 102 | RairUtils.showSnackar(loginTvLogin, "登陆失败"); 103 | break; 104 | } 105 | } 106 | } 107 | }); 108 | } 109 | 110 | @Override 111 | public void onDestroyView() { 112 | super.onDestroyView(); 113 | unbinder.unbind(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/ui/setting/user/RegisterFragment.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.ui.setting.user; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.text.TextUtils; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | import com.rair.diary.R; 14 | import com.rair.diary.bean.User; 15 | import com.rair.diary.utils.RairUtils; 16 | import com.rair.diary.view.EditTextWithDel; 17 | 18 | import butterknife.BindView; 19 | import butterknife.ButterKnife; 20 | import butterknife.OnClick; 21 | import butterknife.Unbinder; 22 | import cn.bmob.v3.exception.BmobException; 23 | import cn.bmob.v3.listener.SaveListener; 24 | 25 | /** 26 | * A simple {@link Fragment} subclass. 27 | */ 28 | public class RegisterFragment extends Fragment { 29 | 30 | 31 | @BindView(R.id.register_et_name) 32 | EditTextWithDel registerEtName; 33 | @BindView(R.id.register_et_email) 34 | EditTextWithDel registerEtEmail; 35 | @BindView(R.id.register_et_pwd) 36 | EditTextWithDel registerEtPwd; 37 | @BindView(R.id.register_tv_register) 38 | TextView registerTvRegister; 39 | Unbinder unbinder; 40 | 41 | public static RegisterFragment newInstance() { 42 | RegisterFragment registerFragment = new RegisterFragment(); 43 | return registerFragment; 44 | } 45 | 46 | @Override 47 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 48 | Bundle savedInstanceState) { 49 | return inflater.inflate(R.layout.fragment_register, container, false); 50 | } 51 | 52 | @Override 53 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { 54 | super.onViewCreated(view, savedInstanceState); 55 | unbinder = ButterKnife.bind(this, view); 56 | } 57 | 58 | @OnClick(R.id.register_tv_register) 59 | public void onViewClicked() { 60 | doRegister(); 61 | } 62 | 63 | /** 64 | * 注册操作 65 | */ 66 | private void doRegister() { 67 | String userName = registerEtName.getText().toString(); 68 | String userMail = registerEtEmail.getText().toString(); 69 | String userPwd = registerEtPwd.getText().toString(); 70 | if (TextUtils.isEmpty(userName)) { 71 | RairUtils.showSnackar(registerTvRegister, "请输入用户名"); 72 | return; 73 | } 74 | if (TextUtils.isEmpty(userMail)) { 75 | RairUtils.showSnackar(registerTvRegister, "请输入邮箱"); 76 | return; 77 | } 78 | if (!RairUtils.isEmail(userMail)) { 79 | RairUtils.showSnackar(registerTvRegister, "邮箱格式不正确"); 80 | return; 81 | } 82 | if (TextUtils.isEmpty(userPwd)) { 83 | RairUtils.showSnackar(registerTvRegister, "请输入密码"); 84 | return; 85 | } 86 | User user = new User(); 87 | user.setUsername(userName); 88 | user.setSign("编辑个性签名"); 89 | user.setEmail(userMail); 90 | user.setNickName(userName); 91 | user.setSex(0); 92 | user.setPassword(userPwd); 93 | user.signUp(new SaveListener() { 94 | @Override 95 | public void done(User user, BmobException e) { 96 | if (e == null) { 97 | RairUtils.showSnackar(registerTvRegister, "注册成功,已登录"); 98 | getActivity().finish(); 99 | } else { 100 | switch (e.getErrorCode()) { 101 | case 202: 102 | RairUtils.showSnackar(registerTvRegister, "注册失败,用户名已经存在"); 103 | break; 104 | case 203: 105 | RairUtils.showSnackar(registerTvRegister, "注册失败,邮箱已经存在"); 106 | break; 107 | default: 108 | RairUtils.showSnackar(registerTvRegister, "注册失败"); 109 | break; 110 | } 111 | } 112 | } 113 | }); 114 | } 115 | 116 | @Override 117 | public void onDestroyView() { 118 | super.onDestroyView(); 119 | unbinder.unbind(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/utils/RairUtils.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.utils; 2 | 3 | import android.content.Context; 4 | import android.graphics.Point; 5 | import android.support.design.widget.Snackbar; 6 | import android.view.Display; 7 | import android.view.View; 8 | import android.view.WindowManager; 9 | import android.view.animation.Animation; 10 | import android.view.animation.CycleInterpolator; 11 | import android.view.animation.TranslateAnimation; 12 | import android.view.inputmethod.InputMethodManager; 13 | 14 | import java.text.SimpleDateFormat; 15 | import java.util.Locale; 16 | import java.util.Random; 17 | import java.util.regex.Matcher; 18 | import java.util.regex.Pattern; 19 | 20 | /** 21 | * Created by mzaiy on 2017/6/2. 22 | */ 23 | 24 | public class RairUtils { 25 | 26 | /** 27 | * 隐藏输入法 28 | * 29 | * @param context 上下文 30 | */ 31 | public static void hideInput(Context context) { 32 | InputMethodManager manager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); 33 | manager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); 34 | } 35 | 36 | /** 37 | * 格式化时间 38 | * 39 | * @param value int 值 40 | * @return 01 41 | */ 42 | public static String format(int value) { 43 | String s = String.valueOf(value); 44 | if (s.length() == 1) 45 | s = "0" + s; 46 | return s; 47 | } 48 | 49 | /** 50 | * 获取屏幕宽高 51 | * 52 | * @param context 53 | * @return 屏幕宽高[宽, 高] 54 | */ 55 | public static int[] screenWH(Context context) { 56 | int[] screenWH = new int[2]; 57 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 58 | Display display = wm.getDefaultDisplay(); 59 | Point size = new Point(); 60 | display.getSize(size); 61 | screenWH[0] = size.x; 62 | screenWH[1] = size.y; 63 | return screenWH; 64 | } 65 | 66 | /** 67 | * 抖动动画 68 | * 69 | * @param CycleTimes 动画重复的次数 70 | * @return 动画 71 | */ 72 | public static Animation shakeAnimation(int CycleTimes) { 73 | Animation translateAnimation = new TranslateAnimation(0, 6, 0, 6); 74 | translateAnimation.setInterpolator(new CycleInterpolator(CycleTimes)); 75 | translateAnimation.setDuration(1000); 76 | return translateAnimation; 77 | } 78 | 79 | /** 80 | * 显示SnackBar 81 | * 82 | * @param view 视图 83 | * @param string 文本 84 | */ 85 | public static void showSnackar(View view, String string) { 86 | Snackbar.make(view, string, Snackbar.LENGTH_SHORT).show(); 87 | } 88 | 89 | /** 90 | * 校验邮箱 91 | * 92 | * @param email 邮箱 93 | * @return 是否正确 94 | */ 95 | public static boolean isEmail(String email) { 96 | Pattern p = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,3}){1,2})$"); 97 | Matcher m = p.matcher(email); 98 | return m.matches(); 99 | } 100 | 101 | /** 102 | * 验证手机号 103 | * 104 | * @param mobiles 手机号 105 | * @return true, false 106 | */ 107 | public static boolean isMobileNO(String mobiles) { 108 | Pattern p = Pattern.compile("[1][3578]\\d{9}"); 109 | Matcher m = p.matcher(mobiles); 110 | return m.matches(); 111 | } 112 | 113 | /** 114 | * 随机生成字符串(nonce) 115 | * 116 | * @return 随机字符串 117 | */ 118 | public static String randomStr(int length) { //length表示生成字符串的长度 119 | String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; //生成字符串从此序列中取 120 | Random random = new Random(); 121 | StringBuffer sb = new StringBuffer(); 122 | for (int i = 0; i < length; i++) {//32位 123 | int number = random.nextInt(base.length()); 124 | sb.append(base.charAt(number)); 125 | } 126 | return sb.toString(); 127 | } 128 | 129 | /** 130 | * 获取时间 131 | * 132 | * @return yyyy-MM-dd HH-mm-ss 133 | */ 134 | public static String getTime() { 135 | long timeMillis = System.currentTimeMillis(); 136 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); 137 | return dateFormat.format(timeMillis); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/utils/SPUtils.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.support.annotation.Nullable; 6 | 7 | import java.util.Map; 8 | import java.util.Set; 9 | 10 | /** 11 | * desc : SP相关工具类 12 | */ 13 | public class SPUtils { 14 | 15 | private SharedPreferences sp; 16 | private SharedPreferences.Editor editor; 17 | 18 | /** 19 | * SPUtils构造函数 20 | *

在Application中初始化

21 | * 22 | * @param spName spName 23 | */ 24 | public SPUtils(String spName) { 25 | sp = Utils.getContext().getSharedPreferences(spName, Context.MODE_PRIVATE); 26 | editor = sp.edit(); 27 | editor.apply(); 28 | } 29 | 30 | /** 31 | * SP中写入String 32 | * 33 | * @param key 键 34 | * @param value 值 35 | */ 36 | public void put(String key, @Nullable String value) { 37 | editor.putString(key, value).apply(); 38 | } 39 | 40 | /** 41 | * SP中读取String 42 | * 43 | * @param key 键 44 | * @return 存在返回对应值,不存在返回默认值{@code null} 45 | */ 46 | public String getString(String key) { 47 | return getString(key, null); 48 | } 49 | 50 | /** 51 | * SP中读取String 52 | * 53 | * @param key 键 54 | * @param defaultValue 默认值 55 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 56 | */ 57 | public String getString(String key, String defaultValue) { 58 | return sp.getString(key, defaultValue); 59 | } 60 | 61 | /** 62 | * SP中写入int 63 | * 64 | * @param key 键 65 | * @param value 值 66 | */ 67 | public void put(String key, int value) { 68 | editor.putInt(key, value).apply(); 69 | } 70 | 71 | /** 72 | * SP中读取int 73 | * 74 | * @param key 键 75 | * @return 存在返回对应值,不存在返回默认值-1 76 | */ 77 | public int getInt(String key) { 78 | return getInt(key, -1); 79 | } 80 | 81 | /** 82 | * SP中读取int 83 | * 84 | * @param key 键 85 | * @param defaultValue 默认值 86 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 87 | */ 88 | public int getInt(String key, int defaultValue) { 89 | return sp.getInt(key, defaultValue); 90 | } 91 | 92 | /** 93 | * SP中写入long 94 | * 95 | * @param key 键 96 | * @param value 值 97 | */ 98 | public void put(String key, long value) { 99 | editor.putLong(key, value).apply(); 100 | } 101 | 102 | /** 103 | * SP中读取long 104 | * 105 | * @param key 键 106 | * @return 存在返回对应值,不存在返回默认值-1 107 | */ 108 | public long getLong(String key) { 109 | return getLong(key, -1L); 110 | } 111 | 112 | /** 113 | * SP中读取long 114 | * 115 | * @param key 键 116 | * @param defaultValue 默认值 117 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 118 | */ 119 | public long getLong(String key, long defaultValue) { 120 | return sp.getLong(key, defaultValue); 121 | } 122 | 123 | /** 124 | * SP中写入float 125 | * 126 | * @param key 键 127 | * @param value 值 128 | */ 129 | public void put(String key, float value) { 130 | editor.putFloat(key, value).apply(); 131 | } 132 | 133 | /** 134 | * SP中读取float 135 | * 136 | * @param key 键 137 | * @return 存在返回对应值,不存在返回默认值-1 138 | */ 139 | public float getFloat(String key) { 140 | return getFloat(key, -1f); 141 | } 142 | 143 | /** 144 | * SP中读取float 145 | * 146 | * @param key 键 147 | * @param defaultValue 默认值 148 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 149 | */ 150 | public float getFloat(String key, float defaultValue) { 151 | return sp.getFloat(key, defaultValue); 152 | } 153 | 154 | /** 155 | * SP中写入boolean 156 | * 157 | * @param key 键 158 | * @param value 值 159 | */ 160 | public void put(String key, boolean value) { 161 | editor.putBoolean(key, value).apply(); 162 | } 163 | 164 | /** 165 | * SP中读取boolean 166 | * 167 | * @param key 键 168 | * @return 存在返回对应值,不存在返回默认值{@code false} 169 | */ 170 | public boolean getBoolean(String key) { 171 | return getBoolean(key, false); 172 | } 173 | 174 | /** 175 | * SP中读取boolean 176 | * 177 | * @param key 键 178 | * @param defaultValue 默认值 179 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 180 | */ 181 | public boolean getBoolean(String key, boolean defaultValue) { 182 | return sp.getBoolean(key, defaultValue); 183 | } 184 | 185 | /** 186 | * SP中写入String集合 187 | * 188 | * @param key 键 189 | * @param values 值 190 | */ 191 | public void put(String key, @Nullable Set values) { 192 | editor.putStringSet(key, values).apply(); 193 | } 194 | 195 | /** 196 | * SP中读取StringSet 197 | * 198 | * @param key 键 199 | * @return 存在返回对应值,不存在返回默认值{@code null} 200 | */ 201 | public Set getStringSet(String key) { 202 | return getStringSet(key, null); 203 | } 204 | 205 | /** 206 | * SP中读取StringSet 207 | * 208 | * @param key 键 209 | * @param defaultValue 默认值 210 | * @return 存在返回对应值,不存在返回默认值{@code defaultValue} 211 | */ 212 | public Set getStringSet(String key, @Nullable Set defaultValue) { 213 | return sp.getStringSet(key, defaultValue); 214 | } 215 | 216 | /** 217 | * SP中获取所有键值对 218 | * 219 | * @return Map对象 220 | */ 221 | public Map getAll() { 222 | return sp.getAll(); 223 | } 224 | 225 | /** 226 | * SP中移除该key 227 | * 228 | * @param key 键 229 | */ 230 | public void remove(String key) { 231 | editor.remove(key).apply(); 232 | } 233 | 234 | /** 235 | * SP中是否存在该key 236 | * 237 | * @param key 键 238 | * @return {@code true}: 存在
{@code false}: 不存在 239 | */ 240 | public boolean contains(String key) { 241 | return sp.contains(key); 242 | } 243 | 244 | /** 245 | * SP中清除所有数据 246 | */ 247 | public void clear() { 248 | editor.clear().apply(); 249 | } 250 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.utils; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | 6 | /** 7 | * desc : Utils初始化相关 8 | * 9 | */ 10 | public final class Utils { 11 | 12 | @SuppressLint("StaticFieldLeak") 13 | private static Context context; 14 | 15 | private Utils() { 16 | throw new UnsupportedOperationException("u can't instantiate me..."); 17 | } 18 | 19 | /** 20 | * 初始化工具类 21 | * 22 | * @param context 上下文 23 | */ 24 | public static void init(Context context) { 25 | Utils.context = context.getApplicationContext(); 26 | } 27 | 28 | /** 29 | * 获取ApplicationContext 30 | * 31 | * @return ApplicationContext 32 | */ 33 | public static Context getContext() { 34 | if (context != null) return context; 35 | throw new NullPointerException("u should init first"); 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/view/BounceScrollView.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.view; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.graphics.Rect; 6 | import android.util.AttributeSet; 7 | import android.view.MotionEvent; 8 | import android.view.View; 9 | import android.view.animation.TranslateAnimation; 10 | import android.widget.ScrollView; 11 | 12 | /** 13 | * 丝般顺滑的ScrollView 14 | * 类名:带有反弹效果的scrollview 15 | */ 16 | public class BounceScrollView extends ScrollView { 17 | private View inner;// 孩子View 18 | 19 | private float y;// 点击时y坐标 20 | 21 | private Rect normal = new Rect();// 矩形(这里只是个形式,只是用于判断是否需要动画.) 22 | 23 | private boolean isCount = false;// 是否开始计算 24 | 25 | public BounceScrollView(Context context, AttributeSet attrs) { 26 | super(context, attrs); 27 | } 28 | 29 | /** 30 | * 根据 XML 生成视图工作完成.该函数在生成视图的最后调用,在所有子视图添加完之后. 即使子类覆盖了 onFinishInflate 31 | * 方法,也应该调用父类的方法,使该方法得以执行. 32 | */ 33 | 34 | @SuppressLint("MissingSuperCall") 35 | @Override 36 | protected void onFinishInflate() { 37 | if (getChildCount() > 0) { 38 | inner = getChildAt(0); 39 | } 40 | } 41 | 42 | /*** 43 | * 监听touch 44 | */ 45 | @Override 46 | public boolean onTouchEvent(MotionEvent ev) { 47 | if (inner != null) { 48 | commOnTouchEvent(ev); 49 | } 50 | 51 | return super.onTouchEvent(ev); 52 | } 53 | 54 | /*** 55 | * 触摸事件 56 | * 57 | * @param ev 58 | */ 59 | public void commOnTouchEvent(MotionEvent ev) { 60 | int action = ev.getAction(); 61 | switch (action) { 62 | case MotionEvent.ACTION_DOWN: 63 | break; 64 | case MotionEvent.ACTION_UP: 65 | // 手指松开. 66 | if (isNeedAnimation()) { 67 | animation(); 68 | isCount = false; 69 | } 70 | break; 71 | /*** 72 | * 排除出第一次移动计算,因为第一次无法得知y坐标, 在MotionEvent.ACTION_DOWN中获取不到, 73 | * 因为此时是MyScrollView的touch事件传递到到了LIstView的孩子item上面.所以从第二次计算开始. 74 | * 然而我们也要进行初始化,就是第一次移动的时候让滑动距离归0. 之后记录准确了就正常执行. 75 | */ 76 | case MotionEvent.ACTION_MOVE: 77 | final float preY = y;// 按下时的y坐标 78 | float nowY = ev.getY();// 时时y坐标 79 | int deltaY = (int) (preY - nowY);// 滑动距离 80 | if (!isCount) { 81 | deltaY = 0; // 在这里要归0. 82 | } 83 | 84 | y = nowY; 85 | // 当滚动到最上或者最下时就不会再滚动,这时移动布局 86 | if (isNeedMove()) { 87 | // 初始化头部矩形 88 | if (normal.isEmpty()) { 89 | // 保存正常的布局位置 90 | normal.set(inner.getLeft(), inner.getTop(), 91 | inner.getRight(), inner.getBottom()); 92 | } 93 | // 移动布局 94 | inner.layout(inner.getLeft(), inner.getTop() - deltaY / 2, 95 | inner.getRight(), inner.getBottom() - deltaY / 2); 96 | } 97 | isCount = true; 98 | break; 99 | 100 | default: 101 | break; 102 | } 103 | } 104 | 105 | /*** 106 | * 回缩动画 107 | */ 108 | public void animation() { 109 | // 开启移动动画 110 | TranslateAnimation ta = new TranslateAnimation(0, 0, inner.getTop(), normal.top); 111 | ta.setDuration(200); 112 | inner.startAnimation(ta); 113 | // 设置回到正常的布局位置 114 | inner.layout(normal.left, normal.top, normal.right, normal.bottom); 115 | normal.setEmpty(); 116 | } 117 | 118 | // 是否需要开启动画 119 | public boolean isNeedAnimation() { 120 | return !normal.isEmpty(); 121 | } 122 | 123 | /*** 124 | * 是否需要移动布局 inner.getMeasuredHeight():获取的是控件的总高度 125 | *

126 | * getHeight():获取的是屏幕的高度 127 | *

128 | * @return 129 | */ 130 | public boolean isNeedMove() { 131 | int offset = inner.getMeasuredHeight() - getHeight(); 132 | int scrollY = getScrollY(); 133 | // 0是顶部,后面那个是底部 134 | if (scrollY == 0 || scrollY == offset) { 135 | return true; 136 | } 137 | return false; 138 | } 139 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/view/CustomLayoutManager.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.view; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | public class CustomLayoutManager extends LinearLayoutManager { 10 | private boolean isScrollEnabled = true; 11 | 12 | public CustomLayoutManager(Context context) { 13 | super(context); 14 | } 15 | 16 | public void setScrollEnabled(boolean flag) { 17 | this.isScrollEnabled = flag; 18 | } 19 | 20 | @Override 21 | public boolean canScrollVertically() { 22 | return isScrollEnabled && super.canScrollVertically(); 23 | } 24 | 25 | private int[] mMeasuredDimension = new int[2]; 26 | 27 | @Override 28 | public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state, 29 | int widthSpec, int heightSpec) { 30 | final int widthMode = View.MeasureSpec.getMode(widthSpec); 31 | final int heightMode = View.MeasureSpec.getMode(heightSpec); 32 | final int widthSize = View.MeasureSpec.getSize(widthSpec); 33 | final int heightSize = View.MeasureSpec.getSize(heightSpec); 34 | int width = 0; 35 | int height = 0; 36 | for (int i = 0; i < getItemCount(); i++) { 37 | measureScrapChild(recycler, i, 38 | View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED), 39 | View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED), 40 | mMeasuredDimension); 41 | 42 | if (getOrientation() == HORIZONTAL) { 43 | width = width + mMeasuredDimension[0]; 44 | if (i == 0) { 45 | height = mMeasuredDimension[1]; 46 | } 47 | } else { 48 | height = height + mMeasuredDimension[1]; 49 | if (i == 0) { 50 | width = mMeasuredDimension[0]; 51 | } 52 | } 53 | } 54 | switch (widthMode) { 55 | case View.MeasureSpec.EXACTLY: 56 | width = widthSize; 57 | case View.MeasureSpec.AT_MOST: 58 | case View.MeasureSpec.UNSPECIFIED: 59 | } 60 | 61 | switch (heightMode) { 62 | case View.MeasureSpec.EXACTLY: 63 | height = heightSize; 64 | case View.MeasureSpec.AT_MOST: 65 | case View.MeasureSpec.UNSPECIFIED: 66 | } 67 | 68 | setMeasuredDimension(width, height); 69 | } 70 | 71 | private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec, 72 | int heightSpec, int[] measuredDimension) { 73 | try { 74 | View view = recycler.getViewForPosition(0);//fix 动态添加时报IndexOutOfBoundsException 75 | 76 | if (view != null) { 77 | RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams(); 78 | 79 | int childWidthSpec = ViewGroup.getChildMeasureSpec(widthSpec, 80 | getPaddingLeft() + getPaddingRight(), p.width); 81 | 82 | int childHeightSpec = ViewGroup.getChildMeasureSpec(heightSpec, 83 | getPaddingTop() + getPaddingBottom(), p.height); 84 | 85 | view.measure(childWidthSpec, childHeightSpec); 86 | measuredDimension[0] = view.getMeasuredWidth() + p.leftMargin + p.rightMargin; 87 | measuredDimension[1] = view.getMeasuredHeight() + p.bottomMargin + p.topMargin; 88 | recycler.recycleView(view); 89 | } 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } finally { 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/view/EditTextWithDel.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.v7.widget.AppCompatEditText; 7 | import android.text.Editable; 8 | import android.text.TextWatcher; 9 | import android.util.AttributeSet; 10 | import android.view.MotionEvent; 11 | 12 | import com.rair.diary.R; 13 | import com.rair.diary.utils.RairUtils; 14 | 15 | public class EditTextWithDel extends AppCompatEditText { 16 | 17 | private Drawable imgInable; 18 | 19 | private Context mContext; 20 | 21 | public EditTextWithDel(Context context) { 22 | super(context); 23 | mContext = context; 24 | init(); 25 | } 26 | 27 | public EditTextWithDel(Context context, AttributeSet attrs, int defStyle) { 28 | super(context, attrs, defStyle); 29 | mContext = context; 30 | init(); 31 | } 32 | 33 | public EditTextWithDel(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | mContext = context; 36 | init(); 37 | } 38 | 39 | private void init() { 40 | imgInable = mContext.getResources().getDrawable(R.mipmap.delete); 41 | addTextChangedListener(new TextWatcher() { 42 | @Override 43 | public void onTextChanged(CharSequence s, int start, int before, int count) { 44 | } 45 | 46 | @Override 47 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { 48 | } 49 | 50 | @Override 51 | public void afterTextChanged(Editable s) { 52 | setDrawable(); 53 | } 54 | }); 55 | setDrawable(); 56 | } 57 | 58 | private void setDrawable() { 59 | if (length() < 1) 60 | setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); 61 | else 62 | setCompoundDrawablesWithIntrinsicBounds(null, null, imgInable, null); 63 | } 64 | 65 | @Override 66 | public boolean onTouchEvent(MotionEvent event) { 67 | if (imgInable != null && event.getAction() == MotionEvent.ACTION_UP) { 68 | int eventX = (int) event.getRawX(); 69 | int eventY = (int) event.getRawY(); 70 | Rect rect = new Rect(); 71 | getGlobalVisibleRect(rect); 72 | rect.left = rect.right - 50; 73 | if (rect.contains(eventX, eventY)) 74 | setText(""); 75 | RairUtils.hideInput(getContext()); 76 | } 77 | return super.onTouchEvent(event); 78 | } 79 | 80 | @Override 81 | protected void finalize() throws Throwable { 82 | super.finalize(); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /app/src/main/java/com/rair/diary/view/LinedEditText.java: -------------------------------------------------------------------------------- 1 | package com.rair.diary.view; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.graphics.Canvas; 7 | import android.graphics.Color; 8 | import android.graphics.DashPathEffect; 9 | import android.graphics.Paint; 10 | import android.graphics.PathEffect; 11 | import android.os.Build; 12 | import android.util.AttributeSet; 13 | import android.widget.EditText; 14 | 15 | @SuppressLint("AppCompatCustomView") 16 | public class LinedEditText extends EditText { 17 | 18 | public LinedEditText(Context context) { 19 | super(context); 20 | initPaint(); 21 | } 22 | 23 | public LinedEditText(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | initPaint(); 26 | } 27 | 28 | public LinedEditText(Context context, AttributeSet attrs, int defStyle) { 29 | super(context, attrs, defStyle); 30 | initPaint(); 31 | } 32 | 33 | private void initPaint() { 34 | 35 | } 36 | 37 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 38 | @Override 39 | protected void onDraw(Canvas canvas) { 40 | Paint mPaint = new Paint(); 41 | mPaint.setStyle(Paint.Style.STROKE); 42 | mPaint.setColor(Color.LTGRAY); 43 | PathEffect effects = new DashPathEffect(new float[]{5, 5, 5, 5}, 5); 44 | mPaint.setPathEffect(effects); 45 | int left = getLeft(); 46 | int right = getRight(); 47 | int paddingTop = getPaddingTop(); 48 | int paddingBottom = getPaddingBottom(); 49 | int paddingLeft = getPaddingLeft(); 50 | int paddingRight = getPaddingRight(); 51 | int height = getHeight(); 52 | int lineHeight = getLineHeight(); 53 | int spcingHeight = (int) getLineSpacingExtra(); 54 | int count = (height - paddingTop - paddingBottom) / lineHeight; 55 | for (int i = 0; i < count; i++) { 56 | int baseline = lineHeight * (i + 1) + paddingTop - spcingHeight / 2; 57 | canvas.drawLine(paddingLeft, baseline, right - paddingRight * (int) 1.8, baseline, mPaint); 58 | } 59 | super.onDraw(canvas); 60 | } 61 | } -------------------------------------------------------------------------------- /app/src/main/res/color/text_color_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/base_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/editor_shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sex_choice_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/textview_bg_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_diary_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 26 | 27 | 28 | 36 | 37 | 42 | 43 | 50 | 51 | 52 | 53 | 61 | 62 | 67 | 68 | 80 | 81 | 97 | 98 | 103 | 104 | 105 | 106 | 112 | 113 | 119 | 120 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_export.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 18 | 19 | 25 | 26 | 27 | 28 | 35 | 36 | 37 | 41 | 42 | 49 | 50 | 56 | 57 | 58 | 59 | 64 | 65 | 73 | 74 | 80 | 81 | 82 | 89 | 90 | 96 | 97 | 98 | 103 | 104 | 110 | 111 | 117 | 118 | 119 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_feed_back.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 20 | 21 | 27 | 28 | 29 | 36 | 37 | 38 | 42 | 43 | 47 | 48 | 55 | 56 | 60 | 61 | 69 | 70 | 84 | 85 | 86 | 87 | 94 | 95 | 99 | 100 | 108 | 109 | 122 | 123 | 124 | 125 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_find_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 18 | 19 | 25 | 26 | 27 | 34 | 35 | 40 | 41 | 48 | 49 | 50 | 51 | 57 | 58 | 66 | 67 | 79 | 80 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 20 | 21 | 27 | 28 | 29 | 36 | 37 | 38 | 39 | 42 | 43 | 48 | 49 | 50 | 60 | 61 | 67 | 68 | 72 | 73 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 20 | 21 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_notify.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 21 | 22 | 29 | 30 | 31 | 32 | 36 | 37 | 44 | 45 | 52 | 53 | 59 | 60 | 61 | 66 | 67 | 74 | 75 | 84 | 85 | 97 | 98 | 99 | 104 | 105 | 110 | 111 | 114 | 115 | 121 | 122 | 130 | 131 | 136 | 137 | 145 | 146 | 147 | 148 | 149 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_recover.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 18 | 19 | 25 | 26 | 27 | 34 | 35 | 36 | 40 | 41 | 50 | 51 | 57 | 58 | 64 | 65 | 66 | 71 | 72 | 81 | 82 | 89 | 90 | 96 | 97 | 98 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_secret.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 18 | 19 | 25 | 26 | 27 | 34 | 35 | 36 | 40 | 41 | 48 | 49 | 56 | 57 | 58 | 59 | 64 | 65 | 72 | 73 | 80 | 81 | 82 | 83 | 88 | 89 | 96 | 97 | 104 | 105 | 106 | 107 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 23 | 24 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_diary.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 18 | 19 | 29 | 30 | 41 | 42 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_find.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_login.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 19 | 20 | 24 | 25 | 37 | 38 | 39 | 48 | 49 | 53 | 54 | 66 | 67 | 68 | 79 | 80 | 89 | 90 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_register.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 19 | 20 | 24 | 25 | 38 | 39 | 40 | 49 | 50 | 54 | 55 | 68 | 69 | 70 | 79 | 80 | 84 | 85 | 98 | 99 | 100 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_comment_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 21 | 22 | 25 | 26 | 31 | 32 | 39 | 40 | 41 | 46 | 47 | 50 | 51 | 58 | 59 | 67 | 68 | 69 | 78 | 79 | 80 | 81 | 85 | 86 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_diary_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 18 | 19 | 26 | 27 | 28 | 32 | 33 | 38 | 39 | 45 | 46 | 54 | 55 | 60 | 61 | 67 | 68 | 77 | 78 | 79 | 80 | 81 | 86 | 87 | 88 | 92 | 93 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_edit_sign_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 23 | 24 | 36 | 37 | 38 | 39 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_find_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 17 | 18 | 23 | 24 | 31 | 32 | 33 | 38 | 39 | 42 | 43 | 51 | 52 | 60 | 61 | 62 | 72 | 73 | 74 | 75 | 76 | 80 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_number_pwd_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 25 | 26 | 39 | 40 | 41 | 50 | 51 | 57 | 58 | 71 | 72 | 73 | 79 | 80 | 89 | 90 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_number_unlock_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 18 | 19 | 25 | 26 | 39 | 40 | 41 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_pattern_pwd_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 32 | 33 | 38 | 39 | 48 | 49 | 59 | 60 | 61 | 67 | 68 | 77 | 78 | 88 | 89 | 90 | 91 | 94 | 95 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_pattern_unlock_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 21 | 22 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_rv_footer.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_rv_header.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 18 | 19 | 24 | 25 | 32 | 33 | 34 | 40 | 41 | 44 | 45 | 52 | 53 | 61 | 62 | 63 | 69 | 70 | 78 | 79 | 80 | 81 | 82 | 88 | 89 | 96 | 97 | 105 | 106 | 111 | 112 | 113 | 118 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/delete.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/female.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_add.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_back.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_bg.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_delete.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_diary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_diary.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_diary_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_diary_sel.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_edit.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_export.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_feedback.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_find.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_find_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_find_sel.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_head.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_head.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_info.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_next.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_notify.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_option.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_option.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_photo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_recover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_recover.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_right.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_save.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_secret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_secret.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_setting.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_setting_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_setting_sel.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_sex_female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_sex_female.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_sex_male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_sex_male.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_user_email.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_user_email.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_user_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_user_name.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_user_pwd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_user_pwd.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_weather_leiyu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_weather_leiyu.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_weather_qing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_weather_qing.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_weather_xue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_weather_xue.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_weather_yin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_weather_yin.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_weather_yu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/ic_weather_yu.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xhdpi/male.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #212121 4 | #212121 5 | #C8E6C9 6 | #212121 7 | 8 | #FFFFFF 9 | #ffffff 10 | #212121 11 | #DCDCDC 12 | #6B6B6B 13 | #388E3C 14 | #303030 15 | #4CAF50 16 | #DCDCDC 17 | #212121 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4CAF50 4 | #388E3C 5 | #4CAF50 6 | #C8E6C9 7 | #FFFFFF 8 | #ffffff 9 | #dfdcd5 10 | #212121 11 | #757575 12 | #ffffff 13 | 14 | #4CAF50 15 | #4CAF50 16 | #388E3C 17 | #eeeade 18 | 19 | #EEEEEE 20 | #ff5252 21 | #ff4081 22 | #4CAF50 23 | #e040fb 24 | #448aff 25 | #ffff00 26 | #616161 27 | #ffab40 28 | #18ffff 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 时光记 3 | 日记 4 | 设置 5 | 我的 6 | 发现 7 | 登录 8 | 注册 9 | 10 | 11 | 晴朗 12 | 多云 13 | 阴天 14 | 降雨 15 | 降雪 16 | 冰雹 17 | 烟雾 18 | 沙尘暴 19 | 20 | 21 | 操作 22 | 分享 23 | 发布 24 | 删除 25 | 导出 26 | 清空 27 | 确定 28 | 取消 29 | 30 | 确定要删除吗? 31 | 日记已经删除! 32 | 33 | 是否导出此日记? 34 | 导出成功!保存到SDCard/RairDiary/ 35 | 导出失败! 36 | 37 | 清空 38 | 确定要清空吗?清空将无法恢复! 39 | 日记已清空! 40 | 41 | 42 | Hello blank fragment 43 | 搜索日记 44 | 创建于:%s 45 | 分享于:%s 46 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 17 | 18 | 23 | 24 | 27 | 28 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/xml/file_path.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.4.0' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | google() 20 | maven { url "https://jitpack.io" } 21 | maven { url "https://raw.githubusercontent.com/Pgyer/mvn_repo_pgyer/master" } 22 | maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" } 23 | } 24 | } 25 | 26 | task clean(type: Delete) { 27 | delete rootProject.buildDir 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed May 15 22:06:47 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /screenshots/Screenshot1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/screenshots/Screenshot1.jpg -------------------------------------------------------------------------------- /screenshots/Screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/screenshots/Screenshot2.png -------------------------------------------------------------------------------- /screenshots/Screenshot3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Reathin/diary-android/a9dc1028c9fdc2fd1820b7c84e0894c9c7eb703c/screenshots/Screenshot3.jpg -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' --------------------------------------------------------------------------------