src\MyApplication\.idea\sonarlint\issuestore\0\3\037b293928bff3f763d72038512124d16aebd627
src\MyApplication\.idea\sonarlint\issuestore\6\5\65764ff37783669e71501692a607a3cea49c4bdc src\MyApplication\.idea\sonarlint\issuestore\9\5\954e8115c9434902b13d9840c149e0ff3fe59df2 src\MyApplication\.idea\sonarlint\issuestore\c\5\c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c src\MyApplication\.idea\sonarlint\issuestore\d\2\d2c92a556e47fd0e9a3fa038dbf835129e2f5090 src\MyApplication\.idea\sonarlint\issuestore\d\9\d9f0b00bd9259256a0cc6a48eb4c59665266c4ea src\MyApplication\.idea\sonarlint\issuestore\f\4\f4db46de912ee15bd8dff2e67791e614cfdc8ae8 src\MyApplication\.idea\sonarlint\issuestore\index.pb src\MyApplication\app\build.gradle src\MyApplication\app\src\main\AndroidManifest.xml src\MyApplication\app\src\main\java\com\example\administrator\myapplication\db\NoteDatabase.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\entity\User.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\LoginActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\WelcomeActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\utils\CommonUtils.java src\MyApplication\app\src\main\res\layout\about_me_fragment.xml src\MyApplication\app\src\main\res\layout\activity_login.xml src\MyApplication\app\src\main\res\layout\activity_user_info.xml src\MyApplication\app\src\main\res\layout\activity_welcome.xml src\MyApplication\app\src\main\res\layout\app_bar_main.xml src\MyApplication\app\src\main\res\layout\fragment_note.xml src\MyApplication\app\src\main\res\layout\fragment_setting.xml src\MyApplication\app\src\main\res\layout\layout_note_detail_menu.xml src\MyApplication\app\src\main\res\layout\nav_header_main.xml src\MyApplication\app\src\main\res\layout\widget_lock_view.xml src\MyApplication\app\src\main\res\values\strings.xml src\MyApplication\build.gradle src\MyApplication\.idea\sonarlint\issuestore\2\4\2432e00ff27b3c4e488bc12d8149cc4f0583cb71 src\MyApplication\.idea\sonarlint\issuestore\6\0\6017e946e5380fbd8e8ec44cf82432536cb0c89d src\MyApplication\.idea\sonarlint\issuestore\9\f\9f49ae81d31735cbb5ea0dec8c22fb85771170ad src\MyApplication\.idea\sonarlint\issuestore\a\c\ac6e0c942798c8a768fab2e3ab7e6a6b69b346f1 src\MyApplication\.idea\sonarlint\issuestore\d\5\d5b72c9513d313bcf937771f4e19798894789154 src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\AboutAppFragment.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\AlarmAlertActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\ChangeBgFragment.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\DateTimePicker.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\DateTimePickerDialog.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\MainActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\NoteBookFragment.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\NoteEditActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\NoteEditFragment.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\RegisterActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\SetLockActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\SettingFragment.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\UnLockActivity.java src\MyApplication\app\src\main\java\com\example\administrator\myapplication\ui\UserInfoActivity.java src\MyApplication\app\src\main\res\layout\note_edit_fraglayout.xml
This commit is contained in:
parent
c5b6bdbb34
commit
358c4f5726
|
@ -1,9 +1,11 @@
|
|||
|
||||
rsquid:S1450"]Remove the "mDefaultBgPath" field and declare it as a local variable in the relevant methods.(çêè
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
csquid:CallToDeprecatedMethod"=Remove this use of "setBackgroundDrawable"; it is deprecated.(Ìý´Ÿ
|
||||
Fsquid:S1905",Remove this unnecessary cast to "ImageView".(„üîÄÿÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
bsquid:S1226"HIntroduce a new variable instead of reusing the parameter "convertView".(îªÙ¨ùÿÿÿÿ
|
||||
Asquid:S1905",Remove this unnecessary cast to "ImageView".(éßÜà
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
>squid:S1659"*Declare "backgroundIv" on a separate line.(·«ï
|
||||
bsquid:S1226"HIntroduce a new variable instead of reusing the parameter "convertView".(îªÙ¨ùÿÿÿÿ
|
||||
rsquid:S1450"]Remove the "mDefaultBgPath" field and declare it as a local variable in the relevant methods.(çêè
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
Esquid:S1905"+Remove this unnecessary cast to "TextView".(©ßåçøÿÿÿÿ
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
esquid:S1301"KReplace this "switch" statement by "if" statements to increase readability.(öÛ«°þÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
_squid:CallToDeprecatedMethod":Remove this use of "setAudioStreamType"; it is deprecated.(¡Ìé0
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¡Õ±š
|
||||
Zsquid:S2147"ECombine this catch with the one at line 106, which has the same body.(ï£Ä
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¹ß„º
|
||||
Xsquid:CallToDeprecatedMethod"2Remove this use of "isScreenOn"; it is deprecated.(¤® ²
|
||||
esquid:CallToDeprecatedMethod":Remove this use of "setAudioStreamType"; it is deprecated.(†Å¨ªùÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
Zsquid:S2147"ECombine this catch with the one at line 106, which has the same body.(‚ùïÄ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(æåÞ˜üÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
||||
_squid:S2147"ECombine this catch with the one at line 106, which has the same body.(ÿëÛßúÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÕÌ<C395>®þÿÿÿÿ
|
||||
=squid:S1148"#Use a logger to log this exception.(€ÉÔ…ýÿÿÿÿ
|
|
@ -2,9 +2,9 @@
|
|||
gsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Š÷˜Í
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(ÆÞ–’
|
||||
Ysquid:S2184"DCast one of the operands of this subtraction operation to a "float".(ð䘊
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(ƒ‰Á¨
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(̲<C38C>íùÿÿÿÿ
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(â¡ú—ÿÿÿÿÿ
|
||||
=squid:S1172"(Remove this unused method parameter "X".(Š÷˜Í
|
||||
^squid:S2184"DCast one of the operands of this subtraction operation to a "float".(¨ùã¸ùÿÿÿÿ
|
||||
Tsquid:S1118":Add a private constructor to hide the implicit public one.(̲<C38C>íùÿÿÿÿ
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(•€ÕÎùÿÿÿÿ
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(â¡ú—ÿÿÿÿÿ
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(ƒ‰Á¨
|
||||
^squid:S2184"DCast one of the operands of this subtraction operation to a "float".(¨ùã¸ùÿÿÿÿ
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
[squid:CallToDeprecatedMethod"0Remove this use of "fromHtml"; it is deprecated.(Ë–ü÷ùÿÿÿÿ
|
||||
ysquid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "builder".(’âÃùÿÿÿÿ
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(¨üÕ¢
|
||||
asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(ïÛôÜýÿÿÿÿ
|
||||
ysquid:S1488"_Immediately return this expression instead of assigning it to the temporary variable "builder".(’âÃùÿÿÿÿ
|
||||
[squid:CallToDeprecatedMethod"0Remove this use of "fromHtml"; it is deprecated.(Ë–ü÷ùÿÿÿÿ
|
||||
\squid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(¸Ø§Î
|
||||
\squid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(¸Ø§Î
|
||||
Osquid:S1118":Add a private constructor to hide the implicit public one.(¨üÕ¢
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÕÝ¥õúÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÕÝ¥õúÿÿÿÿ
|
||||
asquid:S1192"GDefine a constant instead of duplicating this literal "isTran" 3 times.(ý‘™ þÿÿÿÿ
|
|
@ -1,32 +1,34 @@
|
|||
|
||||
=squid:S1481")Remove this unused "list" local variable.(Ì¿Íh
|
||||
`squid:UselessImportCheck">Remove this unused import 'cn.bmob.v3.listener.LogInListener'.(ØÖü³
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÕÓí³þÿÿÿÿ
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÐÀχ
|
||||
fsquid:UselessImportCheck"?Remove this unused import 'cn.bmob.v3.exception.BmobException'.(Æš…Åùÿÿÿÿ
|
||||
Lsquid:S1854"8Remove this useless assignment to local variable "list".(Ì¿Íh
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(·üÏÏúÿÿÿÿ
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(©²ŒÌÿÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ú°à¬
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÒäÕ§
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.( µâ²
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ßÕù•ýÿÿÿÿ
|
||||
msquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(Ì¿Íh
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÆŸßêùÿÿÿÿ
|
||||
lsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(쇯Úþÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(°þíÈÿÿÿÿÿ
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(¹¶Á»
|
||||
nsquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(ÚÒîÊ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>ÄŠæ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(㑨<E28098>úÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(™ØÓ¯ûÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(òü€–
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ò£èÄûÿÿÿÿ
|
||||
~squid:UselessImportCheck"\Remove this unused import 'com.nostra13.universalimageloader.core.ImageLoaderConfiguration'.(좣±
|
||||
[squid:UnusedPrivateMethod"3Remove this unused private "updateUserHead" method.(¤È‚Ìýÿÿÿÿ
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(¹ó¯™
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(“¨ëø
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ôˆ«¿
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(쇯Úþÿÿÿÿ
|
||||
isquid:UselessImportCheck"GRemove this unused import 'com.htq.baidu.coolnote.app.BaseApplication'.(°¤ù‰
|
||||
Lsquid:S1854"8Remove this useless assignment to local variable "list".(Ì¿Íh
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>ÄŠæ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ßÕù•ýÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ú°à¬
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(¹ó¯™
|
||||
‘squid:S1845"|Rename method "Login" to prevent any misunderstanding/clash with method "login" defined in superclass "cn.bmob.v3.BmobUser".(¹ó¯™
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÐÀχ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(òü€–
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(·üÏÏúÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(°þíÈÿÿÿÿÿ
|
||||
[squid:UnusedPrivateMethod"3Remove this unused private "updateUserHead" method.(¤È‚Ìýÿÿÿÿ
|
||||
hsquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(¹¶Á»
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ôˆ«¿
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.( µâ²
|
||||
msquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(Ì¿Íh
|
||||
`squid:UselessImportCheck">Remove this unused import 'cn.bmob.v3.listener.LogInListener'.(ØÖü³
|
||||
fsquid:UselessImportCheck"?Remove this unused import 'cn.bmob.v3.exception.BmobException'.(Æš…Åùÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(™ØÓ¯ûÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ò£èÄûÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(㑨<E28098>úÿÿÿÿ
|
||||
dsquid:S00100"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(¹ó¯™
|
||||
~squid:UselessImportCheck"\Remove this unused import 'com.nostra13.universalimageloader.core.ImageLoaderConfiguration'.(좣±
|
||||
nsquid:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(ÚÒîÊ
|
||||
squid:UselessImportCheck"XRemove this unused import 'com.example.administrator.myapplication.app.BaseApplication'.(‘”ÛÓúÿÿÿÿ
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(©²ŒÌÿÿÿÿÿ
|
||||
–squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(“¨ëø
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÒäÕ§
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÆŸßêùÿÿÿÿ
|
||||
msquid:ModifiersOrderCheck"EReorder the modifiers to comply with the Java Language Specification.(ÕÓí³þÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ú°à¬
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ñÌ–à
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ñÌ–à
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this division operation to a "float".(ĵöö
|
||||
Vsquid:S2184"ACast one of the operands of this addition operation to a "float".(†¬’²
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(̢Ì
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(綸<C2B6>þÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(‚—Å›üÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ïÁ´Ìüÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ÀÌ€»úÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(» æžÿÿÿÿÿ
|
||||
asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(¬ÿºîÿÿÿÿÿ
|
||||
asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(¬ÿºîÿÿÿÿÿ
|
||||
gsquid:S00117"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(ŸÏ™˜
|
||||
dsquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(ʨ¹<C2A8>
|
|
@ -1,13 +1,12 @@
|
|||
|
||||
Isquid:S1066"/Merge this if statement with the enclosing one.(¿±Ïßüÿÿÿÿ
|
||||
<squid:S1214""Move constants to a class or enum.(×™´ªùÿÿÿÿ
|
||||
Lsquid:S1135"2Complete the task associated to this TODO comment.(ÉÓÈìýÿÿÿÿ
|
||||
Gsquid:S1135"2Complete the task associated to this TODO comment.(ž¼í
|
||||
Gsquid:S1135"2Complete the task associated to this TODO comment.(ž¼í
|
||||
Gsquid:S1135"2Complete the task associated to this TODO comment.(Ö¾ã¯
|
||||
Gsquid:S1135"2Complete the task associated to this TODO comment.(Àó‚´
|
||||
gsquid:S3776"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(Æ¿ú„
|
||||
[squid:S2142"FEither re-interrupt this method or rethrow the "InterruptedException".(ä ¹€
|
||||
›squid:S1186"€Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.(ô¬ý¶ùÿÿÿÿ
|
||||
Osquid:S2386"5Move "PROJECTION" to a class and lower its visibility(‡ÎÌÑùÿÿÿÿ
|
||||
dsquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(ôã©Ö
|
||||
S"squid:SwitchLastCaseIsDefaultCheck""Add a default case to this switch.(ד¾ñùÿÿÿÿ
|
||||
esquid:S1301"KReplace this "switch" statement by "if" statements to increase readability.(ד¾ñùÿÿÿÿ
|
||||
esquid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ïðóºÿÿÿÿÿ
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(ìÓ›ù
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ôˆ«¿
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>„…¬
|
||||
^squid:CallToDeprecatedMethod"3Remove this use of "getDrawable"; it is deprecated.(í–‹¦ýÿÿÿÿ
|
||||
^squid:CallToDeprecatedMethod"3Remove this use of "getDrawable"; it is deprecated.(Îôéªûÿÿÿÿ
|
||||
asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(‡…¾Íþÿÿÿÿ
|
||||
asquid:CallToDeprecatedMethod"6Remove this use of "ProgressDialog"; it is deprecated.(‡…¾Íþÿÿÿÿ
|
||||
isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(•«ú§üÿÿÿÿ
|
|
@ -1,2 +1,6 @@
|
|||
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(帜†
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(Ôˆ«¿
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(¢¾ôŽ
|
||||
isquid:MaximumInheritanceDepth"=This class has 10 parents which is greater than 5 authorized.(곤헌<EAB3A4><ED978C><EFBFBD><EFBFBD>
|
||||
`squid:CommentedOutCodeLine"<This block of commented-out lines of code should be removed.(<28>„…¬
|
|
@ -1,77 +1,27 @@
|
|||
|
||||
<
|
||||
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\db\DatabaseHelper.java,a\a\aa2f43374bddf98bfc4aea5a398fe877e5337db3
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\db\NoteDatabase.java,b\3\b395e8da890bfdf6daeefc467704d4b30eac2ea4
|
||||
‡
|
||||
Wapp\src\main\java\com\example\administrator\myapplication\adapter\BgPicGridAdapter.java,0\3\037b293928bff3f763d72038512124d16aebd627
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\entity\Entity.java,8\5\859e5ebe76cd38bc36ca8379efb50fa9654aada0
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\ui\EditImages.java,9\e\9ea0176c0b7c2596ee3a138d5aafcdb83764d0f4
|
||||
{
|
||||
Kapp\src\main\java\com\example\administrator\myapplication\ui\EditNotes.java,9\2\92cf1c7de3acc98eba6f939165f0bb2683705fcf
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\ui\ImagesDisplay.java,a\6\a6e0067cc06ea7f07e5e3c87e060a04c54f022e7
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\entity\NotebookData.java,4\8\487d5149cb35c7a7667af03d218f63298d21b1f0
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\entity\BgPicEntity.java,1\7\17acf378acdba9698dfb6d704084bcd18706d372
|
||||
ˆ
|
||||
Xapp\src\main\java\com\example\administrator\myapplication\entity\OnResponseListener.java,f\8\f8d5ad2e69267983911206328e3836505144d8db
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\entity\Response.java,5\b\5b0e24b16ee3b9a006718e6880c3eb1eeff4d105
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\entity\UpdataEvent.java,d\c\dceb451ef5f82cbe33558978d2a79abc27fb6fe0
|
||||
z
|
||||
Japp\src\main\java\com\example\administrator\myapplication\entity\User.java,c\5\c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c
|
||||
<EFBFBD>
|
||||
]app\src\main\java\com\example\administrator\myapplication\ui\AppCompatPreferenceActivity.java,7\f\7fc1f946c8e0fc0221c21f1cb84787e5b2965d9a
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\utils\AccountUtils.java,6\2\623bf4dae8f8d83b8faa2b618d5550b1a37e5683
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\utils\BmobConstants.java,3\4\342c9edfd27db16bba3e3455e68c749d04c55cbd
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\utils\Constants.java,3\6\36c3f609a5d93035486e7c295cd723418b0f089e
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\CommonUtils.java,3\7\37269061f6dc97247d4050e30277a569050f1b3d
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\utils\HTQAnimations.java,6\5\65764ff37783669e71501692a607a3cea49c4bdc
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\utils\MD5Util.java,0\0\00ede12c640622790c9816ae6766f38a949ed3bd
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\StringUtils.java,a\0\a02bf92a1675ea96231995a8137b01dd95f322ae
|
||||
|
|
||||
Lapp\src\main\java\com\example\administrator\myapplication\utils\SPUtils.java,5\7\57c831202760b4842bfc3ee5ac2511ebb0122f9e
|
||||
€
|
||||
Papp\src\main\java\com\example\administrator\myapplication\utils\SystemUtils.java,6\7\67ee5a70c0947c6377cf1e29856f6a79659f84e7
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\utils\DialogHelp.java,9\5\954e8115c9434902b13d9840c149e0ff3fe59df2
|
||||
ƒ
|
||||
Sapp\src\main\java\com\example\administrator\myapplication\utils\ResourceParser.java,0\e\0eb5e393710f19bb3d38d5884bfea90461e2f527
|
||||
~
|
||||
Napp\src\main\java\com\example\administrator\myapplication\utils\PhotoUtil.java,9\f\9fbe46e342a1ff27349384d89b44b286ccf531a3
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\utils\TimeZoneUtil.java,f\d\fd0acbc65b4f2ecc0ae0379155f8cab404805cfb
|
||||
‘
|
||||
aapp\src\main\java\com\example\administrator\myapplication\widget\patternlock\LockPatternView.java,d\5\d55eada2cdd2dd102362d485231d9b377995b0b0
|
||||
‡
|
||||
Wapp\src\main\java\com\example\administrator\myapplication\widget\patternlock\Point.java,5\5\55a10cdfd1735580de467639a7fadbfa2db674ba
|
||||
…
|
||||
Uapp\src\main\java\com\example\administrator\myapplication\widget\HTQDragGridView.java,8\e\8e104bc4be91ecea7d96ed093e7eefd2be1a136c
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\utils\HTQAnimations.java,6\5\65764ff37783669e71501692a607a3cea49c4bdc
|
||||
z
|
||||
Japp\src\main\java\com\example\administrator\myapplication\entity\User.java,c\5\c5ce6afdb0606af7b3aad034a3799dc44d4d4c5c
|
||||
…
|
||||
Uapp\src\main\java\com\example\administrator\myapplication\widget\CircleImageView.java,d\2\d2c92a556e47fd0e9a3fa038dbf835129e2f5090
|
||||
…
|
||||
Uapp\src\main\java\com\example\administrator\myapplication\utils\ImageLoadOptions.java,6\5\655e5da5fa53bd4a676fde93415f3962c6841a5c
|
||||
†
|
||||
Vapp\src\main\java\com\example\administrator\myapplication\adapter\NotebookAdapter.java,b\f\bf99366384db0ccf7ec0367c3aa4412c93f2a9bb
|
||||
<EFBFBD>
|
||||
_app\src\main\java\com\example\administrator\myapplication\widget\patternlock\RotateDegrees.java,5\4\5407486fb05ebaf77ee187807ac7fbb8cb42de8a
|
||||
ˆ
|
||||
Xapp\src\main\java\com\example\administrator\myapplication\widget\NoteItemCircleView.java,e\7\e71af57077389976b85ce04fe9c4f9e8bc78f9d2
|
||||
„
|
||||
Tapp\src\main\java\com\example\administrator\myapplication\ui\AlarmAlertActivity.java,6\0\6017e946e5380fbd8e8ec44cf82432536cb0c89d
|
||||
P
|
||||
app\src\main\AndroidManifest.xml,a\c\ac6e0c942798c8a768fab2e3ab7e6a6b69b346f1
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\ui\WelcomeActivity.java,f\4\f4db46de912ee15bd8dff2e67791e614cfdc8ae8
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\widget\ToggleButton.java,a\2\a2cac54ed6169d41dc3d4fe37b5f3594fabd1e9d
|
||||
@
|
||||
app\build.gradle,8\3\83d37b2761f0342c28dad5cd3a4bdc7a7b7d55d6
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\ui\AboutAppFragment.java,2\4\2432e00ff27b3c4e488bc12d8149cc4f0583cb71
|
||||
‡
|
||||
Wapp\src\main\java\com\example\administrator\myapplication\adapter\BgPicGridAdapter.java,0\3\037b293928bff3f763d72038512124d16aebd627
|
||||
<EFBFBD>
|
||||
Qapp\src\main\java\com\example\administrator\myapplication\ui\SettingFragment.java,9\f\9f49ae81d31735cbb5ea0dec8c22fb85771170ad
|
||||
|
||||
Oapp\src\main\java\com\example\administrator\myapplication\ui\LoginActivity.java,d\9\d9f0b00bd9259256a0cc6a48eb4c59665266c4ea
|
||||
‚
|
||||
Rapp\src\main\java\com\example\administrator\myapplication\ui\RegisterActivity.java,d\5\d5b72c9513d313bcf937771f4e19798894789154
|
|
@ -35,6 +35,8 @@ android {
|
|||
// 防止在发布的时候出现因MissingTranslation导致Build Failed!
|
||||
disable 'MissingTranslation'
|
||||
}
|
||||
aaptOptions.cruncherEnabled = false
|
||||
aaptOptions.useNewCruncher = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -45,7 +47,6 @@ dependencies {
|
|||
compile 'com.android.support:appcompat-v7:26.+'
|
||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||
compile 'com.jakewharton:butterknife:8.2.1'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
compile 'com.android.support:design:26.+'
|
||||
compile 'com.android.support:support-v4:26.+'
|
||||
compile 'com.android.support:support-vector-drawable:26.+'
|
||||
|
@ -56,4 +57,5 @@ dependencies {
|
|||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2'
|
||||
compile 'com.github.clans:fab:1.6.1'
|
||||
testCompile 'junit:junit:4.12'
|
||||
apt 'com.jakewharton:butterknife-compiler:8.2.1'
|
||||
}
|
||||
|
|
|
@ -1,43 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.administrator.myapplication">
|
||||
package="com.example.administrator.myapplication"
|
||||
android:versionCode="1"
|
||||
android:versionName="2.1.0">
|
||||
|
||||
<!-- To auto-complete the email text field in the login form with the user's emails -->
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.READ_PROFILE"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!--获取GSM(2g)、WCDMA(联通3g)等网络状态的信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!--获取wifi网络状态的信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<!--允许读取手机状态 用于创建BmobInstallation-->
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
|
||||
|
||||
<!--获取sd卡写的权限,用于文件上传和下载-->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- UIL框架所需的权限 -->
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
|
||||
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:icon="@mipmap/app_icon"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.LoginActivity"
|
||||
android:label="@string/title_activity_login">
|
||||
4
|
||||
android:name="com.example.administrator.myapplication.ui.WelcomeActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
|
||||
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.NoteEditActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="vnd.android.cursor.item/text_note" />
|
||||
<data android:mimeType="vnd.android.cursor.item/call_note" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
<activity android:name=".ui.SignActivity"/>
|
||||
<activity android:name=".ui.ListActivity"/>
|
||||
<activity android:name=".ui.SearchActivity">
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.SetLockActivity"></activity>
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:label="@string/app_name"></activity>
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.UnLockActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity android:name=".ui.EditImages">
|
||||
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.LoginActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity android:name=".ui.ScanImages">
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.UserInfoActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity android:name=".ui.ImagesDisplay">
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.RegisterActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
<activity android:name=".ui.EditNotes">
|
||||
</activity>
|
||||
<activity android:name=".ui.WelcomeActivity">
|
||||
<activity
|
||||
android:name="com.example.administrator.myapplication.ui.AlarmAlertActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
android:name="com.example.administrator.myapplication.ui.NoteEditFragment$AlarmReceiver"
|
||||
android:process=":remote" >
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
<!-- android:theme="@style/AppTheme.NoActionBar"-->
|
|
@ -5,9 +5,9 @@ import android.database.Cursor;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
||||
import com.htq.baidu.coolnote.entity.NotebookData;
|
||||
import com.htq.baidu.coolnote.utils.AccountUtils;
|
||||
import com.htq.baidu.coolnote.utils.StringUtils;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -7,12 +7,12 @@ import android.util.Log;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.htq.baidu.coolnote.R;
|
||||
import com.htq.baidu.coolnote.app.BaseApplication;
|
||||
import com.htq.baidu.coolnote.utils.AccountUtils;
|
||||
import com.htq.baidu.coolnote.utils.BmobConstants;
|
||||
import com.htq.baidu.coolnote.utils.ImageLoadOptions;
|
||||
import com.htq.baidu.coolnote.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.app.BaseApplication;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.BmobConstants;
|
||||
import com.example.administrator.myapplication.utils.ImageLoadOptions;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/11.
|
||||
*/
|
||||
public class AboutAppFragment extends Fragment {
|
||||
private View baseView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
baseView=inflater.inflate(R.layout.about_me_fragment, null);
|
||||
initView();
|
||||
return baseView;
|
||||
|
||||
}
|
||||
private void initView()
|
||||
{
|
||||
TextView aboutMeTv=(TextView) baseView.findViewById(R.id.about_me_tv);
|
||||
Linkify.addLinks(aboutMeTv, Linkify.ALL);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnDismissListener;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
|
||||
private long mNoteId;
|
||||
private String mSnippet;
|
||||
private static final int SNIPPET_PREW_MAX_LEN = 60;
|
||||
MediaPlayer mPlayer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
final Window win = getWindow();
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
|
||||
if (!isScreenOn()) {
|
||||
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
||||
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
|
||||
}
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
||||
try {
|
||||
// mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
|
||||
mSnippet = intent.getStringExtra(Constants.ALART_CONTENT);//DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
|
||||
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ?( mSnippet.substring(0,
|
||||
SNIPPET_PREW_MAX_LEN) + "...")
|
||||
: mSnippet;
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
mPlayer = new MediaPlayer();
|
||||
// if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
|
||||
showActionDialog();
|
||||
playAlarmSound();
|
||||
// } else {
|
||||
// finish();
|
||||
// }
|
||||
}
|
||||
|
||||
private boolean isScreenOn() {
|
||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
return pm.isScreenOn();
|
||||
}
|
||||
|
||||
private void playAlarmSound() {
|
||||
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
|
||||
|
||||
int silentModeStreams = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
|
||||
|
||||
if ((silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0) {
|
||||
mPlayer.setAudioStreamType(silentModeStreams);
|
||||
} else {
|
||||
mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
|
||||
}
|
||||
try {
|
||||
mPlayer.setDataSource(this, url);
|
||||
mPlayer.prepare();
|
||||
mPlayer.setLooping(true);
|
||||
mPlayer.start();
|
||||
} catch (IllegalArgumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IllegalStateException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void showActionDialog() {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setTitle(R.string.app_name);
|
||||
dialog.setMessage(mSnippet);
|
||||
dialog.setPositiveButton(R.string.notealert_cancle, this);
|
||||
if (isScreenOn()) {
|
||||
dialog.setNegativeButton(R.string.notealert_look, this);
|
||||
}
|
||||
dialog.show().setOnDismissListener(this);
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_NEGATIVE:
|
||||
Intent intent = new Intent(this, NoteEditActivity.class);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(Intent.EXTRA_UID, mNoteId);
|
||||
startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
stopAlarmSound();
|
||||
finish();
|
||||
}
|
||||
|
||||
private void stopAlarmSound() {
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stop();
|
||||
mPlayer.release();
|
||||
mPlayer = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.adapter.BgPicGridAdapter;
|
||||
import com.example.administrator.myapplication.entity.BgPicEntity;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/11.
|
||||
*/
|
||||
public class ChangeBgFragment extends Fragment {
|
||||
|
||||
private List<BgPicEntity> mBgPicList;
|
||||
private View baseView;
|
||||
private GridView mGridView;
|
||||
private BgPicGridAdapter mBgPicAdapter;
|
||||
private SystemUtils systemUtils;
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
baseView = inflater.inflate(R.layout.fragment_change_background, null);
|
||||
initBackgroundPic();
|
||||
initView();
|
||||
return baseView;
|
||||
}
|
||||
private void initView()
|
||||
{
|
||||
|
||||
mGridView = (GridView) baseView.findViewById(R.id.change_background_grid);
|
||||
mBgPicAdapter = new BgPicGridAdapter(getActivity(),mBgPicList);
|
||||
mGridView.setOnItemClickListener(gridItemClickListener);
|
||||
mGridView.setAdapter(mBgPicAdapter);
|
||||
|
||||
}
|
||||
private void initBackgroundPic()
|
||||
{
|
||||
AssetManager am = getActivity().getAssets();
|
||||
try {
|
||||
String[] drawableList = am.list("bkgs");
|
||||
mBgPicList = new ArrayList<BgPicEntity>();
|
||||
for (String path : drawableList) {
|
||||
BgPicEntity bg = new BgPicEntity();
|
||||
InputStream is = am.open("bkgs/" + path);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
bg.path = path;
|
||||
bg.bitmap = bitmap;
|
||||
mBgPicList.add(bg);
|
||||
is.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AdapterView.OnItemClickListener gridItemClickListener=new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
String path = ((BgPicEntity) mBgPicAdapter.getItem(position)).path;
|
||||
|
||||
systemUtils = new SystemUtils(getActivity());
|
||||
systemUtils.saveBgPicPath(path);
|
||||
Bitmap bitmap = systemUtils.getBitmapByPath(getActivity(), path);
|
||||
if (bitmap != null) {
|
||||
((MainActivity) getActivity()).drawer.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
|
||||
mBgPicAdapter.notifyDataSetChanged();
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,472 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.NumberPicker;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/13.
|
||||
*/
|
||||
public class DateTimePicker extends FrameLayout {
|
||||
|
||||
private static final boolean DEFAULT_ENABLE_STATE = true;
|
||||
|
||||
private static final int HOURS_IN_HALF_DAY = 12;
|
||||
private static final int HOURS_IN_ALL_DAY = 24;
|
||||
private static final int DAYS_IN_ALL_WEEK = 7;
|
||||
private static final int DATE_SPINNER_MIN_VAL = 0;
|
||||
private static final int DATE_SPINNER_MAX_VAL = DAYS_IN_ALL_WEEK - 1;
|
||||
private static final int HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW = 0;
|
||||
private static final int HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW = 23;
|
||||
private static final int HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW = 1;
|
||||
private static final int HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW = 12;
|
||||
private static final int MINUT_SPINNER_MIN_VAL = 0;
|
||||
private static final int MINUT_SPINNER_MAX_VAL = 59;
|
||||
private static final int AMPM_SPINNER_MIN_VAL = 0;
|
||||
private static final int AMPM_SPINNER_MAX_VAL = 1;
|
||||
|
||||
private final NumberPicker mDateSpinner;
|
||||
private final NumberPicker mHourSpinner;
|
||||
private final NumberPicker mMinuteSpinner;
|
||||
private final NumberPicker mAmPmSpinner;
|
||||
private Calendar mDate;
|
||||
|
||||
private String[] mDateDisplayValues = new String[DAYS_IN_ALL_WEEK];
|
||||
|
||||
private boolean mIsAm;
|
||||
|
||||
private boolean mIs24HourView;
|
||||
|
||||
private boolean mIsEnabled = DEFAULT_ENABLE_STATE;
|
||||
|
||||
private boolean mInitialising;
|
||||
|
||||
private OnDateTimeChangedListener mOnDateTimeChangedListener;
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
mDate.add(Calendar.DAY_OF_YEAR, newVal - oldVal);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
boolean isDateChanged = false;
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if (!mIs24HourView) {
|
||||
if (!mIsAm && oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
isDateChanged = true;
|
||||
} else if (mIsAm && oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1);
|
||||
isDateChanged = true;
|
||||
}
|
||||
if (oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY ||
|
||||
oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
|
||||
mIsAm = !mIsAm;
|
||||
updateAmPmControl();
|
||||
}
|
||||
} else {
|
||||
if (oldVal == HOURS_IN_ALL_DAY - 1 && newVal == 0) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
isDateChanged = true;
|
||||
} else if (oldVal == 0 && newVal == HOURS_IN_ALL_DAY - 1) {
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -1);
|
||||
isDateChanged = true;
|
||||
}
|
||||
}
|
||||
int newHour = mHourSpinner.getValue() % HOURS_IN_HALF_DAY + (mIsAm ? 0 : HOURS_IN_HALF_DAY);
|
||||
mDate.set(Calendar.HOUR_OF_DAY, newHour);
|
||||
onDateTimeChanged();
|
||||
if (isDateChanged) {
|
||||
setCurrentYear(cal.get(Calendar.YEAR));
|
||||
setCurrentMonth(cal.get(Calendar.MONTH));
|
||||
setCurrentDay(cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
int minValue = mMinuteSpinner.getMinValue();
|
||||
int maxValue = mMinuteSpinner.getMaxValue();
|
||||
int offset = 0;
|
||||
if (oldVal == maxValue && newVal == minValue) {
|
||||
offset += 1;
|
||||
} else if (oldVal == minValue && newVal == maxValue) {
|
||||
offset -= 1;
|
||||
}
|
||||
if (offset != 0) {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, offset);
|
||||
mHourSpinner.setValue(getCurrentHour());
|
||||
updateDateControl();
|
||||
int newHour = getCurrentHourOfDay();
|
||||
if (newHour >= HOURS_IN_HALF_DAY) {
|
||||
mIsAm = false;
|
||||
updateAmPmControl();
|
||||
} else {
|
||||
mIsAm = true;
|
||||
updateAmPmControl();
|
||||
}
|
||||
}
|
||||
mDate.set(Calendar.MINUTE, newVal);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
|
||||
mIsAm = !mIsAm;
|
||||
if (mIsAm) {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, -HOURS_IN_HALF_DAY);
|
||||
} else {
|
||||
mDate.add(Calendar.HOUR_OF_DAY, HOURS_IN_HALF_DAY);
|
||||
}
|
||||
updateAmPmControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public interface OnDateTimeChangedListener {
|
||||
void onDateTimeChanged(DateTimePicker view, int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute);
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context) {
|
||||
this(context, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context, long date) {
|
||||
this(context, date, DateFormat.is24HourFormat(context));
|
||||
}
|
||||
|
||||
public DateTimePicker(Context context, long date, boolean is24HourView) {
|
||||
super(context);
|
||||
mDate = Calendar.getInstance();
|
||||
mInitialising = true;
|
||||
mIsAm = getCurrentHourOfDay() >= HOURS_IN_HALF_DAY;
|
||||
inflate(context, R.layout.datetime_picker, this);
|
||||
|
||||
mDateSpinner = (NumberPicker) findViewById(R.id.date);
|
||||
mDateSpinner.setMinValue(DATE_SPINNER_MIN_VAL);
|
||||
mDateSpinner.setMaxValue(DATE_SPINNER_MAX_VAL);
|
||||
mDateSpinner.setOnValueChangedListener(mOnDateChangedListener);
|
||||
|
||||
mHourSpinner = (NumberPicker) findViewById(R.id.hour);
|
||||
mHourSpinner.setOnValueChangedListener(mOnHourChangedListener);
|
||||
mMinuteSpinner = (NumberPicker) findViewById(R.id.minute);
|
||||
mMinuteSpinner.setMinValue(MINUT_SPINNER_MIN_VAL);
|
||||
mMinuteSpinner.setMaxValue(MINUT_SPINNER_MAX_VAL);
|
||||
mMinuteSpinner.setOnLongPressUpdateInterval(100);
|
||||
mMinuteSpinner.setOnValueChangedListener(mOnMinuteChangedListener);
|
||||
|
||||
String[] stringsForAmPm = new DateFormatSymbols().getAmPmStrings();
|
||||
mAmPmSpinner = (NumberPicker) findViewById(R.id.amPm);
|
||||
mAmPmSpinner.setMinValue(AMPM_SPINNER_MIN_VAL);
|
||||
mAmPmSpinner.setMaxValue(AMPM_SPINNER_MAX_VAL);
|
||||
mAmPmSpinner.setDisplayedValues(stringsForAmPm);
|
||||
mAmPmSpinner.setOnValueChangedListener(mOnAmPmChangedListener);
|
||||
|
||||
// update controls to initial state
|
||||
updateDateControl();
|
||||
updateHourControl();
|
||||
updateAmPmControl();
|
||||
|
||||
set24HourView(is24HourView);
|
||||
|
||||
// set to current time
|
||||
setCurrentDate(date);
|
||||
|
||||
setEnabled(isEnabled());
|
||||
|
||||
// set the content descriptions
|
||||
mInitialising = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (mIsEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
super.setEnabled(enabled);
|
||||
mDateSpinner.setEnabled(enabled);
|
||||
mMinuteSpinner.setEnabled(enabled);
|
||||
mHourSpinner.setEnabled(enabled);
|
||||
mAmPmSpinner.setEnabled(enabled);
|
||||
mIsEnabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mIsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current date in millis
|
||||
*
|
||||
* @return the current date in millis
|
||||
*/
|
||||
public long getCurrentDateInTimeMillis() {
|
||||
return mDate.getTimeInMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current date
|
||||
*
|
||||
* @param date The current date in millis
|
||||
*/
|
||||
public void setCurrentDate(long date) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(date);
|
||||
setCurrentDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
|
||||
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current date
|
||||
*
|
||||
* @param year The current year
|
||||
* @param month The current month
|
||||
* @param dayOfMonth The current dayOfMonth
|
||||
* @param hourOfDay The current hourOfDay
|
||||
* @param minute The current minute
|
||||
*/
|
||||
public void setCurrentDate(int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute) {
|
||||
setCurrentYear(year);
|
||||
setCurrentMonth(month);
|
||||
setCurrentDay(dayOfMonth);
|
||||
setCurrentHour(hourOfDay);
|
||||
setCurrentMinute(minute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current year
|
||||
*
|
||||
* @return The current year
|
||||
*/
|
||||
public int getCurrentYear() {
|
||||
return mDate.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current year
|
||||
*
|
||||
* @param year The current year
|
||||
*/
|
||||
public void setCurrentYear(int year) {
|
||||
if (!mInitialising && year == getCurrentYear()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.YEAR, year);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current month in the year
|
||||
*
|
||||
* @return The current month in the year
|
||||
*/
|
||||
public int getCurrentMonth() {
|
||||
return mDate.get(Calendar.MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current month in the year
|
||||
*
|
||||
* @param month The month in the year
|
||||
*/
|
||||
public void setCurrentMonth(int month) {
|
||||
if (!mInitialising && month == getCurrentMonth()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.MONTH, month);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current day of the month
|
||||
*
|
||||
* @return The day of the month
|
||||
*/
|
||||
public int getCurrentDay() {
|
||||
return mDate.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current day of the month
|
||||
*
|
||||
* @param dayOfMonth The day of the month
|
||||
*/
|
||||
public void setCurrentDay(int dayOfMonth) {
|
||||
if (!mInitialising && dayOfMonth == getCurrentDay()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
updateDateControl();
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current hour in 24 hour mode, in the range (0~23)
|
||||
* @return The current hour in 24 hour mode
|
||||
*/
|
||||
public int getCurrentHourOfDay() {
|
||||
return mDate.get(Calendar.HOUR_OF_DAY);
|
||||
}
|
||||
|
||||
private int getCurrentHour() {
|
||||
if (mIs24HourView){
|
||||
return getCurrentHourOfDay();
|
||||
} else {
|
||||
int hour = getCurrentHourOfDay();
|
||||
if (hour > HOURS_IN_HALF_DAY) {
|
||||
return hour - HOURS_IN_HALF_DAY;
|
||||
} else {
|
||||
return hour == 0 ? HOURS_IN_HALF_DAY : hour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current hour in 24 hour mode, in the range (0~23)
|
||||
*
|
||||
* @param hourOfDay
|
||||
*/
|
||||
public void setCurrentHour(int hourOfDay) {
|
||||
if (!mInitialising && hourOfDay == getCurrentHourOfDay()) {
|
||||
return;
|
||||
}
|
||||
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
if (!mIs24HourView) {
|
||||
if (hourOfDay >= HOURS_IN_HALF_DAY) {
|
||||
mIsAm = false;
|
||||
if (hourOfDay > HOURS_IN_HALF_DAY) {
|
||||
hourOfDay -= HOURS_IN_HALF_DAY;
|
||||
}
|
||||
} else {
|
||||
mIsAm = true;
|
||||
if (hourOfDay == 0) {
|
||||
hourOfDay = HOURS_IN_HALF_DAY;
|
||||
}
|
||||
}
|
||||
updateAmPmControl();
|
||||
}
|
||||
mHourSpinner.setValue(hourOfDay);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currentMinute
|
||||
*
|
||||
* @return The Current Minute
|
||||
*/
|
||||
public int getCurrentMinute() {
|
||||
return mDate.get(Calendar.MINUTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current minute
|
||||
*/
|
||||
public void setCurrentMinute(int minute) {
|
||||
if (!mInitialising && minute == getCurrentMinute()) {
|
||||
return;
|
||||
}
|
||||
mMinuteSpinner.setValue(minute);
|
||||
mDate.set(Calendar.MINUTE, minute);
|
||||
onDateTimeChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this is in 24 hour view else false.
|
||||
*/
|
||||
public boolean is24HourView () {
|
||||
return mIs24HourView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether in 24 hour or AM/PM mode.
|
||||
*
|
||||
* @param is24HourView True for 24 hour mode. False for AM/PM mode.
|
||||
*/
|
||||
public void set24HourView(boolean is24HourView) {
|
||||
if (mIs24HourView == is24HourView) {
|
||||
return;
|
||||
}
|
||||
mIs24HourView = is24HourView;
|
||||
mAmPmSpinner.setVisibility(is24HourView ? View.GONE : View.VISIBLE);
|
||||
int hour = getCurrentHourOfDay();
|
||||
updateHourControl();
|
||||
setCurrentHour(hour);
|
||||
updateAmPmControl();
|
||||
}
|
||||
|
||||
private void updateDateControl() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(mDate.getTimeInMillis());
|
||||
cal.add(Calendar.DAY_OF_YEAR, -DAYS_IN_ALL_WEEK / 2 - 1);
|
||||
mDateSpinner.setDisplayedValues(null);
|
||||
for (int i = 0; i < DAYS_IN_ALL_WEEK; ++i) {
|
||||
cal.add(Calendar.DAY_OF_YEAR, 1);
|
||||
mDateDisplayValues[i] = (String) DateFormat.format("MM.dd EEEE", cal);
|
||||
}
|
||||
mDateSpinner.setDisplayedValues(mDateDisplayValues);
|
||||
mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
|
||||
mDateSpinner.invalidate();
|
||||
}
|
||||
|
||||
private void updateAmPmControl() {
|
||||
if (mIs24HourView) {
|
||||
mAmPmSpinner.setVisibility(View.GONE);
|
||||
} else {
|
||||
int index = mIsAm ? Calendar.AM : Calendar.PM;
|
||||
mAmPmSpinner.setValue(index);
|
||||
mAmPmSpinner.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHourControl() {
|
||||
if (mIs24HourView) {
|
||||
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW);
|
||||
mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW);
|
||||
} else {
|
||||
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW);
|
||||
mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the callback that indicates the 'Set' button has been pressed.
|
||||
* @param callback the callback, if null will do nothing
|
||||
*/
|
||||
public void setOnDateTimeChangedListener(OnDateTimeChangedListener callback) {
|
||||
mOnDateTimeChangedListener = callback;
|
||||
}
|
||||
|
||||
private void onDateTimeChanged() {
|
||||
if (mOnDateTimeChangedListener != null) {
|
||||
mOnDateTimeChangedListener.onDateTimeChanged(this, getCurrentYear(),
|
||||
getCurrentMonth(), getCurrentDay(), getCurrentHourOfDay(), getCurrentMinute());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.text.format.DateFormat;
|
||||
import android.text.format.DateUtils;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/13.
|
||||
*/
|
||||
public class DateTimePickerDialog extends AlertDialog implements DialogInterface.OnClickListener {
|
||||
|
||||
private Calendar mDate = Calendar.getInstance();
|
||||
private boolean mIs24HourView;
|
||||
private OnDateTimeSetListener mOnDateTimeSetListener;
|
||||
private DateTimePicker mDateTimePicker;
|
||||
|
||||
public interface OnDateTimeSetListener {
|
||||
void OnDateTimeSet(AlertDialog dialog, long date);
|
||||
}
|
||||
|
||||
public DateTimePickerDialog(Context context, long date) {
|
||||
super(context);
|
||||
mDateTimePicker = new DateTimePicker(context);
|
||||
setView(mDateTimePicker);
|
||||
mDateTimePicker.setOnDateTimeChangedListener(new DateTimePicker.OnDateTimeChangedListener() {
|
||||
public void onDateTimeChanged(DateTimePicker view, int year, int month,
|
||||
int dayOfMonth, int hourOfDay, int minute) {
|
||||
mDate.set(Calendar.YEAR, year);
|
||||
mDate.set(Calendar.MONTH, month);
|
||||
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
mDate.set(Calendar.MINUTE, minute);
|
||||
updateTitle(mDate.getTimeInMillis());
|
||||
}
|
||||
});
|
||||
mDate.setTimeInMillis(date);
|
||||
mDate.set(Calendar.SECOND, 0);
|
||||
mDateTimePicker.setCurrentDate(mDate.getTimeInMillis());
|
||||
setButton(context.getString(R.string.datetime_dialog_ok), this);
|
||||
setButton2(context.getString(R.string.datetime_dialog_cancel), (OnClickListener) null);
|
||||
set24HourView(DateFormat.is24HourFormat(this.getContext()));
|
||||
updateTitle(mDate.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void set24HourView(boolean is24HourView) {
|
||||
mIs24HourView = is24HourView;
|
||||
}
|
||||
|
||||
public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) {
|
||||
mOnDateTimeSetListener = callBack;
|
||||
}
|
||||
|
||||
private void updateTitle(long date) {
|
||||
int flag =
|
||||
DateUtils.FORMAT_SHOW_YEAR |
|
||||
DateUtils.FORMAT_SHOW_DATE |
|
||||
DateUtils.FORMAT_SHOW_TIME;
|
||||
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
|
||||
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface arg0, int arg1) {
|
||||
if (mOnDateTimeSetListener != null) {
|
||||
mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,367 +1,133 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.app.LoaderManager.LoaderCallbacks;
|
||||
|
||||
import android.content.CursorLoader;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import android.os.Build;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.MD5Util;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.Manifest.permission.READ_CONTACTS;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
/**
|
||||
* A login screen that offers login via email/password.
|
||||
* Created by htq on 2016/9/3.
|
||||
*/
|
||||
public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<Cursor> {
|
||||
public class LoginActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
/**
|
||||
* Id to identity READ_CONTACTS permission request.
|
||||
*/
|
||||
private static final int REQUEST_READ_CONTACTS = 0;
|
||||
@BindView(R.id.btn_login)
|
||||
Button loginBtn;
|
||||
@BindView(R.id.btn_register)
|
||||
TextView registerBtn;
|
||||
@BindView(R.id.login_name)
|
||||
EditText loginName;
|
||||
@BindView(R.id.login_pwd)
|
||||
EditText loginPwd;
|
||||
|
||||
/**
|
||||
* A dummy authentication store containing known user names and passwords.
|
||||
* TODO: remove after connecting to a real authentication system.
|
||||
*/
|
||||
private static final String[] DUMMY_CREDENTIALS = new String[]{
|
||||
"foo@example.com:hello", "bar@example.com:world"
|
||||
};
|
||||
/**
|
||||
* Keep track of the login task to ensure we can cancel it if requested.
|
||||
*/
|
||||
private UserLoginTask mAuthTask = null;
|
||||
|
||||
// UI references.
|
||||
private AutoCompleteTextView mEmailView;
|
||||
private EditText mPasswordView;
|
||||
private View mProgressView;
|
||||
private View mLoginFormView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
/*set it to be full screen*/
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_login);
|
||||
// Set up the login form.
|
||||
findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
ButterKnife.bind(this);
|
||||
initDrawableSize();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initDrawableSize()
|
||||
{
|
||||
Drawable accountDraw=getResources().getDrawable(R.drawable.login_icon_account);
|
||||
accountDraw.setBounds(0,0,45,45);
|
||||
Drawable passwordDraw=getResources().getDrawable(R.drawable.login_icon_password);
|
||||
passwordDraw.setBounds(0,0,45,45);
|
||||
loginName.setCompoundDrawables(accountDraw,null,null,null);
|
||||
loginPwd.setCompoundDrawables(passwordDraw,null,null,null);
|
||||
}
|
||||
@OnClick({R.id.btn_login, R.id.btn_register})
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(LoginActivity.this, SignActivity.class));
|
||||
switch (v.getId()) {
|
||||
case R.id.btn_login:
|
||||
login();
|
||||
break;
|
||||
case R.id.btn_register:
|
||||
goToRegisterActivity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void login() {
|
||||
final String name=loginName.getText().toString();
|
||||
final String pwd=loginPwd.getText().toString();
|
||||
final ProgressDialog progress = new ProgressDialog(
|
||||
LoginActivity.this);
|
||||
progress.setMessage("正在登陆...");
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.show();
|
||||
|
||||
User user = new User();
|
||||
user.setUsername(name);
|
||||
user.setPassword(MD5Util.MD5(pwd));
|
||||
|
||||
// user.setPassword(pwd);
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
user.login(this, new SaveListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
progress.dismiss();
|
||||
// Snackbar.make(loginBtn,"登录成功!",Snackbar.LENGTH_SHORT).show();
|
||||
//将用户信息保存至本地
|
||||
SPUtils.put(LoginActivity.this,"user_name",name);
|
||||
SPUtils.put(LoginActivity.this,"pwd",MD5Util.MD5(pwd));
|
||||
User user2;
|
||||
user2 = BmobUser.getCurrentUser(LoginActivity.this, User.class);
|
||||
//将登陆信息保存本地
|
||||
AccountUtils.saveUserInfos(LoginActivity.this, user2, MD5Util.MD5(pwd));
|
||||
goToHomeActivity();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
progress.dismiss();
|
||||
Toast.makeText(LoginActivity.this,msg, Toast.LENGTH_LONG).show();
|
||||
// Snackbar.make(loginBtn,"登录失败!",Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.log_in_button).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
startActivity(new Intent(LoginActivity.this, ListActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
mEmailView = (AutoCompleteTextView) findViewById(R.id.account);
|
||||
populateAutoComplete();
|
||||
|
||||
mPasswordView = (EditText) findViewById(R.id.password);
|
||||
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
|
||||
if (id == R.id.login || id == EditorInfo.IME_NULL) {
|
||||
attemptLogin();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Button mEmailSignInButton = (Button) findViewById(R.id.log_in_button);
|
||||
mEmailSignInButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
attemptLogin();
|
||||
}
|
||||
});
|
||||
|
||||
mLoginFormView = findViewById(R.id.login_form);
|
||||
mProgressView = findViewById(R.id.login_progress);
|
||||
}
|
||||
|
||||
private void populateAutoComplete() {
|
||||
if (!mayRequestContacts()) {
|
||||
return;
|
||||
private void goToHomeActivity() {
|
||||
|
||||
Intent intent=new Intent(LoginActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
this.finish();
|
||||
}
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
private boolean mayRequestContacts() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return true;
|
||||
}
|
||||
if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
||||
return true;
|
||||
}
|
||||
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
|
||||
Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(android.R.string.ok, new View.OnClickListener() {
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
public void onClick(View v) {
|
||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback received when a permissions request has been completed.
|
||||
*/
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
if (requestCode == REQUEST_READ_CONTACTS) {
|
||||
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
populateAutoComplete();
|
||||
private void goToRegisterActivity() {
|
||||
Intent intent=new Intent(LoginActivity.this,RegisterActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempts to sign in or register the account specified by the login form.
|
||||
* If there are form errors (invalid email, missing fields, etc.), the
|
||||
* errors are presented and no actual login attempt is made.
|
||||
*/
|
||||
private void attemptLogin() {
|
||||
if (mAuthTask != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset errors.
|
||||
mEmailView.setError(null);
|
||||
mPasswordView.setError(null);
|
||||
|
||||
// Store values at the time of the login attempt.
|
||||
String email = mEmailView.getText().toString();
|
||||
String password = mPasswordView.getText().toString();
|
||||
|
||||
boolean cancel = false;
|
||||
View focusView = null;
|
||||
|
||||
// Check for a valid password, if the user entered one.
|
||||
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
|
||||
mPasswordView.setError(getString(R.string.error_invalid_password));
|
||||
focusView = mPasswordView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
// Check for a valid email address.
|
||||
if (TextUtils.isEmpty(email)) {
|
||||
mEmailView.setError(getString(R.string.error_field_required));
|
||||
focusView = mEmailView;
|
||||
cancel = true;
|
||||
} else if (!isEmailValid(email)) {
|
||||
mEmailView.setError(getString(R.string.error_invalid_email));
|
||||
focusView = mEmailView;
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
// There was an error; don't attempt login and focus the first
|
||||
// form field with an error.
|
||||
focusView.requestFocus();
|
||||
} else {
|
||||
// Show a progress spinner, and kick off a background task to
|
||||
// perform the user login attempt.
|
||||
showProgress(true);
|
||||
mAuthTask = new UserLoginTask(email, password);
|
||||
mAuthTask.execute((Void) null);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmailValid(String email) {
|
||||
//TODO: Replace this with your own logic
|
||||
return email.contains("@");
|
||||
}
|
||||
|
||||
private boolean isPasswordValid(String password) {
|
||||
//TODO: Replace this with your own logic
|
||||
return password.length() > 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the progress UI and hides the login form.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||
private void showProgress(final boolean show) {
|
||||
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
|
||||
// for very easy animations. If available, use these APIs to fade-in
|
||||
// the progress spinner.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
|
||||
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
|
||||
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mProgressView.animate().setDuration(shortAnimTime).alpha(
|
||||
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// The ViewPropertyAnimator APIs are not available, so simply show
|
||||
// and hide the relevant UI components.
|
||||
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
return new CursorLoader(this,
|
||||
// Retrieve data rows for the device user's 'profile' contact.
|
||||
Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
|
||||
ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
|
||||
|
||||
// Select only email addresses.
|
||||
ContactsContract.Contacts.Data.MIMETYPE +
|
||||
" = ?", new String[]{ContactsContract.CommonDataKinds.Email
|
||||
.CONTENT_ITEM_TYPE},
|
||||
|
||||
// Show primary email addresses first. Note that there won't be
|
||||
// a primary email address if the user hasn't specified one.
|
||||
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
||||
List<String> emails = new ArrayList<>();
|
||||
cursor.moveToFirst();
|
||||
while (!cursor.isAfterLast()) {
|
||||
emails.add(cursor.getString(ProfileQuery.ADDRESS));
|
||||
cursor.moveToNext();
|
||||
}
|
||||
|
||||
addEmailsToAutoComplete(emails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> cursorLoader) {
|
||||
|
||||
}
|
||||
|
||||
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
|
||||
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
|
||||
ArrayAdapter<String> adapter =
|
||||
new ArrayAdapter<>(LoginActivity.this,
|
||||
android.R.layout.simple_dropdown_item_1line, emailAddressCollection);
|
||||
|
||||
mEmailView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
private interface ProfileQuery {
|
||||
String[] PROJECTION = {
|
||||
ContactsContract.CommonDataKinds.Email.ADDRESS,
|
||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
||||
};
|
||||
|
||||
int ADDRESS = 0;
|
||||
int IS_PRIMARY = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an asynchronous login/registration task used to authenticate
|
||||
* the user.
|
||||
*/
|
||||
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final String mEmail;
|
||||
private final String mPassword;
|
||||
|
||||
UserLoginTask(String email, String password) {
|
||||
mEmail = email;
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
// TODO: attempt authentication against a network service.
|
||||
|
||||
try {
|
||||
// Simulate network access.
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String credential : DUMMY_CREDENTIALS) {
|
||||
String[] pieces = credential.split(":");
|
||||
if (pieces[0].equals(mEmail)) {
|
||||
// Account exists, return true if the password matches.
|
||||
return pieces[1].equals(mPassword);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: register the new account here.
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Boolean success) {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
|
||||
if (success) {
|
||||
finish();
|
||||
} else {
|
||||
mPasswordView.setError(getString(R.string.error_incorrect_password));
|
||||
mPasswordView.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
mAuthTask = null;
|
||||
showProgress(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,245 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.UpdataEvent;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
//此处不能定义为全局的,否则在调用changFragment函数时会报java.lang.IllegalStateException: commit already called
|
||||
// private FragmentManager fm=getSupportFragmentManager();
|
||||
// private FragmentTransaction ft=fm.beginTransaction();
|
||||
|
||||
protected FloatingActionButton fab;
|
||||
private boolean isFirstUse;
|
||||
protected DrawerLayout drawer;
|
||||
private long mBackPressedTime=0;
|
||||
private NoteBookFragment noteBookFragment;
|
||||
private ImageView headIcon;
|
||||
private View baseView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
isFirstUse=new SystemUtils(MainActivity.this).isFirstUse();
|
||||
if(isFirstUse) {
|
||||
initIntruduceData();
|
||||
}
|
||||
initMainFragment();
|
||||
initUi();
|
||||
initHead();
|
||||
initBgPic();
|
||||
// User.refreshAvatarFromLocal(BmobConstants.MyAvatarDir+"avatarIcon.png",headIcon);
|
||||
//注册EventBus
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于刷新头像的
|
||||
* @param event
|
||||
*/
|
||||
@Subscribe
|
||||
public void onEventBackgroundThread(UpdataEvent event) {
|
||||
if (event.getType() == UpdataEvent.UPDATE_USER_INFOS) {
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
//Snackbar.make(headIcon,"update",Snackbar.LENGTH_LONG).show();
|
||||
// mPresenter.setUserNickName();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initUi()
|
||||
{
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// toggleActionButton();
|
||||
Intent intent = new Intent(MainActivity.this, NoteEditActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(NoteEditFragment.NOTE_FROMWHERE_KEY,
|
||||
NoteEditFragment.QUICK_DIALOG);
|
||||
intent.putExtra(Constants.BUNDLE_KEY_ARGS, bundle);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.setDrawerListener(toggle);
|
||||
toggle.syncState();
|
||||
|
||||
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
baseView= navigationView.getHeaderView(0);
|
||||
headIcon= (ImageView)baseView.findViewById(R.id.imageView);
|
||||
|
||||
headIcon.setOnClickListener(headIconOnTouchListener);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private View.OnClickListener headIconOnTouchListener=new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View vt) {
|
||||
|
||||
Intent intent = new Intent(MainActivity.this, UserInfoActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private void initBgPic()
|
||||
{
|
||||
|
||||
SystemUtils systemUtils=new SystemUtils(this);
|
||||
String path=systemUtils.getPath();
|
||||
if(path!=null) {
|
||||
Bitmap bitmap = systemUtils.getBitmapByPath(this, path);
|
||||
if (bitmap != null) {
|
||||
drawer.setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private void initHead()
|
||||
{
|
||||
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
|
||||
|
||||
}
|
||||
private void initMainFragment()
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
noteBookFragment=new NoteBookFragment();
|
||||
ft.replace(R.id.main_fraglayout, noteBookFragment,null);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
|
||||
protected void changeFragment(Fragment fragment)
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
ft.replace(R.id.main_fraglayout, fragment,null);
|
||||
// ft.addToBackStack(fragment.toString());
|
||||
ft.commit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initIntruduceData()
|
||||
{
|
||||
NoteDatabase noteDb= new NoteDatabase(MainActivity.this);
|
||||
noteDb.insertIntroduce(this);
|
||||
new SystemUtils(MainActivity.this).set("isFirstUse","false");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
if (drawer.isDrawerOpen(GravityCompat.START)) {
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
} else {
|
||||
long curTime = SystemClock.uptimeMillis();
|
||||
if ((curTime - mBackPressedTime) < (2 * 1000)) {
|
||||
finish();
|
||||
System.exit(0);
|
||||
} else {
|
||||
mBackPressedTime = curTime;
|
||||
Snackbar.make(drawer, "双击退出程序", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
// super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
// Handle navigation view item clicks here.
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.nav_change_bg) {
|
||||
|
||||
setTitle("更换皮肤");
|
||||
ChangeBgFragment changeBgFragment=new ChangeBgFragment();
|
||||
changeFragment(changeBgFragment);
|
||||
fab.hide();
|
||||
} else if (id == R.id.nav_home) {
|
||||
setTitle("主页");
|
||||
initMainFragment();
|
||||
|
||||
} else if (id == R.id.nav_setting) {
|
||||
setTitle("设置");
|
||||
SettingFragment settingFragment=new SettingFragment();
|
||||
changeFragment(settingFragment);
|
||||
fab.hide();
|
||||
|
||||
} else if (id == R.id.nav_share) {
|
||||
|
||||
SystemUtils.shareApp(this);
|
||||
|
||||
} else if (id == R.id.nav_about) {
|
||||
|
||||
setTitle("关于应用");
|
||||
AboutAppFragment aboutAppFragment=new AboutAppFragment();
|
||||
changeFragment(aboutAppFragment);
|
||||
fab.hide();
|
||||
}
|
||||
else if (id == R.id.nav_exit) {
|
||||
finish();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.adapter.NotebookAdapter;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.entity.OnResponseListener;
|
||||
import com.example.administrator.myapplication.entity.Response;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.HTQAnimations;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.HTQDragGridView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
|
||||
public class NoteBookFragment extends Fragment implements
|
||||
OnItemClickListener, OnRefreshListener {
|
||||
|
||||
@BindView(R.id.frag_note_list)
|
||||
HTQDragGridView mGrid;
|
||||
@BindView(R.id.frag_note_trash)
|
||||
ImageView mImgTrash;
|
||||
@BindView(R.id.swiperefreshlayout)
|
||||
SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
|
||||
private NoteDatabase noteDb;
|
||||
private List<NotebookData> datas;
|
||||
private NotebookAdapter adapter;
|
||||
private Activity aty;
|
||||
public static final int STATE_NONE = 0;
|
||||
public static final int STATE_REFRESH = 1;
|
||||
public static final int STATE_LOADMORE = 2;
|
||||
public static final int STATE_NOMORE = 3;
|
||||
public static final int STATE_PRESSNONE = 4;// 正在下拉但还没有到刷新的状态
|
||||
public static int mState = STATE_NONE;
|
||||
/**
|
||||
* 用来做更进一步人性化的防手抖策略时使用<br>
|
||||
* 比如由于手抖动上下拉菜单时拉动一部分,但又没有达到可刷新的时候,暂停一段时间,这个时候用户的逻辑应该是要移动item的。<br>
|
||||
* 其实应该还有一种根据setOnFocusChangeListener来改写的方法,我没有尝试。
|
||||
*/
|
||||
// private static final Handler mHandler = new Handler() {
|
||||
// @Override
|
||||
// public void handleMessage(android.os.Message msg) {
|
||||
// mList.setDragEnable(true);
|
||||
// };
|
||||
// };
|
||||
|
||||
/********************************* function method ******************************/
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View rootView = inflater.inflate(R.layout.fragment_note, null,
|
||||
false);
|
||||
aty = getActivity();
|
||||
ButterKnife.bind(this, rootView);
|
||||
initData();
|
||||
initView(rootView);
|
||||
if(new SystemUtils(getActivity()).isTarn())
|
||||
mGrid.setAlpha(0.55f);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
refurbish();
|
||||
((MainActivity) getActivity()).fab.show();
|
||||
//setListCanPull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
noteDb.destroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(NoteEditFragment.NOTE_FROMWHERE_KEY,
|
||||
NoteEditFragment.NOTEBOOK_ITEM);
|
||||
bundle.putSerializable(NoteEditFragment.NOTE_KEY, datas.get(position));
|
||||
|
||||
Intent intent=new Intent(getActivity(),NoteEditActivity.class);
|
||||
intent.putExtra(Constants.BUNDLE_KEY_ARGS, bundle);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***************************** initialization method ***************************/
|
||||
|
||||
|
||||
public void initData() {
|
||||
noteDb = new NoteDatabase(aty);
|
||||
datas = noteDb.query();// 查询操作,忽略耗时
|
||||
if (datas != null) {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
}
|
||||
else //如果本地无数据则尝试从服务器端获取数据
|
||||
{
|
||||
getServerData();
|
||||
}
|
||||
}
|
||||
|
||||
public void getServerData()
|
||||
{
|
||||
String userId = AccountUtils.getUserId(getActivity());
|
||||
User.getUserNotes(getActivity(), userId, new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if(response.isSucces())
|
||||
{
|
||||
datas.clear();//先将datas中的数据全部清除掉
|
||||
datas.addAll(response.getNoteItemList());
|
||||
if (datas.size() > 0) {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
|
||||
} else {
|
||||
Snackbar.make(mGrid,"暂无数据哦!赶快添加一个:)", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void initView(View view) {
|
||||
mGrid.setAdapter(adapter);
|
||||
mGrid.setOnItemClickListener(this);
|
||||
mGrid.setTrashView(mImgTrash);
|
||||
mGrid.setSelector(new ColorDrawable(Color.TRANSPARENT));
|
||||
mGrid.setOnDeleteListener(new HTQDragGridView.OnDeleteListener() {
|
||||
@Override
|
||||
public void onDelete(final int position) {
|
||||
|
||||
|
||||
// datas.get(position).setObjectId(datas.get(position).getObjectId());
|
||||
datas.get(position).deleteNoteInServe(getActivity(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if(!response.isSucces())
|
||||
{
|
||||
Toast.makeText(getActivity(),response.getMsg(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
delete(position);
|
||||
}
|
||||
});
|
||||
mGrid.setOnMoveListener(new HTQDragGridView.OnMoveListener() {
|
||||
@Override
|
||||
public void startMove() {
|
||||
mSwipeRefreshLayout.setEnabled(false);
|
||||
mImgTrash.startAnimation(HTQAnimations.getTranslateAnimation(0,
|
||||
0, mImgTrash.getTop(), 0, 500));
|
||||
mImgTrash.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishMove() {
|
||||
// setListCanPull();
|
||||
mImgTrash.setVisibility(View.INVISIBLE);
|
||||
mImgTrash.startAnimation(HTQAnimations.getTranslateAnimation(0,
|
||||
0, 0, mImgTrash.getTop(), 500));
|
||||
if (adapter.getDataChange()) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
noteDb.reset(adapter.getDatas());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancleMove() {}
|
||||
});
|
||||
|
||||
|
||||
mSwipeRefreshLayout.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
mState = STATE_PRESSNONE;
|
||||
mGrid.setDragEnable(false);
|
||||
// mHandler.sendMessageDelayed(Message.obtain(), 400);
|
||||
} else {
|
||||
mGrid.setDragEnable(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
mSwipeRefreshLayout.setOnRefreshListener(this);
|
||||
mSwipeRefreshLayout.setColorSchemeResources(
|
||||
R.color.swiperefresh_color1, R.color.swiperefresh_color2,
|
||||
R.color.swiperefresh_color3, R.color.swiperefresh_color4);
|
||||
// mEmptyLayout.setErrorType(EmptyLayout.NODATA);
|
||||
// if (!datas.isEmpty()) {
|
||||
// mEmptyLayout.setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
|
||||
/********************************* GridView method ******************************/
|
||||
|
||||
@Override
|
||||
public void onRefresh() {//同步数据,先从服务器端获取数据,然后重置到数据库中
|
||||
if (mState == STATE_REFRESH) {
|
||||
return;
|
||||
}
|
||||
// 设置顶部正在刷新
|
||||
mGrid.setSelection(0);
|
||||
setSwipeRefreshLoadingState();
|
||||
getServerData();
|
||||
adapter.refurbishData(datas);
|
||||
noteDb.reset(datas);//将结果重置到数据库
|
||||
// for(int i=0;i<datas.size();i++)
|
||||
// {
|
||||
//
|
||||
// noteDb.save(datas.get(i));
|
||||
// }
|
||||
|
||||
//refurbish();
|
||||
setSwipeRefreshLoadedState();
|
||||
Snackbar.make(mGrid, "已从服务器端同步数据!", Snackbar.LENGTH_LONG)
|
||||
.setAction("Action", null).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部正在加载的状态
|
||||
*/
|
||||
private void setSwipeRefreshLoadingState() {
|
||||
mState = STATE_REFRESH;
|
||||
mGrid.setDragEnable(false);
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setRefreshing(true);
|
||||
// 防止多次重复刷新
|
||||
// mSwipeRefreshLayout.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶部加载完毕的状态
|
||||
*/
|
||||
private void setSwipeRefreshLoadedState() {
|
||||
mState = STATE_NOMORE;
|
||||
if (mSwipeRefreshLayout != null) {
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
mSwipeRefreshLayout.setEnabled(true);
|
||||
}
|
||||
mGrid.setDragEnable(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************* synchronize method ******************************/
|
||||
|
||||
/**
|
||||
* 使用自带缓存功能的网络请求,防止多次刷新造成的流量损耗以及服务器压力
|
||||
*/
|
||||
private void refurbish() {
|
||||
datas = noteDb.query();
|
||||
if (datas != null) {
|
||||
if (adapter != null) {
|
||||
adapter.refurbishData(datas);
|
||||
} else {
|
||||
adapter = new NotebookAdapter(aty, datas);
|
||||
mGrid.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
private void delete(int index) {
|
||||
final int noteId = datas.get(index).getId();
|
||||
|
||||
noteDb.delete(noteId);
|
||||
datas.remove(index);
|
||||
if (datas != null && adapter != null) {
|
||||
adapter.refurbishData(datas);
|
||||
|
||||
mGrid.setAdapter(adapter);
|
||||
}
|
||||
|
||||
// updateEmptyView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
new SystemUtils(getActivity()).setBoolean("isTran",true);
|
||||
mGrid.setAlpha(0.55f);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/9.
|
||||
*/
|
||||
public class NoteEditActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
private NoteEditFragment noteEditFragment;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_note_edit);
|
||||
setTitle("添加记录");
|
||||
initFragment();
|
||||
|
||||
}
|
||||
|
||||
private void initFragment()
|
||||
{
|
||||
FragmentManager fm=getSupportFragmentManager();
|
||||
FragmentTransaction ft=fm.beginTransaction();
|
||||
noteEditFragment=new NoteEditFragment();
|
||||
ft.replace(R.id.main_fraglayout, noteEditFragment,null);
|
||||
ft.commit();
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
|
||||
if(!noteEditFragment.onBackPressed())
|
||||
super.onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,490 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.github.clans.fab.FloatingActionButton;
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.db.NoteDatabase;
|
||||
import com.example.administrator.myapplication.entity.NotebookData;
|
||||
import com.example.administrator.myapplication.entity.OnResponseListener;
|
||||
import com.example.administrator.myapplication.entity.Response;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.Constants;
|
||||
import com.example.administrator.myapplication.utils.DialogHelp;
|
||||
import com.example.administrator.myapplication.utils.HTQAnimations;
|
||||
import com.example.administrator.myapplication.utils.ResourceParser;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.utils.StringUtils;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/8.
|
||||
*/
|
||||
public class NoteEditFragment extends Fragment implements View.OnClickListener,View.OnTouchListener {
|
||||
@BindView(R.id.note_detail_edit)
|
||||
EditText mEtContent;
|
||||
@BindView(R.id.note_detail_tv_date)
|
||||
TextView mTvDate;
|
||||
@BindView(R.id.note_detail_titlebar)
|
||||
RelativeLayout mLayoutTitle;
|
||||
@BindView(R.id.note_detail_img_thumbtack)
|
||||
ImageView mImgThumbtack;
|
||||
|
||||
@BindView(R.id.note_detail_img_button)
|
||||
ImageView mImgMenu;
|
||||
@BindView(R.id.note_detail_menu)
|
||||
RelativeLayout mLayoutMenu;
|
||||
|
||||
@BindView(R.id.note_detail_img_green)
|
||||
ImageView mImgGreen;
|
||||
@BindView(R.id.note_detail_img_blue)
|
||||
ImageView mImgBlue;
|
||||
@BindView(R.id.note_detail_img_purple)
|
||||
ImageView mImgPurple;
|
||||
@BindView(R.id.note_detail_img_yellow)
|
||||
ImageView mImgYellow;
|
||||
@BindView(R.id.note_detail_img_red)
|
||||
ImageView mImgRed;
|
||||
|
||||
@BindView(R.id.menu_item_text_font)
|
||||
FloatingActionButton menuTextFont;
|
||||
@BindView(R.id.menu_item_clock)
|
||||
FloatingActionButton menuClock;
|
||||
@BindView(R.id.menu_item_desktop)
|
||||
FloatingActionButton menuDesktop;
|
||||
@BindView(R.id.menu_item_share)
|
||||
FloatingActionButton menuShare;
|
||||
|
||||
@BindView(R.id.font_size_selector)
|
||||
View mFontSizeSelector;
|
||||
private NotebookData editData;
|
||||
private NoteDatabase noteDb;
|
||||
protected boolean isNewNote;
|
||||
private int whereFrom = QUICK_DIALOG;// 从哪个界面来
|
||||
|
||||
public static final String NOTE_KEY = "notebook_key";
|
||||
public static final String NOTE_FROMWHERE_KEY = "fromwhere_key";
|
||||
public static final int QUICK_DIALOG = 0;
|
||||
public static final int NOTEBOOK_ITEM = 1;
|
||||
public static final String DESKTOP = "desktop";
|
||||
|
||||
|
||||
private int mFontSizeId;
|
||||
private static final Map<Integer, Integer> sFontSelectorSelectionMap = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_LARGE, R.id.iv_large_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_SMALL, R.id.iv_small_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_MEDIUM, R.id.iv_medium_select);
|
||||
sFontSelectorSelectionMap.put(Constants.TEXT_SUPER, R.id.iv_super_select);
|
||||
}
|
||||
|
||||
private static final Map<Integer, Integer> sFontSizeBtnsMap = new HashMap<Integer, Integer>();
|
||||
|
||||
static {
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_large, Constants.TEXT_LARGE);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_small, Constants.TEXT_SMALL);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_normal,Constants.TEXT_MEDIUM);
|
||||
sFontSizeBtnsMap.put(R.id.ll_font_super, Constants.TEXT_SUPER);
|
||||
}
|
||||
public static final int[] sBackGrounds = { 0xffe5fce8,// 绿色
|
||||
0xfffffdd7,// 黄色
|
||||
0xffffddde,// 红色
|
||||
0xffccf2fd,// 蓝色
|
||||
0xfff7f5f6,// 紫色
|
||||
};
|
||||
public static final int[] sTitleBackGrounds = { 0xffcef3d4,// 绿色
|
||||
0xffebe5a9,// 黄色
|
||||
0xffecc4c3,// 红色
|
||||
0xffa9d5e2,// 蓝色
|
||||
0xffddd7d9,// 紫色
|
||||
};
|
||||
|
||||
public static final int[] sThumbtackImgs = { R.drawable.green,
|
||||
R.drawable.yellow, R.drawable.red, R.drawable.blue,
|
||||
R.drawable.purple };
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View rootView = inflater.inflate(R.layout.note_edit_fraglayout,
|
||||
container, false);
|
||||
ButterKnife.bind(this, rootView);
|
||||
initData();
|
||||
initView(rootView);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
private void initView(View view) {
|
||||
|
||||
mImgGreen.setOnClickListener(this);
|
||||
mImgBlue.setOnClickListener(this);
|
||||
mImgPurple.setOnClickListener(this);
|
||||
mImgYellow.setOnClickListener(this);
|
||||
mImgRed.setOnClickListener(this);
|
||||
|
||||
mEtContent.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
mEtContent.setSingleLine(false);
|
||||
mEtContent.setHorizontallyScrolling(false);
|
||||
mEtContent.setText(Html.fromHtml(editData.getContent()).toString());
|
||||
mTvDate.setText(editData.getDate());
|
||||
|
||||
mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
|
||||
mImgMenu.setOnTouchListener(this);
|
||||
mLayoutMenu.setOnTouchListener(this);
|
||||
|
||||
// mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
// mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
// mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
// closeMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void initData() {
|
||||
noteDb = new NoteDatabase(getActivity());
|
||||
if (editData == null) {
|
||||
editData = new NotebookData();
|
||||
editData.setContent(new SystemUtils(getActivity()).getNoteDraft());
|
||||
isNewNote = true;
|
||||
}
|
||||
if (StringUtils.isEmpty(editData.getDate())) {
|
||||
editData.setDate(StringUtils.getDataTime("yyyy/MM/dd"));
|
||||
}
|
||||
|
||||
mFontSizeId= (int) SPUtils.get(getActivity(),Constants.TEXT_SIZE,Constants.TEXT_MEDIUM);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.note_detail_img_green:
|
||||
editData.setColor(0);
|
||||
break;
|
||||
case R.id.note_detail_img_blue:
|
||||
editData.setColor(3);
|
||||
break;
|
||||
case R.id.note_detail_img_purple:
|
||||
editData.setColor(4);
|
||||
break;
|
||||
case R.id.note_detail_img_yellow:
|
||||
editData.setColor(1);
|
||||
break;
|
||||
case R.id.note_detail_img_red:
|
||||
editData.setColor(2);
|
||||
break;
|
||||
|
||||
}
|
||||
mImgThumbtack.setImageResource(sThumbtackImgs[editData.getColor()]);
|
||||
mEtContent.setBackgroundColor(sBackGrounds[editData.getColor()]);
|
||||
mLayoutTitle.setBackgroundColor(sTitleBackGrounds[editData.getColor()]);
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
@OnClick({R.id.menu_item_share,R.id.menu_item_text_font,R.id.menu_item_clock,R.id.menu_item_desktop})
|
||||
public void click( FloatingActionButton menuItem)
|
||||
{
|
||||
String editContent=mEtContent.getText().toString();
|
||||
switch(menuItem.getId())
|
||||
{
|
||||
case R.id.menu_item_share:{
|
||||
|
||||
if(editContent.equals(""))
|
||||
{
|
||||
Toast.makeText(getActivity(),"您还未输入内容哦", Toast.LENGTH_LONG).show();
|
||||
}else {
|
||||
SystemUtils.shareNote(getActivity(),editContent);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.menu_item_text_font:{
|
||||
showTextSelectorPanel();
|
||||
|
||||
} break;
|
||||
case R.id.menu_item_clock:{
|
||||
if(!editContent.equals("")) {
|
||||
setReminder(editContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(getActivity(),"亲,内容为空哦", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
} break;
|
||||
|
||||
case R.id.menu_item_desktop:{
|
||||
|
||||
if(!editContent.equals("")) {
|
||||
addToDesktop(editContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(getActivity(),"内容为空,添加失败", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@OnClick({R.id.ll_font_small,R.id.ll_font_normal,R.id.ll_font_large,R.id.ll_font_super})
|
||||
public void ClickTextSizeSelector(View v) {
|
||||
int id = v.getId();
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE);
|
||||
mFontSizeId = sFontSizeBtnsMap.get(id);
|
||||
SPUtils.put(getActivity(),Constants.TEXT_SIZE,mFontSizeId);
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
|
||||
mEtContent.setTextAppearance(getActivity(),
|
||||
ResourceParser.TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
|
||||
getActivity().findViewById(R.id.font_size_selector).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
private void showTextSelectorPanel() {
|
||||
mFontSizeSelector.setVisibility(View.VISIBLE);
|
||||
getActivity().findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void addToDesktop(String title) {
|
||||
Intent intent = new Intent();
|
||||
Intent shortcutIntent = new Intent(getActivity(), NoteEditActivity.class);
|
||||
// SPUtils.put(getActivity(),DESKTOP,title);//将内容保存至share中
|
||||
shortcutIntent.putExtra(DESKTOP,title);
|
||||
shortcutIntent.setAction(Intent.ACTION_VIEW);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,title);
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
|
||||
Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.app_icon));
|
||||
intent.putExtra("duplicate", true);
|
||||
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
Toast.makeText(getActivity(),"已添加至桌面", Toast.LENGTH_LONG).show();
|
||||
// showToast(R.string.info_note_enter_desktop);
|
||||
getActivity().sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private void setReminder(final String str) {
|
||||
DateTimePickerDialog d = new DateTimePickerDialog(getActivity(), System.currentTimeMillis());
|
||||
d.setOnDateTimeSetListener(new DateTimePickerDialog.OnDateTimeSetListener() {
|
||||
public void OnDateTimeSet(AlertDialog dialog, long date) {
|
||||
setClock(date, true,str);
|
||||
// mEditNote.setAlertDate(date, true);
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
private void setClock(Long date, boolean set, String str)
|
||||
{
|
||||
|
||||
Intent intent = new Intent(getActivity(), AlarmReceiver.class);
|
||||
intent.putExtra(Constants.ALART_CONTENT,str);
|
||||
// intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, intent, 0);
|
||||
AlarmManager alarmManager = ((AlarmManager) getActivity().getSystemService(getActivity().ALARM_SERVICE));
|
||||
if (!set) {
|
||||
alarmManager.cancel(pendingIntent);
|
||||
} else {
|
||||
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (MotionEvent.ACTION_DOWN == event.getAction()) {
|
||||
if (mLayoutMenu.getVisibility() == View.GONE) {
|
||||
openMenu();
|
||||
} else {
|
||||
closeMenu();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 切换便签颜色的菜单
|
||||
*/
|
||||
private void openMenu() {
|
||||
HTQAnimations.openAnimation(mLayoutMenu, mImgMenu, 700);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换便签颜色的菜单
|
||||
*/
|
||||
private void closeMenu() {
|
||||
HTQAnimations.closeAnimation(mLayoutMenu, mImgMenu, 500);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存已编辑内容到数据库
|
||||
*/
|
||||
private void save() {
|
||||
setNoteProperty();
|
||||
noteDb.save(editData);
|
||||
}
|
||||
private void setNoteProperty()
|
||||
{
|
||||
if (editData.getId() == 0) {
|
||||
editData.setId(-1
|
||||
* StringUtils.toInt(
|
||||
StringUtils.getDataTime("dddHHmmss"), 0));
|
||||
}
|
||||
String userId = AccountUtils.getUserId(getActivity());
|
||||
editData.setUserId(userId);
|
||||
|
||||
editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss"));
|
||||
editData.setContent(mEtContent.getText().toString());
|
||||
editData.setObjectId(editData.getObjectId());
|
||||
}
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
Bundle bundle = getActivity().getIntent().getBundleExtra(Constants.BUNDLE_KEY_ARGS);
|
||||
if (bundle != null) {
|
||||
editData = (NotebookData) bundle.getSerializable(NOTE_KEY);
|
||||
whereFrom = bundle.getInt(NOTE_FROMWHERE_KEY, QUICK_DIALOG);
|
||||
}
|
||||
getActivity().getWindow().setSoftInputMode(
|
||||
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
|
||||
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
String desktopStr=getActivity().getIntent().getStringExtra(DESKTOP);
|
||||
|
||||
if(desktopStr!=null)//表明用户从桌面快捷方式点击过来的
|
||||
{
|
||||
mEtContent.setText(desktopStr);
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.notebook_edit_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.public_menu_send:
|
||||
if (!StringUtils.isEmpty(mEtContent.getText().toString())) {
|
||||
save();
|
||||
|
||||
if(whereFrom==0) {//表明用户是从主机面的加号按钮跳转过来
|
||||
editData.postNoteToServer(getActivity(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if (!response.isSucces()) {
|
||||
Snackbar.make(mImgGreen, "保存至服务器端失败,暂保存在本地", Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else if(whereFrom==1)//表明用户是从主界面的item跳转过来,此时只需更新即可
|
||||
{
|
||||
editData.updateNoteInServe(getActivity(), editData.getObjectId(), new OnResponseListener() {
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
if (!response.isSucces()) {
|
||||
Snackbar.make(mImgGreen, "保存至服务器端失败"+response.getMsg(), Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (isNewNote) {
|
||||
final String content = mEtContent.getText().toString();
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
DialogHelp.getConfirmDialog(getActivity(), "是否保存为草稿?", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
//
|
||||
new SystemUtils(getActivity()).setNoteDraft(content+"[草稿]");
|
||||
getActivity().finish();
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
new SystemUtils(getActivity()).setNoteDraft("");
|
||||
getActivity().finish();
|
||||
}
|
||||
}).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* notice :inner Broadcast receiver must be static ( to be registered through Manifest)
|
||||
* or Non-static broadcast receiver must be registered and unregistered inside the Parent class
|
||||
*
|
||||
*/
|
||||
public static class AlarmReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
intent.setClass(context, AlarmAlertActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// Log.i("alarm content",intent.getStringExtra(Constants.ALART_CONTENT));
|
||||
//intent.putExtra(Constants.ALART_CONTENT,intent.getStringExtra(Constants.ALART_CONTENT));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.MD5Util;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/4.
|
||||
*/
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.et_username)
|
||||
EditText accountEt;
|
||||
@BindView(R.id.et_password)
|
||||
EditText pwdEt;
|
||||
@BindView(R.id.et_email)
|
||||
EditText twicePwdEt;
|
||||
@BindView(R.id.btn_register)
|
||||
Button registerBtn;
|
||||
@BindView(R.id.img_back)
|
||||
ImageButton imgBtnBack;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// // requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// /*set it to be full screen*/
|
||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_register);
|
||||
ButterKnife.bind(this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.img_back)
|
||||
public void back() {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.btn_register)
|
||||
public void register(){
|
||||
String name =accountEt.getText().toString();
|
||||
String password = pwdEt.getText().toString();
|
||||
String pwd_again = twicePwdEt.getText().toString();
|
||||
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Snackbar.make(registerBtn,"账号不能为空", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(password)) {
|
||||
Snackbar.make(registerBtn,"密码不能为空", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (!pwd_again.equals(password)) {
|
||||
Snackbar.make(registerBtn,"两次密码输入不一致", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isNetConnected = com.example.administrator.myapplication.utils.CommonUtils.isNetworkAvailable(this);
|
||||
if(!isNetConnected){
|
||||
Snackbar.make(registerBtn,"网络连接出错", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
final ProgressDialog progress = new ProgressDialog(RegisterActivity.this);
|
||||
progress.setMessage("正在注册...");
|
||||
progress.setCanceledOnTouchOutside(false);
|
||||
progress.show();
|
||||
//由于每个应用的注册所需的资料都不一样,故IM sdk未提供注册方法,用户可按照bmod SDK的注册方式进行注册。
|
||||
//注册的时候需要注意两点:1、User表中绑定设备id和type,2、设备表中绑定username字段
|
||||
final User bu = new User();
|
||||
bu.setUsername(name);
|
||||
bu.setPassword(MD5Util.MD5(password));
|
||||
//将user和设备id进行绑定aa
|
||||
// bu.setUserSex(true);
|
||||
// bu.setDeviceType("android");
|
||||
// bu.setInstallId(BmobInstallation.getInstallationId(this));
|
||||
bu.signUp(RegisterActivity.this, new SaveListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
progress.dismiss();
|
||||
Snackbar.make(registerBtn,"注册成功", Snackbar.LENGTH_LONG).show();
|
||||
// 将设备与username进行绑定
|
||||
// userManager.bindInstallationForRegister(bu.getUsername());
|
||||
// 启动主页
|
||||
// Log.i("test","enter mainActivity");
|
||||
Intent intent = new Intent(RegisterActivity.this,MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(int arg0, String arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(registerBtn,"注册失败:", Snackbar.LENGTH_LONG).show();
|
||||
progress.dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.patternlock.LockPatternView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class SetLockActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.tv_activity_set_lock_title)
|
||||
TextView mTitleTv;
|
||||
|
||||
@BindView(R.id.lockView)
|
||||
LockPatternView mLockPatternView;
|
||||
|
||||
@BindView(R.id.btn_password_clear)
|
||||
Button mClearBtn;
|
||||
|
||||
private String mPassword;
|
||||
private boolean isFirst = true;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_set_lock);
|
||||
ButterKnife.bind(this);
|
||||
setTitle("应用加锁");
|
||||
|
||||
initUI();
|
||||
}
|
||||
|
||||
private void initUI()
|
||||
{
|
||||
mLockPatternView.setActivityContext(SetLockActivity.this);
|
||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
||||
@Override
|
||||
public void getStringPassword(String password) {
|
||||
if (isFirst) {
|
||||
mPassword = password;
|
||||
mTitleTv.setText("再次输入手势密码");
|
||||
isFirst = false;
|
||||
mClearBtn.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (password.equals(mPassword)) {
|
||||
new SystemUtils(SetLockActivity.this).set("password",password);
|
||||
new SystemUtils(SetLockActivity.this).setBoolean("isSetLock", true);
|
||||
startActivity(new Intent(SetLockActivity.this, MainActivity.class));
|
||||
SetLockActivity.this.finish();
|
||||
}else {
|
||||
isFirst =true;
|
||||
Snackbar.make( mTitleTv,"两次密码不一致,请重新设置", Snackbar.LENGTH_LONG).show();
|
||||
mPassword = "";
|
||||
|
||||
mTitleTv.setText("设置手势密码");
|
||||
mClearBtn.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassword() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mClearBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mPassword = "";
|
||||
isFirst = true;
|
||||
mClearBtn.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
// private void initData()
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.ToggleButton;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class SettingFragment extends Fragment {
|
||||
@BindView(R.id.tb_lock)
|
||||
ToggleButton mTbLock;
|
||||
@BindView(R.id.tb_tran)
|
||||
ToggleButton mTbTran;
|
||||
@BindView(R.id.lin)
|
||||
LinearLayout mLinL;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_setting, container,
|
||||
false);
|
||||
|
||||
ButterKnife.bind(this, view);
|
||||
initView();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
initData();
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
|
||||
private void initData() {
|
||||
|
||||
SystemUtils util=new SystemUtils(getActivity());
|
||||
boolean isSetLock =util.getBoolean("isSetLock");
|
||||
if(isSetLock)
|
||||
mTbLock.setToggleOn();
|
||||
else
|
||||
mTbLock.setToggleOff();
|
||||
|
||||
boolean isTran =util.getBoolean("isTran");
|
||||
if(isTran) {
|
||||
mTbTran.setToggleOn();
|
||||
mLinL.setAlpha(0.55f);
|
||||
}
|
||||
else {
|
||||
mTbTran.setToggleOff();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void initView()
|
||||
{
|
||||
mTbLock.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
// AppContext.setLoadImage(on);
|
||||
if(on) {
|
||||
|
||||
Intent intent = new Intent(getActivity(), SetLockActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SystemUtils(getActivity()).setBoolean("isSetLock", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
mTbTran.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
// AppContext.setLoadImage(on);
|
||||
if(on) {
|
||||
|
||||
new SystemUtils(getActivity()).setBoolean("isTran", true);
|
||||
mLinL.setAlpha(0.55f);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SystemUtils(getActivity()).setBoolean("isTran", false);
|
||||
mLinL.setAlpha(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
import com.example.administrator.myapplication.widget.patternlock.LockPatternView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class UnLockActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.lockView)
|
||||
LockPatternView mLockPatternView;
|
||||
|
||||
private String mPasswordStr;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_unlock);
|
||||
ButterKnife.bind(this);
|
||||
Toast.makeText(getApplicationContext(), "密码正确", Toast.LENGTH_SHORT).show();
|
||||
mLockPatternView.setActivityContext(UnLockActivity.this);
|
||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
||||
String password = new SystemUtils(UnLockActivity.this).getString("password");
|
||||
|
||||
@Override
|
||||
public void getStringPassword(String password) {
|
||||
mPasswordStr = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassword() {
|
||||
if (mPasswordStr.equals(password)) {
|
||||
Snackbar.make(mLockPatternView, "密码正确", Snackbar.LENGTH_SHORT).show();
|
||||
Intent intent = new Intent(UnLockActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
UnLockActivity.this.finish();
|
||||
return true;
|
||||
} else {
|
||||
Snackbar.make(mLockPatternView, "密码不正确", Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,493 @@
|
|||
package com.example.administrator.myapplication.ui;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.UpdataEvent;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.AccountUtils;
|
||||
import com.example.administrator.myapplication.utils.BmobConstants;
|
||||
import com.example.administrator.myapplication.utils.PhotoUtil;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import cn.bmob.v3.BmobUser;
|
||||
import cn.bmob.v3.datatype.BmobFile;
|
||||
import cn.bmob.v3.listener.UpdateListener;
|
||||
import cn.bmob.v3.listener.UploadFileListener;
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/9/4.
|
||||
*/
|
||||
|
||||
public class UserInfoActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.mine_avatar)
|
||||
ImageView headIcon;
|
||||
@BindView(R.id.rl_nick)
|
||||
RelativeLayout rlNick;
|
||||
@BindView(R.id.rl_sex)
|
||||
RelativeLayout rlSex;
|
||||
@BindView(R.id.rl_email)
|
||||
RelativeLayout rlEmail;
|
||||
@BindView(R.id.rl_account)
|
||||
RelativeLayout rlAccount;
|
||||
@BindView(R.id.exit_btn)
|
||||
Button exitBtn;
|
||||
@BindView(R.id.img_back)
|
||||
ImageButton imgBtnBack;
|
||||
|
||||
private String userSex = "";
|
||||
private final int UPDATE_USER_DIARYPWD = 1, UPDATE_USER_EMAIL = 2, UPDATE_USER_NICKNAME = 3;
|
||||
private PopupWindow mPopupWindow;
|
||||
protected int mScreenWidth;
|
||||
protected int mScreenHeight;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// /*set it to be full screen*/
|
||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.activity_user_info);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metric);
|
||||
mScreenWidth = metric.widthPixels;
|
||||
mScreenHeight = metric.heightPixels;
|
||||
|
||||
User.initDefaultAvatar(this,headIcon);
|
||||
//refreshAvatarFromLocal(BmobConstants.MyAvatarDir+"avatarIcon.png",headIcon);
|
||||
//userManager = BmobUserManager.getInstance(this);
|
||||
}
|
||||
|
||||
@OnClick(R.id.img_back)
|
||||
public void back() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@OnClick({R.id.mine_avatar, R.id.rl_nick, R.id.rl_sex, R.id.rl_email, R.id.rl_account, R.id.exit_btn})
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.mine_avatar:
|
||||
showAvatarPop();
|
||||
break;
|
||||
case R.id.rl_nick:
|
||||
AlertDialog nickNameDialog = buildeChangeInfoDialog(UPDATE_USER_NICKNAME);
|
||||
nickNameDialog.show();
|
||||
break;
|
||||
case R.id.rl_sex:
|
||||
changeUserSex();
|
||||
break;
|
||||
case R.id.rl_email:
|
||||
AlertDialog emailDialog = buildeChangeInfoDialog(UPDATE_USER_EMAIL);
|
||||
emailDialog.show();
|
||||
break;
|
||||
case R.id.rl_account:
|
||||
// login();
|
||||
break;
|
||||
case R.id.exit_btn:
|
||||
// goToRegisterActivity();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeUserSex() {
|
||||
final String[] sexItems = {"男", "女"};
|
||||
|
||||
AlertDialog.Builder sexBuilder = new AlertDialog.Builder(UserInfoActivity.this)
|
||||
.setTitle("选择性别")
|
||||
.setSingleChoiceItems(sexItems, 1, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
userSex = sexItems[which];
|
||||
}
|
||||
});
|
||||
sexBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// mPresenter.upDateInfo(UserBiz.UPDATE_USER_SEX, userSex);
|
||||
}
|
||||
});
|
||||
sexBuilder.create().show();
|
||||
}
|
||||
|
||||
public AlertDialog buildeChangeInfoDialog(final int chageType) {
|
||||
View layout;
|
||||
final EditText et_pwd;
|
||||
final EditText et_change;
|
||||
ImageView icon;
|
||||
String dialogTitle = "";
|
||||
//载入,初始化自定义对话框布局
|
||||
layout = getLayoutInflater().inflate(R.layout.change_info_dialog_layout, null);
|
||||
// et_pwd = (EditText) layout.findViewById(R.id.ed_pwd_confirm);
|
||||
et_change = (EditText) layout.findViewById(R.id.ed_change_info);
|
||||
icon = (ImageView) layout.findViewById(R.id.iv_change_info_icon);
|
||||
switch (chageType) {
|
||||
case UPDATE_USER_DIARYPWD:
|
||||
dialogTitle = "修改日记密码";
|
||||
et_change.setHint("新的日记密码");
|
||||
Drawable drawable1 = getDrawableByResource(R.drawable.diary_pwd);
|
||||
icon.setImageDrawable(drawable1);
|
||||
break;
|
||||
case UPDATE_USER_EMAIL:
|
||||
dialogTitle = "修改邮箱";
|
||||
et_change.setHint("设置您的邮箱");
|
||||
Drawable drawable2 = getDrawableByResource(R.drawable.email);
|
||||
icon.setImageDrawable(drawable2);
|
||||
break;
|
||||
case UPDATE_USER_NICKNAME:
|
||||
dialogTitle = "修改昵称";
|
||||
et_change.setHint("设置您的昵称");
|
||||
Drawable drawable3 = getDrawableByResource(R.drawable.nickname);
|
||||
icon.setImageDrawable(drawable3);
|
||||
break;
|
||||
}
|
||||
|
||||
//设置对话框
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||
.setTitle(dialogTitle)
|
||||
.setView(layout)
|
||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// String pwd = et_pwd.getText().toString();
|
||||
// if (pwd.equals(AccountUtils.getUserPwd(UserInfoActivity.this))) {
|
||||
// // upDateInfo(chageType, et_change.getText().toString());
|
||||
// } else {
|
||||
// Toast.makeText(UserInfoActivity.this, "密码不正确,重新输入", Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
}
|
||||
});
|
||||
//弹出对话框
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public Drawable getDrawableByResource(int id) {
|
||||
return getResources().getDrawable(id);
|
||||
}
|
||||
|
||||
|
||||
RelativeLayout layout_choose;
|
||||
RelativeLayout layout_photo;
|
||||
PopupWindow avatorPop;
|
||||
|
||||
public String filePath = "";
|
||||
private void showAvatarPop() {
|
||||
View view = LayoutInflater.from(this).inflate(R.layout.pop_showavator,
|
||||
null);
|
||||
layout_choose = (RelativeLayout) view.findViewById(R.id.layout_choose);
|
||||
layout_photo = (RelativeLayout) view.findViewById(R.id.layout_photo);
|
||||
layout_photo.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
layout_choose.setBackgroundColor(getResources().getColor(
|
||||
R.color.base_color_text_white));
|
||||
layout_photo.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.pop_bg_press));
|
||||
File dir = new File(BmobConstants.MyAvatarDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
// 原图
|
||||
File file = new File(dir, new SimpleDateFormat("yyMMddHHmmss")
|
||||
.format(new Date()));
|
||||
filePath = file.getAbsolutePath();// 获取相片的保存路径
|
||||
Uri imageUri = Uri.fromFile(file);
|
||||
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
|
||||
startActivityForResult(intent,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA);
|
||||
}
|
||||
});
|
||||
layout_choose.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
// ShowLog("点击相册");
|
||||
layout_photo.setBackgroundColor(getResources().getColor(
|
||||
R.color.base_color_text_white));
|
||||
layout_choose.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.pop_bg_press));
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, null);
|
||||
intent.setDataAndType(
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
|
||||
startActivityForResult(intent,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_LOCATION);
|
||||
}
|
||||
});
|
||||
|
||||
avatorPop = new PopupWindow(view, mScreenWidth, 600);
|
||||
avatorPop.setTouchInterceptor(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||
avatorPop.dismiss();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
avatorPop.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
|
||||
avatorPop.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
avatorPop.setTouchable(true);
|
||||
avatorPop.setFocusable(true);
|
||||
avatorPop.setOutsideTouchable(true);
|
||||
avatorPop.setBackgroundDrawable(new BitmapDrawable());
|
||||
// 动画效果 从底部弹起
|
||||
avatorPop.setAnimationStyle(R.style.Animations_GrowFromBottom);
|
||||
avatorPop.showAtLocation(exitBtn, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Title: startImageAction
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
private void startImageAction(Uri uri, int outputX, int outputY,
|
||||
int requestCode, boolean isCrop) {
|
||||
Intent intent = null;
|
||||
if (isCrop) {
|
||||
intent = new Intent("com.android.camera.action.CROP");
|
||||
} else {
|
||||
intent = new Intent(Intent.ACTION_GET_CONTENT, null);
|
||||
}
|
||||
intent.setDataAndType(uri, "image/*");
|
||||
// intent.putExtra("output", Uri.fromFile(new File(BaseApplication.avatarPath)));
|
||||
intent.putExtra("crop", "true");
|
||||
intent.putExtra("aspectX", 1);
|
||||
intent.putExtra("aspectY", 1);
|
||||
intent.putExtra("outputX", outputX);
|
||||
intent.putExtra("outputY", outputY);
|
||||
intent.putExtra("scale", true);
|
||||
// intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);//直接输出文件
|
||||
intent.putExtra("return-data", true);
|
||||
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
|
||||
intent.putExtra("noFaceDetection", true); // no face detection
|
||||
startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
Bitmap newBitmap;
|
||||
boolean isFromCamera = false;// 区分拍照旋转
|
||||
int degree = 0;
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CAMERA:// 拍照修改头像
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
Snackbar.make(exitBtn,"SD卡不可用", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
isFromCamera = true;
|
||||
File file = new File(filePath);
|
||||
degree = PhotoUtil.readPictureDegree(file.getAbsolutePath());
|
||||
// Log.i("life", "拍照后的角度:" + degree);
|
||||
startImageAction(Uri.fromFile(file), 200, 200,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP, true);
|
||||
}
|
||||
break;
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_LOCATION:// 本地修改头像
|
||||
if (avatorPop != null) {
|
||||
avatorPop.dismiss();
|
||||
}
|
||||
Uri uri = null;
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (!Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED)) {
|
||||
Snackbar.make(exitBtn,"SD卡不可用", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
isFromCamera = false;
|
||||
uri = data.getData();
|
||||
startImageAction(uri, 200, 200,
|
||||
BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP, true);
|
||||
} else {
|
||||
Snackbar.make(exitBtn,"照片获取失败", Snackbar.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case BmobConstants.REQUESTCODE_UPLOADAVATAR_CROP:// 裁剪头像返回
|
||||
// TODO sent to crop
|
||||
if (avatorPop != null) {
|
||||
avatorPop.dismiss();
|
||||
}
|
||||
if (data == null) {
|
||||
// Toast.makeText(this, , Toast.LENGTH_SHORT).show();
|
||||
Snackbar.make(exitBtn,"取消选择", Snackbar.LENGTH_LONG).show();
|
||||
return;
|
||||
} else {
|
||||
saveCropAvator(data);
|
||||
SPUtils.put(this,"isSetAvatar",true);
|
||||
|
||||
}
|
||||
|
||||
// 初始化文件路径
|
||||
filePath = "";
|
||||
// 上传头像
|
||||
uploadAvatar();
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void uploadAvatar() {
|
||||
//BmobLog.i("头像地址:" + path);
|
||||
final BmobFile bmobFile = new BmobFile(new File(path));
|
||||
bmobFile.upload(this, new UploadFileListener() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
String url = bmobFile.getFileUrl(UserInfoActivity.this);
|
||||
updateUserAvatar(url);
|
||||
AccountUtils.saveUserHeadUrl(UserInfoActivity.this,url);
|
||||
toUpdateUserInfo(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(Integer arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(int arg0, String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像上传失败:" + msg+ String.valueOf(arg0), Snackbar.LENGTH_LONG).show();
|
||||
// ShowToast("头像上传失败:" + msg+String.valueOf(arg0));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateUserAvatar(final String url) {
|
||||
User u =new User();
|
||||
u.setUserHeadUrl(url);
|
||||
updateUserData(u,new UpdateListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像更新成功!", Snackbar.LENGTH_SHORT).show();
|
||||
//ShowToast();
|
||||
// 更新头像
|
||||
User.refreshAvatarFromServe(url,headIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(int code, String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
Snackbar.make(exitBtn,"头像更新失败:" + msg+ String.valueOf(code), Snackbar.LENGTH_SHORT).show();
|
||||
//ShowToast();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateUserData(User user,UpdateListener listener){
|
||||
BmobUser current = user.getCurrentUser(UserInfoActivity.this);
|
||||
user.setObjectId(current.getObjectId());
|
||||
user.update(this, listener);
|
||||
}
|
||||
|
||||
String path;
|
||||
String avatarFile="avatarIcon.png";
|
||||
/**
|
||||
* 保存裁剪的头像
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void saveCropAvator(Intent data) {
|
||||
Bundle extras = data.getExtras();
|
||||
if (extras != null) {
|
||||
Bitmap bitmap = extras.getParcelable("data");
|
||||
// Log.i("life", "avatar - bitmap = " + bitmap);
|
||||
if (bitmap != null) {
|
||||
bitmap = PhotoUtil.toRoundCorner(bitmap, 10);
|
||||
if (isFromCamera && degree != 0) {
|
||||
bitmap = PhotoUtil.rotaingImageView(degree, bitmap);
|
||||
}
|
||||
headIcon.setImageBitmap(bitmap);
|
||||
|
||||
// 保存图片
|
||||
String filename = new SimpleDateFormat("yyMMddHHmmss")
|
||||
.format(new Date())+".png";
|
||||
path = BmobConstants.MyAvatarDir + avatarFile;//filename;
|
||||
|
||||
// PhotoUtil.saveBitmap(BmobConstants.MyAvatarDir, filename,
|
||||
// bitmap, true);
|
||||
PhotoUtil.saveBitmap(BmobConstants.MyAvatarDir, avatarFile,
|
||||
bitmap, true);
|
||||
// 上传头像
|
||||
if (bitmap != null && bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新其他界面的头像
|
||||
*/
|
||||
public void toUpdateUserInfo(String url) {
|
||||
UpdataEvent event = new UpdataEvent();
|
||||
event.setType(UpdataEvent.UPDATE_USER_INFOS);
|
||||
// event.setString(BmobConstants.MyAvatarDir+avatarFile);
|
||||
event.setString(url);
|
||||
EventBus.getDefault().post(event);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,16 @@ import android.view.WindowManager;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.example.administrator.myapplication.R;
|
||||
import com.example.administrator.myapplication.entity.User;
|
||||
import com.example.administrator.myapplication.utils.SPUtils;
|
||||
import com.example.administrator.myapplication.utils.SystemUtils;
|
||||
|
||||
import cn.bmob.v3.listener.SaveListener;
|
||||
|
||||
|
||||
/**
|
||||
* Created by htq on 2016/8/12.
|
||||
*/
|
||||
public class WelcomeActivity extends AppCompatActivity {
|
||||
private boolean isSetLock;
|
||||
|
||||
|
@ -26,7 +35,7 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||
// String libName = "bmob";
|
||||
// System.loadLibrary(libName );
|
||||
|
||||
isSetLock = new com.htq.baidu.coolnote.utils.SystemUtils(WelcomeActivity.this).getBoolean("isSetLock");
|
||||
isSetLock = new SystemUtils(WelcomeActivity.this).getBoolean("isSetLock");
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -47,10 +56,10 @@ public class WelcomeActivity extends AppCompatActivity {
|
|||
}
|
||||
private void autoLogin()
|
||||
{
|
||||
if(com.htq.baidu.coolnote.utils.SPUtils.contains(this,"user_name"))
|
||||
if(SPUtils.contains(this,"user_name"))
|
||||
{
|
||||
String name=(String) com.htq.baidu.coolnote.utils.SPUtils.get(this,"user_name","");
|
||||
String pwd=(String) com.htq.baidu.coolnote.utils.SPUtils.get(this,"pwd","");
|
||||
String name=(String)SPUtils.get(this,"user_name","");
|
||||
String pwd=(String)SPUtils.get(this,"pwd","");
|
||||
User user = new User();
|
||||
user.setUsername(name);
|
||||
user.setPassword(pwd);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.htq.baidu.coolnote.utils;
|
||||
package com.example.administrator.myapplication.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
android:textSize="20sp"
|
||||
android:text="@string/app_name" />
|
||||
|
||||
<com.htq.baidu.coolnote.widget.CircleImageView
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/imageView1"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
|
@ -51,7 +51,7 @@
|
|||
android:layout_below="@+id/textView2"
|
||||
android:layout_marginTop="10dp">
|
||||
|
||||
<com.htq.baidu.coolnote.widget.CircleImageView
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="125dp"
|
||||
android:layout_height="125dp"
|
||||
|
|
|
@ -1,83 +1,98 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.example.administrator.myapplication.ui.LoginActivity">
|
||||
|
||||
<!-- Login progress -->
|
||||
<ProgressBar
|
||||
android:id="@+id/login_progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/login_form"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:background="@drawable/login_bg" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/email_login_form"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/iv_icon"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:src="@mipmap/app_icon" />
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/account"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="电子邮箱/电话号码"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_margin="10dp"
|
||||
android:background="@drawable/input_bg"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:id="@+id/login_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/base_action_bar_height"
|
||||
android:background="@color/transparent"
|
||||
android:drawableLeft="@drawable/login_icon_account"
|
||||
android:drawablePadding="25dip"
|
||||
android:hint="@string/login_username_hint"
|
||||
android:paddingLeft="15dip"
|
||||
android:shadowDx="0.0"
|
||||
android:shadowDy="1.0"
|
||||
android:shadowRadius="1.0"
|
||||
android:textColorHint="#ffdddddd" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="密码"
|
||||
android:imeActionId="@+id/login"
|
||||
android:imeOptions="actionUnspecified"
|
||||
android:layout_height="0.5dp"
|
||||
android:background="@drawable/base_horization_line" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/login_pwd"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/base_action_bar_height"
|
||||
android:background="@color/transparent"
|
||||
android:drawableLeft="@drawable/login_icon_password"
|
||||
android:drawablePadding="25dip"
|
||||
android:hint="@string/login_password_hint"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true" />
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
android:paddingLeft="15dip"
|
||||
android:textColorHint="#ffdddddd" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/log_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
android:id="@+id/btn_login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="登录"
|
||||
android:textStyle="bold" />
|
||||
android:layout_height="@dimen/base_action_bar_height"
|
||||
android:layout_margin="@dimen/activity_vertical_margin"
|
||||
android:background="@drawable/btn_login_selector"
|
||||
android:gravity="center"
|
||||
android:text="@string/login"
|
||||
android:textColor="@color/base_color_text_white"
|
||||
android:textSize="@dimen/text_size_large" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/sign_in_button"
|
||||
style="?android:textAppearanceSmall"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="新用户请注册"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/register_txt1"
|
||||
android:textColor="@color/base_color_text_gray"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_register"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/register_txt2"
|
||||
android:textColor="@color/color_theme"
|
||||
android:textSize="20sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -45,7 +45,7 @@
|
|||
android:layout_height="75dp"
|
||||
>
|
||||
|
||||
<com.htq.baidu.coolnote.widget.CircleImageView
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/mine_avatar"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
|
|
|
@ -4,35 +4,47 @@
|
|||
android:layout_height="match_parent"
|
||||
android:background="@mipmap/welc_bg" >
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/soucang_icon"
|
||||
android:id="@+id/beauty_note_icon"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginTop="60dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="77dp"
|
||||
android:src="@mipmap/app_icon"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:scaleType="centerCrop"/>
|
||||
android:scaleType="centerCrop"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sou"
|
||||
android:id="@+id/beauty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="20sp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@id/soucang_icon"
|
||||
android:layout_below="@id/beauty_note_icon"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textColor="#fff"
|
||||
android:text="@string/app_name"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="50dp"
|
||||
android:textSize="20sp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@id/sou"
|
||||
android:textColor="#fff"
|
||||
android:text="嗖得一下,让收藏变得更简单"
|
||||
android:text="@string/slogan"
|
||||
android:gravity="center"
|
||||
/>
|
||||
android:id="@+id/textView4"
|
||||
android:layout_above="@+id/textView5"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="87dp"/>
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#000"
|
||||
android:text="@string/author"
|
||||
android:id="@+id/textView5"/>
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="com.htq.baidu.coolnote.ui.MainActivity">
|
||||
tools:context="com.example.administrator.myapplication.ui.MainActivity">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:visibility="visible" >
|
||||
|
||||
<com.htq.baidu.coolnote.widget.HTQDragGridView
|
||||
<com.example.administrator.myapplication.widget.HTQDragGridView
|
||||
android:id="@+id/frag_note_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<com.htq.baidu.coolnote.widget.ToggleButton
|
||||
<com.example.administrator.myapplication.widget.ToggleButton
|
||||
android:id="@+id/tb_lock"
|
||||
style="@style/option_item_toggleButton"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
@ -34,7 +34,7 @@
|
|||
android:textColor="#000"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<com.htq.baidu.coolnote.widget.ToggleButton
|
||||
<com.example.administrator.myapplication.widget.ToggleButton
|
||||
android:id="@+id/tb_tran"
|
||||
style="@style/option_item_toggleButton"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:visibility="invisible"
|
||||
/>
|
||||
<!-- android:visibility="invisible" -->
|
||||
<com.htq.baidu.coolnote.widget.NoteItemCircleView
|
||||
<com.example.administrator.myapplication.widget.NoteItemCircleView
|
||||
android:id="@+id/note_detail_img_green"
|
||||
style="@style/note_detail_menu_item"
|
||||
android:layout_alignLeft="@+id/note_detail_img_menu"
|
||||
|
@ -30,7 +30,7 @@
|
|||
app:border_width="2dip"
|
||||
/>
|
||||
<!-- android:src="#ffcef3d4"-->
|
||||
<com.htq.baidu.coolnote.widget.NoteItemCircleView
|
||||
<com.example.administrator.myapplication.widget.NoteItemCircleView
|
||||
android:id="@+id/note_detail_img_blue"
|
||||
style="@style/note_detail_menu_item"
|
||||
android:layout_alignLeft="@+id/note_detail_img_menu"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark">
|
||||
|
||||
<com.htq.baidu.coolnote.widget.CircleImageView
|
||||
<com.example.administrator.myapplication.widget.CircleImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="110dp"
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:fab="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/note_detail_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="50dp"
|
||||
android:gravity="top"
|
||||
android:hint="@null"
|
||||
android:singleLine="false"
|
||||
android:textColor="#333" />
|
||||
|
||||
<include
|
||||
android:id="@+id/note_detail_menu"
|
||||
layout="@layout/layout_note_detail_menu" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/note_detail_titlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/note_detail_tv_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:gravity="center"
|
||||
android:textColor="#666" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/note_detail_img_button"
|
||||
style="@style/note_detail_menu"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:contentDescription="@null"
|
||||
android:src="@drawable/icon_color" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/note_detail_img_thumbtack"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/note_detail_titlebar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:contentDescription="@null"
|
||||
android:paddingBottom="5dp" />
|
||||
|
||||
<com.github.clans.fab.FloatingActionMenu
|
||||
android:id="@+id/floating_action_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:paddingLeft="10dp"
|
||||
fab:menu_labels_ellipsize="end"
|
||||
fab:menu_labels_singleLine="true"
|
||||
fab:menu_backgroundColor="@color/transparent"
|
||||
><!-- fab:menu_icon="@drawable/actionbar_icon_add" #ccffffff-->
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/menu_item_text_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu_font_size"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="字体大小" />
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/menu_item_clock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu_alert"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="设置闹钟" />
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/menu_item_desktop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu_to_desktop"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="添加到桌面" />
|
||||
<com.github.clans.fab.FloatingActionButton
|
||||
android:id="@+id/menu_item_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/menu_share"
|
||||
fab:fab_size="mini"
|
||||
fab:fab_label="分享记录" />
|
||||
|
||||
</com.github.clans.fab.FloatingActionMenu>
|
||||
<LinearLayout
|
||||
android:id="@+id/font_size_selector"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="115dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/font_size_selector_bg"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<!--android:layout_gravity="bottom"-->
|
||||
<FrameLayout
|
||||
android:id="@+id/ll_font_small"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dip"
|
||||
android:src="@drawable/font_small" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/font_small"
|
||||
android:textAppearance="@style/TextAppearanceUnderMenuIcon" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_small_select"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="-7dip"
|
||||
android:layout_marginRight="7dip"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/selected"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
<!-- -->
|
||||
<FrameLayout
|
||||
android:id="@+id/ll_font_normal"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dip"
|
||||
android:src="@drawable/font_normal" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/font_normal"
|
||||
android:textAppearance="@style/TextAppearanceUnderMenuIcon" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_medium_select"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="-7dip"
|
||||
android:layout_marginRight="7dip"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/selected"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/ll_font_large"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dip"
|
||||
android:src="@drawable/font_large" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/font_large"
|
||||
android:textAppearance="@style/TextAppearanceUnderMenuIcon" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_large_select"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="-7dip"
|
||||
android:layout_marginRight="7dip"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/selected"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/ll_font_super"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dip"
|
||||
android:src="@drawable/font_super" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/font_super"
|
||||
android:textAppearance="@style/TextAppearanceUnderMenuIcon" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_super_select"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="bottom|right"
|
||||
android:layout_marginBottom="-7dip"
|
||||
android:layout_marginRight="7dip"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/selected"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -2,7 +2,7 @@
|
|||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.htq.baidu.coolnote.widget.patternlock.LockPatternView
|
||||
<com.example.administrator.myapplication.widget.patternlock.LockPatternView
|
||||
android:id="@+id/lockView"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<string name="about_me">作者:@:Curry </string>
|
||||
<string name="setting">设置</string>
|
||||
<string name="home">主页</string>
|
||||
<string name="author">嗖藏 @htq All rights reserved </string>
|
||||
<string name="author">嗖藏 @Curry All rights reserved </string>
|
||||
<string name="jia_mi">应用加密</string>
|
||||
<string name="slogan">漂亮好用的记事本</string>
|
||||
<string name="slogan">嗖嗖嗖,世界都是你的</string>
|
||||
<string name="exit">退出</string>
|
||||
<string name="settran">应用透明背景</string>
|
||||
<string name="pop_photo">拍照</string>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<string name="login_email_hint">请再次输入密码</string>
|
||||
<string name="register_account">注册账号</string>
|
||||
<string name="user_info">个人资料</string>
|
||||
<string name="my_blog">http://blog.csdn.net/htq__欢迎大家访问</string>
|
||||
<string name="my_blog">欢迎大家访问1905563644</string>
|
||||
<string name="datetime_dialog_ok">设置</string>
|
||||
<string name="datetime_dialog_cancel">取消</string>
|
||||
<string name="notealert_look">查看详情</string>
|
||||
|
|
|
@ -15,7 +15,9 @@ buildscript {
|
|||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
|
Loading…
Reference in New Issue