├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── libs │ ├── fastjson.jar │ ├── libammsdk.jar │ └── BmobSDK_V3.3.8_0521.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_wx_logo.png │ │ │ │ ├── ic_done_white.png │ │ │ │ ├── ic_edit_white.png │ │ │ │ ├── ic_more_grey.png │ │ │ │ ├── ic_share_more.png │ │ │ │ ├── ic_sina_logo.png │ │ │ │ ├── ic_wx_collect.png │ │ │ │ ├── ic_wx_moments.png │ │ │ │ └── alipay_erweima.jpg │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_done_white.png │ │ │ │ └── ic_edit_white.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_done_white.png │ │ │ │ └── ic_edit_white.png │ │ │ ├── drawable │ │ │ │ ├── blue_round.xml │ │ │ │ ├── pink_round.xml │ │ │ │ ├── red_round.xml │ │ │ │ ├── brown_round.xml │ │ │ │ ├── green_round.xml │ │ │ │ ├── yellow_round.xml │ │ │ │ ├── blue_grey_round.xml │ │ │ │ ├── deep_purple_round.xml │ │ │ │ ├── white_button_background.xml │ │ │ │ ├── selectable_background.xml │ │ │ │ ├── toolbar_shadow.xml │ │ │ │ └── activated_background.xml │ │ │ ├── xml │ │ │ │ ├── searchable.xml │ │ │ │ └── prefs.xml │ │ │ ├── layout │ │ │ │ ├── toolbar_shadow_layout.xml │ │ │ │ ├── toolbar_layout.xml │ │ │ │ ├── edit_layout.xml │ │ │ │ ├── colors_panel_layout.xml │ │ │ │ ├── activity_setting.xml │ │ │ │ ├── colors_image_layout.xml │ │ │ │ ├── drawer_list_item_layout.xml │ │ │ │ ├── activity_pay.xml │ │ │ │ ├── activity_edit_note_type.xml │ │ │ │ ├── md_simplelist_item.xml │ │ │ │ ├── activity_note.xml │ │ │ │ ├── notes_item_layout.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── activity_about.xml │ │ │ ├── menu │ │ │ │ ├── menu_note.xml │ │ │ │ ├── menu_about.xml │ │ │ │ ├── menu_notes_more.xml │ │ │ │ └── menu_main.xml │ │ │ └── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── lguipeng │ │ │ │ └── notes │ │ │ │ ├── listener │ │ │ │ ├── bmob │ │ │ │ │ ├── SaveListenerImpl.java │ │ │ │ │ ├── UpdateListenerImpl.java │ │ │ │ │ └── FindListenerImpl.java │ │ │ │ └── view │ │ │ │ │ └── RecyclerViewClickListener.java │ │ │ │ ├── adpater │ │ │ │ ├── DrawerListAdapter.java │ │ │ │ ├── MaterialSimpleListAdapter.java │ │ │ │ ├── SimpleListAdapter.java │ │ │ │ ├── ColorsListAdapter.java │ │ │ │ ├── NotesItemViewHolder.java │ │ │ │ ├── BaseListAdapter.java │ │ │ │ ├── NotesAdapter.java │ │ │ │ └── BaseRecyclerViewAdapter.java │ │ │ │ ├── utils │ │ │ │ ├── NoteConfig.java │ │ │ │ ├── ViewHelper.java │ │ │ │ ├── SnackbarUtils.java │ │ │ │ ├── JsonUtils.java │ │ │ │ ├── ThemeUtils.java │ │ │ │ ├── AccountUtils.java │ │ │ │ ├── PreferenceUtils.java │ │ │ │ ├── TimeUtils.java │ │ │ │ └── NotesLog.java │ │ │ │ ├── module │ │ │ │ ├── AppModule.java │ │ │ │ └── DataModule.java │ │ │ │ ├── model │ │ │ │ ├── NoteType.java │ │ │ │ ├── NoteOperateLog.java │ │ │ │ ├── CloudNote.java │ │ │ │ ├── MaterialSimpleListItem.java │ │ │ │ └── Note.java │ │ │ │ ├── ui │ │ │ │ ├── PayActivity.java │ │ │ │ ├── SettingActivity.java │ │ │ │ ├── fragments │ │ │ │ │ └── BaseFragment.java │ │ │ │ ├── EditNoteTypeActivity.java │ │ │ │ └── BaseActivity.java │ │ │ │ ├── view │ │ │ │ └── FixedRecyclerView.java │ │ │ │ └── App.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── lguipeng │ │ └── notes │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── orm-library ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── net │ │ │ └── tsz │ │ │ └── afinal │ │ │ ├── db │ │ │ ├── table │ │ │ │ ├── Id.java │ │ │ │ ├── OneToMany.java │ │ │ │ ├── ManyToOne.java │ │ │ │ ├── KeyValue.java │ │ │ │ ├── Property.java │ │ │ │ └── TableInfo.java │ │ │ └── sqlite │ │ │ │ ├── SqlInfo.java │ │ │ │ ├── OneToManyLazyLoader.java │ │ │ │ ├── ManyToOneLazyLoader.java │ │ │ │ ├── DbModel.java │ │ │ │ └── CursorUtils.java │ │ │ ├── annotation │ │ │ └── sqlite │ │ │ │ ├── Table.java │ │ │ │ ├── Transient.java │ │ │ │ ├── ManyToOne.java │ │ │ │ ├── OneToMany.java │ │ │ │ ├── Property.java │ │ │ │ └── Id.java │ │ │ ├── exception │ │ │ ├── DbException.java │ │ │ └── AfinalException.java │ │ │ ├── core │ │ │ └── FileNameGenerator.java │ │ │ └── utils │ │ │ └── Utils.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── lguipeng │ │ └── library │ │ └── ApplicationTest.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── MaterialPreference ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── fonts │ │ │ ├── Roboto-Medium.ttf │ │ │ └── Roboto-Regular.ttf │ │ ├── res │ │ ├── values │ │ │ └── mp_attrs.xml │ │ └── layout │ │ │ ├── mp_checkbox_preference.xml │ │ │ ├── mp_switch_preference.xml │ │ │ ├── mp_preference_category.xml │ │ │ └── mp_preference.xml │ │ └── java │ │ └── com │ │ └── jenzz │ │ └── materialpreference │ │ ├── Typefaces.java │ │ ├── ThemeUtils.java │ │ ├── SwitchPreference.java │ │ ├── CheckBoxPreference.java │ │ ├── PreferenceCategory.java │ │ ├── PreferenceImageView.java │ │ └── Preference.java └── build.gradle ├── screenshot ├── S50603-103314.jpg ├── S50605-164248.jpg ├── S50605-164615.jpg ├── S50611-163425.jpg ├── S50611-163752.jpg ├── S50611-164132.jpg └── S50611-164146.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── Notes.iml ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | Notes -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /orm-library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':orm-library', ':MaterialPreference' 2 | -------------------------------------------------------------------------------- /app/libs/fastjson.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/libs/fastjson.jar -------------------------------------------------------------------------------- /MaterialPreference/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/libs/libammsdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/libs/libammsdk.jar -------------------------------------------------------------------------------- /screenshot/S50603-103314.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50603-103314.jpg -------------------------------------------------------------------------------- /screenshot/S50605-164248.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50605-164248.jpg -------------------------------------------------------------------------------- /screenshot/S50605-164615.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50605-164615.jpg -------------------------------------------------------------------------------- /screenshot/S50611-163425.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50611-163425.jpg -------------------------------------------------------------------------------- /screenshot/S50611-163752.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50611-163752.jpg -------------------------------------------------------------------------------- /screenshot/S50611-164132.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50611-164132.jpg -------------------------------------------------------------------------------- /screenshot/S50611-164146.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/screenshot/S50611-164146.jpg -------------------------------------------------------------------------------- /app/libs/BmobSDK_V3.3.8_0521.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/libs/BmobSDK_V3.3.8_0521.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /orm-library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | library 3 | 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_wx_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_wx_logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-hdpi/ic_done_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_edit_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-hdpi/ic_edit_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_done_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_edit_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_edit_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_more_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_more_grey.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_share_more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_share_more.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_sina_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_sina_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_wx_collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_wx_collect.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_wx_moments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/ic_wx_moments.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/alipay_erweima.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xhdpi/alipay_erweima.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_done_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xxhdpi/ic_done_white.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_edit_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/app/src/main/res/drawable-xxhdpi/ic_edit_white.png -------------------------------------------------------------------------------- /MaterialPreference/src/main/assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/MaterialPreference/src/main/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /MaterialPreference/src/main/assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Notes/HEAD/MaterialPreference/src/main/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/res/values/mp_attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/blue_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/pink_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/red_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/brown_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/green_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/yellow_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/blue_grey_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/deep_purple_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/xml/searchable.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | -------------------------------------------------------------------------------- /orm-library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/white_button_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar_shadow_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/selectable_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/toolbar_shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/res/layout/mp_checkbox_preference.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_note.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/toolbar_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/edit_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/res/layout/mp_switch_preference.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/lguipeng/notes/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /orm-library/src/androidTest/java/com/lguipeng/library/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.library; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_notes_more.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 12 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/res/layout/mp_preference_category.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 40dp 4 | 18dp 5 | 16sp 6 | 48dp 7 | 8dp 8 | 24dp 9 | 200dp 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/listener/bmob/SaveListenerImpl.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.listener.bmob; 2 | 3 | import com.lguipeng.notes.utils.NotesLog; 4 | 5 | import cn.bmob.v3.listener.SaveListener; 6 | 7 | /** 8 | * Created by lgp on 2015/5/30. 9 | */ 10 | public class SaveListenerImpl extends SaveListener { 11 | @Override 12 | public void onSuccess() { 13 | 14 | } 15 | 16 | @Override 17 | public void onFailure(int i, String s) { 18 | NotesLog.e(s); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/listener/bmob/UpdateListenerImpl.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.listener.bmob; 2 | 3 | import com.lguipeng.notes.utils.NotesLog; 4 | 5 | import cn.bmob.v3.listener.UpdateListener; 6 | 7 | /** 8 | * Created by lgp on 2015/5/30. 9 | */ 10 | public class UpdateListenerImpl extends UpdateListener { 11 | @Override 12 | public void onSuccess() { 13 | 14 | } 15 | 16 | @Override 17 | public void onFailure(int i, String s) { 18 | NotesLog.e(s); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/activated_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/listener/bmob/FindListenerImpl.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.listener.bmob; 2 | 3 | import com.lguipeng.notes.utils.NotesLog; 4 | 5 | import java.util.List; 6 | 7 | import cn.bmob.v3.listener.FindListener; 8 | 9 | /** 10 | * Created by lgp on 2015/5/30. 11 | */ 12 | public class FindListenerImpl extends FindListener { 13 | @Override 14 | public void onSuccess(List list) { 15 | 16 | } 17 | 18 | @Override 19 | public void onError(int i, String s) { 20 | NotesLog.e(s); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/colors_panel_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/adpater/DrawerListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.adpater; 2 | 3 | import android.content.Context; 4 | 5 | import com.lguipeng.notes.R; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by lgp on 2015/5/24. 11 | */ 12 | public class DrawerListAdapter extends SimpleListAdapter{ 13 | 14 | public DrawerListAdapter(Context mContext, List list) { 15 | super(mContext, list); 16 | } 17 | 18 | @Override 19 | protected int getLayout() { 20 | return R.layout.drawer_list_item_layout; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /orm-library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 14 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(include: ['*.jar'], dir: 'libs') 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MaterialPreference/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion Integer.parseInt(ANDROID_BUILD_COMPILE_SDK_VERSION) 5 | buildToolsVersion ANDROID_BUILD_TOOLS_VERSION 6 | 7 | defaultConfig { 8 | minSdkVersion Integer.parseInt(MIN_SDK_VERSION) 9 | targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION) 10 | versionCode Integer.parseInt(VERSION_CODE) 11 | versionName VERSION_NAME 12 | } 13 | 14 | lintOptions { 15 | abortOnError false 16 | } 17 | } 18 | 19 | dependencies { 20 | compile 'com.android.support:appcompat-v7:22.2.0' 21 | compile 'com.balysv:material-ripple:1.0.2' 22 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/listener/view/RecyclerViewClickListener.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.listener.view; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Interface definition for a callback to be invoked when an item in a 7 | * RecyclerView has been clicked. 8 | */ 9 | public interface RecyclerViewClickListener { 10 | 11 | /** 12 | * Callback method to be invoked when a item in a 13 | * RecyclerView is clicked 14 | * @param v The view within the RecyclerView.Adapter 15 | * @param position The position of the view in the adapter 16 | * @param x 17 | * @param y 18 | */ 19 | void onClick(View v, int position, float x, float y); 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/NoteConfig.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | /** 4 | * Created by lgp on 2015/5/25. 5 | */ 6 | public class NoteConfig { 7 | 8 | public final static int NOTE_CREATE_OPR = 0x00; 9 | public final static int NOTE_EDIT_OPR = 0x01; 10 | 11 | public final static int NOTE_STUDY_TYPE = 0x00; 12 | public final static int NOTE_WORK_TYPE = 0x01; 13 | public final static int NOTE_OTHER_TYPE = 0x02; 14 | public final static int NOTE_TRASH_TYPE = 0x03; 15 | 16 | public final static int NOTE_UPDATE_EVENT = 0x00; 17 | public final static int NOTE_TYPE_UPDATE_EVENT = 0x01; 18 | public final static int CHANGE_THEME_EVENT = 0x02; 19 | } 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\adt-bundle-windows-x86_64-20131030/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /orm-library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\adt-bundle-windows-x86_64-20131030/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/colors_image_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 17 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/module/AppModule.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.module; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.lguipeng.notes.App; 7 | 8 | import dagger.Module; 9 | import dagger.Provides; 10 | 11 | /** 12 | * Created by lgp on 2015/5/26. 13 | */ 14 | @Module( 15 | injects = { 16 | App.class 17 | }, 18 | library = true 19 | ) 20 | public class AppModule { 21 | private App app; 22 | 23 | public AppModule(App app) { 24 | this.app = app; 25 | } 26 | 27 | @Provides 28 | Application provideApplication() { 29 | return app; 30 | } 31 | 32 | @Provides 33 | Context provideContext() { 34 | return app.getApplicationContext(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/table/Id.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.db.table; 17 | 18 | public class Id extends Property{ 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/drawer_list_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/ViewHelper.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.support.v4.view.ViewCompat; 4 | import android.view.View; 5 | 6 | /** 7 | * Created by lgp on 2015/5/27. 8 | */ 9 | public class ViewHelper { 10 | public static void clear(View v) { 11 | ViewCompat.setAlpha(v, 1); 12 | ViewCompat.setScaleY(v, 1); 13 | ViewCompat.setScaleX(v, 1); 14 | ViewCompat.setTranslationY(v, 0); 15 | ViewCompat.setTranslationX(v, 0); 16 | ViewCompat.setRotation(v, 0); 17 | ViewCompat.setRotationY(v, 0); 18 | ViewCompat.setRotationX(v, 0); 19 | // @TODO https://code.google.com/p/android/issues/detail?id=80863 20 | // ViewCompat.setPivotY(v, v.getMeasuredHeight() / 2); 21 | v.setPivotY(v.getMeasuredHeight() / 2); 22 | ViewCompat.setPivotX(v, v.getMeasuredWidth() / 2); 23 | ViewCompat.animate(v).setInterpolator(null); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Notes.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/table/OneToMany.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.db.table; 17 | 18 | public class OneToMany extends Property{ 19 | 20 | private Class oneClass; 21 | 22 | public Class getOneClass() { 23 | return oneClass; 24 | } 25 | 26 | public void setOneClass(Class oneClass) { 27 | this.oneClass = oneClass; 28 | } 29 | 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/table/ManyToOne.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.db.table; 17 | 18 | public class ManyToOne extends Property{ 19 | 20 | private Class manyClass; 21 | 22 | public Class getManyClass() { 23 | return manyClass; 24 | } 25 | 26 | public void setManyClass(Class manyClass) { 27 | this.manyClass = manyClass; 28 | } 29 | 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/model/NoteType.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.model; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.alibaba.fastjson.annotation.JSONField; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by lgp on 2015/6/2. 12 | */ 13 | public class NoteType{ 14 | 15 | @JSONField(serialize=false, deserialize=false) 16 | public final static int ALL_COUNT = 4; 17 | 18 | private List types = new ArrayList<>(); 19 | 20 | public void addType(String type){ 21 | if (types != null && types.size() < ALL_COUNT && !TextUtils.isEmpty(type)){ 22 | types.add(type); 23 | } 24 | } 25 | 26 | public String getType(int location){ 27 | if (types != null && types.size() > location){ 28 | return types.get(location); 29 | } 30 | return ""; 31 | } 32 | 33 | public List getTypes() { 34 | return types; 35 | } 36 | 37 | public void setTypes(List types) { 38 | this.types = types; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/ui/PayActivity.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.Toolbar; 5 | 6 | import com.lguipeng.notes.R; 7 | import com.lguipeng.notes.module.DataModule; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | import butterknife.InjectView; 13 | 14 | /** 15 | * Created by lgp on 2015/6/1. 16 | */ 17 | public class PayActivity extends BaseActivity{ 18 | @InjectView(R.id.toolbar) 19 | Toolbar toolbar; 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | } 24 | 25 | @Override 26 | protected int getLayoutView() { 27 | return R.layout.activity_pay; 28 | } 29 | 30 | @Override 31 | protected List getModules() { 32 | return Arrays.asList(new DataModule()); 33 | } 34 | 35 | @Override 36 | protected void initToolbar(){ 37 | super.initToolbar(toolbar); 38 | toolbar.setTitle(R.string.pay_for_me); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/Table.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Target(ElementType.TYPE) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface Table { 26 | public String name(); 27 | } -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/Transient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | 24 | @Target(ElementType.FIELD) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | public @interface Transient { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/view/FixedRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.view; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.AttributeSet; 6 | 7 | /** 8 | * Created by lgp on 2015/6/11. 9 | */ 10 | public class FixedRecyclerView extends RecyclerView { 11 | public FixedRecyclerView(Context context) { 12 | super(context); 13 | } 14 | 15 | public FixedRecyclerView(Context context, AttributeSet attrs) { 16 | super(context, attrs); 17 | } 18 | 19 | public FixedRecyclerView(Context context, AttributeSet attrs, int defStyle) { 20 | super(context, attrs, defStyle); 21 | } 22 | 23 | @Override 24 | public boolean canScrollVertically(int direction) { 25 | // check if scrolling up 26 | if (direction < 1) { 27 | boolean original = super.canScrollVertically(direction); 28 | return !original && getChildAt(0) != null && getChildAt(0).getTop() < 0 || original; 29 | } 30 | return super.canScrollVertically(direction); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_pay.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 15 | 16 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 11 | 12 | 13 | 17 | 18 | 21 | 24 | 27 | 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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | ANDROID_BUILD_COMPILE_SDK_VERSION=22 21 | ANDROID_BUILD_TARGET_SDK_VERSION=22 22 | ANDROID_BUILD_TOOLS_VERSION=22.0.1 23 | MIN_SDK_VERSION=14 24 | TARGET_SDK_VERSION=22 25 | VERSION_CODE=3 26 | VERSION_NAME=1.1.2 -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/ManyToOne.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Target(ElementType.FIELD) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface ManyToOne { 26 | public String column() default ""; 27 | } 28 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/OneToMany.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Target(ElementType.FIELD) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface OneToMany { 26 | 27 | public String manyColumn(); 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/App.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes; 2 | 3 | import android.app.Application; 4 | 5 | import com.lguipeng.notes.module.AppModule; 6 | 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | import cn.bmob.v3.Bmob; 11 | import dagger.ObjectGraph; 12 | 13 | /** 14 | * Created by lgp on 2015/5/24. 15 | */ 16 | public class App extends Application{ 17 | private ObjectGraph objectGraph; 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | objectGraph = ObjectGraph.create(getModules().toArray()); 22 | objectGraph.inject(this); 23 | Bmob.initialize(this, BuildConfig.BMOB_KEY); 24 | } 25 | 26 | @Override 27 | public void onTerminate() { 28 | super.onTerminate(); 29 | } 30 | 31 | @Override 32 | public void onLowMemory() { 33 | super.onLowMemory(); 34 | } 35 | 36 | private List getModules() { 37 | return Arrays.asList(new AppModule(this)); 38 | } 39 | 40 | public ObjectGraph createScopedGraph(Object... modules) { 41 | return objectGraph.plus(modules); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/sqlite/SqlInfo.java: -------------------------------------------------------------------------------- 1 | package net.tsz.afinal.db.sqlite; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class SqlInfo { 6 | 7 | private String sql; 8 | private LinkedList bindArgs; 9 | 10 | public String getSql() { 11 | return sql; 12 | } 13 | public void setSql(String sql) { 14 | this.sql = sql; 15 | } 16 | 17 | public LinkedList getBindArgs() { 18 | return bindArgs; 19 | } 20 | public void setBindArgs(LinkedList bindArgs) { 21 | this.bindArgs = bindArgs; 22 | } 23 | 24 | public Object[] getBindArgsAsArray() { 25 | if(bindArgs!=null) 26 | return bindArgs.toArray(); 27 | return null; 28 | } 29 | 30 | public String[] getBindArgsAsStringArray() { 31 | if(bindArgs!=null){ 32 | String[] strings = new String[bindArgs.size()]; 33 | for(int i = 0;i(); 44 | 45 | bindArgs.add(obj); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/model/NoteOperateLog.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.model; 2 | 3 | import net.tsz.afinal.annotation.sqlite.ManyToOne; 4 | import net.tsz.afinal.annotation.sqlite.Table; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Created by lgp on 2015/5/25. 10 | */ 11 | @Table(name = "note_opr_log") 12 | public class NoteOperateLog implements Serializable { 13 | private int id; 14 | private int type; 15 | private long time; 16 | @ManyToOne(column = "noteId") 17 | private Note note; 18 | 19 | public int getId() { 20 | return id; 21 | } 22 | 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | 27 | public int getType() { 28 | return type; 29 | } 30 | 31 | public void setType(int type) { 32 | this.type = type; 33 | } 34 | 35 | public long getTime() { 36 | return time; 37 | } 38 | 39 | public void setTime(long time) { 40 | this.time = time; 41 | } 42 | 43 | public Note getNote() { 44 | return note; 45 | } 46 | 47 | public void setNote(Note note) { 48 | this.note = note; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/Property.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | @Target(ElementType.FIELD) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface Property { 26 | public String column() default ""; 27 | public String defaultValue() default ""; 28 | } 29 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/exception/DbException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.exception; 17 | 18 | public class DbException extends AfinalException { 19 | private static final long serialVersionUID = 1L; 20 | 21 | public DbException() {} 22 | 23 | 24 | public DbException(String msg) { 25 | super(msg); 26 | } 27 | 28 | public DbException(Throwable ex) { 29 | super(ex); 30 | } 31 | 32 | public DbException(String msg,Throwable ex) { 33 | super(msg,ex); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/exception/AfinalException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.exception; 17 | 18 | public class AfinalException extends RuntimeException { 19 | private static final long serialVersionUID = 1L; 20 | 21 | public AfinalException() { 22 | super(); 23 | } 24 | 25 | public AfinalException(String msg) { 26 | super(msg); 27 | } 28 | 29 | public AfinalException(Throwable ex) { 30 | super(ex); 31 | } 32 | 33 | public AfinalException(String msg,Throwable ex) { 34 | super(msg,ex); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/sqlite/OneToManyLazyLoader.java: -------------------------------------------------------------------------------- 1 | package net.tsz.afinal.db.sqlite; 2 | 3 | import net.tsz.afinal.FinalDb; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * 10 | * 一对多延迟加载类 11 | * Created by pwy on 13-7-25. 12 | * @param 宿主实体的class 13 | * @param 多放实体class 14 | */ 15 | public class OneToManyLazyLoader { 16 | O ownerEntity; 17 | Class ownerClazz; 18 | Class listItemClazz; 19 | FinalDb db; 20 | public OneToManyLazyLoader(O ownerEntity,Class ownerClazz,Class listItemclazz,FinalDb db){ 21 | this.ownerEntity = ownerEntity; 22 | this.ownerClazz = ownerClazz; 23 | this.listItemClazz = listItemclazz; 24 | this.db = db; 25 | } 26 | List entities; 27 | 28 | /** 29 | * 如果数据未加载,则调用loadOneToMany填充数据 30 | * @return 31 | */ 32 | public List getList(){ 33 | if(entities==null){ 34 | this.db.loadOneToMany((O)this.ownerEntity,this.ownerClazz,this.listItemClazz); 35 | } 36 | if(entities==null){ 37 | entities =new ArrayList(); 38 | } 39 | return entities; 40 | } 41 | public void setList(List value){ 42 | entities = value; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/Typefaces.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.content.Context; 4 | import android.graphics.Typeface; 5 | import android.util.Log; 6 | import java.util.Hashtable; 7 | 8 | final class Typefaces { 9 | 10 | private static final String TAG = Typefaces.class.getSimpleName(); 11 | private static final Hashtable cache = new Hashtable<>(); 12 | 13 | private Typefaces() { 14 | // no instances 15 | } 16 | 17 | static Typeface get(Context context, String assetPath) { 18 | synchronized (cache) { 19 | if (!cache.containsKey(assetPath)) { 20 | try { 21 | Typeface t = Typeface.createFromAsset(context.getAssets(), assetPath); 22 | cache.put(assetPath, t); 23 | } catch (Exception e) { 24 | Log.e(TAG, "Could not get typeface '" + assetPath + "' Error: " + e.getMessage()); 25 | return null; 26 | } 27 | } 28 | return cache.get(assetPath); 29 | } 30 | } 31 | 32 | static Typeface getRobotoRegular(Context context) { 33 | return get(context, "fonts/Roboto-Regular.ttf"); 34 | } 35 | 36 | static Typeface getRobotoMedium(Context context) { 37 | return get(context, "fonts/Roboto-Medium.ttf"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/annotation/sqlite/Id.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.annotation.sqlite; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | /** 23 | * @title Id主键配置 24 | * @description 不配置的时候默认找类的id或_id字段作为主键,column不配置的是默认为字段名 25 | * @author michael Young (www.YangFuhai.com) 26 | * @version 1.0 27 | * @created 2012-10-31 28 | */ 29 | @Target(ElementType.FIELD) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | public @interface Id { 32 | public String column() default ""; 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_edit_note_type.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 18 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/adpater/MaterialSimpleListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.adpater; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.ArrayAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.lguipeng.notes.R; 11 | import com.lguipeng.notes.model.MaterialSimpleListItem; 12 | 13 | /** 14 | * Created by lgp on 2015/6/10. 15 | */ 16 | public class MaterialSimpleListAdapter extends ArrayAdapter { 17 | 18 | public MaterialSimpleListAdapter(Context context) { 19 | super(context, R.layout.md_simplelist_item, android.R.id.title); 20 | } 21 | 22 | @Override 23 | public View getView(final int index, View convertView, ViewGroup parent) { 24 | final View view = super.getView(index, convertView, parent); 25 | final MaterialSimpleListItem item = getItem(index); 26 | ImageView ic = (ImageView) view.findViewById(android.R.id.icon); 27 | if (item.getIcon() != null) 28 | ic.setImageDrawable(item.getIcon()); 29 | else 30 | ic.setVisibility(View.GONE); 31 | TextView tv = (TextView) view.findViewById(android.R.id.title); 32 | tv.setText(item.getContent()); 33 | return view; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/adpater/SimpleListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.adpater; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import com.lguipeng.notes.R; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by lgp on 2014/8/27. 15 | */ 16 | public abstract class SimpleListAdapter extends BaseListAdapter { 17 | 18 | public SimpleListAdapter(Context mContext, List list) { 19 | super(mContext, list); 20 | } 21 | 22 | @Override 23 | public View bindView(int position, View convertView, ViewGroup parent) { 24 | Holder holder; 25 | if (convertView == null){ 26 | convertView = LayoutInflater.from(mContext).inflate(getLayout(), null); 27 | holder = new Holder(); 28 | holder.textView = (TextView)convertView.findViewById(R.id.textView); 29 | convertView.setTag(holder); 30 | }else{ 31 | holder = (Holder)convertView.getTag(); 32 | } 33 | holder.textView.setText(list.get(position)); 34 | return convertView; 35 | } 36 | 37 | protected abstract int getLayout(); 38 | 39 | static class Holder { 40 | TextView textView; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/ui/SettingActivity.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.ui; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.Toolbar; 5 | 6 | import com.lguipeng.notes.R; 7 | import com.lguipeng.notes.module.DataModule; 8 | import com.lguipeng.notes.ui.fragments.SettingFragment; 9 | 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | import butterknife.InjectView; 14 | 15 | /** 16 | * Created by lgp on 2015/5/24. 17 | */ 18 | public class SettingActivity extends BaseActivity{ 19 | @InjectView(R.id.toolbar) 20 | Toolbar toolbar; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | init(); 26 | } 27 | 28 | @Override 29 | protected int getLayoutView() { 30 | return R.layout.activity_setting; 31 | } 32 | 33 | @Override 34 | protected List getModules() { 35 | return Arrays.asList(new DataModule()); 36 | } 37 | 38 | @Override 39 | protected void initToolbar(){ 40 | super.initToolbar(toolbar); 41 | toolbar.setTitle(R.string.setting); 42 | } 43 | 44 | private void init(){ 45 | SettingFragment settingFragment = SettingFragment.newInstance(); 46 | getFragmentManager().beginTransaction().replace(R.id.fragment_content, settingFragment).commit(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/sqlite/ManyToOneLazyLoader.java: -------------------------------------------------------------------------------- 1 | package net.tsz.afinal.db.sqlite; 2 | 3 | import net.tsz.afinal.FinalDb; 4 | 5 | /** 6 | * 7 | * 一对多延迟加载类 8 | * Created by pwy on 13-7-25. 9 | * @param 宿主实体的class 10 | * @param 多放实体class 11 | */ 12 | public class ManyToOneLazyLoader { 13 | M manyEntity; 14 | Class manyClazz; 15 | Class oneClazz; 16 | FinalDb db; 17 | /** 18 | * 用于 19 | */ 20 | private Object fieldValue; 21 | public ManyToOneLazyLoader(M manyEntity, Class manyClazz, Class oneClazz, FinalDb db){ 22 | this.manyEntity = manyEntity; 23 | this.manyClazz = manyClazz; 24 | this.oneClazz = oneClazz; 25 | this.db = db; 26 | } 27 | O oneEntity; 28 | boolean hasLoaded = false; 29 | 30 | /** 31 | * 如果数据未加载,则调用loadManyToOne填充数据 32 | * @return 33 | */ 34 | public O get(){ 35 | if(oneEntity==null && !hasLoaded){ 36 | this.db.loadManyToOne(null,this.manyEntity,this.manyClazz,this.oneClazz); 37 | hasLoaded = true; 38 | } 39 | return oneEntity; 40 | } 41 | public void set(O value){ 42 | oneEntity = value; 43 | } 44 | 45 | public Object getFieldValue() { 46 | return fieldValue; 47 | } 48 | 49 | public void setFieldValue(Object fieldValue) { 50 | this.fieldValue = fieldValue; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/ThemeUtils.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.content.res.Resources.Theme; 6 | import android.content.res.TypedArray; 7 | 8 | import static android.graphics.Color.parseColor; 9 | import static android.os.Build.VERSION.SDK_INT; 10 | import static android.os.Build.VERSION_CODES.LOLLIPOP; 11 | 12 | final class ThemeUtils { 13 | 14 | // material_deep_teal_500 15 | static final int FALLBACK_COLOR = parseColor("#009688"); 16 | 17 | private ThemeUtils() { 18 | // no instances 19 | } 20 | 21 | static boolean isAtLeastL() { 22 | return SDK_INT >= LOLLIPOP; 23 | } 24 | 25 | @TargetApi(LOLLIPOP) 26 | static int resolveAccentColor(Context context) { 27 | Theme theme = context.getTheme(); 28 | 29 | // on Lollipop, grab system colorAccent attribute 30 | // pre-Lollipop, grab AppCompat colorAccent attribute 31 | // finally, check for custom mp_colorAccent attribute 32 | int attr = isAtLeastL() ? android.R.attr.colorAccent : R.attr.colorAccent; 33 | TypedArray typedArray = theme.obtainStyledAttributes(new int[] { attr, R.attr.mp_colorAccent }); 34 | 35 | int accentColor = typedArray.getColor(0, FALLBACK_COLOR); 36 | accentColor = typedArray.getColor(1, accentColor); 37 | typedArray.recycle(); 38 | 39 | return accentColor; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/SnackbarUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Color; 5 | 6 | import com.lguipeng.notes.ui.BaseActivity; 7 | import com.nispok.snackbar.Snackbar; 8 | import com.nispok.snackbar.SnackbarManager; 9 | 10 | /** 11 | * Author: lgp 12 | * Date: 2014/12/31. 13 | */ 14 | public class SnackbarUtils { 15 | 16 | public static void show(Activity activity, int message) { 17 | // Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show(); 18 | // Toast toast = new Toast(mContext); 19 | // View view = LayoutInflater.from(mContext).inflate(R.layout.toast_layout, null, false); 20 | // TextView textView = (TextView)view.findViewById(R.id.toast_text); 21 | // textView.setText(message); 22 | // toast.setView(view); 23 | // toast.setDuration(Toast.LENGTH_SHORT); 24 | // toast.show(); 25 | int color = Color.BLACK; 26 | if (activity instanceof BaseActivity){ 27 | color = (((BaseActivity) activity)).getColorPrimary(); 28 | } 29 | color = color & 0xddffffff; 30 | SnackbarManager.show( 31 | Snackbar.with(activity.getApplicationContext()) 32 | .color(color) 33 | .duration((Snackbar.SnackbarDuration.LENGTH_SHORT.getDuration() / 2)) 34 | .text(message), activity); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/table/KeyValue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.db.table; 17 | 18 | import net.tsz.afinal.utils.FieldUtils; 19 | 20 | public class KeyValue { 21 | private String key; 22 | private Object value; 23 | 24 | public KeyValue(String key, Object value) { 25 | this.key = key; 26 | this.value = value; 27 | } 28 | 29 | 30 | public KeyValue() {} 31 | 32 | 33 | public String getKey() { 34 | return key; 35 | } 36 | public void setKey(String key) { 37 | this.key = key; 38 | } 39 | public Object getValue() { 40 | if(value instanceof java.util.Date || value instanceof java.sql.Date){ 41 | return FieldUtils.SDF.format(value); 42 | } 43 | return value; 44 | } 45 | public void setValue(Object value) { 46 | this.value = value; 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/md_simplelist_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 24 | 25 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.alibaba.fastjson.JSON; 6 | import com.lguipeng.notes.model.Note; 7 | import com.lguipeng.notes.model.NoteType; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Created by lgp on 2015/5/28. 13 | */ 14 | public class JsonUtils { 15 | 16 | public static String json(T note){ 17 | if (note == null) 18 | return ""; 19 | try { 20 | return JSON.toJSONString(note); 21 | }catch (Exception e){ 22 | e.printStackTrace(); 23 | return ""; 24 | } 25 | } 26 | 27 | public static T parse(String json, Class clazz){ 28 | if (TextUtils.isEmpty(json)) 29 | return null; 30 | try { 31 | return JSON.parseObject(json, clazz); 32 | }catch (Exception e){ 33 | e.printStackTrace(); 34 | return null; 35 | } 36 | } 37 | 38 | public static Note parseNote(String json){ 39 | return parse(json, Note.class); 40 | } 41 | 42 | public static String jsonNote(Note note){ 43 | return json(note); 44 | } 45 | 46 | public static List parseNoteType(String json){ 47 | NoteType type = parse(json, NoteType.class); 48 | if (type == null) 49 | return null; 50 | return type.getTypes(); 51 | } 52 | 53 | public static String jsonNoteType(NoteType type){ 54 | return json(type); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/module/DataModule.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.module; 2 | 3 | import android.content.Context; 4 | 5 | import com.lguipeng.notes.ui.AboutActivity; 6 | import com.lguipeng.notes.ui.EditNoteTypeActivity; 7 | import com.lguipeng.notes.ui.MainActivity; 8 | import com.lguipeng.notes.ui.NoteActivity; 9 | import com.lguipeng.notes.ui.PayActivity; 10 | import com.lguipeng.notes.ui.SettingActivity; 11 | import com.lguipeng.notes.ui.fragments.SettingFragment; 12 | 13 | import net.tsz.afinal.FinalDb; 14 | 15 | import javax.inject.Singleton; 16 | 17 | import dagger.Module; 18 | import dagger.Provides; 19 | 20 | /** 21 | * Created by lgp on 2015/5/26. 22 | */ 23 | @Module( 24 | injects = { 25 | AboutActivity.class, 26 | MainActivity.class, 27 | NoteActivity.class, 28 | SettingActivity.class, 29 | SettingFragment.class, 30 | PayActivity.class, 31 | EditNoteTypeActivity.class 32 | }, 33 | addsTo = AppModule.class, 34 | library = true 35 | ) 36 | public class DataModule { 37 | 38 | @Provides @Singleton 39 | FinalDb.DaoConfig provideDaoConfig(Context context) { 40 | FinalDb.DaoConfig config = new FinalDb.DaoConfig(); 41 | config.setDbName("notes.db"); 42 | config.setDbVersion(1); 43 | config.setDebug(true); 44 | config.setContext(context); 45 | return config; 46 | } 47 | 48 | @Provides @Singleton 49 | FinalDb provideFinalDb(FinalDb.DaoConfig config) { 50 | return FinalDb.create(config); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #ScreenShot 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | #1.1.2 14 | - 增加了多款彩色主题的选择 15 | - 增加了关于界面的分享功能 16 | - 修复了笔记过长的显示问题 17 | - 修复了SwipeRefreshLayout和RecyclerView的组合问题 18 | - 优化界面的一些细节,修复已知的小bug 19 | 20 | #1.1.0 21 | - 增加了笔记列表的卡片式的布局,可在设置里面切换 22 | - 增加了下拉同步笔记的组件 23 | - 增加编辑笔记时点击返回询问是否保存 24 | - 使用了Snackbar代替了Toast的提示 25 | - 去除了编辑笔记内容的下划线 26 | - 修改了笔记列表的显示时间方式 27 | - 修复了小米2s 5.0上CardView的显示问题 28 | 29 | #1.0.2 30 | - Material Design风格,采用抽屉式菜单,悬浮滑动按钮,点击控件时的水波纹效果,状态栏透明使得与应用融为一体,用户即使在Android L系统以下的手机也能感受到良好的用户体验 31 | - 用文字记录身边随时发生的事情,或者你的待办事项 32 | - 同步,同步需要你在手机设置里面添加一个邮箱,并作为你的同步账号,提交到服务器 33 | 34 | #License 35 | ``` 36 | Copyright 2015 Liaoguipeng 37 | 38 | Licensed under the Apache License, Version 2.0 (the "License"); 39 | you may not use this file except in compliance with the License. 40 | You may obtain a copy of the License at 41 | 42 | http://www.apache.org/licenses/LICENSE-2.0 43 | 44 | Unless required by applicable law or agreed to in writing, software 45 | distributed under the License is distributed on an "AS IS" BASIS, 46 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 47 | See the License for the specific language governing permissions and 48 | limitations under the License. 49 | ``` 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/adpater/ColorsListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.adpater; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | 9 | import com.lguipeng.notes.R; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Created by lgp on 2015/6/7. 15 | */ 16 | public class ColorsListAdapter extends BaseListAdapter{ 17 | 18 | private int checkItem; 19 | 20 | public ColorsListAdapter(Context context, List list) { 21 | super(context, list); 22 | } 23 | 24 | @Override 25 | public View bindView(int position, View convertView, ViewGroup parent) { 26 | Holder holder; 27 | if (convertView == null){ 28 | convertView = LayoutInflater.from(mContext).inflate(R.layout.colors_image_layout, null); 29 | holder = new Holder(); 30 | holder.imageView1 = (ImageView)convertView.findViewById(R.id.img_1); 31 | holder.imageView2 = (ImageView)convertView.findViewById(R.id.img_2); 32 | convertView.setTag(holder); 33 | }else{ 34 | holder = (Holder)convertView.getTag(); 35 | } 36 | holder.imageView1.setImageResource(list.get(position)); 37 | if (checkItem == position){ 38 | holder.imageView2.setImageResource(R.drawable.ic_done_white); 39 | } 40 | return convertView; 41 | } 42 | 43 | public int getCheckItem() { 44 | return checkItem; 45 | } 46 | 47 | public void setCheckItem(int checkItem) { 48 | this.checkItem = checkItem; 49 | } 50 | 51 | static class Holder { 52 | ImageView imageView1; 53 | ImageView imageView2; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/db/sqlite/DbModel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.db.sqlite; 17 | 18 | import java.util.HashMap; 19 | 20 | public class DbModel { 21 | 22 | private HashMap dataMap = new HashMap(); 23 | 24 | public Object get(String column){ 25 | return dataMap.get(column); 26 | } 27 | 28 | public String getString(String column){ 29 | return String.valueOf(get(column)); 30 | } 31 | 32 | public int getInt(String column){ 33 | return Integer.valueOf(getString(column)); 34 | } 35 | 36 | public boolean getBoolean(String column){ 37 | return Boolean.valueOf(getString(column)); 38 | } 39 | 40 | public double getDouble(String column){ 41 | return Double.valueOf(getString(column)); 42 | } 43 | 44 | public float getFloat(String column){ 45 | return Float.valueOf(getString(column)); 46 | } 47 | 48 | public long getLong(String column){ 49 | return Long.valueOf(getString(column)); 50 | } 51 | 52 | public void set(String key,Object value){ 53 | dataMap.put(key, value); 54 | } 55 | 56 | public HashMap getDataMap(){ 57 | return dataMap; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /orm-library/src/main/java/net/tsz/afinal/core/FileNameGenerator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package net.tsz.afinal.core; 17 | 18 | import java.security.MessageDigest; 19 | import java.security.NoSuchAlgorithmException; 20 | 21 | public class FileNameGenerator { 22 | 23 | 24 | public static String generator(String key) { 25 | String cacheKey; 26 | try { 27 | final MessageDigest mDigest = MessageDigest.getInstance("MD5"); 28 | mDigest.update(key.getBytes()); 29 | cacheKey = bytesToHexString(mDigest.digest()); 30 | } catch (NoSuchAlgorithmException e) { 31 | cacheKey = String.valueOf(key.hashCode()); 32 | } 33 | return cacheKey; 34 | } 35 | 36 | private static String bytesToHexString(byte[] bytes) { 37 | // http://stackoverflow.com/questions/332079 38 | StringBuilder sb = new StringBuilder(); 39 | for (int i = 0; i < bytes.length; i++) { 40 | String hex = Integer.toHexString(0xFF & bytes[i]); 41 | if (hex.length() == 1) { 42 | sb.append('0'); 43 | } 44 | sb.append(hex); 45 | } 46 | return sb.toString(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FF6347 4 | #F4511E 5 | #FF5722 6 | 7 | #795548 8 | #5D4037 9 | #795548 10 | 11 | 12 | #2196F3 13 | #1976D2 14 | #448AFF 15 | 16 | #607D8B 17 | #455A64 18 | #607D8B 19 | 20 | #FF9800 21 | #F57C00 22 | #FF9800 23 | 24 | #673AB7 25 | #512DA8 26 | #7C4DFF 27 | 28 | #E91E63 29 | #C2185B 30 | #FF5722 31 | 32 | #4CAF50 33 | #388E3C 34 | #4CAF50 35 | 36 | #212121 37 | #727272 38 | 39 | #ffbebebe 40 | #9E9E9E 41 | #FF080808 42 | #ffbebebe 43 | #FFEEEEEE 44 | 45 | #88EEEEEE 46 | @android:color/white 47 | @android:color/white 48 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/SwitchPreference.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.support.v7.widget.SwitchCompat; 6 | import android.util.AttributeSet; 7 | import android.view.View; 8 | 9 | public class SwitchPreference extends TwoStatePreference { 10 | 11 | public SwitchPreference(Context context) { 12 | super(context); 13 | init(context, null, 0, 0); 14 | } 15 | 16 | public SwitchPreference(Context context, AttributeSet attrs) { 17 | super(context, attrs); 18 | init(context, attrs, 0, 0); 19 | } 20 | 21 | public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) { 22 | super(context, attrs, defStyleAttr); 23 | init(context, attrs, defStyleAttr, 0); 24 | } 25 | 26 | public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 27 | super(context, attrs, defStyleAttr, defStyleRes); 28 | init(context, attrs, defStyleAttr, defStyleRes); 29 | } 30 | 31 | private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 32 | TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[] { 33 | android.R.attr.summaryOn, android.R.attr.summaryOff, android.R.attr.disableDependentsState 34 | }, defStyleAttr, defStyleRes); 35 | 36 | setSummaryOn(typedArray.getString(0)); 37 | setSummaryOff(typedArray.getString(1)); 38 | setDisableDependentsState(typedArray.getBoolean(2, false)); 39 | 40 | typedArray.recycle(); 41 | 42 | setWidgetLayoutResource(R.layout.mp_switch_preference); 43 | } 44 | 45 | @Override 46 | protected void onBindView(View view) { 47 | super.onBindView(view); 48 | 49 | SwitchCompat switchCompat = (SwitchCompat) view.findViewById(R.id.switch_compat); 50 | switchCompat.setChecked(isChecked()); 51 | 52 | syncSummaryView(view); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/model/CloudNote.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.model; 2 | 3 | import com.lguipeng.notes.utils.JsonUtils; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import cn.bmob.v3.BmobObject; 9 | 10 | /** 11 | * Created by lgp on 2015/5/28. 12 | */ 13 | public class CloudNote extends BmobObject { 14 | 15 | public CloudNote() { 16 | this("CloudNote"); 17 | } 18 | 19 | public CloudNote(String theClassName) { 20 | super(theClassName); 21 | } 22 | 23 | private String email; 24 | 25 | private List noteList = new ArrayList<>(); 26 | 27 | private String noteType; 28 | 29 | private long version; 30 | 31 | public long getVersion() { 32 | return version; 33 | } 34 | 35 | public void setVersion(long version) { 36 | this.version = version; 37 | } 38 | 39 | public String getNoteType() { 40 | return noteType; 41 | } 42 | 43 | public void setNoteType(String noteType) { 44 | this.noteType = noteType; 45 | } 46 | 47 | public String getEmail() { 48 | return email; 49 | } 50 | 51 | public void setEmail(String email) { 52 | this.email = email; 53 | } 54 | 55 | public List getNoteList() { 56 | return noteList; 57 | } 58 | 59 | public void setNoteList(List noteList) { 60 | this.noteList = noteList; 61 | } 62 | 63 | public void addNote(Note note) { 64 | noteList.add(JsonUtils.jsonNote(note)); 65 | } 66 | 67 | public void clearNotes() { 68 | noteList.clear(); 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | StringBuilder sb = new StringBuilder(); 74 | //sb.append(super.toString()); 75 | //sb.append("\n"); 76 | for (String note : noteList){ 77 | sb.append(note); 78 | sb.append("\n"); 79 | } 80 | return sb.toString(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/adpater/NotesItemViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.adpater; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | import android.text.TextUtils; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | import com.lguipeng.notes.R; 9 | 10 | /** 11 | * Created by lgp on 2015/4/6. 12 | */ 13 | public class NotesItemViewHolder extends RecyclerView.ViewHolder{ 14 | 15 | private final TextView mNoteLabelTextView; 16 | private final TextView mNoteContentTextView; 17 | private final TextView mNoteTimeTextView; 18 | public NotesItemViewHolder(View parent) { 19 | super(parent); 20 | mNoteLabelTextView = (TextView) parent.findViewById(R.id.note_label_text); 21 | mNoteContentTextView = (TextView) parent.findViewById(R.id.note_content_text); 22 | mNoteTimeTextView = (TextView) parent.findViewById(R.id.note_last_edit_text); 23 | } 24 | 25 | public void setLabelText(CharSequence text){ 26 | setTextView(mNoteLabelTextView, text); 27 | } 28 | 29 | public void setLabelText(int text){ 30 | setTextView(mNoteLabelTextView, text); 31 | } 32 | 33 | public void setContentText(CharSequence text){ 34 | setTextView(mNoteContentTextView, text); 35 | } 36 | 37 | public void setContentText(int text){ 38 | setTextView(mNoteContentTextView, text); 39 | } 40 | 41 | public void setTimeText(CharSequence text){ 42 | setTextView(mNoteTimeTextView, text); 43 | } 44 | 45 | public void setTimeText(int text){ 46 | setTextView(mNoteTimeTextView, text); 47 | } 48 | 49 | private void setTextView(TextView view, CharSequence text){ 50 | if (view == null || TextUtils.isEmpty(text)) 51 | return; 52 | view.setText(text); 53 | } 54 | 55 | private void setTextView(TextView view, int text){ 56 | if (view == null || text <= 0) 57 | return; 58 | view.setText(text); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/src/main/res/xml/prefs.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 14 | 17 | 20 | 23 | 24 | 25 | 26 | 29 | 32 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/model/MaterialSimpleListItem.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.model; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.Drawable; 5 | import android.support.annotation.DrawableRes; 6 | import android.support.annotation.StringRes; 7 | import android.support.v4.content.ContextCompat; 8 | 9 | /** 10 | * Created by lgp on 2015/6/10. 11 | */ 12 | public class MaterialSimpleListItem { 13 | 14 | private Builder mBuilder; 15 | 16 | private MaterialSimpleListItem(Builder builder) { 17 | mBuilder = builder; 18 | } 19 | 20 | public Drawable getIcon() { 21 | return mBuilder.mIcon; 22 | } 23 | 24 | public CharSequence getContent() { 25 | return mBuilder.mContent; 26 | } 27 | 28 | public static class Builder { 29 | 30 | private Context mContext; 31 | protected Drawable mIcon; 32 | protected CharSequence mContent; 33 | 34 | public Builder(Context context) { 35 | mContext = context; 36 | } 37 | 38 | public Builder icon(Drawable icon) { 39 | this.mIcon = icon; 40 | return this; 41 | } 42 | 43 | public Builder icon(@DrawableRes int iconRes) { 44 | if (iconRes == 0) 45 | return this; 46 | return icon(ContextCompat.getDrawable(mContext, iconRes)); 47 | } 48 | 49 | public Builder content(CharSequence content) { 50 | this.mContent = content; 51 | return this; 52 | } 53 | 54 | public Builder content(@StringRes int contentRes) { 55 | return content(mContext.getString(contentRes)); 56 | } 57 | 58 | public MaterialSimpleListItem build() { 59 | return new MaterialSimpleListItem(this); 60 | } 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | if (getContent() != null) 66 | return getContent().toString(); 67 | else return "(no content)"; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/model/Note.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.model; 2 | 3 | import com.alibaba.fastjson.annotation.JSONField; 4 | import com.lguipeng.notes.utils.JsonUtils; 5 | 6 | import net.tsz.afinal.annotation.sqlite.OneToMany; 7 | import net.tsz.afinal.annotation.sqlite.Table; 8 | import net.tsz.afinal.db.sqlite.OneToManyLazyLoader; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | * Created by lgp on 2015/5/25. 14 | */ 15 | @Table(name = "notes") 16 | public class Note implements Serializable{ 17 | @JSONField(serialize=false, deserialize=false) 18 | private int id; 19 | private int type; 20 | private String label; 21 | private String content; 22 | private long lastOprTime; 23 | @JSONField(serialize=false, deserialize=false) 24 | @OneToMany(manyColumn = "noteId") 25 | private OneToManyLazyLoader logs; 26 | 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | public String getLabel() { 36 | return label; 37 | } 38 | 39 | public void setLabel(String label) { 40 | this.label = label; 41 | } 42 | 43 | public String getContent() { 44 | return content; 45 | } 46 | 47 | public void setContent(String content) { 48 | this.content = content; 49 | } 50 | 51 | public long getLastOprTime() { 52 | return lastOprTime; 53 | } 54 | 55 | public void setLastOprTime(long lastOprTime) { 56 | this.lastOprTime = lastOprTime; 57 | } 58 | 59 | public int getType() { 60 | return type; 61 | } 62 | 63 | public void setType(int type) { 64 | this.type = type; 65 | } 66 | 67 | public OneToManyLazyLoader getLogs() { 68 | return logs; 69 | } 70 | 71 | public void setLogs(OneToManyLazyLoader logs) { 72 | this.logs = logs; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return JsonUtils.jsonNote(this); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/CheckBoxPreference.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | import android.view.View; 7 | import android.widget.CheckBox; 8 | 9 | import static com.jenzz.materialpreference.ThemeUtils.isAtLeastL; 10 | 11 | public class CheckBoxPreference extends TwoStatePreference { 12 | 13 | public CheckBoxPreference(Context context) { 14 | super(context); 15 | init(context, null, 0, 0); 16 | } 17 | 18 | public CheckBoxPreference(Context context, AttributeSet attrs) { 19 | super(context, attrs); 20 | init(context, attrs, 0, 0); 21 | } 22 | 23 | public CheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) { 24 | super(context, attrs, defStyleAttr); 25 | init(context, attrs, defStyleAttr, 0); 26 | } 27 | 28 | public CheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr, 29 | int defStyleRes) { 30 | super(context, attrs, defStyleAttr, defStyleRes); 31 | init(context, attrs, defStyleAttr, defStyleRes); 32 | } 33 | 34 | private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 35 | TypedArray typedArray = context.obtainStyledAttributes(attrs, new int[] { 36 | android.R.attr.summaryOn, android.R.attr.summaryOff, android.R.attr.disableDependentsState 37 | }, defStyleAttr, defStyleRes); 38 | 39 | setSummaryOn(typedArray.getString(0)); 40 | setSummaryOff(typedArray.getString(1)); 41 | setDisableDependentsState(typedArray.getBoolean(2, false)); 42 | 43 | typedArray.recycle(); 44 | 45 | setWidgetLayoutResource(R.layout.mp_checkbox_preference); 46 | } 47 | 48 | @Override @SuppressWarnings("deprecation") 49 | protected void onBindView(View view) { 50 | super.onBindView(view); 51 | 52 | CheckBox checkboxView = (CheckBox) view.findViewById(R.id.checkbox); 53 | checkboxView.setChecked(isChecked()); 54 | 55 | if (isAtLeastL()) { 56 | // remove circular background when pressed 57 | checkboxView.setBackgroundDrawable(null); 58 | } 59 | 60 | syncSummaryView(view); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/ThemeUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.app.Activity; 4 | 5 | import com.lguipeng.notes.R; 6 | 7 | /** 8 | * Created by lgp on 2015/6/7. 9 | */ 10 | public class ThemeUtils { 11 | 12 | public static void changTheme(Activity activity, Theme theme){ 13 | if (activity == null) 14 | return; 15 | int style = R.style.RedTheme; 16 | switch (theme){ 17 | case BROWN: 18 | style = R.style.BrownTheme; 19 | break; 20 | case BLUE: 21 | style = R.style.BlueTheme; 22 | break; 23 | case BLUE_GREY: 24 | style = R.style.BlueGreyTheme; 25 | break; 26 | case YELLOW: 27 | style = R.style.YellowTheme; 28 | break; 29 | case DEEP_PURPLE: 30 | style = R.style.DeepPurpleTheme; 31 | break; 32 | case PINK: 33 | style = R.style.PinkTheme; 34 | break; 35 | case GREEN: 36 | style = R.style.GreenTheme; 37 | break; 38 | default: 39 | break; 40 | } 41 | activity.setTheme(style); 42 | } 43 | 44 | public enum Theme{ 45 | RED(0x00), 46 | BROWN(0x01), 47 | BLUE(0x02), 48 | BLUE_GREY(0x03), 49 | YELLOW(0x04), 50 | DEEP_PURPLE(0x05), 51 | PINK(0x06), 52 | GREEN(0x07); 53 | 54 | private int mValue; 55 | 56 | Theme(int value){ 57 | this.mValue = value; 58 | } 59 | 60 | public static Theme mapValueToTheme(final int value) { 61 | for (Theme theme : Theme.values()) { 62 | if (value == theme.getIntValue()) { 63 | return theme; 64 | } 65 | } 66 | // If run here, return default 67 | return RED; 68 | } 69 | 70 | static Theme getDefault() 71 | { 72 | return RED; 73 | } 74 | public int getIntValue() { 75 | return mValue; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/PreferenceCategory.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import static android.content.Context.LAYOUT_INFLATER_SERVICE; 12 | import static android.os.Build.VERSION_CODES.LOLLIPOP; 13 | import static android.text.TextUtils.isEmpty; 14 | import static android.view.View.GONE; 15 | import static android.view.View.VISIBLE; 16 | import static com.jenzz.materialpreference.ThemeUtils.resolveAccentColor; 17 | import static com.jenzz.materialpreference.Typefaces.getRobotoMedium; 18 | 19 | public class PreferenceCategory extends android.preference.PreferenceCategory { 20 | 21 | private int accentColor; 22 | 23 | public PreferenceCategory(Context context) { 24 | super(context); 25 | init(); 26 | } 27 | 28 | public PreferenceCategory(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | init(); 31 | } 32 | 33 | public PreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | init(); 36 | } 37 | 38 | @TargetApi(LOLLIPOP) 39 | public PreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr, 40 | int defStyleRes) { 41 | super(context, attrs, defStyleAttr, defStyleRes); 42 | init(); 43 | } 44 | 45 | private void init() { 46 | accentColor = resolveAccentColor(getContext()); 47 | } 48 | 49 | @Override 50 | protected View onCreateView(ViewGroup parent) { 51 | LayoutInflater layoutInflater = 52 | (LayoutInflater) getContext().getSystemService(LAYOUT_INFLATER_SERVICE); 53 | return layoutInflater.inflate(R.layout.mp_preference_category, parent, false); 54 | } 55 | 56 | @Override 57 | protected void onBindView(View view) { 58 | super.onBindView(view); 59 | 60 | CharSequence title = getTitle(); 61 | TextView titleView = (TextView) view.findViewById(R.id.title); 62 | titleView.setText(title); 63 | titleView.setTextColor(accentColor); 64 | titleView.setVisibility(!isEmpty(title) ? VISIBLE : GONE); 65 | titleView.setTypeface(getRobotoMedium(getContext())); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/AccountUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.accounts.Account; 4 | import android.accounts.AccountManager; 5 | import android.content.Context; 6 | import android.text.TextUtils; 7 | import android.util.Patterns; 8 | 9 | import com.lguipeng.notes.R; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | import java.util.regex.Pattern; 14 | 15 | /** 16 | * Created by lgp on 2015/5/29. 17 | */ 18 | public class AccountUtils { 19 | 20 | private static final String EMAIL_TYPE = "com.android.email"; 21 | 22 | public static void findValidAccount(Context context, AccountFinderListener listener){ 23 | if (listener == null) 24 | return; 25 | String accountString = PreferenceUtils.getInstance(context).getStringParam(context.getString(R.string.sync_account_key)); 26 | if (!TextUtils.isEmpty(accountString)){ 27 | listener.setHasAccountSave(true); 28 | } 29 | Pattern emailPattern = Patterns.EMAIL_ADDRESS; 30 | Account[] accounts = AccountManager.get(context.getApplicationContext()).getAccounts(); 31 | List accountItems = new ArrayList<>(); 32 | for (Account account : accounts) { 33 | if (emailPattern.matcher(account.name).matches() && TextUtils.equals(EMAIL_TYPE, account.type)) { 34 | accountItems.add(account.name); 35 | } 36 | } 37 | if (accountItems.size() <= 0){ 38 | if (listener.isHasAccountSave()){ 39 | listener.onOne(accountString); 40 | return; 41 | } 42 | listener.onNone(); 43 | } 44 | if (accountItems.size() == 1){ 45 | if (listener.isHasAccountSave()){ 46 | listener.onOne(accountString); 47 | return; 48 | } 49 | listener.onOne(accountItems.get(0)); 50 | } 51 | 52 | if (accountItems.size() > 1){ 53 | listener.onMore(accountItems); 54 | } 55 | } 56 | 57 | public static abstract class AccountFinderListener{ 58 | private boolean hasAccountSave = false; 59 | protected abstract void onNone(); 60 | protected abstract void onOne(String account); 61 | protected abstract void onMore(List accountItems); 62 | 63 | public boolean isHasAccountSave() { 64 | return hasAccountSave; 65 | } 66 | 67 | public void setHasAccountSave(boolean hasAccountSave) { 68 | this.hasAccountSave = hasAccountSave; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/java/com/jenzz/materialpreference/PreferenceImageView.java: -------------------------------------------------------------------------------- 1 | package com.jenzz.materialpreference; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.util.AttributeSet; 6 | import android.widget.ImageView; 7 | 8 | import static android.os.Build.VERSION_CODES.LOLLIPOP; 9 | import static android.view.View.MeasureSpec.AT_MOST; 10 | import static android.view.View.MeasureSpec.UNSPECIFIED; 11 | import static android.view.View.MeasureSpec.getMode; 12 | import static android.view.View.MeasureSpec.getSize; 13 | import static android.view.View.MeasureSpec.makeMeasureSpec; 14 | import static java.lang.Integer.MAX_VALUE; 15 | 16 | /** 17 | * Extension of ImageView that correctly applies maxWidth and maxHeight. 18 | */ 19 | public class PreferenceImageView extends ImageView { 20 | 21 | private int maxWidth = MAX_VALUE; 22 | private int maxHeight = MAX_VALUE; 23 | 24 | public PreferenceImageView(Context context) { 25 | super(context); 26 | } 27 | 28 | public PreferenceImageView(Context context, AttributeSet attrs) { 29 | super(context, attrs); 30 | } 31 | 32 | public PreferenceImageView(Context context, AttributeSet attrs, int defStyleAttr) { 33 | super(context, attrs, defStyleAttr); 34 | } 35 | 36 | @TargetApi(LOLLIPOP) 37 | public PreferenceImageView(Context context, AttributeSet attrs, int defStyleAttr, 38 | int defStyleRes) { 39 | super(context, attrs, defStyleAttr, defStyleRes); 40 | } 41 | 42 | @Override 43 | public void setMaxWidth(int maxWidth) { 44 | super.setMaxWidth(maxWidth); 45 | this.maxWidth = maxWidth; 46 | } 47 | 48 | @Override 49 | public void setMaxHeight(int maxHeight) { 50 | super.setMaxHeight(maxHeight); 51 | this.maxHeight = maxHeight; 52 | } 53 | 54 | @Override 55 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 56 | int widthMode = getMode(widthMeasureSpec); 57 | if (widthMode == AT_MOST || widthMode == UNSPECIFIED) { 58 | int widthSize = getSize(widthMeasureSpec); 59 | if (maxWidth != MAX_VALUE && (maxWidth < widthSize || widthMode == UNSPECIFIED)) { 60 | widthMeasureSpec = makeMeasureSpec(maxWidth, AT_MOST); 61 | } 62 | } 63 | 64 | int heightMode = getMode(heightMeasureSpec); 65 | if (heightMode == AT_MOST || heightMode == UNSPECIFIED) { 66 | int heightSize = getSize(heightMeasureSpec); 67 | if (maxHeight != MAX_VALUE && (maxHeight < heightSize || heightMode == UNSPECIFIED)) { 68 | heightMeasureSpec = makeMeasureSpec(maxHeight, AT_MOST); 69 | } 70 | } 71 | 72 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 73 | } 74 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 34 | 35 | 36 | 41 | 42 | 43 | 47 | 48 | 49 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/ui/fragments/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.ui.fragments; 2 | 3 | import android.os.Bundle; 4 | import android.preference.PreferenceFragment; 5 | import android.support.v7.app.AlertDialog; 6 | 7 | import com.lguipeng.notes.App; 8 | import com.lguipeng.notes.R; 9 | import com.lguipeng.notes.ui.BaseActivity; 10 | import com.lguipeng.notes.utils.PreferenceUtils; 11 | import com.lguipeng.notes.utils.ThemeUtils; 12 | 13 | import java.util.List; 14 | 15 | import dagger.ObjectGraph; 16 | 17 | /** 18 | * Created by lgp on 2015/5/26. 19 | */ 20 | public abstract class BaseFragment extends PreferenceFragment { 21 | 22 | private ObjectGraph activityGraph; 23 | protected BaseActivity activity; 24 | protected PreferenceUtils preferenceUtils; 25 | @Override 26 | public void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | activityGraph = ((App) getActivity().getApplication()).createScopedGraph(getModules().toArray()); 29 | activityGraph.inject(this); 30 | } 31 | 32 | @Override 33 | public void onActivityCreated(Bundle savedInstanceState) { 34 | super.onActivityCreated(savedInstanceState); 35 | if (getActivity() != null && getActivity() instanceof BaseActivity){ 36 | activity = (BaseActivity)getActivity(); 37 | } 38 | preferenceUtils = PreferenceUtils.getInstance(getActivity()); 39 | } 40 | 41 | @Override 42 | public void onDestroy() { 43 | super.onDestroy(); 44 | activityGraph = null; 45 | } 46 | 47 | protected AlertDialog.Builder generateDialogBuilder(){ 48 | ThemeUtils.Theme theme = getCurrentTheme(); 49 | AlertDialog.Builder builder; 50 | switch (theme){ 51 | case BROWN: 52 | builder = new AlertDialog.Builder(getActivity(), R.style.BrownDialogTheme); 53 | break; 54 | case BLUE: 55 | builder = new AlertDialog.Builder(getActivity(), R.style.BlueDialogTheme); 56 | break; 57 | case BLUE_GREY: 58 | builder = new AlertDialog.Builder(getActivity(), R.style.BlueGreyDialogTheme); 59 | break; 60 | default: 61 | builder = new AlertDialog.Builder(getActivity(), R.style.RedDialogTheme); 62 | break; 63 | } 64 | return builder; 65 | } 66 | 67 | protected ThemeUtils.Theme getCurrentTheme(){ 68 | int value = preferenceUtils.getIntParam(getString(R.string.change_theme_key), 0); 69 | return ThemeUtils.Theme.mapValueToTheme(value); 70 | } 71 | 72 | protected abstract List getModules(); 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/PreferenceUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import com.lguipeng.notes.ui.fragments.SettingFragment; 7 | 8 | /** 9 | * Created by lgp on 2014/10/30. 10 | */ 11 | public class PreferenceUtils{ 12 | 13 | private SharedPreferences sharedPreferences; 14 | 15 | private SharedPreferences.Editor shareEditor; 16 | 17 | private static PreferenceUtils preferenceUtils = null; 18 | 19 | public static final String NOTE_TYPE_KEY = "NOTE_TYPE_KEY"; 20 | 21 | private PreferenceUtils(Context context){ 22 | sharedPreferences = context.getSharedPreferences(SettingFragment.PREFERENCE_FILE_NAME, Context.MODE_PRIVATE); 23 | shareEditor = sharedPreferences.edit(); 24 | } 25 | 26 | public static PreferenceUtils getInstance(Context context){ 27 | if (preferenceUtils == null) { 28 | synchronized (PreferenceUtils.class) { 29 | if (preferenceUtils == null) { 30 | preferenceUtils = new PreferenceUtils(context.getApplicationContext()); 31 | } 32 | } 33 | } 34 | return preferenceUtils; 35 | } 36 | 37 | public String getStringParam(String key){ 38 | return getStringParam(key, ""); 39 | } 40 | 41 | public String getStringParam(String key, String defaultString){ 42 | return sharedPreferences.getString(key, defaultString); 43 | } 44 | 45 | public void saveParam(String key, String value) 46 | { 47 | shareEditor.putString(key,value).commit(); 48 | } 49 | 50 | public boolean getBooleanParam(String key){ 51 | return getBooleanParam(key, false); 52 | } 53 | 54 | public boolean getBooleanParam(String key, boolean defaultBool){ 55 | return sharedPreferences.getBoolean(key, defaultBool); 56 | } 57 | 58 | public void saveParam(String key, boolean value){ 59 | shareEditor.putBoolean(key, value).commit(); 60 | } 61 | 62 | public int getIntParam(String key){ 63 | return getIntParam(key, 0); 64 | } 65 | 66 | public int getIntParam(String key, int defaultInt){ 67 | return sharedPreferences.getInt(key, defaultInt); 68 | } 69 | 70 | public void saveParam(String key, int value){ 71 | shareEditor.putInt(key, value).commit(); 72 | } 73 | 74 | public long getLongParam(String key){ 75 | return getLongParam(key, 0); 76 | } 77 | 78 | public long getLongParam(String key, long defaultInt){ 79 | return sharedPreferences.getLong(key, defaultInt); 80 | } 81 | 82 | public void saveParam(String key, long value){ 83 | shareEditor.putLong(key, value).commit(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_note.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 | 24 | 29 | 38 | 48 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /MaterialPreference/src/main/res/layout/mp_preference.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 18 | 30 | 37 | 38 | 39 | 46 | 47 | 56 | 57 | 67 | 68 | 69 | 70 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | package com.lguipeng.notes.utils; 2 | 3 | import android.content.Context; 4 | 5 | import com.lguipeng.notes.R; 6 | 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | 10 | /** 11 | * Created by lgp on 2015/5/25. 12 | */ 13 | public class TimeUtils { 14 | public static final long DAY_Millis = 24 * 60 * 60 * 1000; 15 | public static final long MONTH_Millis = 30 * DAY_Millis; 16 | public static final long YEAR_Millis = 365 * DAY_Millis; 17 | public static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH : mm"); 18 | public static final SimpleDateFormat DATE_FORMAT_DATE_1 = new SimpleDateFormat(" HH : mm "); 19 | 20 | private TimeUtils() { 21 | throw new AssertionError(); 22 | } 23 | 24 | /** 25 | * long time to string 26 | * 27 | * @param timeInMillis 28 | * @param dateFormat 29 | * @return 30 | */ 31 | public static String getTime(long timeInMillis, SimpleDateFormat dateFormat) { 32 | return dateFormat.format(new Date(timeInMillis)); 33 | } 34 | 35 | /** 36 | * long time to string, format is {@link #DEFAULT_DATE_FORMAT} 37 | * 38 | * @param timeInMillis 39 | * @return 40 | */ 41 | public static String getTime(long timeInMillis) { 42 | return getTime(timeInMillis, DEFAULT_DATE_FORMAT); 43 | } 44 | 45 | @SuppressWarnings("Deprecated") 46 | public static String getConciseTime(long timeInMillis, long nowInMillis, Context context) { 47 | if (context == null) 48 | return ""; 49 | Date date = new Date(timeInMillis); 50 | Date now = new Date(nowInMillis); 51 | 52 | if (now.getYear() == date.getYear()) { 53 | if (now.getMonth() == date.getMonth()) { 54 | if (now.getDate() == date.getDate()) 55 | return context.getString(R.string.today, getTime(timeInMillis, DATE_FORMAT_DATE_1)); 56 | else{ 57 | return context.getString(R.string.before_day, now.getDate() - date.getDate()); 58 | } 59 | }else { 60 | return context.getString(R.string.before_month, now.getMonth() - date.getMonth()); 61 | } 62 | } 63 | return context.getString(R.string.before_year, now.getYear() - date.getYear()); 64 | } 65 | 66 | 67 | public static String getConciseTime(long timeInMillis, Context context) { 68 | return getConciseTime(timeInMillis, getCurrentTimeInLong(), context); 69 | } 70 | /** 71 | * get current time in milliseconds 72 | * 73 | * @return 74 | */ 75 | public static long getCurrentTimeInLong() { 76 | return System.currentTimeMillis(); 77 | } 78 | 79 | /** 80 | * get current time in milliseconds, format is {@link #DEFAULT_DATE_FORMAT} 81 | * 82 | * @return 83 | */ 84 | public static String getCurrentTimeInString() { 85 | return getTime(getCurrentTimeInLong()); 86 | } 87 | 88 | /** 89 | * get current time in milliseconds 90 | * 91 | * @return 92 | */ 93 | public static String getCurrentTimeInString(SimpleDateFormat dateFormat) { 94 | return getTime(getCurrentTimeInLong(), dateFormat); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/java/com/lguipeng/notes/utils/NotesLog.java: -------------------------------------------------------------------------------- 1 | /*** 2 | This is free and unencumbered software released into the public domain. 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | For more information, please refer to 8 | */ 9 | 10 | package com.lguipeng.notes.utils; 11 | 12 | import android.util.Log; 13 | 14 | import com.lguipeng.notes.BuildConfig; 15 | 16 | /** 17 | * @date 21.06.2012 18 | * @author Mustafa Ferhan Akman 19 | * 20 | * Create a simple and more understandable Android logs. 21 | * */ 22 | 23 | public class NotesLog{ 24 | 25 | static String className; 26 | static String methodName; 27 | static int lineNumber; 28 | 29 | private NotesLog(){ 30 | /* Protect from instantiations */ 31 | } 32 | 33 | public static boolean isDebuggable() { 34 | return BuildConfig.DEBUG; 35 | } 36 | 37 | private static String createLog( String log ) { 38 | 39 | StringBuffer buffer = new StringBuffer(); 40 | buffer.append("["); 41 | buffer.append(methodName); 42 | buffer.append(":"); 43 | buffer.append(lineNumber); 44 | buffer.append("]"); 45 | buffer.append(log); 46 | 47 | return buffer.toString(); 48 | } 49 | 50 | private static void getMethodNames(StackTraceElement[] sElements){ 51 | className = sElements[1].getFileName(); 52 | methodName = sElements[1].getMethodName(); 53 | lineNumber = sElements[1].getLineNumber(); 54 | } 55 | 56 | public static void e(String message){ 57 | if (!isDebuggable()) 58 | return; 59 | 60 | // Throwable instance must be created before any methods 61 | getMethodNames(new Throwable().getStackTrace()); 62 | Log.e(className, createLog(message)); 63 | } 64 | 65 | public static void i(String message){ 66 | if (!isDebuggable()) 67 | return; 68 | 69 | getMethodNames(new Throwable().getStackTrace()); 70 | Log.i(className, createLog(message)); 71 | } 72 | 73 | public static void d(String message){ 74 | if (!isDebuggable()) 75 | return; 76 | 77 | getMethodNames(new Throwable().getStackTrace()); 78 | Log.d(className, createLog(message)); 79 | } 80 | 81 | public static void d(){ 82 | d(""); 83 | } 84 | 85 | public static void v(String message){ 86 | if (!isDebuggable()) 87 | return; 88 | 89 | getMethodNames(new Throwable().getStackTrace()); 90 | Log.v(className, createLog(message)); 91 | } 92 | 93 | public static void w(String message){ 94 | if (!isDebuggable()) 95 | return; 96 | 97 | getMethodNames(new Throwable().getStackTrace()); 98 | Log.w(className, createLog(message)); 99 | } 100 | 101 | public static void wtf(String message){ 102 | if (!isDebuggable()) 103 | return; 104 | 105 | getMethodNames(new Throwable().getStackTrace()); 106 | Log.wtf(className, createLog(message)); 107 | } 108 | 109 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/notes_item_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 18 | 22 | 36 | 46 | 47 | 57 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 19 | 23 | 27 | 28 | 39 | 48 | 49 | 50 | 51 | 57 | 65 |