diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/AboutActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/AboutActivity.class new file mode 100644 index 0000000..972ae39 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/AboutActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/BuildConfig.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/BuildConfig.class new file mode 100644 index 0000000..7114e6a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/BuildConfig.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$1.class new file mode 100644 index 0000000..ddb754d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$2.class new file mode 100644 index 0000000..224ec20 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1.class new file mode 100644 index 0000000..acaad4d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$2.class new file mode 100644 index 0000000..0df5680 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1.class new file mode 100644 index 0000000..0ebd778 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$2.class new file mode 100644 index 0000000..715fe97 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$3.class new file mode 100644 index 0000000..644956c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$GoalListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$GoalListItemView.class new file mode 100644 index 0000000..d4c7e87 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter$GoalListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter.class new file mode 100644 index 0000000..eafb3d4 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity$GoalListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity.class new file mode 100644 index 0000000..9f652ad Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/CurrentGoalActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HelpActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HelpActivity.class new file mode 100644 index 0000000..96576b7 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HelpActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$1.class new file mode 100644 index 0000000..d390be9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$2.class new file mode 100644 index 0000000..c0c3569 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$3.class new file mode 100644 index 0000000..e737e96 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$4.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$4.class new file mode 100644 index 0000000..369999a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$4.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$5.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$5.class new file mode 100644 index 0000000..c380c1f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity$5.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity.class new file mode 100644 index 0000000..4996056 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$1.class new file mode 100644 index 0000000..06eed94 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$1.class new file mode 100644 index 0000000..96ea92f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$2.class new file mode 100644 index 0000000..762de55 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$3.class new file mode 100644 index 0000000..875e5a1 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$TaskListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$TaskListItemView.class new file mode 100644 index 0000000..4c11619 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter$TaskListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter.class new file mode 100644 index 0000000..2145538 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$HistoryTaskListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$ImageAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$ImageAdapter.class new file mode 100644 index 0000000..6c7b116 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity$ImageAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity.class new file mode 100644 index 0000000..c764e82 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/HistoryOnedayActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$1.class new file mode 100644 index 0000000..98e379b Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$2.class new file mode 100644 index 0000000..4d9d3fa Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$3.class new file mode 100644 index 0000000..88c498c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$HistoryGoalAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$HistoryGoalAdapter.class new file mode 100644 index 0000000..6a7c1bc Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$HistoryGoalAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$1.class new file mode 100644 index 0000000..341a152 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$2.class new file mode 100644 index 0000000..5e4cd0f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener.class new file mode 100644 index 0000000..d31d454 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity$ItemClickListener.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity.class new file mode 100644 index 0000000..ea4d682 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/PastGoalActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$anim.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$anim.class new file mode 100644 index 0000000..e2c0184 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$anim.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$array.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$array.class new file mode 100644 index 0000000..768ad48 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$array.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$attr.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$attr.class new file mode 100644 index 0000000..41d6c66 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$attr.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$color.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$color.class new file mode 100644 index 0000000..067f8f7 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$color.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$dimen.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$dimen.class new file mode 100644 index 0000000..6a4a682 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$dimen.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$drawable.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$drawable.class new file mode 100644 index 0000000..34cd04e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$drawable.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$id.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$id.class new file mode 100644 index 0000000..a6ed4f2 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$id.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$layout.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$layout.class new file mode 100644 index 0000000..37f5353 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$layout.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$plurals.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$plurals.class new file mode 100644 index 0000000..b6ff3c3 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$plurals.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$string.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$string.class new file mode 100644 index 0000000..ccf39f7 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$string.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$style.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$style.class new file mode 100644 index 0000000..d796e9f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$style.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$xml.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$xml.class new file mode 100644 index 0000000..5a068c8 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R$xml.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R.class new file mode 100644 index 0000000..7fe11cc Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/R.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$1.class new file mode 100644 index 0000000..93162e5 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$2.class new file mode 100644 index 0000000..457efaf Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$3.class new file mode 100644 index 0000000..0f7d072 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$4.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$4.class new file mode 100644 index 0000000..b61ec7a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$4.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference$1.class new file mode 100644 index 0000000..dbfe21c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference.class new file mode 100644 index 0000000..bdec1f9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity$StatusPreference.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity.class new file mode 100644 index 0000000..f10cc1e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/SetupActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$1.class new file mode 100644 index 0000000..7b7e4ea Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$10.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$10.class new file mode 100644 index 0000000..d6e94e9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$10.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$11.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$11.class new file mode 100644 index 0000000..0197ec3 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$11.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$12.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$12.class new file mode 100644 index 0000000..4e50cef Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$12.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$13.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$13.class new file mode 100644 index 0000000..6240c61 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$13.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$14.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$14.class new file mode 100644 index 0000000..6186f1f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$14.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$15.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$15.class new file mode 100644 index 0000000..4c33cde Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$15.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$1.class new file mode 100644 index 0000000..5d43171 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$2.class new file mode 100644 index 0000000..b97b700 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$3.class new file mode 100644 index 0000000..81f6212 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$4.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$4.class new file mode 100644 index 0000000..c037ea0 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$4.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$1.class new file mode 100644 index 0000000..12beea6 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$2.class new file mode 100644 index 0000000..7ce4db9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5.class new file mode 100644 index 0000000..94c5059 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$5.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$6.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$6.class new file mode 100644 index 0000000..6f6ca82 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16$6.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16.class new file mode 100644 index 0000000..d79a015 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$16.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$2.class new file mode 100644 index 0000000..cf091d5 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$3.class new file mode 100644 index 0000000..36b824a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$4.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$4.class new file mode 100644 index 0000000..75f6f79 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$4.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$5.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$5.class new file mode 100644 index 0000000..51fb45c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$5.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$6.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$6.class new file mode 100644 index 0000000..ded4062 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$6.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$7.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$7.class new file mode 100644 index 0000000..c8c12cf Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$7.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$8.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$8.class new file mode 100644 index 0000000..410c235 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$8.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$9.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$9.class new file mode 100644 index 0000000..84cdce1 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$9.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$1.class new file mode 100644 index 0000000..2dcf653 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$10.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$10.class new file mode 100644 index 0000000..1a704a0 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$10.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$11.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$11.class new file mode 100644 index 0000000..83cd5da Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$11.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$2.class new file mode 100644 index 0000000..e132b0e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$3.class new file mode 100644 index 0000000..2ed64a5 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$4.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$4.class new file mode 100644 index 0000000..74eb31d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$4.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$5.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$5.class new file mode 100644 index 0000000..1aeb2f4 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$5.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$6.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$6.class new file mode 100644 index 0000000..76047de Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$6.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$7.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$7.class new file mode 100644 index 0000000..cb17f30 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$7.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$8.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$8.class new file mode 100644 index 0000000..0ce5c5b Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$8.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$9.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$9.class new file mode 100644 index 0000000..7a9cd86 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener$9.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener.class new file mode 100644 index 0000000..d7bf2a0 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$AddTaskListener.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$NofifyTimeTask.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$NofifyTimeTask.class new file mode 100644 index 0000000..5a49e2a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$NofifyTimeTask.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$PullDateListener.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$PullDateListener.class new file mode 100644 index 0000000..8096372 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$PullDateListener.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter$TaskListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter$TaskListItemView.class new file mode 100644 index 0000000..f3cdf6c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter$TaskListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter.class new file mode 100644 index 0000000..30eba5a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TodayTaskListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter$TaskListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter$TaskListItemView.class new file mode 100644 index 0000000..70cf04d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter$TaskListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter.class new file mode 100644 index 0000000..8256e23 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$TomorrowTaskListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$1.class new file mode 100644 index 0000000..99e03b6 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$2.class new file mode 100644 index 0000000..4e87f0c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$3.class new file mode 100644 index 0000000..6672868 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$TaskListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$TaskListItemView.class new file mode 100644 index 0000000..930daca Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter$TaskListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter.class new file mode 100644 index 0000000..417cf83 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity$YesterdayTaskListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity.class new file mode 100644 index 0000000..952d3fa Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity$1.class new file mode 100644 index 0000000..205fb60 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity.class new file mode 100644 index 0000000..5790d8e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskAlertActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskNotifyActivity.class b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskNotifyActivity.class new file mode 100644 index 0000000..4b98471 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/activity/TaskNotifyActivity.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/HistoryGoalAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/HistoryGoalAdapter.class new file mode 100644 index 0000000..f3c13b0 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/HistoryGoalAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$1.class new file mode 100644 index 0000000..8c81427 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$2.class new file mode 100644 index 0000000..0f34426 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$3.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$3.class new file mode 100644 index 0000000..ffc1ced Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$3.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$TaskListItemView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$TaskListItemView.class new file mode 100644 index 0000000..a54ba40 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter$TaskListItemView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter.class b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter.class new file mode 100644 index 0000000..1adc5bf Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/adapter/TomorrowTaskListViewAdapter.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/alarm/Alarm.class b/代码/TimeBetter-master/bin/classes/com/timebetter/alarm/Alarm.class new file mode 100644 index 0000000..7092f51 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/alarm/Alarm.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/bean/GoalBean.class b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/GoalBean.class new file mode 100644 index 0000000..b2e263e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/GoalBean.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/bean/HeartMessage.class b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/HeartMessage.class new file mode 100644 index 0000000..438d93f Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/HeartMessage.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/bean/SummaryBean.class b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/SummaryBean.class new file mode 100644 index 0000000..9c0707d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/SummaryBean.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/bean/TaskBean.class b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/TaskBean.class new file mode 100644 index 0000000..ca512df Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/bean/TaskBean.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/DayStyle.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/DayStyle.class new file mode 100644 index 0000000..d58285a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/DayStyle.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GMailConsts.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GMailConsts.class new file mode 100644 index 0000000..70b682d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GMailConsts.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GoalConstant.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GoalConstant.class new file mode 100644 index 0000000..ae211f6 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/GoalConstant.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MenuItemId.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MenuItemId.class new file mode 100644 index 0000000..4847f16 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MenuItemId.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MotionEventConstant.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MotionEventConstant.class new file mode 100644 index 0000000..8c52283 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/MotionEventConstant.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/constant/TaskConstant.class b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/TaskConstant.class new file mode 100644 index 0000000..edb4ef7 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/constant/TaskConstant.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseHelper.class b/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseHelper.class new file mode 100644 index 0000000..cd25486 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseHelper.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseUtil.class b/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseUtil.class new file mode 100644 index 0000000..25aaf5e Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/dao/DatabaseUtil.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/date/DateUtils.class b/代码/TimeBetter-master/bin/classes/com/timebetter/date/DateUtils.class new file mode 100644 index 0000000..e9a66ca Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/date/DateUtils.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/DataForm.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/DataForm.class new file mode 100644 index 0000000..6e8cbc9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/DataForm.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$1.class new file mode 100644 index 0000000..1b96766 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$AuthenticationErrorException.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$AuthenticationErrorException.class new file mode 100644 index 0000000..fafee63 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$AuthenticationErrorException.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GMailSyncState.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GMailSyncState.class new file mode 100644 index 0000000..55e4670 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GMailSyncState.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GeneralErrorException.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GeneralErrorException.class new file mode 100644 index 0000000..f4cf6c5 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$GeneralErrorException.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$StateChangeListener.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$StateChangeListener.class new file mode 100644 index 0000000..8b20ede Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService$StateChangeListener.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService.class new file mode 100644 index 0000000..b2e822d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/GMailService.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/mail/PrefStore.class b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/PrefStore.class new file mode 100644 index 0000000..eef4598 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/mail/PrefStore.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/AlarmReceiver.class b/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/AlarmReceiver.class new file mode 100644 index 0000000..27b6337 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/AlarmReceiver.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/PlanBetterReceiver.class b/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/PlanBetterReceiver.class new file mode 100644 index 0000000..aea9f6d Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/receiver/PlanBetterReceiver.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$1.class new file mode 100644 index 0000000..2347246 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$2.class new file mode 100644 index 0000000..d6a7ac9 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$LocalBinder.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$LocalBinder.class new file mode 100644 index 0000000..265badc Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService$LocalBinder.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService.class new file mode 100644 index 0000000..a2bbe8a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/AlertService.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit$LocalBinder.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit$LocalBinder.class new file mode 100644 index 0000000..eab5f1b Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit$LocalBinder.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit.class b/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit.class new file mode 100644 index 0000000..4f10909 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/service/PlanBetterInit.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/AlwaysMarqueeTextView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/AlwaysMarqueeTextView.class new file mode 100644 index 0000000..6703856 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/AlwaysMarqueeTextView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/CoverFlow.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/CoverFlow.class new file mode 100644 index 0000000..7015fc7 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/CoverFlow.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell$OnItemClick.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell$OnItemClick.class new file mode 100644 index 0000000..e7e60b1 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell$OnItemClick.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell.class new file mode 100644 index 0000000..f362d20 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayCell.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayHeader.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayHeader.class new file mode 100644 index 0000000..8ea8d5c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/DateWidgetDayHeader.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/HistoryGoalGalleryFlow.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/HistoryGoalGalleryFlow.class new file mode 100644 index 0000000..efa920b Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/HistoryGoalGalleryFlow.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$1.class new file mode 100644 index 0000000..99ee597 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$2.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$2.class new file mode 100644 index 0000000..e0ec962 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog$2.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog.class new file mode 100644 index 0000000..f397f88 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/IphoneAlertDialog.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/MyImgView.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/MyImgView.class new file mode 100644 index 0000000..32e24cf Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/MyImgView.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout$1.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout$1.class new file mode 100644 index 0000000..d89e74b Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout$1.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout.class new file mode 100644 index 0000000..f89ffd5 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/ResizeLayout.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton$symbol.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton$symbol.class new file mode 100644 index 0000000..827b4a2 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton$symbol.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton.class b/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton.class new file mode 100644 index 0000000..71a11d2 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/view/SymbolButton.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TodayTaskWidget.class b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TodayTaskWidget.class new file mode 100644 index 0000000..02b9e4c Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TodayTaskWidget.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidget.class b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidget.class new file mode 100644 index 0000000..44d1f41 Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidget.class differ diff --git a/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidgetService.class b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidgetService.class new file mode 100644 index 0000000..f67412a Binary files /dev/null and b/代码/TimeBetter-master/bin/classes/com/timebetter/widget/TomorrowTaskWidgetService.class differ diff --git a/代码/TimeBetter-master/gen/com/timebetter/activity/BuildConfig.java b/代码/TimeBetter-master/gen/com/timebetter/activity/BuildConfig.java new file mode 100644 index 0000000..50f11f7 --- /dev/null +++ b/代码/TimeBetter-master/gen/com/timebetter/activity/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package com.timebetter.activity; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/代码/TimeBetter-master/gen/com/timebetter/activity/R.java b/代码/TimeBetter-master/gen/com/timebetter/activity/R.java new file mode 100644 index 0000000..7e35b0f --- /dev/null +++ b/代码/TimeBetter-master/gen/com/timebetter/activity/R.java @@ -0,0 +1,483 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.timebetter.activity; + +public final class R { + public static final class anim { + public static final int my_scale_action=0x7f040000; + public static final int popup_window_bottom=0x7f040001; + public static final int popup_window_top=0x7f040002; + public static final int push_left_in=0x7f040003; + public static final int push_left_in_slowly=0x7f040004; + public static final int push_left_out=0x7f040005; + public static final int push_left_out_slowly=0x7f040006; + public static final int push_right_in=0x7f040007; + public static final int push_right_in_slowly=0x7f040008; + public static final int push_right_out=0x7f040009; + public static final int push_right_out_slowly=0x7f04000a; + } + public static final class array { + public static final int gmail_time=0x7f060000; + public static final int gmail_time_value=0x7f060001; + } + public static final class attr { + } + public static final class color { + public static final int Green=0x7f070008; + public static final int Red=0x7f070007; + public static final int alarm_btn_bg=0x7f070013; + public static final int alarm_line=0x7f070012; + public static final int app_title=0x7f07000c; + public static final int black=0x7f070004; + public static final int blue=0x7f070000; + public static final int days_color=0x7f070009; + public static final int grey=0x7f070001; + public static final int guide_title_color=0x7f070011; + public static final int help_bg=0x7f070019; + public static final int orange=0x7f070005; + public static final int pls_talk_normal=0x7f070002; + public static final int save_button=0x7f07000a; + public static final int search_hint=0x7f070003; + public static final int status_done=0x7f070016; + public static final int status_error=0x7f070018; + public static final int status_idle=0x7f070015; + public static final int status_sync=0x7f070017; + public static final int title=0x7f07000b; + public static final int white=0x7f070006; + public static final int white_special=0x7f070014; + public static final int widget_days=0x7f07000e; + public static final int widget_silver=0x7f07000f; + public static final int widget_text=0x7f070010; + public static final int widget_title=0x7f07000d; + } + public static final class dimen { + public static final int day_container_width=0x7f080003; + public static final int expanded_height=0x7f080001; + public static final int normal_height=0x7f080000; + public static final int task_item_name_width=0x7f080006; + public static final int widget_font_size=0x7f080002; + public static final int widget_task_height=0x7f080005; + public static final int widget_task_width=0x7f080004; + } + public static final class drawable { + public static final int add_task_btn_normal=0x7f020000; + public static final int add_task_btn_pressed=0x7f020001; + public static final int add_task_dialog_icon=0x7f020002; + public static final int alert=0x7f020003; + public static final int bg_add_task_btn=0x7f020004; + public static final int bg_quick_dial=0x7f020005; + public static final int calendar_bg=0x7f020006; + public static final int chatfrom_bg=0x7f020007; + public static final int chatfrom_bg_focused=0x7f020008; + public static final int chatfrom_bg_normal=0x7f020009; + public static final int chatto_bg=0x7f02000a; + public static final int chatto_bg_focused=0x7f02000b; + public static final int chatto_bg_normal=0x7f02000c; + public static final int clock=0x7f02000d; + public static final int custom_button=0x7f02000e; + public static final int custom_button1=0x7f02000f; + public static final int dialog=0x7f020010; + public static final int dialog_divider_horizontal_light=0x7f020011; + public static final int droid_widget=0x7f020012; + public static final int droid_widget_focused=0x7f020013; + public static final int droid_widget_normal=0x7f020014; + public static final int droid_widget_pressed=0x7f020015; + public static final int droidman_closed=0x7f020016; + public static final int droidman_down_closed=0x7f020017; + public static final int droidman_down_open=0x7f020018; + public static final int droidman_open=0x7f020019; + public static final int edit_text=0x7f02001a; + public static final int face_gallery_bg=0x7f02001b; + public static final int focused=0x7f02001c; + public static final int goal1=0x7f02001d; + public static final int goal2=0x7f02001e; + public static final int goal3=0x7f02001f; + public static final int goal_bg=0x7f020020; + public static final int goal_delete=0x7f020021; + public static final int goal_edit=0x7f020022; + public static final int goal_edit_img=0x7f020023; + public static final int goal_empty=0x7f020024; + public static final int goal_full=0x7f020025; + public static final int h1=0x7f020026; + public static final int h2=0x7f020027; + public static final int h3=0x7f020028; + public static final int h4=0x7f020029; + public static final int h5=0x7f02002a; + public static final int h6=0x7f02002b; + public static final int h7=0x7f02002c; + public static final int heart_message=0x7f02002d; + public static final int history_flag=0x7f02002e; + public static final int ic_clock_alarm_selected=0x7f02002f; + public static final int ic_done=0x7f020030; + public static final int ic_error=0x7f020031; + public static final int ic_idle=0x7f020032; + public static final int ic_syncing=0x7f020033; + public static final int icon=0x7f020034; + public static final int im_my_del_btn=0x7f020035; + public static final int im_other_del_btn=0x7f020036; + public static final int img0002=0x7f020037; + public static final int img0003=0x7f020038; + public static final int img0004=0x7f020039; + public static final int img0005=0x7f02003a; + public static final int img0006=0x7f02003b; + public static final int img0007=0x7f02003c; + public static final int img0008=0x7f02003d; + public static final int layoutbg=0x7f02003e; + public static final int mm_chat_listitem=0x7f02003f; + public static final int mm_trans=0x7f020040; + public static final int mmtitle_bg=0x7f020041; + public static final int nofocused=0x7f020042; + public static final int notepad=0x7f020043; + public static final int option_normal=0x7f020044; + public static final int option_selected=0x7f020045; + public static final int popupview_down=0x7f020046; + public static final int popupview_up=0x7f020047; + public static final int recommend_bg=0x7f020048; + public static final int shape_selector=0x7f020049; + public static final int sms_embeded_text_editor_bg=0x7f02004a; + public static final int sms_insert=0x7f02004b; + public static final int sms_send_button_bg=0x7f02004c; + public static final int sms_send_button_bg_disabled=0x7f02004d; + public static final int sms_send_button_bg_normal=0x7f02004e; + public static final int sms_send_button_bg_pressed=0x7f02004f; + public static final int star1=0x7f020050; + public static final int star2=0x7f020051; + public static final int star3=0x7f020052; + public static final int star4=0x7f020053; + public static final int task_today_bg=0x7f020054; + public static final int task_tomorrow_bg=0x7f020055; + public static final int task_yesterday_bg=0x7f020056; + public static final int textfield_disabled=0x7f020057; + public static final int textfield_disabled_selected=0x7f020058; + public static final int textfield_pressed=0x7f020059; + public static final int theme_checked=0x7f02005a; + public static final int theme_checked_disable=0x7f02005b; + public static final int theme_checked_pressed=0x7f02005c; + public static final int tomorrowtask_love=0x7f02005d; + public static final int txt_msg_bg=0x7f02005e; + public static final int wifisms_insert_normal_bg=0x7f02005f; + public static final int wifisms_insert_pressed_bg=0x7f020060; + public static final int yesterday_delete_btn_bg=0x7f020061; + } + public static final class id { + public static final int HistoryGoalGallery=0x7f0c0030; + public static final int addTask=0x7f0c004e; + public static final int body=0x7f0c002f; + public static final int bugdroid=0x7f0c000e; + public static final int cancel=0x7f0c002d; + public static final int cb_time_alert=0x7f0c0008; + public static final int cb_tomorrow_time_alert=0x7f0c0019; + public static final int chatting_history_lv=0x7f0c0023; + public static final int current_goal_listview=0x7f0c0013; + public static final int details_error=0x7f0c003a; + public static final int details_sync=0x7f0c0036; + public static final int details_sync_label=0x7f0c0039; + public static final int details_sync_progress=0x7f0c0037; + public static final int details_sync_progress_indet=0x7f0c0038; + public static final int dialog_message=0x7f0c002c; + public static final int dialog_title=0x7f0c002b; + public static final int dp_tomorrow_task_date=0x7f0c0016; + public static final int edit_goal_dialog_et=0x7f0c0014; + public static final int et_task_info=0x7f0c0000; + public static final int et_task_position=0x7f0c0002; + public static final int et_tomorrow_task_info=0x7f0c0015; + public static final int goal_clear_btn=0x7f0c001c; + public static final int goal_content_textview=0x7f0c001e; + public static final int goal_edit_btn=0x7f0c001b; + public static final int goal_edit_popup_view=0x7f0c001a; + public static final int goal_rank_img=0x7f0c001d; + public static final int heart_content_itv=0x7f0c0021; + public static final int heart_state_iv=0x7f0c0022; + public static final int heart_time_tv=0x7f0c0020; + public static final int history_gallery=0x7f0c002a; + public static final int history_task_listview=0x7f0c0029; + public static final int linearLayout1=0x7f0c0018; + public static final int myCursor=0x7f0c001f; + public static final int ok=0x7f0c002e; + public static final int past_goal_popwindow_button=0x7f0c0032; + public static final int past_goal_popwindow_imageview=0x7f0c0031; + public static final int send_button=0x7f0c0026; + public static final int sms_button_insert=0x7f0c0024; + public static final int status_icon=0x7f0c0033; + public static final int status_label=0x7f0c0035; + public static final int sync_button=0x7f0c0034; + public static final int task_alert_dialog_confirm_btn=0x7f0c003c; + public static final int task_alert_dialog_content=0x7f0c003b; + public static final int task_rank_first=0x7f0c0004; + public static final int task_rank_fourth=0x7f0c0007; + public static final int task_rank_group=0x7f0c0003; + public static final int task_rank_second=0x7f0c0005; + public static final int task_rank_third=0x7f0c0006; + public static final int task_repeat=0x7f0c0009; + public static final int task_repeat_days_button=0x7f0c000c; + public static final int task_repeat_days_date=0x7f0c000a; + public static final int task_repeat_days_total=0x7f0c000b; + public static final int textView_datematter=0x7f0c004f; + public static final int textView_datemattermessage=0x7f0c0050; + public static final int textView_daysleft=0x7f0c0052; + public static final int textView_future=0x7f0c004c; + public static final int textView_futuremessage=0x7f0c004d; + public static final int textView_history=0x7f0c0027; + public static final int textView_history_date=0x7f0c0028; + public static final int textView_today=0x7f0c0044; + public static final int textView_today_date=0x7f0c0045; + public static final int textView_tomorrow_day=0x7f0c0051; + public static final int textView_yesterday=0x7f0c005d; + public static final int textView_yesterday_date=0x7f0c005e; + public static final int text_editor=0x7f0c0025; + public static final int tip_bubble=0x7f0c000d; + public static final int tip_callout=0x7f0c0010; + public static final int tip_footer=0x7f0c000f; + public static final int tip_header=0x7f0c0011; + public static final int tip_message=0x7f0c0012; + public static final int today_add_task_btn=0x7f0c0046; + public static final int today_repeat_days=0x7f0c003f; + public static final int today_star_rank=0x7f0c0040; + public static final int today_task_complete_state=0x7f0c0043; + public static final int today_task_info=0x7f0c003e; + public static final int today_task_listview=0x7f0c0047; + public static final int today_task_time_position_textview=0x7f0c0041; + public static final int today_task_widget=0x7f0c0048; + public static final int today_time_alert=0x7f0c0042; + public static final int tomorrow_item_textView_datematter=0x7f0c0049; + public static final int tomorrow_item_textView_daysleft=0x7f0c004a; + public static final int tomorrow_item_textView_tomorrow_day=0x7f0c004b; + public static final int tomorrow_task_listview=0x7f0c0053; + public static final int tomorrow_widget_date=0x7f0c0057; + public static final int tomorrow_widget_days=0x7f0c0056; + public static final int tomorrow_widget_event=0x7f0c0058; + public static final int tomorrow_widget_layout_inside=0x7f0c0054; + public static final int tomorrow_widget_title=0x7f0c0055; + public static final int tp_task_time=0x7f0c0001; + public static final int tp_tomorrow_task_time=0x7f0c0017; + public static final int viewFlipper=0x7f0c003d; + public static final int yesterday_star_rank=0x7f0c005a; + public static final int yesterday_task_edit_btn=0x7f0c005c; + public static final int yesterday_task_info=0x7f0c0059; + public static final int yesterday_task_listview=0x7f0c005f; + public static final int yesterday_task_time_position_textview=0x7f0c005b; + } + public static final class layout { + public static final int about_layout=0x7f030000; + public static final int add_task_dialog_layout=0x7f030001; + public static final int bubble=0x7f030002; + public static final int current_goal_layout=0x7f030003; + public static final int droid=0x7f030004; + public static final int edit_goal_dialog=0x7f030005; + public static final int edit_tomorrow_task_dialog_layout=0x7f030006; + public static final int goal_edit_popup_window=0x7f030007; + public static final int goal_item=0x7f030008; + public static final int goal_layout=0x7f030009; + public static final int heart_item_from=0x7f03000a; + public static final int heart_item_to=0x7f03000b; + public static final int heart_layout=0x7f03000c; + public static final int help_layout=0x7f03000d; + public static final int history_oneday=0x7f03000e; + public static final int iphone_alert_dialog_layout=0x7f03000f; + public static final int past_goal_layout=0x7f030010; + public static final int past_goal_popwindow=0x7f030011; + public static final int status=0x7f030012; + public static final int task_alert_layout=0x7f030013; + public static final int task_main_layout=0x7f030014; + public static final int task_notify_layout=0x7f030015; + public static final int today_task_item=0x7f030016; + public static final int today_task_layout=0x7f030017; + public static final int today_task_widget_layout=0x7f030018; + public static final int tomorrow_task_item=0x7f030019; + public static final int tomorrow_task_layout=0x7f03001a; + public static final int tomorrow_task_widget_in=0x7f03001b; + public static final int tomorrow_task_widget_layout=0x7f03001c; + public static final int yesterday_task_item=0x7f03001d; + public static final int yesterday_task_layout=0x7f03001e; + } + public static final class plurals { + public static final int status_done_details=0x7f0a0000; + } + public static final class string { + /** 关于 + */ + public static final int about_string=0x7f090036; + public static final int about_title=0x7f090007; + /** 对话框 + */ + public static final int add_task_dialog_title=0x7f09001a; + /** button text + */ + public static final int add_task_label=0x7f090019; + public static final int alarm_notify_text=0x7f090072; + public static final int app_name=0x7f090000; + public static final int cancel_dialog_text=0x7f09001d; + public static final int current_goal_intro=0x7f090026; + public static final int delete_dialog_text=0x7f090035; + public static final int edit_goal_dialog_cancel=0x7f090034; + public static final int edit_goal_dialog_et_hint=0x7f090032; + public static final int edit_goal_dialog_ok=0x7f090033; + public static final int edit_goal_dialog_title=0x7f090030; + public static final int edit_goal_dialog_tv=0x7f090031; + public static final int edit_task_dialog_title=0x7f09001b; + public static final int err_communication_error=0x7f090071; + public static final int err_could_not_create_folder=0x7f09006f; + public static final int err_sync_requires_login_info=0x7f090070; + /** Tab + */ + public static final int goal_tab_current_text=0x7f090027; + public static final int goal_tab_past_text=0x7f090028; + public static final int heart_list_view_empty=0x7f090038; + public static final int help_goal=0x7f090075; + public static final int help_history=0x7f090077; + public static final int help_main_string=0x7f090073; + public static final int help_setup=0x7f090078; + public static final int help_task=0x7f090074; + public static final int help_tips=0x7f090076; + public static final int help_title=0x7f090006; + public static final int help_widget=0x7f090079; + public static final int history_task_list_view_empty=0x7f09003a; + public static final int label_history=0x7f090018; + /** label + */ + public static final int label_today=0x7f090015; + public static final int label_tomorrow=0x7f090016; + public static final int label_yesterday=0x7f090017; + public static final int limit_title=0x7f090003; + public static final int long_title=0x7f090004; + public static final int menu_about=0x7f09000e; + public static final int menu_delete_location=0x7f090011; + public static final int menu_exit=0x7f09000f; + public static final int menu_help=0x7f09000d; + public static final int menu_limit=0x7f09000a; + public static final int menu_long=0x7f09000b; + public static final int menu_modify_location=0x7f090010; + public static final int menu_setup=0x7f09000c; + /** 菜单项名称 + */ + public static final int menu_task=0x7f090008; + public static final int menu_time=0x7f090009; + public static final int menu_widget=0x7f090012; + public static final int pager_footer=0x7f09003e; + public static final int planbetter_widget_title=0x7f090025; + public static final int save_task_dialog_text=0x7f09001c; + public static final int setting_one=0x7f090040; + public static final int setting_three=0x7f090042; + public static final int setting_two=0x7f090041; + public static final int setup_title=0x7f090005; + public static final int status_auth_failure=0x7f090054; + public static final int status_auth_failure_details=0x7f090055; + public static final int status_calc=0x7f090056; + public static final int status_calc_details=0x7f090057; + public static final int status_canceled=0x7f090058; + public static final int status_canceled_details=0x7f090059; + public static final int status_done=0x7f09004f; + public static final int status_done_details_max_per_sync=0x7f090050; + public static final int status_done_details_noitems=0x7f090051; + public static final int status_idle=0x7f090048; + public static final int status_idle_details=0x7f090049; + public static final int status_idle_details_never=0x7f09004a; + public static final int status_login=0x7f09004d; + public static final int status_login_details=0x7f09004e; + public static final int status_sync=0x7f09004b; + public static final int status_sync_details=0x7f09004c; + public static final int status_unknown_error=0x7f090052; + public static final int status_unknown_error_details=0x7f090053; + public static final int task_alert_dialog_confirm=0x7f09002f; + /** 闹钟提示对话框 + */ + public static final int task_alert_dialog_title=0x7f09002e; + public static final int task_item_long_click_menu_delete=0x7f09002b; + public static final int task_item_long_click_menu_edit=0x7f09002a; + public static final int task_item_long_click_menu_pull=0x7f09002c; + /** menu + */ + public static final int task_item_long_click_menu_title=0x7f090029; + /** 帮助 + + \tPlanBetter计划更好点是一个时间管理软件,这个软件专注于历史、今天和未来,通过自身目标的设立和鼓励自己的心语督促自己利用好每一天的时间去使自己计划更好点,达到自己想要的目标。 + 整个软件共有任务、目标、心语、历史、设置这几个主要菜单项\n\n + \t1 + 任务;任务专注于昨天、今天和未来。滑动屏幕可以进行昨天、今天和未来的切换。快捷回顾昨天的时间安排状况,并且通过帕累托原则将任务划分轻重缓急,合理安排今天,并有闹钟提醒、重复任务、widget桌面提示等功能,采用倒数日的方式规划明天,就是任务项的特色所在。\n\n + \t2 + 目标:目标分为两部分,当前目标和历史目标。当前目标显示的你当前的三个目标,当你对当前目标进行修改的时候,这些目标选项自动保存至历史目标。这个设计是为了让使用这个软件的人时刻牢记自己的目标,为未来奋斗。\n\n + \t3 心语:心语即自己的心路历程,你可以写下任何你想说的话,软件会保存这些内容,鼓励自己一步步向前。\n\n + \t4 历史:历史的主界面是个日历,点击这个日历,可以快捷的查看你当天的任务完成状况,让你不错过你的每一段历史。\n\n + \t5 设置: + + edittext + 今天活动列表为空时默认显示内容 + */ + public static final int task_list_view_empty=0x7f090037; + public static final int task_long_click_menu_delete=0x7f09007b; + public static final int task_long_click_menu_edit=0x7f09007a; + public static final int task_long_click_menu_pull=0x7f09007c; + public static final int task_long_click_menu_title=0x7f09007d; + /** notifycation + */ + public static final int task_notification=0x7f09002d; + public static final int task_position_title=0x7f090014; + public static final int task_rank_first_text=0x7f09001e; + public static final int task_rank_fourth_text=0x7f090021; + public static final int task_rank_second_text=0x7f09001f; + public static final int task_rank_third_text=0x7f090020; + public static final int task_time_alert_text=0x7f090022; + public static final int task_time_pull_dialog_title=0x7f090024; + public static final int task_time_repeat_dialog_title=0x7f090023; + /** 任务信息 + */ + public static final int task_time_title=0x7f090013; + /** activity标题 + */ + public static final int task_title=0x7f090001; + public static final int time_title=0x7f090002; + public static final int today_task_widget_name=0x7f09003d; + public static final int tomorrow_task_list_view_empty=0x7f090039; + public static final int tomorrow_task_widget_name=0x7f09003f; + public static final int tts_pause=0x7f09003c; + public static final int ui_dialog_invalid_imap_folder_msg=0x7f09006c; + public static final int ui_dialog_invalid_imap_folder_title=0x7f09006b; + public static final int ui_dialog_missing_credentials_msg=0x7f090068; + public static final int ui_dialog_missing_credentials_title=0x7f090067; + public static final int ui_dialog_need_first_manual_sync_msg=0x7f09006e; + public static final int ui_dialog_need_first_manual_sync_title=0x7f09006d; + public static final int ui_dialog_sync_data_reset_msg=0x7f09006a; + public static final int ui_dialog_sync_data_reset_title=0x7f090069; + public static final int ui_imap_folder_desc=0x7f090063; + public static final int ui_imap_folder_label=0x7f090062; + public static final int ui_imap_folder_label_dialog_msg=0x7f090064; + public static final int ui_login_desc=0x7f09005d; + public static final int ui_login_dialog_msg=0x7f09005e; + public static final int ui_login_label=0x7f09005c; + public static final int ui_max_items_per_sync_desc=0x7f090066; + public static final int ui_max_items_per_sync_label=0x7f090065; + public static final int ui_password_desc=0x7f090060; + public static final int ui_password_dialog_msg=0x7f090061; + public static final int ui_password_label=0x7f09005f; + public static final int ui_settings_label=0x7f09005b; + public static final int ui_status_label=0x7f09005a; + public static final int ui_sync_button_label_canceling=0x7f090047; + public static final int ui_sync_button_label_done=0x7f090044; + public static final int ui_sync_button_label_error=0x7f090045; + public static final int ui_sync_button_label_idle=0x7f090043; + /** TODO(chstuder): Rename the following string resource. + */ + public static final int ui_sync_button_label_syncing=0x7f090046; + public static final int yesterday_task_list_view_empty=0x7f09003b; + } + public static final class style { + public static final int ChattingUISplit=0x7f0b0000; + public static final int ChattingUIText=0x7f0b0001; + public static final int MMTheme_Basic=0x7f0b0003; + public static final int MMTitleStyle=0x7f0b0002; + public static final int TipText=0x7f0b0004; + public static final int TipText_Footer=0x7f0b0007; + public static final int TipText_Header=0x7f0b0005; + public static final int TipText_Message=0x7f0b0006; + } + public static final class xml { + public static final int main_screen=0x7f050000; + public static final int today_task_widget_build=0x7f050001; + public static final int tomorrow_task_widget_build=0x7f050002; + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/AboutActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/AboutActivity.java new file mode 100644 index 0000000..c31122a --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/AboutActivity.java @@ -0,0 +1,17 @@ +package com.timebetter.activity; + +import com.timebetter.activity.R; + +import android.app.Activity; +import android.os.Bundle; + +public class AboutActivity extends Activity { + + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.about_layout); + setTitle("TimeBetter "); + + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/CurrentGoalActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/CurrentGoalActivity.java new file mode 100644 index 0000000..1457ef9 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/CurrentGoalActivity.java @@ -0,0 +1,398 @@ +package com.timebetter.activity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import android.app.Activity; +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.ContentValues; +import android.content.DialogInterface; +import android.database.Cursor; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.Window; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.animation.AnimationUtils; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.PopupWindow; +import android.widget.TextView; +import android.widget.Toast; + +import com.timebetter.activity.R; +import com.timebetter.bean.GoalBean; +import com.timebetter.constant.GoalConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; + +/** + * ǰĿ + * + * + * + */ +public class CurrentGoalActivity extends Activity { + + private ListView goalListView = null; + private List> goalItemList = null; + private GoalListViewAdapter goalAdapter = null; + private Cursor goalCur; + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.current_goal_layout); + + initGoalAdapter(); + goalListView = (ListView) findViewById(R.id.current_goal_listview); + goalListView.setAdapter(goalAdapter); + + } + + private void initGoalAdapter() { + initGoalItemList(); + goalAdapter = new GoalListViewAdapter(); + } + + private void initGoalItemList() { + goalItemList = new ArrayList>(); + + String firstGoal = ""; + String secondGoal = ""; + String thirdGoal = ""; + + goalCur = DatabaseUtil.query(CurrentGoalActivity.this, GoalBean.TABLE_NAME, new String[]{GoalBean.GOAL_CONTENT,GoalBean.GOAL_FLAG}, + GoalBean.GOAL_FLAG+"!="+GoalConstant.FORMER_GOAL, null, null, null, GoalBean.GOAL_FLAG+" ASC"); + + for(goalCur.moveToFirst();!goalCur.isAfterLast();goalCur.moveToNext()) { + + switch(goalCur.getInt(goalCur.getColumnIndex(GoalBean.GOAL_FLAG))) { + case GoalConstant.RANK_FIRST: + firstGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + case GoalConstant.RANK_SECOND: + secondGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + case GoalConstant.RANK_THIRD: + thirdGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + } + + } + DatabaseUtil.closeDatabase(); + + Map map1 = new HashMap(); + map1.put(GoalBean.GOAL_CONTENT, firstGoal); + map1.put(GoalBean.GOAL_FLAG, GoalConstant.RANK_FIRST); + goalItemList.add(0, map1); + + Map map2 = new HashMap(); + map2.put(GoalBean.GOAL_CONTENT, secondGoal); + map2.put(GoalBean.GOAL_FLAG, GoalConstant.RANK_SECOND); + goalItemList.add(1, map2); + + Map map3 = new HashMap(); + map3.put(GoalBean.GOAL_CONTENT, thirdGoal); + map3.put(GoalBean.GOAL_FLAG, GoalConstant.RANK_THIRD); + goalItemList.add(2, map3); + } + + public class GoalListViewAdapter extends BaseAdapter { + + private View popupView; + private PopupWindow popup; + + private Button goalEditBtn; + private Button goalClearBtn; + + private int goalFlag = GoalConstant.FORMER_GOAL; + private int curPosition = 0; + private boolean isEmpty = true; + + final class GoalListItemView { + public ImageView goalRankImg; // Ŀ꼶ͼƬ + public TextView goalContent; // Ŀ + public ImageView myCursor; // ͷͼƬ + } + + public GoalListViewAdapter() { + initPopupWindow(); + } + + private void initPopupWindow() { + popupView = LayoutInflater.from(CurrentGoalActivity.this).inflate( + R.layout.goal_edit_popup_window, null); + popup = new PopupWindow(popupView, + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + popup.setOutsideTouchable(true); + goalEditBtn = (Button) popupView.findViewById(R.id.goal_edit_btn); + goalClearBtn = (Button) popupView.findViewById(R.id.goal_clear_btn); + } + + public int getCount() { + // TODO Auto-generated method stub + return goalItemList.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return goalItemList.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return Integer.parseInt(goalItemList.get(position).get(GoalBean.GOAL_FLAG).toString()); + } + + public View getView(final int position, View convertView, ViewGroup parent) { + // TODO Auto-generated method stub + GoalListItemView listItemView = null; + if (convertView == null) { + listItemView = new GoalListItemView(); + convertView = LayoutInflater.from(CurrentGoalActivity.this) + .inflate(R.layout.goal_item, null); + // ȡؼ + listItemView.goalContent = (TextView) convertView + .findViewById(R.id.goal_content_textview); + listItemView.goalRankImg = (ImageView) convertView + .findViewById(R.id.goal_rank_img); + listItemView.myCursor = (ImageView) convertView + .findViewById(R.id.myCursor); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (GoalListItemView) convertView.getTag(); + } + + // + listItemView.goalContent.setText(goalItemList.get(position) + .get(GoalBean.GOAL_CONTENT).toString()); + + // ȼͼƬ goalRank + switch (Integer.parseInt(goalItemList.get(position) + .get(GoalBean.GOAL_FLAG).toString())) { + case GoalConstant.RANK_FIRST: + listItemView.goalRankImg + .setBackgroundResource(R.drawable.goal1); + break; + case GoalConstant.RANK_SECOND: + listItemView.goalRankImg + .setBackgroundResource(R.drawable.goal2); + break; + case GoalConstant.RANK_THIRD: + listItemView.goalRankImg + .setBackgroundResource(R.drawable.goal3); + break; + } + + listItemView.myCursor.setOnClickListener(new OnClickListener() { + + private View editGoalDialogView; + private EditText goalEditText; + + @Override + public void onClick(View view) { + // TODO Auto-generated method stub + curPosition = position; + goalFlag = position + 1; + final String goalContent = goalItemList.get(position).get(GoalBean.GOAL_CONTENT).toString(); + isEmpty = goalContent.equals("") ? true : false; + Log.d("debug", "curPosition="+position); + + if (popup.isShowing()) { + popup.dismiss(); + } else { + if(isEmpty) { + goalClearBtn.setBackgroundResource(R.drawable.goal_empty); + } else { + goalClearBtn.setBackgroundResource(R.drawable.goal_full); + } + ((LinearLayout) (popupView + .findViewById(R.id.goal_edit_popup_view))) + .setBackgroundResource(R.drawable.popupview_down); + popup.setAnimationStyle(R.anim.popup_window_bottom); + popup.update(); + popup.showAsDropDown(view); + goalEditBtn.startAnimation(AnimationUtils.loadAnimation( + CurrentGoalActivity.this, R.anim.my_scale_action)); + goalClearBtn.startAnimation(AnimationUtils.loadAnimation( + CurrentGoalActivity.this, R.anim.my_scale_action)); + + goalEditBtn.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // TODO Auto-generated method stub + popup.dismiss(); + editGoalDialogView = LayoutInflater.from( + CurrentGoalActivity.this).inflate( + R.layout.edit_goal_dialog, null); + goalEditText = (EditText) editGoalDialogView + .findViewById(R.id.edit_goal_dialog_et); + if(!isEmpty) { + goalEditText.setText(goalContent); + } + new AlertDialog.Builder(CurrentGoalActivity.this) + .setTitle(R.string.edit_goal_dialog_title) + .setIcon(android.R.drawable.ic_menu_edit) + .setView(editGoalDialogView) + .setPositiveButton( + R.string.edit_goal_dialog_ok, + new DialogInterface.OnClickListener() { + + @Override + public void onClick( + DialogInterface dialog, + int which) { + // TODO Auto-generated + // method stub + // 水ť + // ȡ + String content = goalEditText + .getText() + .toString() + .trim() + .replaceAll("\r", + "") + .replaceAll("\t", + "") + .replaceAll("\n", + "") + .replaceAll("\f", + ""); + if (content.equals("")) { + Toast.makeText(CurrentGoalActivity.this, "Ŀ겻Ϊ", Toast.LENGTH_SHORT).show(); + } else { + // + ContentValues values = new ContentValues(); + values.put(GoalBean.GOAL_CONTENT,content); + values.put(GoalBean.DATE,DateUtils.now()); + values.put(GoalBean.GOAL_FLAG,goalFlag); + Log.d("debug","goalFlag="+goalFlag+" curPosition="+curPosition); + if(isEmpty) { + //뵽ݿ + long id = DatabaseUtil.insert(CurrentGoalActivity.this, GoalBean.TABLE_NAME, GoalBean.ID, values); + if(id != -1) { + //listview + Map map = goalItemList.get(curPosition); + map.put(GoalBean.GOAL_CONTENT, content); + goalItemList.set(curPosition, map); + goalAdapter.notifyDataSetChanged(); + Toast.makeText(CurrentGoalActivity.this, "ĿѾȷ,ҪúŬŶ", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(CurrentGoalActivity.this, "ݿʧ", Toast.LENGTH_SHORT).show(); + } + } else { + //޸IJ + ContentValues former = new ContentValues(); + former.put(GoalBean.GOAL_FLAG, GoalConstant.FORMER_GOAL); + int rows = DatabaseUtil.update(CurrentGoalActivity.this, GoalBean.TABLE_NAME, former, + GoalBean.GOAL_FLAG+"="+goalFlag, null); + long id = DatabaseUtil.insert(CurrentGoalActivity.this, GoalBean.TABLE_NAME, GoalBean.ID, values); + if(id != -1 && rows > 0) { + Map map = goalItemList.get(curPosition); + map.put(GoalBean.GOAL_CONTENT, content); + goalItemList.set(curPosition, map); + goalAdapter.notifyDataSetChanged(); + Toast.makeText(CurrentGoalActivity.this, "ĿѾȷ,ǰĿʷĿв鿴", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(CurrentGoalActivity.this, "ݿʧ", Toast.LENGTH_SHORT).show(); + } + } + } + } + }) + .setNegativeButton( + R.string.edit_goal_dialog_cancel, + new DialogInterface.OnClickListener() { + + @Override + public void onClick( + DialogInterface dialog, + int which) { + // TODO Auto-generated + // method stub + + } + }).create().show(); + + } + }); + + goalClearBtn.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // TODO Auto-generated method stub + popup.dismiss(); + showCustomMessage("ȷɾ","ȷɾĿ?"); + } + }); + } + } + }); + + return convertView; + } + + private void showCustomMessage(String pTitle, final String pMsg) { + final Dialog lDialog = new Dialog(CurrentGoalActivity.this, + android.R.style.Theme_Translucent_NoTitleBar); + lDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + lDialog.setContentView(R.layout.iphone_alert_dialog_layout); + ((TextView) lDialog.findViewById(R.id.dialog_title)).setText(pTitle); + ((TextView) lDialog.findViewById(R.id.dialog_message)).setText(pMsg); + ((Button) lDialog.findViewById(R.id.cancel)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // CANCEL + lDialog.dismiss(); + } + }); + ((Button) lDialog.findViewById(R.id.ok)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks OK + lDialog.dismiss(); + //Ŀ + if(isEmpty) { + //Ϊ + Toast.makeText(CurrentGoalActivity.this, "ĿΪ޷ɾ", Toast.LENGTH_SHORT).show(); + } else { + //Ϊ + ContentValues values = new ContentValues(); + values.put(GoalBean.GOAL_FLAG, GoalConstant.FORMER_GOAL); + int rows = DatabaseUtil.update(CurrentGoalActivity.this,GoalBean.TABLE_NAME,values,GoalBean.GOAL_FLAG+"="+goalFlag,null); + if(rows > 0) { + //ˢlistview + Map map = goalItemList.get(curPosition); + map.put(GoalBean.GOAL_CONTENT, ""); + goalItemList.set(curPosition, map); + goalAdapter.notifyDataSetChanged(); + Toast.makeText(CurrentGoalActivity.this, "Ŀɾɹ,ʷĿв鿴", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(CurrentGoalActivity.this, "ݿֶʧ", Toast.LENGTH_SHORT).show(); + } + } + } + }); + lDialog.show(); + + } + + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/HelpActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/HelpActivity.java new file mode 100644 index 0000000..f1e2563 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/HelpActivity.java @@ -0,0 +1,17 @@ +package com.timebetter.activity; + +import com.timebetter.activity.R; + +import android.app.Activity; +import android.os.Bundle; + +public class HelpActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + + setContentView(R.layout.help_layout); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/HistoryActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/HistoryActivity.java new file mode 100644 index 0000000..961508f --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/HistoryActivity.java @@ -0,0 +1,504 @@ +package com.timebetter.activity; + +import java.util.ArrayList; +import java.util.Calendar; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.DisplayMetrics; +import android.view.GestureDetector; +import android.view.GestureDetector.OnGestureListener; +import android.view.Gravity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; + +import com.timebetter.activity.R; +import com.timebetter.constant.DayStyle; +import com.timebetter.constant.MenuItemId; +import com.timebetter.constant.MotionEventConstant; +import com.timebetter.view.DateWidgetDayCell; +import com.timebetter.view.DateWidgetDayHeader; +import com.timebetter.view.SymbolButton; + +public class HistoryActivity extends Activity implements OnGestureListener { + private ArrayList days = new ArrayList(); + // private SimpleDateFormat dateMonth = new SimpleDateFormat("MMMM yyyy"); + private Calendar calStartDate = Calendar.getInstance(); + private Calendar calToday = Calendar.getInstance(); + private Calendar calCalendar = Calendar.getInstance(); + private Calendar calSelected = Calendar.getInstance(); + LinearLayout layContent = null; + + Button btnPrev = null; + Button btnToday = null; + Button btnNext = null; + + private int iFirstDayOfWeek = Calendar.MONDAY; + private int iMonthViewCurrentMonth = 0; + private int iMonthViewCurrentYear = 0; + public static final int SELECT_DATE_REQUEST = 111; + private int iDayCellSize = 42;// ԭֵ38 + private int iDayHeaderHeight = 24;// ԭֵ24 + private int cellpadding = 8; + private int iTotalWidth = (iDayCellSize * 7); + +// private int mYear = 0; +// private int mMonth = 0; +// private int mDay = 0; + + private GestureDetector mGestureDetector; + + @Override + public void onCreate(Bundle icicle) { + DisplayMetrics metric = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metric); + int width = metric.widthPixels; // Ļȣأ +// int height = metric.heightPixels; // Ļ߶ȣأ + + iDayCellSize = (width - 30) / 7; + iTotalWidth = (iDayCellSize * 7); + iDayHeaderHeight = iDayCellSize; + + super.onCreate(icicle); + iFirstDayOfWeek = Calendar.MONDAY; +// mYear = calSelected.get(Calendar.YEAR); +// mMonth = calSelected.get(Calendar.MONTH); +// mDay = calSelected.get(Calendar.DAY_OF_MONTH); + setContentView(generateContentView()); + calStartDate = getCalendarStartDate(); + DateWidgetDayCell daySelected = updateCalendar(); + if (daySelected != null) + daySelected.requestFocus(); + + mGestureDetector = new GestureDetector(this); + + } + + @Override + public void onStart() { + super.onStart(); + + } + + private LinearLayout createLayout(int iOrientation) { + LinearLayout lay = new LinearLayout(this); + lay.setLayoutParams(new LayoutParams( + android.view.ViewGroup.LayoutParams.FILL_PARENT, + android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); + lay.setOrientation(iOrientation); + return lay; + } + + private Button createButton(String sText, int iWidth, int iHeight) { + Button btn = new Button(this); + btn.setText(sText); + btn.setLayoutParams(new LayoutParams(iWidth, iHeight)); + return btn; + } + + /* buttonȺandriodԴϵͳͼ */ + private void generateTopButtons(LinearLayout layTopControls) { + final int iHorPadding = 24; + final int iSmallButtonWidth = 60; + btnToday = createButton("", iTotalWidth - iSmallButtonWidth + - iSmallButtonWidth, + android.view.ViewGroup.LayoutParams.WRAP_CONTENT); + btnToday.setPadding(iHorPadding, btnToday.getPaddingTop(), iHorPadding, + btnToday.getPaddingBottom()); + btnToday.setBackgroundResource(android.R.drawable.btn_default_small); + + SymbolButton btnPrev = new SymbolButton(this, + SymbolButton.symbol.arrowLeft); + btnPrev.setLayoutParams(new LayoutParams(iSmallButtonWidth, + android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); + btnPrev.setBackgroundResource(android.R.drawable.btn_default_small); + + SymbolButton btnNext = new SymbolButton(this, + SymbolButton.symbol.arrowRight); + btnNext.setLayoutParams(new LayoutParams(iSmallButtonWidth, + android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); + btnNext.setBackgroundResource(android.R.drawable.btn_default_small); + + // set events + btnPrev.setOnClickListener(new Button.OnClickListener() { + public void onClick(View arg0) { + setPrevViewItem();/* һµʾ */ + } + }); + btnToday.setOnClickListener(new Button.OnClickListener() { + public void onClick(View arg0) { + + setTodayViewItem();/* ʾϢ */ + String s = calToday.get(Calendar.YEAR) + "" + + (calToday.get(Calendar.MONTH) + 1) + ""; + btnToday.setText(s); + } + }); + btnNext.setOnClickListener(new Button.OnClickListener() { + public void onClick(View arg0) { + setNextViewItem();/* һµʾ */ + } + }); + + /* ָؼĻλãˮƽ */ + layTopControls.setGravity(Gravity.CENTER_HORIZONTAL); + layTopControls.addView(btnPrev); + layTopControls.addView(btnToday); + layTopControls.addView(btnNext); + } + + /* ͼ */ + private View generateContentView() { + LinearLayout layMain = createLayout(LinearLayout.VERTICAL); + layMain.setPadding(cellpadding, cellpadding, cellpadding, cellpadding); + layMain.setBackgroundResource(R.drawable.calendar_bg); + LinearLayout layTopControls = createLayout(LinearLayout.HORIZONTAL); + + layContent = createLayout(LinearLayout.VERTICAL); + layContent.setPadding(5, 0, 5, 0);/* 20,0,20,0 */ + generateTopButtons(layTopControls); + generateCalendar(layContent); + + layMain.addView(layTopControls);/* ͷѡ */ + layMain.addView(layContent);/* ݲ */ + + return layMain; + } + + /* һʾ */ + private View generateCalendarRow() { + LinearLayout layRow = createLayout(LinearLayout.HORIZONTAL); + for (int iDay = 0; iDay < 7; iDay++) { + DateWidgetDayCell dayCell = new DateWidgetDayCell(this, + iDayCellSize, iDayCellSize + 10);// ޸Ĺ + dayCell.setItemClick(mOnDayCellClick); + days.add(dayCell); + layRow.addView(dayCell); + } + return layRow; + } + + /* ͷһ */ + private View generateCalendarHeader() { + LinearLayout layRow = createLayout(LinearLayout.HORIZONTAL); + for (int iDay = 0; iDay < 7; iDay++) { + DateWidgetDayHeader day = new DateWidgetDayHeader(this, + iDayCellSize, iDayHeaderHeight); + final int iWeekDay = DayStyle.getWeekDay(iDay, iFirstDayOfWeek); + day.setData(iWeekDay); + layRow.addView(day); + } + return layRow; + } + + /* ϲ˵ */ + private void generateCalendar(LinearLayout layContent) { + layContent.addView(generateCalendarHeader()); + days.clear(); + for (int iRow = 0; iRow < 6; iRow++) { + layContent.addView(generateCalendarRow()); + } + } + + /* õʼʱ */ + private Calendar getCalendarStartDate() { + calToday.setTimeInMillis(System.currentTimeMillis()); + calToday.setFirstDayOfWeek(iFirstDayOfWeek); + + if (calSelected.getTimeInMillis() == 0) { + calStartDate.setTimeInMillis(System.currentTimeMillis()); + calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); + } else { + calStartDate.setTimeInMillis(calSelected.getTimeInMillis()); + calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); + } + + UpdateStartDateForMonth(); + + return calStartDate; + } + + private DateWidgetDayCell updateCalendar() { + DateWidgetDayCell daySelected = null; + boolean bSelected = false; + final boolean bIsSelection = (calSelected.getTimeInMillis() != 0); + final int iSelectedYear = calSelected.get(Calendar.YEAR); + final int iSelectedMonth = calSelected.get(Calendar.MONTH); + final int iSelectedDay = calSelected.get(Calendar.DAY_OF_MONTH); + calCalendar.setTimeInMillis(calStartDate.getTimeInMillis()); + for (int i = 0; i < days.size(); i++) { + final int iYear = calCalendar.get(Calendar.YEAR); + final int iMonth = calCalendar.get(Calendar.MONTH); + final int iDay = calCalendar.get(Calendar.DAY_OF_MONTH); + final int iDayOfWeek = calCalendar.get(Calendar.DAY_OF_WEEK); + DateWidgetDayCell dayCell = days.get(i); + // check today + boolean bToday = false; + if (calToday.get(Calendar.YEAR) == iYear) + if (calToday.get(Calendar.MONTH) == iMonth) + if (calToday.get(Calendar.DAY_OF_MONTH) == iDay) + bToday = true; + // check holiday + boolean bHoliday = false; + if ((iDayOfWeek == Calendar.SATURDAY) + || (iDayOfWeek == Calendar.SUNDAY)) + bHoliday = true; + if ((iMonth == Calendar.JANUARY) && (iDay == 1)) + bHoliday = true; + + dayCell.setData(iYear, iMonth, iDay, bToday, bHoliday, + iMonthViewCurrentMonth); + bSelected = false; + if (bIsSelection) + if ((iSelectedDay == iDay) && (iSelectedMonth == iMonth) + && (iSelectedYear == iYear)) { + bSelected = true; + } + dayCell.setSelected(bSelected); + if (bSelected) + daySelected = dayCell; + calCalendar.add(Calendar.DAY_OF_MONTH, 1); + } + layContent.invalidate(); + return daySelected; + } + + private void UpdateStartDateForMonth() { + iMonthViewCurrentMonth = calStartDate.get(Calendar.MONTH); + iMonthViewCurrentYear = calStartDate.get(Calendar.YEAR); + calStartDate.set(Calendar.DAY_OF_MONTH, 1); + UpdateCurrentMonthDisplay(); + // update days for week + int iDay = 0; + int iStartDay = iFirstDayOfWeek; + if (iStartDay == Calendar.MONDAY) { + iDay = calStartDate.get(Calendar.DAY_OF_WEEK) - Calendar.MONDAY; + if (iDay < 0) + iDay = 6; + } + if (iStartDay == Calendar.SUNDAY) { + iDay = calStartDate.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY; + if (iDay < 0) + iDay = 6; + } + calStartDate.add(Calendar.DAY_OF_WEEK, -iDay); + } + + private void UpdateCurrentMonthDisplay() { + String s = calStartDate.get(Calendar.YEAR) + "" + + (calStartDate.get(Calendar.MONTH) + 1) + "";// dateMonth.format(calCalendar.getTime()); + btnToday.setText(s); +// mYear = calCalendar.get(Calendar.YEAR); + } + + private void setPrevViewItem() { + iMonthViewCurrentMonth--; + if (iMonthViewCurrentMonth == -1) { + iMonthViewCurrentMonth = 11; + iMonthViewCurrentYear--; + } + calStartDate.set(Calendar.DAY_OF_MONTH, 1); + calStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); + calStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); + UpdateStartDateForMonth(); + updateCalendar(); + + } + + public boolean onTouchEvent(MotionEvent event) { + return mGestureDetector.onTouchEvent(event); + } + + private void setTodayViewItem() { + calToday.setTimeInMillis(System.currentTimeMillis()); + calToday.setFirstDayOfWeek(iFirstDayOfWeek); + calStartDate.setTimeInMillis(calToday.getTimeInMillis()); + calStartDate.setFirstDayOfWeek(iFirstDayOfWeek); + UpdateStartDateForMonth(); + updateCalendar(); + } + + private void setNextViewItem() { + iMonthViewCurrentMonth++; + if (iMonthViewCurrentMonth == 12) { + iMonthViewCurrentMonth = 0; + iMonthViewCurrentYear++; + } + calStartDate.set(Calendar.DAY_OF_MONTH, 1); + calStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth); + calStartDate.set(Calendar.YEAR, iMonthViewCurrentYear); + UpdateStartDateForMonth(); + updateCalendar(); + + } + + private DateWidgetDayCell.OnItemClick mOnDayCellClick = new DateWidgetDayCell.OnItemClick() { + public void OnClick(DateWidgetDayCell item) { + calSelected.setTimeInMillis(item.getDate().getTimeInMillis()); + + item.setSelected(true); + updateCalendar(); + + int year = calSelected.get(Calendar.YEAR); + int month = calSelected.get(Calendar.MONTH) + 2; + int day = calSelected.get(Calendar.DAY_OF_MONTH); + int x = year * 10000 + month * 100 + day; + + Intent intent = new Intent(HistoryActivity.this, + HistoryOnedayActivity.class); + intent.putExtra("today", x); + startActivity(intent); + } + }; + + public boolean onDown(MotionEvent e) { + // TODO Auto-generated method stub + return false; + } + + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + // һ + if (e2.getX() - e1.getX() > MotionEventConstant.getFlingMinDistance() + && Math.abs(velocityX) > MotionEventConstant + .getFlingMinVelocity()) { + Message mes = new Message(); + mes.what = SET_PREV_VIEW; + handler.sendMessage(mes); + } + // 󻬶 + else if (e1.getX() - e2.getX() > MotionEventConstant + .getFlingMinDistance() + && Math.abs(velocityX) > MotionEventConstant + .getFlingMinVelocity()) { + Message mes = new Message(); + mes.what = SET_NETX_VIEW; + handler.sendMessage(mes); + } + + return true; + } + + public static final int SET_NETX_VIEW = 1; + public static final int SET_PREV_VIEW = 2; + + private Handler handler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + switch(msg.what) { + case SET_NETX_VIEW: + setNextViewItem();/* һµʾ */ + break; + case SET_PREV_VIEW: + setPrevViewItem();/* һµʾ */ + break; + } + } + + }; + + public void onLongPress(MotionEvent e) { + // TODO Auto-generated method stub + + } + + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, + float distanceY) { + // TODO Auto-generated method stub + return false; + } + + public void onShowPress(MotionEvent e) { + // TODO Auto-generated method stub + + } + + public boolean onSingleTapUp(MotionEvent e) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // TODO Auto-generated method stub + switch (item.getItemId()) { + case MenuItemId.MENU_ITEM_TASK: + Intent ht_intent = new Intent(HistoryActivity.this, + TaskActivity.class); + startActivity(ht_intent); + break; + // Ŀ + case MenuItemId.MENU_ITEM_TIME: + Intent tg_intent = new Intent(HistoryActivity.this, + HelpActivity.class); + startActivity(tg_intent); + break; + // + case MenuItemId.MENU_ITEM_LIMIT: + Intent tt_intent = new Intent(HistoryActivity.this, + HelpActivity.class); + startActivity(tt_intent); + break; + // + case MenuItemId.MENU_ITEM_SETUP: + Intent ti_intent = new Intent(HistoryActivity.this, + SetupActivity.class); + startActivity(ti_intent); + break; + // + case MenuItemId.MENU_ITEM_HELP: + Intent tx_intent = new Intent(HistoryActivity.this, + HelpActivity.class); + startActivity(tx_intent); + break; + // + case MenuItemId.MENU_ITEM_ABOUT: + Intent ty_intent = new Intent(HistoryActivity.this, + AboutActivity.class); + startActivity(ty_intent); + break; + } + return true; + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // TODO Auto-generated method stub + MenuItem menu_task = menu.add(0, MenuItemId.MENU_ITEM_TASK, 0, + R.string.menu_task); + menu_task.setIcon(android.R.drawable.ic_menu_agenda); + + MenuItem menu_goal = menu.add(0, MenuItemId.MENU_ITEM_TIME, 0, + R.string.menu_time); + menu_goal.setIcon(android.R.drawable.ic_menu_directions); + + MenuItem menu_tips = menu.add(0, MenuItemId.MENU_ITEM_LIMIT, 0, + R.string.menu_limit); + menu_tips.setIcon(android.R.drawable.ic_menu_compass); + + MenuItem menu_setup = menu.add(0, MenuItemId.MENU_ITEM_SETUP, 0, + R.string.menu_setup); + menu_setup.setIcon(android.R.drawable.ic_menu_preferences); + + MenuItem menu_help = menu.add(0, MenuItemId.MENU_ITEM_HELP, 0, + R.string.menu_help); + menu_help.setIcon(android.R.drawable.ic_menu_help); + + MenuItem menu_about = menu.add(0, MenuItemId.MENU_ITEM_ABOUT, 0, + R.string.menu_about); + menu_about.setIcon(android.R.drawable.ic_menu_info_details); + + return true; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/HistoryOnedayActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/HistoryOnedayActivity.java new file mode 100644 index 0000000..e855a9c --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/HistoryOnedayActivity.java @@ -0,0 +1,554 @@ +package com.timebetter.activity; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.content.Intent; +import android.content.res.Resources; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.Window; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.Gallery; +import android.widget.ImageSwitcher; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.Toast; +import android.widget.RelativeLayout.LayoutParams; +import android.widget.TextView; +import android.widget.ViewSwitcher.ViewFactory; + +import com.timebetter.activity.R; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; + +public class HistoryOnedayActivity extends Activity implements ViewFactory, + OnItemSelectedListener { + private View historyView = null; // ͼ + private List> historyTaskItemList = null; // ListϢ + private ListView historyTaskList = null; // Ϣбͼ + private static HistoryTaskListViewAdapter historyAdapter = null; // бͼadapter + private Cursor historyTaskCur; + private TextView listEmptyView; + private TextView historyDate; + + private static final int REFRESH_LAYOUT = 0; + + //ImageSwitcher mSwitcher; + Resources r; + int today; + int tyear; + int tmonth; + int tday; + + private Integer[] HistoryOnebgIds = { R.drawable.h1, R.drawable.h2, + R.drawable.h3, R.drawable.h4, R.drawable.h5, R.drawable.h6, + R.drawable.h7 }; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + requestWindowFeature(Window.FEATURE_NO_TITLE); + historyView = LayoutInflater.from(HistoryOnedayActivity.this).inflate( + R.layout.history_oneday, null); + setContentView(historyView); + + setTitle("ImageShowActivity"); + Intent intent = getIntent(); + today = intent.getIntExtra("today", 0); + tyear = today / 10000; + tmonth = today / 100 - tyear * 100; + tday = today % 100; + initViews(today); + + Gallery g = (Gallery) findViewById(R.id.history_gallery); + // Ϊͼָһ + g.setAdapter(new ImageAdapter(this)); + // Ӧ ͼбѡijͼ ¼ + g.setSelection(10); + g.setOnItemSelectedListener(this); + r = this.getResources(); + + } + + private Handler handler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + switch(msg.arg1) { + case REFRESH_LAYOUT: + refreshHistoryLayout(msg.arg2); + break; + } + } + + }; + + + private void initViews(int date) { + int year = date / 10000; + int month = date / 100 - year * 100; + int day = date % 100; + String currentDate = DateUtils.formatDate(year, month, day); + + String dateStr = getWeekDayFormat(date);// õFormatyyyymmdd + int weekday = getIntWeekDay(dateStr);// õܼ + String WeekDay = getStringWeekDay(weekday);// õַܼ + String dateString = getStringday(date) + " " + WeekDay; + + /*õһպڵʱ*/ + historyDate = (TextView) historyView + .findViewById(R.id.textView_history_date); + historyDate.setText(dateString); + + // ʼͼ + historyTaskList = (ListView) historyView + .findViewById(R.id. history_task_listview); + initHistoryAdapter(currentDate); + + historyTaskList.setAdapter(historyAdapter); + + listEmptyView=new TextView(this); + listEmptyView.setText(R.string.history_task_list_view_empty); + listEmptyView.setGravity(Gravity.CENTER); + listEmptyView.setTextSize(20); //С + listEmptyView.setTextColor(0xffffffff); + addContentView(listEmptyView, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); + historyTaskList.setEmptyView(listEmptyView); + } + + private void refreshHistoryLayout(int date) { + int year = date / 10000; + int month = date / 100 - year * 100; + int day = date % 100; + String currentDate = DateUtils.formatDate(year, month, day); + + String dateStr = getWeekDayFormat(date);// õFormatyyyymmdd + int weekday = getIntWeekDay(dateStr);// õܼ + String WeekDay = getStringWeekDay(weekday);// õַܼ + String dateString = getStringday(date) + " " + WeekDay; + + historyDate.setText(dateString); + + historyTaskItemList.clear(); + initHistoryListItem(currentDate); + historyAdapter.notifyDataSetChanged(); + } + + private void initHistoryAdapter(String date){ + historyTaskItemList = new ArrayList>(); + initHistoryListItem(date); + historyAdapter = new HistoryTaskListViewAdapter(); + } + + private void initHistoryListItem(String date) { + // ѯݿ,ȡϢ + historyTaskCur = DatabaseUtil.query(HistoryOnedayActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " LIKE ?", + new String[] {date + "%" }, null, null, TaskBean.ID + + " ASC"); + + // Ϣ + + for (historyTaskCur.moveToFirst(); !historyTaskCur.isAfterLast(); historyTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(historyTaskCur); + historyTaskItemList.add(map); + } + + DatabaseUtil.closeDatabase(); + } + + public void onItemSelected(AdapterView parent, View v, int position, long id) { + int curdate = Countday(today, position); + Message mes = new Message(); + mes.arg1 = REFRESH_LAYOUT; + mes.arg2 = curdate; + handler.sendMessage(mes); + } + + public void onNothingSelected(AdapterView parent) { + } + + public View makeView() { + ImageView i = new ImageView(this); + i.setBackgroundColor(0xFF000000); + i.setScaleType(ImageView.ScaleType.FIT_CENTER); + i.setLayoutParams(new ImageSwitcher.LayoutParams( + LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + return i; + } + + public class ImageAdapter extends BaseAdapter { + private Context mContext; + + public ImageAdapter(Context c) { + mContext = c; + } + + public int getCount() { + return 21; + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + return position; + } + + // getView̬һImageView,ȻsetLayoutParamssetImageResource + // setBackgroundResourceֱ趨ͼƬСͼƬԴļͼƬͼƬʾǰ + // ĻʱͻᱻԶصṩҪʾImageView + public View getView(int position, View convertView, ViewGroup parent) { + ImageView i = new ImageView(mContext); + + Bitmap newb = Bitmap.createBitmap(120, 70, Config.ARGB_8888); + + Canvas canvasTemp = new Canvas(newb); + Paint pt = new Paint(); + canvasTemp.drawColor(Color.TRANSPARENT); + + pt.setColor(Color.WHITE); + pt.setTypeface(null); + pt.setAntiAlias(true); + pt.setShader(null); + pt.setFakeBoldText(true); + pt.setTextSize(20); + + int curdate = Countday(today, position); + String dateStr = getWeekDayFormat(curdate);// õFormatyyyymmdd + int weekday = getIntWeekDay(dateStr);// õܼ + String WeekDay = getStringWeekDay(weekday);// õַܼ + + canvasTemp.drawText(WeekDay, 30, 30, pt); + pt.setTextSize(14); + + String date = getStringday(curdate); + canvasTemp.drawText(date, 5, 50, pt); + + i.setImageBitmap(newb); + + i.setAdjustViewBounds(true); + i.setLayoutParams(new Gallery.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + // i.setBackgroundResource(R.drawable.bg); + i.setBackgroundResource(HistoryOnebgIds[weekday - 1]);// ܼʾͬı + return i; + } + + + + + } + + public int Countday(int today, int position) { + String DateStr = getWeekDayFormat(today); + SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd"); + + Date date = null; + int selday = 0; + try { + date = f.parse(DateStr);// String תΪϸʽ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DATE, position - 10); + + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH); + int day = calendar.get(Calendar.DAY_OF_MONTH); + selday = year * 10000 + month * 100 + day; + System.out.println(selday); + } catch (Exception e) { + e.printStackTrace(); + } + + return selday; + } + + /* εڵõַ */ + public String getStringday(int today) { + int year = today / 10000; + int month = today / 100 - year * 100; + int day = today % 100; + + String date = year + "" + month + "" + day + ""; + + return date; + } + + /* õʽַ */ + public String getWeekDayFormat(int today) { + int year = today / 10000; + int month = today / 100 - year * 100; + int day = today % 100; + String dateStr; + + String xmonth; + String xday; + if (month < 10) + xmonth = "0" + month; + else + xmonth = month + ""; + if (day < 10) + xday = "0" + day; + else + xday = day + ""; + + dateStr = year + xmonth + xday; + + return dateStr; + } + + /* õʽַ */ + public String getWeekDayFormat2(int today) { + int year = today / 10000; + int month = today / 100 - year * 100; + int day = today % 100; + String dateStr; + + String xmonth; + String xday; + if (month < 10) + xmonth = "0" + month; + else + xmonth = month + ""; + if (day < 10) + xday = "0" + day; + else + xday = day + ""; + + dateStr = year + "-"+xmonth +"-"+ xday; + + return dateStr; + } + + /* һܼ */ + public String getStringWeekDay(int weekday) { + String weekday1 = ""; + if (weekday == 1) + weekday1 = ""; + else if (weekday == 2) + weekday1 = "һ"; + else if (weekday == 3) + weekday1 = "ܶ"; + else if (weekday == 4) + weekday1 = ""; + else if (weekday == 5) + weekday1 = ""; + else if (weekday == 6) + weekday1 = ""; + else if (weekday == 7) + weekday1 = ""; + + return weekday1; + } + + /* õܼ */ + public int getIntWeekDay(String DateStr) { + SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd"); + + Date date = null; + int weekDay = 0; + try { + date = f.parse(DateStr);// String תΪϸʽ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + weekDay = calendar.get(Calendar.DAY_OF_WEEK); + System.out.println(weekDay); + } catch (Exception e) { + e.printStackTrace(); + } + // System.out.println(":"+DateStr+" "+weekDay); + return weekDay; + } + + private class HistoryTaskListViewAdapter extends BaseAdapter{ + + private int taskId = 0; + private int curPosition = 0; + + final class TaskListItemView { + public TextView taskInfo; // + public TextView taskTimeAndPositionInfo; // ʱ͵صϢ + public Button taskEditBtn; // ༭ť + public ImageView taskStarRank; // ȼͼƬ + } + + public int getCount() { + // TODO Auto-generated method stub + return historyTaskItemList.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return historyTaskItemList.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return Integer.parseInt(historyTaskItemList.get(position).get(TaskBean.ID).toString()); + } + + public View getView(final int position, View convertView, + ViewGroup parent) { + // TODO Auto-generated method stub + TaskListItemView listItemView = null; + if (convertView == null) { + listItemView = new TaskListItemView(); + convertView = LayoutInflater.from(HistoryOnedayActivity.this).inflate(R.layout.yesterday_task_item, + null); + // ȡؼ + listItemView.taskInfo = (TextView) convertView + .findViewById(R.id.yesterday_task_info); + listItemView.taskTimeAndPositionInfo = (TextView) convertView + .findViewById(R.id.yesterday_task_time_position_textview); + listItemView.taskEditBtn = (Button) convertView + .findViewById(R.id.yesterday_task_edit_btn); + listItemView.taskStarRank = (ImageView) convertView + .findViewById(R.id.yesterday_star_rank); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (TaskListItemView) convertView.getTag(); + } + + // + listItemView.taskInfo.setText((String) historyTaskItemList.get( + position).get(TaskBean.TASK_NAME)); + + // ʱ͵صϢ + String positionName = (String) historyTaskItemList.get(position).get( + TaskBean.POSITION_NAME); + String timeAndPosition = "ʱ:" + + DateUtils.getTaskTime((String) historyTaskItemList.get( + position).get(TaskBean.DATETIME)); + if (!positionName.equals("")) { + timeAndPosition += (" ص:" + positionName); + } + listItemView.taskTimeAndPositionInfo.setText(timeAndPosition); + + Log.d("debug", + "position = " + + position + + " timeAlertFlag = " + + (String) historyTaskItemList.get(position).get( + TaskBean.TIME_ALERT_FLAG)); + + + + // ȼͼƬ taskStarRank + switch (Integer.parseInt(historyTaskItemList.get(position) + .get(TaskBean.PRIORITY).toString())) { + case TaskConstant.RANK_FOURTH: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star1); + break; + case TaskConstant.RANK_THIRD: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star2); + break; + case TaskConstant.RANK_SECOND: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star3); + break; + case TaskConstant.RANK_FIRST: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star4); + break; + } + + if (TaskConstant.TASK_NOT_COMPLETE == Integer + .parseInt(historyTaskItemList.get(position) + .get(TaskBean.IF_COMPLETE).toString())) { + listItemView.taskTimeAndPositionInfo.setTextColor(0xff000000); + listItemView.taskInfo.setTextColor(0xff000000); + } else { + listItemView.taskTimeAndPositionInfo.setTextColor(0xff808080); + listItemView.taskInfo.setTextColor(0xff808080); + } + + listItemView.taskEditBtn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + taskId = Integer.parseInt(historyTaskItemList + .get(position).get(TaskBean.ID).toString()); + curPosition = position; + // + showCustomMessage("ȷɾ", "ȷɾ˻"); + + } + }); + return convertView; + } + + private void showCustomMessage(String pTitle, final String pMsg) { + final Dialog lDialog = new Dialog(HistoryOnedayActivity.this, + android.R.style.Theme_Translucent_NoTitleBar); + lDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + lDialog.setContentView(R.layout.iphone_alert_dialog_layout); + ((TextView) lDialog.findViewById(R.id.dialog_title)) + .setText(pTitle); + ((TextView) lDialog.findViewById(R.id.dialog_message)) + .setText(pMsg); + ((Button) lDialog.findViewById(R.id.cancel)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // CANCEL + lDialog.dismiss(); + } + }); + ((Button) lDialog.findViewById(R.id.ok)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // OK + lDialog.dismiss(); + // ɾ + DatabaseUtil.delete(HistoryOnedayActivity.this, TaskBean.TABLE_NAME, TaskBean.ID+"="+taskId, null); + + Toast.makeText(HistoryOnedayActivity.this, "ɾɹ", + Toast.LENGTH_SHORT).show(); + // ˢб + historyTaskItemList.remove(curPosition); + historyAdapter.notifyDataSetChanged(); + } + }); + lDialog.show(); + + } + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/PastGoalActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/PastGoalActivity.java new file mode 100644 index 0000000..841e1e5 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/PastGoalActivity.java @@ -0,0 +1,416 @@ +package com.timebetter.activity; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.LinearGradient; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.PorterDuff.Mode; +import android.graphics.PorterDuffXfermode; +import android.graphics.Shader.TileMode; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.Gravity; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.view.Window; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.PopupWindow; +import android.widget.TextView; +import android.widget.Toast; + +import com.timebetter.activity.R; +import com.timebetter.bean.GoalBean; +import com.timebetter.constant.GoalConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.view.HistoryGoalGalleryFlow; + +/** + * ʷĿ + * + * + * + */ +public class PastGoalActivity extends Activity { + private ImageView popupView; + private ImageView popupButton; + HistoryGoalGalleryFlow galleryFlow; + private PopupWindow popup; + private List> pastGoalItemList = null; + private int imagesize = 0; + private HistoryGoalAdapter adapter; + private static final int REFRESH_PASTACITVITY = 1; + private static final int REFRESH_ADAPTER = 2; + + private Handler handler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + switch(msg.what) { + case REFRESH_PASTACITVITY: + init(); + break; + case REFRESH_ADAPTER: + Map map = pastGoalItemList.get(msg.arg1); + String id = map.get(GoalBean.ID).toString(); + Log.d("debug", "delete curViewId=" + id); + DatabaseUtil.delete(PastGoalActivity.this, GoalBean.TABLE_NAME, GoalBean.ID+"="+id, null); + Toast.makeText(PastGoalActivity.this, "Ŀɾɹ", + Toast.LENGTH_SHORT).show(); + pastGoalItemList.remove(msg.arg1); + adapter.notifyDataSetChanged(); + break; + } + } + + }; + + // ͼƬ + private Integer[] images = new Integer[] { R.drawable.img0002, + R.drawable.img0003, R.drawable.img0004, R.drawable.img0005, + R.drawable.img0006, R.drawable.img0007, R.drawable.img0008 }; + + private void init() { + setContentView(R.layout.past_goal_layout); + imagesize = images.length; + pastGoalItemList = new ArrayList>(); + initPopupWindow(); + initPastGoalItemList(); + + adapter = new HistoryGoalAdapter(this, images); + adapter.createReflectedImages(); // ӳͼƬ + + galleryFlow = (HistoryGoalGalleryFlow) findViewById(R.id.HistoryGoalGallery); + galleryFlow.setAdapter(adapter); + galleryFlow.setOnItemClickListener(new ItemClickListener()); // ӵ¼ + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + init(); + } + + private void initPastGoalItemList() { + + Cursor pastGoalCur = DatabaseUtil.query(PastGoalActivity.this, + GoalBean.TABLE_NAME, null, GoalBean.GOAL_FLAG + "=" + + GoalConstant.FORMER_GOAL, null, null, null, + GoalBean.ID + " ASC"); + + // Ϣ + + int i = 0; + for (pastGoalCur.moveToFirst(); !pastGoalCur.isAfterLast(); pastGoalCur + .moveToNext()) { + + Map map1 = new HashMap(); + map1.put(GoalBean.GOAL_CONTENT, + pastGoalCur.getString(pastGoalCur.getColumnIndex(GoalBean.GOAL_CONTENT))); + map1.put(GoalBean.DATE, pastGoalCur.getString(pastGoalCur.getColumnIndex(GoalBean.DATE))); + map1.put(GoalBean.ID, pastGoalCur.getInt(pastGoalCur.getColumnIndex(GoalBean.ID))); + map1.put(GoalBean.GOAL_FLAG, + pastGoalCur.getInt(pastGoalCur.getColumnIndex(GoalBean.GOAL_FLAG))); + pastGoalItemList.add(i, map1); + i++; + } + + DatabaseUtil.closeDatabase(); + } + + private void initPopupWindow() { + View view = LayoutInflater.from(PastGoalActivity.this).inflate( + R.layout.past_goal_popwindow, null); + popup = new PopupWindow(view, + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + popup.setOutsideTouchable(true); + + popupView = (ImageView) view.findViewById(R.id.past_goal_popwindow_imageview); + popupButton = (ImageView) view.findViewById(R.id.past_goal_popwindow_button); + } + + @Override + protected void onPause() { + if (popup.isShowing()) { + popup.dismiss(); + } + + super.onPause(); + } + + @Override + protected void onStop() { + if (popup.isShowing()) { + popup.dismiss(); + } + super.onStop(); + } + + @Override + protected void onDestroy() { + if (popup.isShowing()) { + popup.dismiss(); + } + super.onDestroy(); + } + + class ItemClickListener implements OnItemClickListener { + + public void onItemClick(AdapterView parent, View view, final int position, + long id) { + Log.d("historygoal", "this one is on item long clicked!" + position); + + Bitmap newb = Bitmap.createBitmap(120, 200, Config.ARGB_8888); + Canvas canvasTemp = new Canvas(newb); + + Paint pt = new Paint(); + canvasTemp.drawColor(Color.TRANSPARENT); + pt.setColor(Color.WHITE); + pt.setAntiAlias(true); + + Map map = pastGoalItemList.get(position); + String content = (String)map.get(GoalBean.GOAL_CONTENT); + String date = (String)map.get(GoalBean.DATE); + + pt.setTextSize(10); + canvasTemp.drawText(date, 10, 30, pt); + + pt.setTextSize(20); + int contentLength = content.length(); + int x = contentLength/5 + 1; + for(int i=0; i map = pastGoalItemList.get(position); + String content = (String)map.get(GoalBean.GOAL_CONTENT); + String date = (String)map.get(GoalBean.DATE); + + pt.setTextSize(30); + canvasTemp.drawText(date, 30, 60, pt); + + pt.setTextSize(40); + int contentLength = content.length(); + int x = contentLength/5 + 1; + for(int i=0; i 0) { + statusDetails = getResources().getQuantityString( + R.plurals.status_done_details, backedUpCount, + backedUpCount); + } else { + statusDetails = getString( + R.string.status_done_details_noitems); + progressMax = 1; + progressVal = 1; + } + + progressIndeterminate = false; + + status = STATUS_DONE; + } else { + statusLabel = getText(R.string.status_idle); + long lastSync = PrefStore.getLastSync(SetupActivity.this); + String lastSyncStr; + if (lastSync == PrefStore.DEFAULT_LAST_SYNC) { + lastSyncStr = + getString(R.string.status_idle_details_never); + } else { + lastSyncStr = new Date(lastSync).toLocaleString(); + } + statusDetails = getString(R.string.status_idle_details, + lastSyncStr); + status = STATUS_IDLE; + } + break; + case LOGIN: + statusLabel = getText(R.string.status_login); + statusDetails = getString(R.string.status_login_details); + progressIndeterminate = true; + status = STATUS_WORKING; + break; + case SYNC: + statusLabel = getText(R.string.status_sync); + statusDetails = getString(R.string.status_sync_details, + GMailService.getCurrentSyncedItems(), + GMailService.getItemsToSyncCount()); + progressMax = GMailService.getItemsToSyncCount(); + progressVal = GMailService.getCurrentSyncedItems(); + status = STATUS_WORKING; + break; + case GENERAL_ERROR: + statusLabel = getString(R.string.status_unknown_error); + statusDetails = getString(R.string.status_unknown_error_details, + GMailService.getErrorDescription()); + status = STATUS_ERROR; + break; + case CANCELED: + statusLabel = getString(R.string.status_canceled); + statusDetails = getString(R.string.status_canceled_details, + GMailService.getCurrentSyncedItems(), + GMailService.getItemsToSyncCount()); + status = STATUS_IDLE; + } // switch (newStatus) { ... } + + + int color; + TextView detailTextView; + int syncButtonText; + int icon; + + if (status == STATUS_IDLE) { + color = R.color.status_idle; + detailTextView = mSyncDetailsLabel; + syncButtonText = R.string.ui_sync_button_label_idle; + icon = R.drawable.ic_idle; + } else if (status == STATUS_WORKING) { + color = R.color.status_sync; + detailTextView = mSyncDetailsLabel; + syncButtonText = R.string.ui_sync_button_label_syncing; + icon = R.drawable.ic_syncing; + } else if (status == STATUS_DONE) { + color = R.color.status_done; + detailTextView = mSyncDetailsLabel; + syncButtonText = R.string.ui_sync_button_label_done; + icon = R.drawable.ic_done; + } else if (status == STATUS_ERROR) { + color = R.color.status_error; + detailTextView = mErrorDetails; + syncButtonText = R.string.ui_sync_button_label_error; + icon = R.drawable.ic_error; + } else { + Log.w(GMailConsts.TAG, "Illegal state: Unknown status."); + return; + } + + if (status != STATUS_ERROR) { + mSyncDetails.setVisibility(View.VISIBLE); + mErrorDetails.setVisibility(View.INVISIBLE); + if (progressIndeterminate) { + mProgressBarIndet.setVisibility(View.VISIBLE); + mProgressBar.setVisibility(View.GONE); + } else { + mProgressBar.setVisibility(View.VISIBLE); + mProgressBarIndet.setVisibility(View.GONE); + mProgressBar.setIndeterminate(progressIndeterminate); + mProgressBar.setMax(progressMax); + mProgressBar.setProgress(progressVal); + } + + } else { + mErrorDetails.setVisibility(View.VISIBLE); + mSyncDetails.setVisibility(View.INVISIBLE); + } + + mStatusLabel.setText(statusLabel); + mStatusLabel.setTextColor(getResources().getColor(color)); + mSyncButton.setText(syncButtonText); + mSyncButton.setEnabled(true); + detailTextView.setText(statusDetails); + mStatusIcon.setImageResource(icon); + + } + }); + } + } + + @Override + public void onClick(View v) { + if (v == mSyncButton) { + if (!GMailService.isWorking()) { + initiateSync(); + } else { + GMailService.cancel(); + // Sync button will be restored on next status update. + mSyncButton.setText(R.string.ui_sync_button_label_canceling); + mSyncButton.setEnabled(false); + } + } + } + + @Override + public View getView(View convertView, ViewGroup parent) { + if (mView == null) { + mView = getLayoutInflater().inflate(R.layout.status, parent, false); + mSyncButton = (Button) mView.findViewById(R.id.sync_button); + mSyncButton.setOnClickListener(this); + mStatusIcon = (ImageView) mView.findViewById(R.id.status_icon); + mStatusLabel = (TextView) mView.findViewById(R.id.status_label); + mSyncDetails = mView.findViewById(R.id.details_sync); + mSyncDetailsLabel = (TextView) mSyncDetails.findViewById(R.id.details_sync_label); + mProgressBar = (ProgressBar) mSyncDetails.findViewById(R.id.details_sync_progress); + mProgressBarIndet = + (ProgressBar) mSyncDetails.findViewById(R.id.details_sync_progress_indet); + mErrorDetails = (TextView) mView.findViewById(R.id.details_error); + update(); + } + return mView; + } + } + + @Override + protected Dialog onCreateDialog(final int id) { + String title; + String msg; + Builder builder; + switch (id) { + case DIALOG_MISSING_CREDENTIALS: + title = getString(R.string.ui_dialog_missing_credentials_title); + msg = getString(R.string.ui_dialog_missing_credentials_msg); + break; + case DIALOG_SYNC_DATA_RESET: + title = getString(R.string.ui_dialog_sync_data_reset_title); + msg = getString(R.string.ui_dialog_sync_data_reset_msg); + break; + case DIALOG_INVALID_IMAP_FOLDER: + title = getString(R.string.ui_dialog_invalid_imap_folder_title); + msg = getString(R.string.ui_dialog_invalid_imap_folder_msg); + break; + case DIALOG_NEED_FIRST_MANUAL_SYNC: + DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // BUTTON1 == BUTTON_POSITIVE == "Yes" + if (which == DialogInterface.BUTTON1) { + startSync(); + } + } + }; + + builder = new AlertDialog.Builder(this); + builder.setTitle(R.string.ui_dialog_need_first_manual_sync_title); + builder.setMessage(R.string.ui_dialog_need_first_manual_sync_msg); + builder.setPositiveButton(android.R.string.yes, dialogClickListener); + builder.setNegativeButton(android.R.string.no, dialogClickListener); + builder.setCancelable(false); + return builder.create(); + + default: + return null; + } + + return createMessageDialog(id, title, msg); + } + + private Dialog createMessageDialog(final int id, String title, String msg) { + Builder builder = new AlertDialog.Builder(this); + builder.setTitle(title); + builder.setMessage(msg); + builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dismissDialog(id); + } + }); + return builder.create(); + } + + + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + if (PrefStore.PREF_LOGIN_USER.equals(preference.getKey())) { + preference.setTitle(newValue.toString()); + SharedPreferences prefs = preference.getSharedPreferences(); + final String oldValue = prefs.getString(PrefStore.PREF_LOGIN_USER, null); + if (!newValue.equals(oldValue)) { + // We need to post the reset of sync state such that we do not interfere + // with the current transaction of the SharedPreference. + runOnUiThread(new Runnable() { + @Override + public void run() { + PrefStore.clearSyncData(SetupActivity.this); + if (oldValue != null) { + showDialog(DIALOG_SYNC_DATA_RESET); + } + } + }); + } + } else if (PrefStore.PREF_IMAP_FOLDER.equals(preference.getKey())) { + String imapFolder = newValue.toString(); + if (PrefStore.isValidImapFolder(imapFolder)) { + preference.setTitle(imapFolder); + } else { + runOnUiThread(new Runnable() { + @Override + public void run() { + showDialog(DIALOG_INVALID_IMAP_FOLDER); + } + }); + return false; + } + } else if (PrefStore.PREF_LOGIN_PASSWORD.equals(preference.getKey())) { + if (PrefStore.isLoginUsernameSet(this)) { + showDialog(DIALOG_NEED_FIRST_MANUAL_SYNC); + } + } else if (PrefStore.PREF_MAX_ITEMS_PER_SYNC.equals(preference.getKey())) { + updateMaxItemsPerSync((String) newValue); + if(newValue.equals("1")) + preference.setSummary("͵"); + else if(newValue.equals("2")) + preference.setSummary("ʷ"); + else if(newValue.equals("3")) + preference.setSummary("͵"); + else if(newValue.equals("4")) + preference.setSummary("Ŀ"); + else if(newValue.equals("5")) + preference.setSummary(""); + else + preference.setSummary("ñѡ"); + + } + return true; + } + + private void updateMaxItemsPerSync(String newValue) { +// Preference pref = getPreferenceManager().findPreference(PrefStore.PREF_MAX_ITEMS_PER_SYNC); + if (newValue == null) { + newValue = String.valueOf(PrefStore.getMaxItemsPerSync(this)); + } + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/TaskActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/TaskActivity.java new file mode 100644 index 0000000..e8368c6 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/TaskActivity.java @@ -0,0 +1,2592 @@ +package com.timebetter.activity; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; + +import android.app.Activity; +import android.app.AlarmManager; +import android.app.AlertDialog; +import android.app.DatePickerDialog; +import android.app.DatePickerDialog.OnDateSetListener; +import android.app.Dialog; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.ComponentName; +import android.content.ContentValues; +import android.content.DialogInterface; +import android.content.Intent; +import android.database.Cursor; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.view.ContextMenu; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.GestureDetector; +import android.view.GestureDetector.OnGestureListener; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnCreateContextMenuListener; +import android.view.ViewGroup; +import android.view.ViewGroup.LayoutParams; +import android.view.Window; +import android.view.animation.AnimationUtils; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemLongClickListener; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.DatePicker; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.ListView; +import android.widget.RadioButton; +import android.widget.RadioGroup; +import android.widget.RadioGroup.OnCheckedChangeListener; +import android.widget.TextView; +import android.widget.TimePicker; +import android.widget.TimePicker.OnTimeChangedListener; +import android.widget.Toast; +import android.widget.ViewFlipper; + +import com.timebetter.activity.R; +import com.timebetter.alarm.Alarm; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.MenuItemId; +import com.timebetter.constant.MotionEventConstant; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; +import com.timebetter.receiver.PlanBetterReceiver; +import com.timebetter.widget.TodayTaskWidget; +import com.timebetter.widget.TomorrowTaskWidgetService; + +public class TaskActivity extends Activity implements OnGestureListener { + private ViewFlipper flipper = null; + private GestureDetector gestureDetector = null; + + private View todayView = null; // ͼ + private View yesterdayView = null; // ͼ + private View tomorrowView = null; // ͼ + + private Button todayAddTaskBtn = null; // ť + private Button tomorrowAddTaskBtn = null; // ť + + private TextView todayTaskTV = null; + + /* Ϣбͼбͼadapter */ + private List> todayTaskItemList = null; // ListϢ + private ListView todayTaskList = null; // Ϣбͼ + private static TodayTaskListViewAdapter todayAdapter = null; // бͼadapter + + /* δϢбͼбͼadapter */ + private List> tomorrowTaskItemList = null; // ListδϢ + private ListView tomorrowTaskList = null; // δϢбͼ + private static TomorrowTaskListViewAdapter tomorrowAdapter = null; // δбͼadapter + private TextView tomorrowTaskName = null; + private TextView tomorrowTaskDate = null; + private TextView tomorrowTaskLeftDay = null; + private String tomorrowTaskMessageID = null; + + /* Ϣбͼбͼadapter */ + private List> yesterdayTaskItemList = null; // ListϢ + private ListView yesterdayTaskList = null; // Ϣбͼ + private static YesterdayTaskListViewAdapter yesterdayAdapter = null; // бͼadapter + + private int index = START_INDEX; // ǰview + private static final int START_INDEX = 0; // һview + private static final int MIDDLE_INDEX = 1; + private static final int END_INDEX = 2; // һview + + private Cursor todayTaskCur; + private Cursor tomorrowTaskCur; + private Cursor yesterdayTaskCur; + + private int priority = TaskConstant.RANK_FIRST; + private int timeAlertValue = TaskConstant.NO_TIME_ALERT; + private String time = ""; + private int repeatDays = TaskConstant.INIT_REPEAT_DAYS; + + private TextView repeatDateTimeTV = null; + private TextView repeatDaysTV = null; + + private NotificationManager notificationManager; + private Notification notification; + private Intent notifyIntent; + private PendingIntent notifyPendingIntent; + + private int alarmHour; + private int alarmMinute; + private int initYear; + private int initMonth; + private int initDay; + + private TextView todayListEmptyView; + private TextView tomorrowListEmptyView; + private TextView yesterdayListEmptyView; + + private static final int REFRESH_TASKACTIVITY = 1; + private static final int REFRESH_FUTURE = 2; + private static final int INIT_TASKCTIVITY = 3; + + private boolean hasInit = false; + + private int todayClickViewId = 0; + private int todayClickPosition = 0; + + private int todayClickCompleteState = TaskConstant.TASK_NOT_COMPLETE; + + // private Typeface typeFace; + + @Override + public void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + + // ʼTaskActivityĽ + initUI(); + + // typeFace = + // Typeface.createFromAsset(getAssets(),"fonts/vavont-bolder.ttf"); + + setMyDateChangedAlarm(); + + // ʾ + notifyIntent = new Intent(TaskActivity.this, TaskNotifyActivity.class); + notifyPendingIntent = PendingIntent.getActivity(TaskActivity.this, 0, + notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + notification = new Notification(); + notification.icon = R.drawable.icon; + notification.tickerText = "һлͼ"; + notification.defaults = Notification.DEFAULT_LIGHTS; + notification.setLatestEventInfo(TaskActivity.this, "PlanBetter", + "ͼл", notifyPendingIntent); + + Timer timer = new Timer(); + timer.schedule(new NofifyTimeTask(), 1000); + // Ϣ + Message mes = new Message(); + mes.what = INIT_TASKCTIVITY; + handler.sendMessageDelayed(mes, 1000); + } + + private void setMyDateChangedAlarm() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + cal.add(Calendar.DAY_OF_MONTH, 1); + AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); + Intent intent = new Intent(PlanBetterReceiver.DATE_CHANGED); + PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, + PendingIntent.FLAG_CANCEL_CURRENT); + am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); + } + + private void startServiceToFreshTomorrowWidget() { + Intent intent = new Intent(this, TomorrowTaskWidgetService.class); + startService(intent); + } + + private void sendBroadcastToTodayWidget() { + Intent bcast = new Intent(this, TodayTaskWidget.class); + bcast.setAction(TodayTaskWidget.ACTION_NEXT_TIP); + sendBroadcast(bcast); + } + + private Handler handler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + switch (msg.what) { + case REFRESH_TASKACTIVITY: + initUI(); + flipper.showNext(); + index++; + // γЧ + if (yesterdayTaskItemList.size() == 0) { + yesterdayListEmptyView.setVisibility(View.INVISIBLE); + } + if (todayTaskItemList.size() == 0) { + todayListEmptyView.setVisibility(View.VISIBLE); + } + break; + case REFRESH_FUTURE: + refreshFuture(); + break; + case INIT_TASKCTIVITY: + flipper.setInAnimation(AnimationUtils.loadAnimation( + TaskActivity.this, R.anim.push_left_in_slowly)); + flipper.setOutAnimation(AnimationUtils.loadAnimation( + TaskActivity.this, R.anim.push_left_out_slowly)); + flipper.showNext(); + index++; + + // γЧ + if (yesterdayTaskItemList.size() == 0) { + yesterdayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(TaskActivity.this, + R.anim.push_left_out_slowly)); + yesterdayListEmptyView.setVisibility(View.INVISIBLE); + } + if (todayTaskItemList.size() == 0) { + todayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(TaskActivity.this, + R.anim.push_left_in_slowly)); + todayListEmptyView.setVisibility(View.VISIBLE); + } + break; + } + } + + }; + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + if (hasInit) { + Message mes = new Message(); + mes.what = REFRESH_TASKACTIVITY; + handler.sendMessage(mes); + } + hasInit = true; + } + + private void refreshFuture() { + tomorrowTaskItemList = new ArrayList>(); + initTomorrowListItem(); + tomorrowAdapter.notifyDataSetChanged(); + } + + private void initUI() { + + setContentView(R.layout.task_main_layout); + + index = START_INDEX; + + initViews(); + + // ť + todayAddTaskBtn = (Button) todayView + .findViewById(R.id.today_add_task_btn); + todayAddTaskBtn.setOnClickListener(new AddTaskListener()); + todayTaskTV = (TextView) todayView + .findViewById(R.id.textView_today_date); + todayTaskTV.setText(DateUtils.timeDetail(DateUtils.TODAY)); + + // ť + tomorrowAddTaskBtn = (Button) tomorrowView.findViewById(R.id.addTask); + tomorrowAddTaskBtn.setOnClickListener(new AddTaskListener()); + + flipper = (ViewFlipper) findViewById(R.id.viewFlipper); + flipper.addView(yesterdayView); + flipper.addView(todayView); + flipper.addView(tomorrowView); + + gestureDetector = new GestureDetector(this); + + } + + private class NofifyTimeTask extends TimerTask { + @Override + public void run() { + notificationManager.notify(0, notification); + } + } + + private void registerAlarm(int id, int hourOfDay, int minute) { + // жʱǷϷ + if (DateUtils.checkTimeAlertable(hourOfDay, minute)) { + Intent intent = new Intent(Alarm.ALARM_REGISTRATION_DETAIL_ACTION); + Bundle bundle = new Bundle(); + bundle.putInt(Alarm.ID, id); + bundle.putInt(Alarm.HOUR, hourOfDay); + bundle.putInt(Alarm.MINUTE, minute); + intent.putExtra(Alarm.ALARM_REGISTRATION_BUNDLE_TAG, bundle); + sendBroadcast(intent); + } + } + + private void registerAlarm(int id, String datetime) throws ParseException { + if (DateUtils.checkTimeAlertable(datetime)) { + Intent intent = new Intent(Alarm.ALARM_REGISTRATION_SIMPLE_ACTION); + Bundle bundle = new Bundle(); + bundle.putInt(Alarm.ID, id); + bundle.putString(Alarm.DATETIME, datetime); + intent.putExtra(Alarm.ALARM_REGISTRATION_BUNDLE_TAG, bundle); + sendBroadcast(intent); + } + } + + private void cancelAlarm(int id) { + Intent intent = new Intent(Alarm.ALARM_CANCEL_ACTION); + intent.putExtra(Alarm.ID, id); + sendBroadcast(intent); + } + + /** + * + * + * + * + */ + private class AddTaskListener implements OnClickListener { + private int differDays = 1; + + public void onClick(View v) { + priority = TaskConstant.RANK_FIRST; + int[] nowHourAndMinute = DateUtils.getNowHourAndMinute(); + alarmHour = nowHourAndMinute[0]; + alarmMinute = nowHourAndMinute[1]; + time = DateUtils.formatTime(alarmHour, alarmMinute); + timeAlertValue = TaskConstant.NO_TIME_ALERT; + repeatDays = TaskConstant.INIT_REPEAT_DAYS; + + switch (index) { + // ǽ + case MIDDLE_INDEX: + int[] nowYearMonthDay = DateUtils.getNowDate(); + initYear = nowYearMonthDay[0]; + initMonth = nowYearMonthDay[1]; + initDay = nowYearMonthDay[2]; + // view + final View addTaskView = getViewById(R.layout.add_task_dialog_layout); + final EditText taskContent = (EditText) addTaskView + .findViewById(R.id.et_task_info); + final EditText taskPosition = (EditText) addTaskView + .findViewById(R.id.et_task_position); + TimePicker timePicker = (TimePicker) addTaskView + .findViewById(R.id.tp_task_time); + timePicker.setCurrentHour(alarmHour); + timePicker.setCurrentMinute(alarmMinute); + timePicker + .setOnTimeChangedListener(new OnTimeChangedListener() { + + @Override + public void onTimeChanged(TimePicker view, + int hourOfDay, int minute) { + time = DateUtils.formatTime(hourOfDay, minute); + alarmHour = hourOfDay; + alarmMinute = minute; + } + }); + RadioGroup rankGroup = (RadioGroup) addTaskView + .findViewById(R.id.task_rank_group); + final RadioButton rankFirst = (RadioButton) addTaskView + .findViewById(R.id.task_rank_first); + final RadioButton rankSecond = (RadioButton) addTaskView + .findViewById(R.id.task_rank_second); + final RadioButton rankThird = (RadioButton) addTaskView + .findViewById(R.id.task_rank_third); + final RadioButton rankFourth = (RadioButton) addTaskView + .findViewById(R.id.task_rank_fourth); + + rankGroup + .setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(RadioGroup group, + int checkedId) { + if (checkedId == rankFirst.getId()) { + priority = TaskConstant.RANK_FIRST; + } else if (checkedId == rankSecond.getId()) { + priority = TaskConstant.RANK_SECOND; + } else if (checkedId == rankThird.getId()) { + priority = TaskConstant.RANK_THIRD; + } else if (checkedId == rankFourth.getId()) { + priority = TaskConstant.RANK_FOURTH; + } + } + }); + + final CheckBox timeAlertCB = (CheckBox) addTaskView + .findViewById(R.id.cb_time_alert); + timeAlertCB + .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged( + CompoundButton buttonView, boolean isChecked) { + if (timeAlertCB.isChecked()) { + timeAlertValue = TaskConstant.TIME_ALERT; + } else { + timeAlertValue = TaskConstant.NO_TIME_ALERT; + } + } + }); + + repeatDateTimeTV = (TextView) addTaskView + .findViewById(R.id.task_repeat_days_date); + repeatDaysTV = (TextView) addTaskView + .findViewById(R.id.task_repeat_days_total); + refreshRepeatDaysTextView(); + + Button setRepeatDaysBtn = (Button) addTaskView + .findViewById(R.id.task_repeat_days_button); + setRepeatDaysBtn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + int[] dayInfo = DateUtils + .getDayInfoByRepeatDays(repeatDays); + // ڶԻ + DatePickerDialog dlg = new DatePickerDialog( + TaskActivity.this, dateListener, dayInfo[0], + dayInfo[1], dayInfo[2]); + dlg.setTitle(R.string.task_time_repeat_dialog_title); + dlg.show(); + } + }); + + // ½Ի + new AlertDialog.Builder(TaskActivity.this) + .setTitle(R.string.add_task_dialog_title) + .setIcon(R.drawable.add_task_dialog_icon) + .setView(addTaskView) + .setPositiveButton(R.string.save_task_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + String taskContentStr = taskContent + .getText().toString().trim(); + String taskPositionStr = taskPosition + .getText().toString().trim(); + if (taskContentStr.equals("")) { + Toast.makeText(TaskActivity.this, + "ƲΪ", + Toast.LENGTH_SHORT).show(); + } else { + String datetime = DateUtils.now() + + " " + time; + ContentValues values = new ContentValues(); + + values.put(TaskBean.TASK_NAME, + taskContentStr); + values.put(TaskBean.DATETIME, + datetime); + values.put( + TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + values.put(TaskBean.POSITION_NAME, + taskPositionStr); + values.put( + TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + values.put(TaskBean.PRIORITY, + priority); + values.put(TaskBean.REPEAT_DAYS, + repeatDays); + values.put(TaskBean.IF_FUTURE, + TaskConstant.NOT_FUTURE); + values.put(TaskBean.PARENT, + TaskConstant.IS_PARENT); + + // DatabaseHelper helper = new + // DatabaseHelper(TaskActivity.this); + // SQLiteDatabase db = + // helper.getWritableDatabase(); + // long id = + // db.insert(TaskBean.TABLE_NAME,TaskBean.ID,values); + + long id = DatabaseUtil.insert( + TaskActivity.this, + TaskBean.TABLE_NAME, + TaskBean.ID, values); + if (id == -1) { + Toast.makeText( + TaskActivity.this, + "ݿʧ", + Toast.LENGTH_SHORT) + .show(); + } else { + + if (repeatDays > 1) { + // 㲥 + Intent insertData = new Intent( + PlanBetterReceiver.INSERT_DATA_ACTION); + Bundle bundle = new Bundle(); + bundle.putString( + TaskBean.TASK_NAME, + taskContentStr); + bundle.putString( + TaskBean.POSITION_NAME, + taskPositionStr); + bundle.putInt( + TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + bundle.putInt( + TaskBean.PRIORITY, + priority); + bundle.putString( + TaskBean.DATETIME, + datetime); + bundle.putInt( + TaskBean.REPEAT_DAYS, + repeatDays); + bundle.putInt( + TaskBean.PARENT, + (int) id); + insertData + .putExtra( + PlanBetterReceiver.INSERT_DATA_INTENT_BUNDLE_TAG, + bundle); + sendBroadcast(insertData); + } + + Map map = new HashMap(); + map.put(TaskBean.TASK_NAME, + taskContentStr); + map.put(TaskBean.DATETIME, + datetime); + map.put(TaskBean.POSITION_NAME, + taskPositionStr); + map.put(TaskBean.PRIORITY, + priority + ""); + map.put(TaskBean.TIME_ALERT_FLAG, + timeAlertValue + ""); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE + + ""); + map.put(TaskBean.ID, id + ""); + map.put(TaskBean.REPEAT_DAYS, + repeatDays + ""); + map.put(TaskBean.PARENT, + TaskConstant.IS_PARENT); + + refreshTodayTaskAfterInsert(map); + + // ע + if (timeAlertValue == TaskConstant.TIME_ALERT) + registerAlarm((int) id, + alarmHour, + alarmMinute); + sendBroadcastToTodayWidget(); + } + } + } + }) + .setNegativeButton(R.string.cancel_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + + } + + }).create().show(); + + break; + // δ + case END_INDEX: + int[] tomorrowYearMonthDay = DateUtils.getTomorrowDate(); + initYear = tomorrowYearMonthDay[0]; + initMonth = tomorrowYearMonthDay[1]; + initDay = tomorrowYearMonthDay[2]; + final View addTomorrowTaskView = getViewById(R.layout.edit_tomorrow_task_dialog_layout); + final EditText tomorrowtaskContent = (EditText) addTomorrowTaskView + .findViewById(R.id.et_tomorrow_task_info); + + DatePicker datePicker = (DatePicker) addTomorrowTaskView + .findViewById(R.id.dp_tomorrow_task_date); + datePicker.init(initYear, initMonth - 1, initDay, + new DatePicker.OnDateChangedListener() { + + @Override + public void onDateChanged(DatePicker view, + int year, + + int monthOfYear, int dayOfMonth) { + + initYear = year; + initMonth = monthOfYear + 1; + initDay = dayOfMonth; + + differDays = DateUtils.getDifferDays(year, + monthOfYear + 1, dayOfMonth); + if (differDays < 0) + Toast.makeText(TaskActivity.this, + "óɽԺʱ~", Toast.LENGTH_SHORT) + .show(); + + } + + }); + + TimePicker timePicker2 = (TimePicker) addTomorrowTaskView + .findViewById(R.id.tp_tomorrow_task_time); + timePicker2.setCurrentHour(alarmHour); + timePicker2.setCurrentMinute(alarmMinute); + + timePicker2 + .setOnTimeChangedListener(new OnTimeChangedListener() { + + @Override + public void onTimeChanged(TimePicker view, + int hourOfDay, int minute) { + time = DateUtils.formatTime(hourOfDay, minute); + alarmHour = hourOfDay; + alarmMinute = minute; + } + }); + + final CheckBox timeAlertCB2 = (CheckBox) addTomorrowTaskView + .findViewById(R.id.cb_tomorrow_time_alert); + + timeAlertCB2 + .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged( + CompoundButton buttonView, boolean isChecked) { + if (timeAlertCB2.isChecked()) { + timeAlertValue = TaskConstant.TIME_ALERT; + alarmMinute = 0; + alarmHour = 0; + + } else { + timeAlertValue = TaskConstant.NO_TIME_ALERT; + alarmMinute = 0; + alarmHour = 0; + time = DateUtils.formatTime(alarmHour, + alarmMinute); + } + } + }); + + // ½Ի + new AlertDialog.Builder(TaskActivity.this) + .setTitle(R.string.edit_task_dialog_title) + .setIcon(android.R.drawable.ic_menu_edit) + .setView(addTomorrowTaskView) + .setPositiveButton(R.string.save_task_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + String taskContentStr = tomorrowtaskContent + .getText().toString().trim(); + + if (taskContentStr.equals("")) { + Toast.makeText(TaskActivity.this, + "ƲΪ", + Toast.LENGTH_SHORT).show(); + } else if (differDays < 0) { + Toast.makeText(TaskActivity.this, + "ʱòδ洢", + Toast.LENGTH_SHORT).show(); + } else { + String datetime = DateUtils + .formatDate(initYear, + initMonth, initDay) + + " " + time; + ContentValues values = new ContentValues(); + + values.put(TaskBean.TASK_NAME, + taskContentStr); + values.put(TaskBean.DATETIME, + datetime); + values.put( + TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + values.put(TaskBean.POSITION_NAME, + ""); + values.put( + TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + values.put(TaskBean.PRIORITY, + TaskConstant.RANK_FOURTH); + values.put( + TaskBean.REPEAT_DAYS, + TaskConstant.INIT_REPEAT_DAYS); + values.put(TaskBean.IF_FUTURE, + TaskConstant.IS_FUTURE); + values.put(TaskBean.PARENT, + TaskConstant.IS_PARENT); + + long id = DatabaseUtil.insert( + TaskActivity.this, + TaskBean.TABLE_NAME, + TaskBean.ID, values); + if (id == -1) { + Toast.makeText( + TaskActivity.this, + "ݿʧ", + Toast.LENGTH_SHORT) + .show(); + } else { + + Map map = new HashMap(); + map.put(TaskBean.TASK_NAME, + taskContentStr); + map.put(TaskBean.DATETIME, + datetime); + map.put(TaskBean.POSITION_NAME, + ""); + map.put(TaskBean.PRIORITY, + TaskConstant.RANK_FOURTH + + ""); + map.put(TaskBean.TIME_ALERT_FLAG, + timeAlertValue + ""); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE + + ""); + map.put(TaskBean.ID, id + ""); + map.put(TaskBean.REPEAT_DAYS, + TaskConstant.INIT_REPEAT_DAYS + + ""); + + // refreshYesterdayTaskAfterInsert(map); + refreshTomorrowTaskAfterInsert(map); + String taskid = id + ""; + refreshTomorrowMessageSendMessage( + taskid, taskContentStr, + datetime); + startServiceToFreshTomorrowWidget(); + } + } + } + }) + + .setNegativeButton(R.string.cancel_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + + } + + }).create().show(); + break; + } + } + + } + + private void refreshTomorrowMessageSendMessage(String id, String taskname, + String date) { + Message mes = new Message(); + mes.what = REFRESH_TOMORROW_MESSAGE; + Bundle bundle = new Bundle(); + bundle.putString(TaskBean.ID, id); + bundle.putString(TaskBean.TASK_NAME, taskname); + bundle.putString(TaskBean.DATETIME, date); + mes.setData(bundle); + refreshHandler.sendMessage(mes); + } + + private void refreshTomorrowMessageDelete() { + String id = null; + String taskName = null; + String dateStr = null; + int x = Integer.MAX_VALUE; + int size = tomorrowTaskItemList.size(); + /* ѰmapоǸ */ + for (int i = 0; i < size; i++) { + Map map = tomorrowTaskItemList.get(i); + String date = (String) map.get(TaskBean.DATETIME); + int[] yearMonthDay = DateUtils + .getYearMonthDayHourAndMinuteByDateTime(date); + int taskYear = yearMonthDay[0]; + int taskMonth = yearMonthDay[1]; + int taskDay = yearMonthDay[2]; + + String datetime = DateUtils + .formatDate(taskYear, taskMonth, taskDay); + + int differ = x + 1; + try { + differ = DateUtils.getDifferDays(datetime); + } catch (ParseException e) { + e.printStackTrace(); + } + + if (differ <= x) { + taskName = (String) map.get(TaskBean.TASK_NAME); + dateStr = (String) map.get(TaskBean.DATETIME); + id = (String) map.get(TaskBean.ID); + x = differ; + } + } + refreshTomorrowMessageSendMessage(id, taskName, dateStr); + } + + private void refreshRepeatDaysTextView() { + repeatDateTimeTV.setText(DateUtils.getDateByRepeatDays(repeatDays)); + repeatDaysTV.setText(DateUtils.getDayByRepeatDays(repeatDays)); + } + + private OnDateSetListener dateListener = new OnDateSetListener() { + + @Override + public void onDateSet(DatePicker view, int year, int monthOfYear, + int dayOfMonth) { + try { + repeatDays = DateUtils.getDifferDays(year + "-" + + (monthOfYear + 1) + "-" + dayOfMonth); + } catch (ParseException e) { + e.printStackTrace(); + } + if (repeatDays < -1) { + Toast.makeText(getApplicationContext(), "ֹڲڽ֮ǰ", + Toast.LENGTH_SHORT).show(); + repeatDays = 1; + } else if (repeatDays == -1) { + repeatDays = 1; + } else { + repeatDays++; + } + + refreshRepeatDaysTextView(); + } + }; + + private void deleteAfterTodayInfo(int position, int id) { + int parent = Integer.parseInt(todayTaskItemList.get(position) + .get(TaskBean.PARENT).toString()); + + String delSql = ""; + + // ɾparentcurViewIdparentparent,СǰڵĻ + if (parent == TaskConstant.IS_PARENT) { + delSql = "DELETE FROM " + TaskBean.TABLE_NAME + " WHERE " + + TaskBean.PARENT + "=" + id; + } else { + delSql = "DELETE FROM " + + TaskBean.TABLE_NAME + + " WHERE " + + TaskBean.PARENT + + "=" + + parent + + " AND " + + TaskBean.REPEAT_DAYS + + "<" + + todayTaskItemList.get(position).get(TaskBean.REPEAT_DAYS) + .toString(); + } + + DatabaseUtil.delete(TaskActivity.this, delSql); + } + + public class PullDateListener implements OnDateSetListener { + + private String formerDate; + private int id; + private int position; + + public PullDateListener(String date, int id, int position) { + this.formerDate = date; + this.id = id; + this.position = position; + } + + @Override + public void onDateSet(DatePicker view, int year, int monthOfYear, + int dayOfMonth) { + int pullDays = 0; + try { + pullDays = DateUtils.getDifferDays(year + "-" + + (monthOfYear + 1) + "-" + dayOfMonth); + } catch (ParseException e) { + e.printStackTrace(); + } + if (pullDays <= -1) { + Toast.makeText(getApplicationContext(), "Ƴڲڽ֮ǰ", + Toast.LENGTH_SHORT).show(); + } else { + // 滻µ + String newDate = year + "-" + (monthOfYear + 1) + "-" + + dayOfMonth; + String newDateTime = newDate + " " + formerDate.split(" ")[1]; + deleteAfterTodayInfo(position, id); + ContentValues values = new ContentValues(); + values.put(TaskBean.DATETIME, newDateTime); + values.put(TaskBean.REPEAT_DAYS, TaskConstant.INIT_REPEAT_DAYS); + values.put(TaskBean.IF_FUTURE, TaskConstant.IS_FUTURE); + values.put(TaskBean.PARENT, TaskConstant.IS_PARENT); + int rows = DatabaseUtil.update(TaskActivity.this, + TaskBean.TABLE_NAME, values, TaskBean.ID + "=" + id, + null); + if (rows > 0) { + + // ݿ³ɹ + Log.d("debug", "ʱƳٵ" + newDateTime); + Toast.makeText(TaskActivity.this, + "Ƴٻɹ,ԶΪ1,δͼнв鿴", Toast.LENGTH_SHORT) + .show(); + // ȡ + cancelAlarm(id); + todayTaskItemList.remove(position); + todayAdapter.notifyDataSetChanged(); + + todayTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.ID + "=" + id, + null, null, null, null); + + // õϢmap + for (todayTaskCur.moveToFirst(); !todayTaskCur + .isAfterLast(); todayTaskCur.moveToNext()) { + Map map = TaskBean + .generateTask(todayTaskCur); + refreshTomorrowTaskAfterInsert(map); + } + DatabaseUtil.closeDatabase(); + startServiceToFreshTomorrowWidget(); + sendBroadcastToTodayWidget(); + + } else { + Toast.makeText(TaskActivity.this, "ݿʧ", + Toast.LENGTH_SHORT).show(); + } + } + } + }; + + @Override + public boolean onContextItemSelected(MenuItem item) { + // TODO Auto-generated method stub + switch (item.getItemId()) { + case MenuItemId.TASK_ITEM_LONG_CLICK_MENU_EDIT: + // ༭¼ + todayTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.ID + "=" + + todayClickViewId, null, null, null, null); + Map map = null; + for (todayTaskCur.moveToFirst(); !todayTaskCur.isAfterLast(); todayTaskCur + .moveToNext()) { + map = TaskBean.generateTask(todayTaskCur); + } + + DatabaseUtil.closeDatabase(); + + final View editTaskView = getViewById(R.layout.add_task_dialog_layout); + final EditText taskContent = (EditText) editTaskView + .findViewById(R.id.et_task_info); + taskContent.setText(map.get(TaskBean.TASK_NAME).toString()); + final EditText taskPosition = (EditText) editTaskView + .findViewById(R.id.et_task_position); + taskPosition.setText(map.get(TaskBean.POSITION_NAME).toString()); + + int[] minuteAndHour = DateUtils.getHourAndMinuteByDateTime(map.get( + TaskBean.DATETIME).toString()); + + TimePicker timePicker = (TimePicker) editTaskView + .findViewById(R.id.tp_task_time); + timePicker.setCurrentHour(minuteAndHour[0]); + timePicker.setCurrentMinute(minuteAndHour[1]); + alarmHour = minuteAndHour[0]; + alarmMinute = minuteAndHour[1]; + timePicker.setOnTimeChangedListener(new OnTimeChangedListener() { + + @Override + public void onTimeChanged(TimePicker view, int hourOfDay, + int minute) { + // TODO Auto-generated method stub + time = DateUtils.formatTime(hourOfDay, minute); + // alarmHour = hourOfDay; + // alarmMinute = minute; + } + }); + + RadioGroup rankGroup = (RadioGroup) editTaskView + .findViewById(R.id.task_rank_group); + final RadioButton rankFirst = (RadioButton) editTaskView + .findViewById(R.id.task_rank_first); + final RadioButton rankSecond = (RadioButton) editTaskView + .findViewById(R.id.task_rank_second); + final RadioButton rankThird = (RadioButton) editTaskView + .findViewById(R.id.task_rank_third); + final RadioButton rankFourth = (RadioButton) editTaskView + .findViewById(R.id.task_rank_fourth); + + priority = Integer.parseInt(map.get(TaskBean.PRIORITY).toString()); + switch (priority) { + case TaskConstant.RANK_FIRST: + rankFirst.setChecked(true); + break; + case TaskConstant.RANK_SECOND: + rankSecond.setChecked(true); + break; + case TaskConstant.RANK_THIRD: + rankThird.setChecked(true); + break; + case TaskConstant.RANK_FOURTH: + rankFourth.setChecked(true); + break; + } + + rankGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + // TODO Auto-generated method stub + if (checkedId == rankFirst.getId()) { + priority = TaskConstant.RANK_FIRST; + } else if (checkedId == rankSecond.getId()) { + priority = TaskConstant.RANK_SECOND; + } else if (checkedId == rankThird.getId()) { + priority = TaskConstant.RANK_THIRD; + } else if (checkedId == rankFourth.getId()) { + priority = TaskConstant.RANK_FOURTH; + } + } + }); + + final CheckBox timeAlertCB = (CheckBox) editTaskView + .findViewById(R.id.cb_time_alert); + + timeAlertValue = Integer.parseInt(map.get(TaskBean.TIME_ALERT_FLAG) + .toString()); + if (timeAlertValue == TaskConstant.TIME_ALERT) { + timeAlertCB.setChecked(true); + } else { + timeAlertCB.setChecked(false); + } + + timeAlertCB + .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + // TODO Auto-generated method stub + if (timeAlertCB.isChecked()) { + timeAlertValue = TaskConstant.TIME_ALERT; + } else { + timeAlertValue = TaskConstant.NO_TIME_ALERT; + } + } + }); + + repeatDays = Integer.parseInt(map.get(TaskBean.REPEAT_DAYS) + .toString()); + + repeatDateTimeTV = (TextView) editTaskView + .findViewById(R.id.task_repeat_days_date); + repeatDaysTV = (TextView) editTaskView + .findViewById(R.id.task_repeat_days_total); + refreshRepeatDaysTextView(); + + Button setRepeatDaysBtn = (Button) editTaskView + .findViewById(R.id.task_repeat_days_button); + setRepeatDaysBtn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + int[] dayInfo = DateUtils + .getDayInfoByRepeatDays(repeatDays); + // ڶԻ + DatePickerDialog dlg = new DatePickerDialog( + TaskActivity.this, dateListener, dayInfo[0], + dayInfo[1], dayInfo[2]); + dlg.setTitle(R.string.task_time_repeat_dialog_title); + dlg.show(); + } + }); + + // ½Ի + new AlertDialog.Builder(TaskActivity.this) + .setTitle(R.string.edit_task_dialog_title) + .setIcon(android.R.drawable.ic_menu_edit) + .setView(editTaskView) + .setPositiveButton(R.string.save_task_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + // TODO Auto-generated method stub + String taskContentStr = taskContent + .getText().toString().trim(); + String taskPositionStr = taskPosition + .getText().toString().trim(); + if (taskContentStr.equals("")) { + Toast.makeText(TaskActivity.this, + "ƲΪ", Toast.LENGTH_SHORT) + .show(); + } else { + String datetime = DateUtils.now() + " " + + time; + ContentValues values = new ContentValues(); + + values.put(TaskBean.TASK_NAME, + taskContentStr); + values.put(TaskBean.DATETIME, datetime); + values.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + values.put(TaskBean.POSITION_NAME, + taskPositionStr); + values.put(TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + values.put(TaskBean.PRIORITY, priority); + values.put(TaskBean.REPEAT_DAYS, + repeatDays); + + deleteAfterTodayInfo( + todayClickPosition, + todayClickViewId); + int rows = DatabaseUtil.update( + TaskActivity.this, + TaskBean.TABLE_NAME, values, + TaskBean.ID + "=" + + todayClickViewId, + null); + + if (rows > 0) { + int parent = Integer + .parseInt(todayTaskItemList + .get(todayClickPosition) + .get(TaskBean.PARENT) + .toString()); + // ͹㲥̨֪ͨ޸ݿ + if (repeatDays > 1) { + // 㲥 + Intent insertData = new Intent( + PlanBetterReceiver.INSERT_DATA_AFTER_MODIFY); + Bundle bundle = new Bundle(); + bundle.putString( + TaskBean.TASK_NAME, + taskContentStr); + bundle.putString( + TaskBean.POSITION_NAME, + taskPositionStr); + bundle.putInt( + TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + bundle.putInt( + TaskBean.PRIORITY, + priority); + bundle.putString( + TaskBean.DATETIME, + datetime); + bundle.putInt( + TaskBean.REPEAT_DAYS, + repeatDays); + bundle.putInt(TaskBean.PARENT, + (int) parent); + bundle.putInt( + TaskBean.CURVIEWID, + todayClickViewId); + insertData + .putExtra( + PlanBetterReceiver.INSERT_DATA_AFTER_MODIFY_INTENT_BUNDLE_TAG, + bundle); + sendBroadcast(insertData); + } + + Map map = new HashMap(); + map.put(TaskBean.TASK_NAME, + taskContentStr); + map.put(TaskBean.DATETIME, datetime); + map.put(TaskBean.POSITION_NAME, + taskPositionStr); + map.put(TaskBean.PRIORITY, priority + + ""); + map.put(TaskBean.TIME_ALERT_FLAG, + timeAlertValue + ""); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE + + ""); + map.put(TaskBean.ID, + todayClickViewId + ""); + map.put(TaskBean.REPEAT_DAYS, + repeatDays + ""); + map.put(TaskBean.PARENT, parent + + ""); + + refreshTodayTaskAfterUpdate( + todayClickPosition, map); + Toast.makeText(TaskActivity.this, + "޸Ļɹ", + Toast.LENGTH_SHORT).show(); + cancelAlarm(todayClickViewId); + if (timeAlertValue == TaskConstant.TIME_ALERT) { + try { + registerAlarm( + todayClickViewId, + datetime); + } catch (ParseException e) { + // TODO Auto-generated catch + // block + e.printStackTrace(); + } + } + sendBroadcastToTodayWidget(); + } else { + Toast.makeText(TaskActivity.this, + "޸Ļʧ", + Toast.LENGTH_SHORT).show(); + } + } + } + }) + .setNegativeButton(R.string.cancel_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, + int which) { + // TODO Auto-generated method stub + + } + + }).create().show(); + + return true; + case MenuItemId.TASK_ITEM_LONG_CLICK_MENU_DELETE: + // ɾ¼ + deleteTodayTaskItem("ȷɾ", "ȷɾ"); + return true; + case MenuItemId.TASK_ITEM_LONG_CLICK_MENU_PULL: + // Ƴٻ¼ + if (todayClickCompleteState == TaskConstant.TASK_NOT_COMPLETE) { + // Ƴ + // ѯʱ + todayTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, + new String[] { TaskBean.DATETIME }, TaskBean.ID + "=" + + todayClickViewId, null, null, null, null); + String datetime = ""; + for (todayTaskCur.moveToFirst(); !todayTaskCur.isAfterLast(); todayTaskCur + .moveToNext()) { + datetime = todayTaskCur.getString(todayTaskCur + .getColumnIndex(TaskBean.DATETIME)); + } + DatabaseUtil.closeDatabase(); + int[] yearMonthAndDay = DateUtils + .getYearMonthAndDayByDateTime(datetime); + DatePickerDialog dlg = new DatePickerDialog(TaskActivity.this, + new PullDateListener(datetime, todayClickViewId, + todayClickPosition), yearMonthAndDay[0], + yearMonthAndDay[1] - 1, yearMonthAndDay[2]); + dlg.setTitle(R.string.task_time_pull_dialog_title); + dlg.show(); + } else { + Toast.makeText(TaskActivity.this, "޷Ƴ", + Toast.LENGTH_SHORT).show(); + } + return true; + } + return super.onContextItemSelected(item); + } + + private void deleteTodayTaskItem(String pTitle, final String pMsg) { + final Dialog lDialog = new Dialog(TaskActivity.this, + android.R.style.Theme_Translucent_NoTitleBar); + lDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + lDialog.setContentView(R.layout.iphone_alert_dialog_layout); + ((TextView) lDialog.findViewById(R.id.dialog_title)).setText(pTitle); + ((TextView) lDialog.findViewById(R.id.dialog_message)).setText(pMsg); + ((Button) lDialog.findViewById(R.id.cancel)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // CANCEL + lDialog.dismiss(); + } + }); + ((Button) lDialog.findViewById(R.id.ok)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // OK + + lDialog.dismiss(); + // ɾ + Log.d("debug", "delete curViewId=" + todayClickViewId); + + deleteAfterTodayInfo(todayClickPosition, + todayClickViewId); + DatabaseUtil.delete(TaskActivity.this, + TaskBean.TABLE_NAME, TaskBean.ID + "=" + + todayClickViewId, null); + + Toast.makeText(TaskActivity.this, "ɾɹ", + Toast.LENGTH_SHORT).show(); + // ˢб + cancelAlarm(todayClickViewId); + todayTaskItemList.remove(todayClickPosition); + todayAdapter.notifyDataSetChanged(); + sendBroadcastToTodayWidget(); + } + }); + lDialog.show(); + } + + private void initViews() { + // ʼͼ + todayView = LayoutInflater.from(TaskActivity.this).inflate( + R.layout.today_task_layout, null); + initTodayAdapter(); + todayTaskList = (ListView) todayView + .findViewById(R.id.today_task_listview); + todayTaskList.setAdapter(todayAdapter); + todayListEmptyView = new TextView(this); + todayListEmptyView.setText(R.string.task_list_view_empty); + todayListEmptyView.setGravity(Gravity.CENTER); + todayListEmptyView.setTextSize(20); // С + todayListEmptyView.setTextColor(0xff000000); + addContentView(todayListEmptyView, new LayoutParams( + LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + todayTaskList.setEmptyView(todayListEmptyView); + + todayTaskList.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, + int position, long id) { + // TODO Auto-generated method stub + ContentValues values = new ContentValues(); + if (Integer.parseInt(todayTaskItemList.get(position) + .get(TaskBean.IF_COMPLETE).toString()) == TaskConstant.TASK_NOT_COMPLETE) { + values.put(TaskBean.IF_COMPLETE, TaskConstant.TASK_COMPLETE); + int rows = DatabaseUtil.update(TaskActivity.this, + TaskBean.TABLE_NAME, values, + TaskBean.ID + "=" + id, null); + if (rows > 0) { + // ³ɹ + Map map = todayTaskItemList + .get(position); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_COMPLETE + ""); + todayTaskItemList.set(position, map); + todayAdapter.notifyDataSetChanged(); + // ȡ + cancelAlarm((int) id); + Toast.makeText(TaskActivity.this, "Ѿ", + Toast.LENGTH_SHORT).show(); + } else { + // ʧ + Toast.makeText(TaskActivity.this, "ݿʧ", + Toast.LENGTH_SHORT).show(); + } + } else { + values.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + int rows = DatabaseUtil.update(TaskActivity.this, + TaskBean.TABLE_NAME, values, + TaskBean.ID + "=" + id, null); + if (rows > 0) { + // ³ɹ + Map map = todayTaskItemList + .get(position); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE + ""); + todayTaskItemList.set(position, map); + todayAdapter.notifyDataSetChanged(); + if (Integer.parseInt(todayTaskItemList.get(position) + .get(TaskBean.TIME_ALERT_FLAG).toString()) == TaskConstant.TIME_ALERT) { + String datetime = todayTaskItemList.get(position) + .get(TaskBean.DATETIME).toString(); + int[] val = DateUtils + .getHourAndMinuteByDateTime(datetime); + registerAlarm((int) id, val[0], val[1]); + } + Toast.makeText(TaskActivity.this, "δ", + Toast.LENGTH_SHORT).show(); + } else { + // ʧ + Toast.makeText(TaskActivity.this, "ݿʧ", + Toast.LENGTH_SHORT).show(); + } + } + } + }); + + todayTaskList.setOnItemLongClickListener(new OnItemLongClickListener() { + + @Override + public boolean onItemLongClick(AdapterView parent, View view, + int position, long id) { + // TODO Auto-generated method stub + todayClickViewId = (int) id; + todayClickPosition = position; + todayClickCompleteState = Integer.parseInt(todayTaskItemList + .get(position).get(TaskBean.IF_COMPLETE).toString()); + return false; + } + }); + + todayTaskList + .setOnCreateContextMenuListener(new OnCreateContextMenuListener() { + + @Override + public void onCreateContextMenu(ContextMenu menu, View v, + ContextMenuInfo menuInfo) { + // TODO Auto-generated method stub + menu.setHeaderIcon(android.R.drawable.ic_menu_more); + menu.setHeaderTitle(R.string.task_long_click_menu_title); + menu.add(0, MenuItemId.TASK_ITEM_LONG_CLICK_MENU_EDIT, + 0, R.string.task_long_click_menu_edit); + menu.add(0, + MenuItemId.TASK_ITEM_LONG_CLICK_MENU_DELETE, 0, + R.string.task_long_click_menu_delete); + menu.add(0, MenuItemId.TASK_ITEM_LONG_CLICK_MENU_PULL, + 0, R.string.task_long_click_menu_pull); + } + }); + + // ʼͼ + tomorrowView = LayoutInflater.from(TaskActivity.this).inflate( + R.layout.tomorrow_task_layout, null); + tomorrowTaskName = (TextView) tomorrowView + .findViewById(R.id.textView_datematter); + tomorrowTaskDate = (TextView) tomorrowView + .findViewById(R.id.textView_datemattermessage); + tomorrowTaskLeftDay = (TextView) tomorrowView + .findViewById(R.id.textView_daysleft); + + initTomorrowAdapter(); + + tomorrowTaskList = (ListView) tomorrowView + .findViewById(R.id.tomorrow_task_listview); + tomorrowTaskList.setAdapter(tomorrowAdapter); + tomorrowTaskList.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, + int position, final long id) { + tomorrowTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.ID + "=" + id, + null, null, null, null); + Map map = null; + for (tomorrowTaskCur.moveToFirst(); !tomorrowTaskCur + .isAfterLast(); tomorrowTaskCur.moveToNext()) { + map = TaskBean.generateTask(tomorrowTaskCur); + } + DatabaseUtil.closeDatabase(); + String taskName = (String) map.get(TaskBean.TASK_NAME); + String dateStr = (String) map.get(TaskBean.DATETIME); + refreshTomorrowMessageSendMessage(id + "", taskName, dateStr); + } + + }); + tomorrowTaskList + .setOnItemLongClickListener(new OnItemLongClickListener() { + String tPosition; + String tpriority; + String trepeatDays; + int tViewPoition; + int tyear; + int tmonth; + int tday; + int thour; + int tminute; + int differDays = -1; + + @Override + public boolean onItemLongClick(AdapterView parent, + View view, int position, final long id) { + + tViewPoition = position; + + tomorrowTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.ID + "=" + + id, null, null, null, null); + Map map = null; + for (tomorrowTaskCur.moveToFirst(); !tomorrowTaskCur + .isAfterLast(); tomorrowTaskCur.moveToNext()) { + map = TaskBean.generateTask(tomorrowTaskCur); + } + + DatabaseUtil.closeDatabase(); + + tPosition = (String) map.get(TaskBean.POSITION_NAME); + trepeatDays = (String) map.get(TaskBean.REPEAT_DAYS); + final View editTaskView = getViewById(R.layout.edit_tomorrow_task_dialog_layout); + final EditText taskContent = (EditText) editTaskView + .findViewById(R.id.et_tomorrow_task_info); + taskContent.setText(map.get(TaskBean.TASK_NAME) + .toString()); + + int[] yearMonthDay = DateUtils + .getYearMonthDayHourAndMinuteByDateTime(map + .get(TaskBean.DATETIME).toString()); + tyear = yearMonthDay[0]; + tmonth = yearMonthDay[1]; + tday = yearMonthDay[2]; + tminute = yearMonthDay[4]; + thour = yearMonthDay[3]; + DatePicker datePicker = (DatePicker) editTaskView + .findViewById(R.id.dp_tomorrow_task_date); + datePicker.init(tyear, tmonth - 1, tday, + new DatePicker.OnDateChangedListener() { + + @Override + public void onDateChanged(DatePicker view, + int year, + + int monthOfYear, int dayOfMonth) { + + tyear = year; + tmonth = monthOfYear + 1; + tday = dayOfMonth; + + differDays = DateUtils.getDifferDays( + year, monthOfYear + 1, + dayOfMonth); + + if (differDays < 0) + Toast.makeText(TaskActivity.this, + "óɽԺʱ䣡", + Toast.LENGTH_SHORT).show(); + } + + }); + + TimePicker timePicker = (TimePicker) editTaskView + .findViewById(R.id.tp_tomorrow_task_time); + timePicker.setCurrentHour(thour); + timePicker.setCurrentMinute(tminute); + + timePicker + .setOnTimeChangedListener(new OnTimeChangedListener() { + + @Override + public void onTimeChanged(TimePicker view, + int hourOfDay, int minute) { + time = DateUtils.formatTime(hourOfDay, + minute); + thour = hourOfDay; + tminute = minute; + } + }); + + final CheckBox timeAlertCB = (CheckBox) editTaskView + .findViewById(R.id.cb_tomorrow_time_alert); + + timeAlertValue = Integer.parseInt(map.get( + TaskBean.TIME_ALERT_FLAG).toString()); + if (timeAlertValue == TaskConstant.TIME_ALERT) { + timeAlertCB.setChecked(true); + } else { + timeAlertCB.setChecked(false); + } + + timeAlertCB + .setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + + @Override + public void onCheckedChanged( + CompoundButton buttonView, + boolean isChecked) { + if (timeAlertCB.isChecked()) { + timeAlertValue = TaskConstant.TIME_ALERT; + tminute = 0; + thour = 0; + } else { + timeAlertValue = TaskConstant.NO_TIME_ALERT; + } + } + }); + + // ½Ի + new AlertDialog.Builder(TaskActivity.this) + .setTitle(R.string.edit_task_dialog_title) + .setIcon(android.R.drawable.ic_menu_edit) + .setView(editTaskView) + .setPositiveButton( + R.string.save_task_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick( + DialogInterface dialog, + int which) { + String taskContentStr = taskContent + .getText().toString() + .trim(); + + if (taskContentStr.equals("")) { + Toast.makeText( + TaskActivity.this, + "ƲΪ", + Toast.LENGTH_SHORT) + .show(); + } else if (differDays < 0) { + Toast.makeText( + TaskActivity.this, + "òδ洢", + Toast.LENGTH_SHORT) + .show(); + } else { + String datetime = DateUtils + .formatDate(tyear, + tmonth, + tday) + + " " + time; + ContentValues values = new ContentValues(); + + values.put( + TaskBean.TASK_NAME, + taskContentStr); + values.put( + TaskBean.DATETIME, + datetime); + values.put( + TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + values.put( + TaskBean.POSITION_NAME, + tPosition); + values.put( + TaskBean.TIME_ALERT_FLAG, + timeAlertValue); + + int rows = DatabaseUtil + .update(TaskActivity.this, + TaskBean.TABLE_NAME, + values, + TaskBean.ID + + "=" + + id, + null); + + if (rows > 0) { + Map map = new HashMap(); + map.put(TaskBean.TASK_NAME, + taskContentStr); + map.put(TaskBean.DATETIME, + datetime); + map.put(TaskBean.POSITION_NAME, + tPosition); + map.put(TaskBean.PRIORITY, + tpriority + ""); + map.put(TaskBean.TIME_ALERT_FLAG, + timeAlertValue + + ""); + map.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE + + ""); + map.put(TaskBean.ID, id + + ""); + map.put(TaskBean.REPEAT_DAYS, + trepeatDays + + ""); + + refreshTomorrowTaskAfterUpdate( + tViewPoition, + map); + Toast.makeText( + TaskActivity.this, + "޸Ļɹ", + Toast.LENGTH_SHORT) + .show(); + + refreshTomorrowMessageSendMessage( + id + "", + taskContentStr, + datetime); + startServiceToFreshTomorrowWidget(); + } else { + Toast.makeText( + TaskActivity.this, + "޸Ļʧ", + Toast.LENGTH_SHORT) + .show(); + } + } + } + }) + .setNeutralButton(R.string.delete_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick( + DialogInterface dialog, + int which) { + final Dialog lDialog = new Dialog( + TaskActivity.this, + android.R.style.Theme_Translucent_NoTitleBar); + lDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + lDialog.setContentView(R.layout.iphone_alert_dialog_layout); + ((TextView) lDialog + .findViewById(R.id.dialog_title)) + .setText("ȷɾ˻"); + ((TextView) lDialog + .findViewById(R.id.dialog_message)) + .setText("ɾɹ"); + ((Button) lDialog + .findViewById(R.id.cancel)) + .setOnClickListener(new OnClickListener() { + + public void onClick( + View v) { + lDialog.dismiss(); + } + }); + ((Button) lDialog + .findViewById(R.id.ok)) + .setOnClickListener(new OnClickListener() { + + public void onClick( + View v) { + + lDialog.dismiss(); + // ɾ + + int rows = DatabaseUtil + .delete(TaskActivity.this, + TaskBean.TABLE_NAME, + TaskBean.ID + + "=" + + id, + null); + if (rows > 0) { + Toast.makeText( + TaskActivity.this, + "ɾɹ", + Toast.LENGTH_SHORT) + .show(); + // ˢб + + tomorrowTaskItemList + .remove(tViewPoition); + tomorrowAdapter + .notifyDataSetChanged(); + String taskid = id + + ""; + if (tomorrowTaskMessageID + .equals(taskid)) + refreshTomorrowMessageDelete(); + startServiceToFreshTomorrowWidget(); + } + } + }); + lDialog.show(); + } + + }) + .setNegativeButton(R.string.cancel_dialog_text, + new DialogInterface.OnClickListener() { + + public void onClick( + DialogInterface dialog, + int which) { + + } + + }).create().show(); + return false; + } + }); + + tomorrowListEmptyView = new TextView(this); + tomorrowListEmptyView.setText(R.string.tomorrow_task_list_view_empty); + tomorrowListEmptyView.setGravity(Gravity.CENTER); + tomorrowListEmptyView.setTextSize(20); // С + tomorrowListEmptyView.setTextColor(0xff000000); + addContentView(tomorrowListEmptyView, new LayoutParams( + LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + tomorrowTaskList.setEmptyView(tomorrowListEmptyView); + // if(tomorrowTaskItemList.size() == 0) { + // tomorrowListEmptyView.setVisibility(View.INVISIBLE); + // } + + // ʼͼ + yesterdayView = LayoutInflater.from(TaskActivity.this).inflate( + R.layout.yesterday_task_layout, null); + initYesterdayAdapter(); + yesterdayTaskList = (ListView) yesterdayView + .findViewById(R.id.yesterday_task_listview); + yesterdayTaskList.setAdapter(yesterdayAdapter); + TextView yesterdayDate = (TextView) yesterdayView + .findViewById(R.id.textView_yesterday_date); + yesterdayDate.setText(DateUtils.timeDetail("yesterday")); + yesterdayListEmptyView = new TextView(this); + yesterdayListEmptyView.setText(R.string.yesterday_task_list_view_empty); + yesterdayListEmptyView.setGravity(Gravity.CENTER); + yesterdayListEmptyView.setTextSize(20); // С + yesterdayListEmptyView.setTextColor(0xff000000); + addContentView(yesterdayListEmptyView, new LayoutParams( + LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + yesterdayTaskList.setEmptyView(yesterdayListEmptyView); + + // ж + if (tomorrowTaskItemList.size() == 0) { + tomorrowListEmptyView.setVisibility(View.INVISIBLE); + } + if (todayTaskItemList.size() == 0) { + todayListEmptyView.setVisibility(View.INVISIBLE); + } + } + + // ʼϢList + private void initTodayListItem() { + // ѯݿ,ȡϢ + todayTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " LIKE ?", + new String[] { DateUtils.now() + "%" }, null, null, TaskBean.ID + + " ASC"); + + // Ϣ + + for (todayTaskCur.moveToFirst(); !todayTaskCur.isAfterLast(); todayTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(todayTaskCur); + todayTaskItemList.add(map); + } + + DatabaseUtil.closeDatabase(); + } + + // ʼAdapter + private void initTodayAdapter() { + todayTaskItemList = new ArrayList>(); + initTodayListItem(); + todayAdapter = new TodayTaskListViewAdapter(); + } + + private void initTomorrowListItem() { + tomorrowTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.IF_FUTURE + "=" + + TaskConstant.IS_FUTURE + " AND " + TaskBean.PARENT + + "=" + TaskConstant.IS_PARENT, null, null, null, + TaskBean.ID + " ASC"); + int x = Integer.MAX_VALUE; + String taskName = null; + String dateStr = null; + String id = null; + // δϢ + for (tomorrowTaskCur.moveToFirst(); !tomorrowTaskCur.isAfterLast(); tomorrowTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(tomorrowTaskCur); + tomorrowTaskItemList.add(map); + Log.d("debug", "future map: δϢ"); + + String date = (String) map.get(TaskBean.DATETIME); + int[] yearMonthDay = DateUtils + .getYearMonthDayHourAndMinuteByDateTime(date); + int taskYear = yearMonthDay[0]; + int taskMonth = yearMonthDay[1]; + int taskDay = yearMonthDay[2]; + + String datetime = DateUtils + .formatDate(taskYear, taskMonth, taskDay); + + int differ = x + 1; + try { + differ = DateUtils.getDifferDays(datetime); + } catch (ParseException e) { + e.printStackTrace(); + } + + if (differ <= x) { + taskName = (String) map.get(TaskBean.TASK_NAME); + dateStr = (String) map.get(TaskBean.DATETIME); + id = (String) map.get(TaskBean.ID); + x = differ; + } + } + Log.d("debug", "initTomorrowListItem"); + DatabaseUtil.closeDatabase(); + + initTomorrowMessage(id, taskName, dateStr); + } + + private static final int REFRESH_TOMORROW_MESSAGE = 0; + + private Handler refreshHandler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + // + switch (msg.what) { + case REFRESH_TOMORROW_MESSAGE: + Bundle bundle = msg.getData(); + initTomorrowMessage(bundle.getString(TaskBean.ID), + bundle.getString(TaskBean.TASK_NAME), + bundle.getString(TaskBean.DATETIME)); + break; + } + } + + }; + + private void initTomorrowMessage(String id, String name, String date) { + tomorrowTaskMessageID = id; + int taskYear; + int taskMonth; + int taskDay; + if (name == null) { + tomorrowTaskName.setText("롭"); + tomorrowTaskDate.setText(DateUtils.timeDetail("TOMORROW")); + tomorrowTaskLeftDay.setText("X"); + } else { + int[] yearMonthDay = DateUtils + .getYearMonthDayHourAndMinuteByDateTime(date); + + taskYear = yearMonthDay[0]; + taskMonth = yearMonthDay[1]; + taskDay = yearMonthDay[2]; + + String taskcontent = "" + name + "ʣ"; + + String datetime = DateUtils + .formatDate(taskYear, taskMonth, taskDay); + String weekDay = DateUtils.getWeekDay(datetime); + String daysmatter = "գ" + datetime + " " + weekDay; + + int differ = 0; + try { + differ = DateUtils.getDifferDays(datetime); + } catch (ParseException e) { + e.printStackTrace(); + } + + tomorrowTaskName.setText(taskcontent); + tomorrowTaskDate.setText(daysmatter); + tomorrowTaskLeftDay.setText(differ + ""); + } + } + + private void initTomorrowAdapter() { + tomorrowTaskItemList = new ArrayList>(); + initTomorrowListItem(); + tomorrowAdapter = new TomorrowTaskListViewAdapter(); + } + + private void refreshTodayTaskAfterInsert(Map map) { + // ˢб + todayTaskItemList.add(map); + todayAdapter.notifyDataSetChanged(); + } + + private void refreshTomorrowTaskAfterInsert(Map map) { + // ˢб + tomorrowTaskItemList.add(map); + tomorrowAdapter.notifyDataSetChanged(); + } + + // private void refreshYesterdayTaskAfterInsert(Map map) { + // // ˢб + // yesterdayTaskItemList.add(map); + // yesterdayAdapter.notifyDataSetChanged(); + // } + + private void refreshTodayTaskAfterUpdate(int position, + Map map) { + // + todayTaskItemList.set(position, map); + todayAdapter.notifyDataSetChanged(); + } + + private void refreshTomorrowTaskAfterUpdate(int position, + Map map) { + // + tomorrowTaskItemList.set(position, map); + tomorrowAdapter.notifyDataSetChanged(); + } + + private void initYesterdayAdapter() { + yesterdayTaskItemList = new ArrayList>(); + initYesterdayListItem(); + yesterdayAdapter = new YesterdayTaskListViewAdapter(); + } + + private void initYesterdayListItem() { + // ѯݿ,ȡϢ + yesterdayTaskCur = DatabaseUtil.query(TaskActivity.this, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " LIKE ?", + new String[] { DateUtils.yesterday() + "%" }, null, null, + TaskBean.ID + " ASC"); + + // Ϣ + + for (yesterdayTaskCur.moveToFirst(); !yesterdayTaskCur.isAfterLast(); yesterdayTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(yesterdayTaskCur); + yesterdayTaskItemList.add(map); + + } + + DatabaseUtil.closeDatabase(); + } + + // ȡview + private View getViewById(int resourceId) { + LayoutInflater inflater = LayoutInflater.from(this); + return inflater.inflate(resourceId, null); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // TODO Auto-generated method stub + switch (item.getItemId()) { + //ʱ䶼ȥ + case MenuItemId.MENU_ITEM_TIME: + Intent tt_intent = new Intent(Intent.ACTION_MAIN); + tt_intent.setComponent(new ComponentName("com.android.settings","com.android.settings.UsageStats")); + //intent.setClassName("com.android.settings", "UsageStats"); + startActivity(tt_intent); + break; + // ʹʱ + case MenuItemId.MENU_ITEM_LONG: + Intent tg_intent = new Intent(TaskActivity.this, + HelpActivity.class); + startActivity(tg_intent); + break; + // ʹʱ + case MenuItemId.MENU_ITEM_LIMIT: + Intent tl_intent = new Intent(TaskActivity.this, + HelpActivity.class); + startActivity(tl_intent); + break; + // + case MenuItemId.MENU_ITEM_SETUP: + Intent ti_intent = new Intent(TaskActivity.this, + SetupActivity.class); + startActivity(ti_intent); + break; + // + case MenuItemId.MENU_ITEM_HELP: + Intent tx_intent = new Intent(TaskActivity.this, HelpActivity.class); + startActivity(tx_intent); + break; + // + case MenuItemId.MENU_ITEM_ABOUT: + Intent ty_intent = new Intent(); + ty_intent.setClass(TaskActivity.this, AboutActivity.class); + startActivity(ty_intent); + break; + } + return true; + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + + MenuItem menu_goal = menu.add(0, MenuItemId.MENU_ITEM_TIME, 0, + R.string.menu_time); + menu_goal.setIcon(android.R.drawable.ic_menu_directions); + + MenuItem menu_limit = menu.add(0, MenuItemId.MENU_ITEM_LIMIT, 0, + R.string.menu_limit); + menu_limit.setIcon(android.R.drawable.ic_menu_recent_history); + + MenuItem menu_long = menu.add(0, MenuItemId.MENU_ITEM_LONG, 0, + R.string.menu_long); + menu_long.setIcon(android.R.drawable.ic_lock_lock); + + MenuItem menu_setup = menu.add(0, MenuItemId.MENU_ITEM_SETUP, 0, + R.string.menu_setup); + menu_setup.setIcon(android.R.drawable.ic_menu_preferences); + + MenuItem menu_help = menu.add(0, MenuItemId.MENU_ITEM_HELP, 0, + R.string.menu_help); + menu_help.setIcon(android.R.drawable.ic_menu_help); + + MenuItem menu_about = menu.add(0, MenuItemId.MENU_ITEM_ABOUT, 0, + R.string.menu_about); + menu_about.setIcon(android.R.drawable.ic_menu_info_details); + + return true; + } + + public boolean onTouchEvent(MotionEvent event) { + return gestureDetector.onTouchEvent(event); + } + + public boolean onDown(MotionEvent e) { + // TODO Auto-generated method stub + return false; + } + + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + // TODO Auto-generated method stub + if (e1.getX() - e2.getX() > MotionEventConstant.getFlingMinDistance() + && Math.abs(velocityX) > MotionEventConstant + .getFlingMinVelocity()) { + + if (index != END_INDEX) { + // playSound(Sound.OPEN_SOUND); + this.flipper.setInAnimation(AnimationUtils.loadAnimation(this, + R.anim.push_left_in)); + this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this, + R.anim.push_left_out)); + this.flipper.showNext(); + index++; + + if (index != MIDDLE_INDEX) { + if (todayTaskItemList.size() == 0) { + todayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_left_out)); + todayListEmptyView.setVisibility(View.INVISIBLE); + } + } else { + if (yesterdayTaskItemList.size() == 0) { + yesterdayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_left_out)); + yesterdayListEmptyView.setVisibility(View.INVISIBLE); + } + if (todayTaskItemList.size() == 0) { + todayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_left_in)); + todayListEmptyView.setVisibility(View.VISIBLE); + } + } + if (index == END_INDEX) { + if (tomorrowTaskItemList.size() == 0) { + tomorrowListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_left_in)); + tomorrowListEmptyView.setVisibility(View.VISIBLE); + } + } + + return true; + } + } else if (e2.getX() - e1.getX() > MotionEventConstant + .getFlingMinDistance() + && Math.abs(velocityX) > MotionEventConstant + .getFlingMinVelocity()) { + if (index != START_INDEX) { + // playSound(Sound.OPEN_SOUND); + this.flipper.setInAnimation(AnimationUtils.loadAnimation(this, + R.anim.push_right_in)); + this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this, + R.anim.push_right_out)); + this.flipper.showPrevious(); + index--; + if (index != MIDDLE_INDEX) { + if (todayTaskItemList.size() == 0) { + todayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_right_out)); + todayListEmptyView.setVisibility(View.INVISIBLE); + } + if (yesterdayTaskItemList.size() == 0) { + yesterdayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_right_in)); + yesterdayListEmptyView.setVisibility(View.VISIBLE); + } + } else { + if (todayTaskItemList.size() == 0) { + todayListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_right_in)); + todayListEmptyView.setVisibility(View.VISIBLE); + } + if (tomorrowTaskItemList.size() == 0) { + tomorrowListEmptyView.startAnimation(AnimationUtils + .loadAnimation(this, R.anim.push_right_out)); + tomorrowListEmptyView.setVisibility(View.INVISIBLE); + } + } + return true; + } + } + return false; + } + + public void onLongPress(MotionEvent e) { + // TODO Auto-generated method stub + + } + + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, + float distanceY) { + return false; + } + + public void onShowPress(MotionEvent e) { + // TODO Auto-generated method stub + + } + + public boolean onSingleTapUp(MotionEvent e) { + // TODO Auto-generated method stub + return false; + } + + private class TodayTaskListViewAdapter extends BaseAdapter { + + final class TaskListItemView { + public TextView taskInfo; // + public ImageView timeAlert; // ʱͼƬ + public TextView taskTimeAndPositionInfo; // ʱ͵صϢ + public ImageView taskcompleteState; // ״̬ͼƬ + public ImageView taskStarRank; // ȼͼƬ + public TextView taskRepeatDays; // + } + + public int getCount() { + // TODO Auto-generated method stub + return todayTaskItemList.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return todayTaskItemList.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return Integer.parseInt(todayTaskItemList.get(position) + .get(TaskBean.ID).toString()); + } + + public View getView(final int position, View convertView, + ViewGroup parent) { + // TODO Auto-generated method stub + TaskListItemView listItemView = null; + if (convertView == null) { + listItemView = new TaskListItemView(); + convertView = LayoutInflater.from(TaskActivity.this).inflate( + R.layout.today_task_item, null); + // ȡؼ + listItemView.taskInfo = (TextView) convertView + .findViewById(R.id.today_task_info); + listItemView.timeAlert = (ImageView) convertView + .findViewById(R.id.today_time_alert); + listItemView.taskTimeAndPositionInfo = (TextView) convertView + .findViewById(R.id.today_task_time_position_textview); + listItemView.taskcompleteState = (ImageView) convertView + .findViewById(R.id.today_task_complete_state); + listItemView.taskStarRank = (ImageView) convertView + .findViewById(R.id.today_star_rank); + listItemView.taskRepeatDays = (TextView) convertView + .findViewById(R.id.today_repeat_days); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (TaskListItemView) convertView.getTag(); + } + + // + listItemView.taskInfo.setText((String) todayTaskItemList.get( + position).get(TaskBean.TASK_NAME)); + + // + listItemView.taskRepeatDays.setText((String) todayTaskItemList.get( + position).get(TaskBean.REPEAT_DAYS)); + + // ʱ͵صϢ + String positionName = (String) todayTaskItemList.get(position).get( + TaskBean.POSITION_NAME); + String timeAndPosition = "ʱ:" + + DateUtils.getTaskTime((String) todayTaskItemList.get( + position).get(TaskBean.DATETIME)); + if (!positionName.equals("")) { + timeAndPosition += (" ص:" + positionName); + } + listItemView.taskTimeAndPositionInfo.setText(timeAndPosition); + + Log.d("debug", + "position = " + + position + + " timeAlertFlag = " + + (String) todayTaskItemList.get(position).get( + TaskBean.TIME_ALERT_FLAG)); + + // ʱͼƬǷʾ timeAlert + if (Integer.parseInt(((String) todayTaskItemList.get(position).get( + TaskBean.TIME_ALERT_FLAG))) == TaskConstant.NO_TIME_ALERT) { + listItemView.timeAlert.setVisibility(View.INVISIBLE); + Log.d("debug", "ʱѰťʾ"); + } else { + listItemView.timeAlert.setVisibility(View.VISIBLE); + } + + // ȼͼƬ taskStarRank + switch (Integer.parseInt(todayTaskItemList.get(position) + .get(TaskBean.PRIORITY).toString())) { + case TaskConstant.RANK_FOURTH: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star1); + break; + case TaskConstant.RANK_THIRD: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star2); + break; + case TaskConstant.RANK_SECOND: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star3); + break; + case TaskConstant.RANK_FIRST: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star4); + break; + } + + if (TaskConstant.TASK_NOT_COMPLETE == Integer + .parseInt(todayTaskItemList.get(position) + .get(TaskBean.IF_COMPLETE).toString())) { + listItemView.taskcompleteState + .setBackgroundResource(R.drawable.theme_checked); + listItemView.taskTimeAndPositionInfo.setTextColor(0xff000000); + listItemView.taskInfo.setTextColor(0xff000000); + } else { + listItemView.taskcompleteState + .setBackgroundResource(R.drawable.theme_checked_disable); + listItemView.taskTimeAndPositionInfo.setTextColor(0xff808080); + listItemView.taskInfo.setTextColor(0xff808080); + } + + return convertView; + } + } + + private class TomorrowTaskListViewAdapter extends BaseAdapter { + + private LayoutInflater layoutInflater; + + final class TaskListItemView { + public TextView taskInfo; // + public TextView leftday; + } + + public TomorrowTaskListViewAdapter() { + this.layoutInflater = LayoutInflater.from(TaskActivity.this); + } + + public int getCount() { + // TODO Auto-generated method stub + return tomorrowTaskItemList.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return tomorrowTaskItemList.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return Integer.parseInt(tomorrowTaskItemList.get(position) + .get(TaskBean.ID).toString()); + } + + public View getView(final int position, View convertView, + ViewGroup parent) { + // TODO Auto-generated method stub + TaskListItemView listItemView = null; + if (convertView == null) { + listItemView = new TaskListItemView(); + convertView = layoutInflater.inflate( + R.layout.tomorrow_task_item, null); + // ȡؼ + listItemView.taskInfo = (TextView) convertView + .findViewById(R.id.tomorrow_item_textView_datematter); + listItemView.leftday = (TextView) convertView + .findViewById(R.id.tomorrow_item_textView_daysleft); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (TaskListItemView) convertView.getTag(); + } + + // + String x = "" + + (String) tomorrowTaskItemList.get(position).get( + TaskBean.TASK_NAME) + "ʣ"; + listItemView.taskInfo.setText(x); + // ʣ + + String datetime = (String) tomorrowTaskItemList.get(position).get( + TaskBean.DATETIME); + String[] spliteOnce = datetime.split(" ", 2); + String yearmd = spliteOnce[0]; + int differdays = 0; + try { + differdays = DateUtils.getDifferDays(yearmd); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String differ = differdays + ""; + listItemView.leftday.setText(differ); + + Log.d("debug", + "tomorrowposition = " + + position + + " timeAlertFlag = " + + (String) tomorrowTaskItemList.get(position).get( + TaskBean.TIME_ALERT_FLAG)); + + return convertView; + } + } + + private class YesterdayTaskListViewAdapter extends BaseAdapter { + + private int taskId = 0; + private int curPosition = 0; + + final class TaskListItemView { + public TextView taskInfo; // + public TextView taskTimeAndPositionInfo; // ʱ͵صϢ + public Button taskEditBtn; // ༭ť + public ImageView taskStarRank; // ȼͼƬ + } + + public int getCount() { + // TODO Auto-generated method stub + return yesterdayTaskItemList.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return yesterdayTaskItemList.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return Integer.parseInt(yesterdayTaskItemList.get(position) + .get(TaskBean.ID).toString()); + } + + public View getView(final int position, View convertView, + ViewGroup parent) { + // TODO Auto-generated method stub + TaskListItemView listItemView = null; + if (convertView == null) { + listItemView = new TaskListItemView(); + convertView = LayoutInflater.from(TaskActivity.this).inflate( + R.layout.yesterday_task_item, null); + // ȡؼ + listItemView.taskInfo = (TextView) convertView + .findViewById(R.id.yesterday_task_info); + listItemView.taskTimeAndPositionInfo = (TextView) convertView + .findViewById(R.id.yesterday_task_time_position_textview); + listItemView.taskEditBtn = (Button) convertView + .findViewById(R.id.yesterday_task_edit_btn); + listItemView.taskStarRank = (ImageView) convertView + .findViewById(R.id.yesterday_star_rank); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (TaskListItemView) convertView.getTag(); + } + + // + listItemView.taskInfo.setText((String) yesterdayTaskItemList.get( + position).get(TaskBean.TASK_NAME)); + + // ʱ͵صϢ + String positionName = (String) yesterdayTaskItemList.get(position) + .get(TaskBean.POSITION_NAME); + String timeAndPosition = "ʱ:" + + DateUtils.getTaskTime((String) yesterdayTaskItemList.get( + position).get(TaskBean.DATETIME)); + if (!positionName.equals("")) { + timeAndPosition += (" ص:" + positionName); + } + listItemView.taskTimeAndPositionInfo.setText(timeAndPosition); + + Log.d("debug", + "position = " + + position + + " timeAlertFlag = " + + (String) yesterdayTaskItemList.get(position).get( + TaskBean.TIME_ALERT_FLAG)); + + // ȼͼƬ taskStarRank + switch (Integer.parseInt(yesterdayTaskItemList.get(position) + .get(TaskBean.PRIORITY).toString())) { + case TaskConstant.RANK_FOURTH: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star1); + break; + case TaskConstant.RANK_THIRD: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star2); + break; + case TaskConstant.RANK_SECOND: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star3); + break; + case TaskConstant.RANK_FIRST: + listItemView.taskStarRank + .setBackgroundResource(R.drawable.star4); + break; + } + + if (TaskConstant.TASK_NOT_COMPLETE == Integer + .parseInt(yesterdayTaskItemList.get(position) + .get(TaskBean.IF_COMPLETE).toString())) { + listItemView.taskTimeAndPositionInfo.setTextColor(0xff000000); + listItemView.taskInfo.setTextColor(0xff000000); + } else { + listItemView.taskTimeAndPositionInfo.setTextColor(0xff808080); + listItemView.taskInfo.setTextColor(0xff808080); + } + + // + // listItemView.taskInfo.setTypeface(typeFace); + + listItemView.taskEditBtn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + + // ɾ + // ȡid + taskId = Integer.parseInt(yesterdayTaskItemList + .get(position).get(TaskBean.ID).toString()); + curPosition = position; + // + showCustomMessage("ȷɾ", "ȷɾ˻"); + } + }); + return convertView; + } + + private void showCustomMessage(String pTitle, final String pMsg) { + final Dialog lDialog = new Dialog(TaskActivity.this, + android.R.style.Theme_Translucent_NoTitleBar); + lDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + lDialog.setContentView(R.layout.iphone_alert_dialog_layout); + ((TextView) lDialog.findViewById(R.id.dialog_title)) + .setText(pTitle); + ((TextView) lDialog.findViewById(R.id.dialog_message)) + .setText(pMsg); + ((Button) lDialog.findViewById(R.id.cancel)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // CANCEL + lDialog.dismiss(); + } + }); + ((Button) lDialog.findViewById(R.id.ok)) + .setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // write your code to do things after users clicks + // OK + lDialog.dismiss(); + // ɾ + DatabaseUtil.delete(TaskActivity.this, + TaskBean.TABLE_NAME, TaskBean.ID + "=" + + taskId, null); + + Toast.makeText(TaskActivity.this, "ɾɹ", + Toast.LENGTH_SHORT).show(); + // ˢб + yesterdayTaskItemList.remove(curPosition); + yesterdayAdapter.notifyDataSetChanged(); + } + }); + lDialog.show(); + + } + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/TaskAlertActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/TaskAlertActivity.java new file mode 100644 index 0000000..939e5d6 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/TaskAlertActivity.java @@ -0,0 +1,119 @@ +package com.timebetter.activity; + +import android.app.Activity; +import android.app.KeyguardManager; +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.TextView; + +import com.timebetter.activity.R; +import com.timebetter.alarm.Alarm; +import com.timebetter.bean.TaskBean; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; +import com.timebetter.service.AlertService; + +public class TaskAlertActivity extends Activity { + + private TextView alertViewContent; + private Cursor databaseCur; + private Button confirmBtn; + private int taskId; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + + Intent i=new Intent(this,AlertService.class); + startService(i); + + KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); + km.newKeyguardLock("Tag For Debug").disableKeyguard(); + requestWindowFeature(Window.FEATURE_NO_TITLE); + setContentView(LayoutInflater.from(this).inflate( + R.layout.task_alert_layout, null)); + + alertViewContent = (TextView) findViewById(R.id.task_alert_dialog_content); + confirmBtn = (Button) findViewById(R.id.task_alert_dialog_confirm_btn); + confirmBtn.requestFocus(); + confirmBtn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + Intent intent = new Intent(Alarm.ALARM_CANCEL_ACTION); + intent.putExtra(Alarm.ID, taskId); + Alarm.disableAlarm(TaskAlertActivity.this, intent); + Intent i= new Intent(TaskAlertActivity.this,AlertService.class); + stopService(i); + finish(); + } + }); + + taskId = getIntent().getIntExtra(TaskBean.ID, 1); + String taskName = ""; + String taskPosition = ""; + String dateTime = ""; + databaseCur = DatabaseUtil.query(TaskAlertActivity.this, + TaskBean.TABLE_NAME, new String[] { TaskBean.POSITION_NAME, + TaskBean.TASK_NAME, TaskBean.DATETIME }, TaskBean.ID + + "=" + taskId, null, null, null, null); + for (databaseCur.moveToFirst(); !databaseCur.isAfterLast(); databaseCur + .moveToNext()) { + taskName = databaseCur.getString(databaseCur + .getColumnIndex(TaskBean.TASK_NAME)); + taskPosition = databaseCur.getString(databaseCur + .getColumnIndex(TaskBean.POSITION_NAME)); + dateTime = databaseCur.getString(databaseCur + .getColumnIndex(TaskBean.DATETIME)); + } + DatabaseUtil.closeDatabase(); + + StringBuffer sb = new StringBuffer(); + sb.append(":" + taskName + "\n"); + sb.append("ʱ:" + DateUtils.getTaskTime(dateTime) + "\n"); + sb.append("ص:" + (taskPosition.equals("") ? "δ֪" : taskPosition)); + alertViewContent.setText(sb.toString()); + + getWindow().addFlags( + WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON + | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + // TODO Auto-generated method stub + if (KeyEvent.KEYCODE_HOME == keyCode + || KeyEvent.KEYCODE_BACK == keyCode) { + return true; + } + return super.onKeyDown(keyCode, event); + } + + @Override + protected void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + } + + @Override + public void onAttachedToWindow() { + // TODO Auto-generated method stub + this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); + super.onAttachedToWindow(); + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/activity/TaskNotifyActivity.java b/代码/TimeBetter-master/src/com/timebetter/activity/TaskNotifyActivity.java new file mode 100644 index 0000000..72887f2 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/activity/TaskNotifyActivity.java @@ -0,0 +1,17 @@ +package com.timebetter.activity; + +import com.timebetter.activity.R; + +import android.app.Activity; +import android.os.Bundle; + +public class TaskNotifyActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.task_notify_layout); + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/adapter/HistoryGoalAdapter.java b/代码/TimeBetter-master/src/com/timebetter/adapter/HistoryGoalAdapter.java new file mode 100644 index 0000000..48b95b4 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/adapter/HistoryGoalAdapter.java @@ -0,0 +1,103 @@ +package com.timebetter.adapter; +import com.timebetter.view.HistoryGoalGalleryFlow; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.LinearGradient; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.graphics.PorterDuffXfermode; +import android.graphics.Bitmap.Config; +import android.graphics.PorterDuff.Mode; +import android.graphics.Shader.TileMode; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; + + +public class HistoryGoalAdapter extends BaseAdapter { + int mGalleryItemBackground; + private Context mContext; + private Integer[] mImageIds; + private ImageView[] mImages; + + public HistoryGoalAdapter(Context c, Integer[] ImageIds) { + mContext = c; + mImageIds = ImageIds; + mImages = new ImageView[mImageIds.length]; + } + + public boolean createReflectedImages() { + final int reflectionGap = 4; + int index = 0; + + for (int imageId : mImageIds) { + Bitmap originalImage = BitmapFactory.decodeResource(mContext + .getResources(), imageId); + int width = originalImage.getWidth(); + int height = originalImage.getHeight(); + + Matrix matrix = new Matrix(); + matrix.preScale(1, -1); + + Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, + height / 2, width, height / 2, matrix, false); + + Bitmap bitmapWithReflection = Bitmap.createBitmap(width/2, + height/2, Config.ARGB_8888); + + Canvas canvas = new Canvas(bitmapWithReflection); + + canvas.drawBitmap(originalImage, 0, 0, null); + + Paint deafaultPaint = new Paint(); + canvas.drawRect(0, height, width, height + reflectionGap, + deafaultPaint); + + canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null); + + Paint paint = new Paint(); + LinearGradient shader = new LinearGradient(0, originalImage + .getHeight(), 0, bitmapWithReflection.getHeight() + + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP); + + paint.setShader(shader); + + paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); + + canvas.drawRect(0, height, width, bitmapWithReflection.getHeight() + + reflectionGap, paint); + + ImageView imageView = new ImageView(mContext); + imageView.setImageBitmap(bitmapWithReflection); + imageView.setLayoutParams(new HistoryGoalGalleryFlow.LayoutParams(180, 240)); +// imageView.setScaleType(ScaleType.MATRIX); + mImages[index++] = imageView; + } + return true; + } + + public int getCount() { + return mImageIds.length; + } + + public Object getItem(int position) { + return position; + } + + public long getItemId(int position) { + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + return mImages[position]; + } + + public float getScale(boolean focused, int offset) { + return Math.max(0, 1.0f / (float) Math.pow(2, Math.abs(offset))); + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/adapter/TomorrowTaskListViewAdapter.java b/代码/TimeBetter-master/src/com/timebetter/adapter/TomorrowTaskListViewAdapter.java new file mode 100644 index 0000000..5e0428c --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/adapter/TomorrowTaskListViewAdapter.java @@ -0,0 +1,146 @@ +package com.timebetter.adapter; + +import java.util.List; +import java.util.Map; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.Button; +import android.widget.ImageView; +import android.widget.Toast; + +import com.timebetter.activity.R; +import com.timebetter.view.AlwaysMarqueeTextView; +import com.timebetter.view.IphoneAlertDialog; + +public class TomorrowTaskListViewAdapter extends BaseAdapter { + + private Context context; + private List> taskListItems; //бϢ + private LayoutInflater layoutInflater; + + static final class TaskListItemView { + public AlwaysMarqueeTextView taskInfo; // + public ImageView timeAlert; //ʱͼƬ + public ImageView positionAlert; //صͼƬ + public AlwaysMarqueeTextView taskTimeAndPositionInfo; //ʱ͵صϢ + public Button taskEditBtn; //༭ť + public Button taskDeleteBtn; //ɾť + public Button taskPullBtn; //ǰť + public ImageView taskStarRank; //ȼͼƬ + } + + public TomorrowTaskListViewAdapter(Context context, List> taskListItems) { + this.context = context; + this.layoutInflater = LayoutInflater.from(context); + this.taskListItems = taskListItems; + } + + public int getCount() { + // TODO Auto-generated method stub + return taskListItems.size(); + } + + public Object getItem(int arg0) { + // TODO Auto-generated method stub + return taskListItems.get(arg0); + } + + public long getItemId(int position) { + // TODO Auto-generated method stub + return position; + } + + public View getView(int position, View convertView, ViewGroup parent) { + // TODO Auto-generated method stub + TaskListItemView listItemView = null; + if (convertView == null) { + listItemView = new TaskListItemView(); + convertView = layoutInflater.inflate(R.layout.tomorrow_task_item, null); + // ȡؼ +// listItemView.taskInfo = (AlwaysMarqueeTextView) convertView +// .findViewById(R.id.tomorrow_task_info); +// listItemView.timeAlert = (ImageView) convertView +// .findViewById(R.id.tomorrow_time_alert); +// listItemView.positionAlert = (ImageView) convertView +// .findViewById(R.id.tomorrow_position_alert); +// listItemView.taskTimeAndPositionInfo = (AlwaysMarqueeTextView) convertView +// .findViewById(R.id.tomorrow_task_time_position_textview); +// listItemView.taskEditBtn = (Button) convertView +// .findViewById(R.id.tomorrow_task_edit_btn); +// listItemView.taskDeleteBtn = (Button) convertView +// .findViewById(R.id.tomorrow_task_delete_btn); +// listItemView.taskPullBtn = (Button) convertView +// .findViewById(R.id.tomorrow_task_pull_btn); +// listItemView.taskStarRank = (ImageView) convertView +// .findViewById(R.id.tomorrow_star_rank); + // ÿؼconvertView + convertView.setTag(listItemView); + } else { + listItemView = (TaskListItemView) convertView.getTag(); + } + + // + listItemView.taskInfo.setText((String)taskListItems.get(position).get("taskInfo")); + + // ʱ͵صϢ + String timeAndPosition = "ʱ䣺"+(String)taskListItems.get(position).get("time")+" ص㣺"+(String)taskListItems.get(position).get("position"); + listItemView.taskTimeAndPositionInfo.setText(timeAndPosition); + + // ʱͼƬǷʾ timeAlert + + // õصͼƬǷʾ positionAlert + + // ȼͼƬ taskStarRank + switch(Integer.parseInt(taskListItems.get(position).get("taskRank").toString())) { + case 1: + listItemView.taskStarRank.setBackgroundResource(R.drawable.star1); + break; + case 2: + listItemView.taskStarRank.setBackgroundResource(R.drawable.star2); + break; + case 3: + listItemView.taskStarRank.setBackgroundResource(R.drawable.star3); + break; + case 4: + listItemView.taskStarRank.setBackgroundResource(R.drawable.star4); + break; + } + + //༭ť + listItemView.taskEditBtn.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // TODO Auto-generated method stub + Toast.makeText(context, "˱༭ť", Toast.LENGTH_SHORT).show(); + } + }); + + //ɾť + listItemView.taskDeleteBtn.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // TODO Auto-generated method stub +// Toast.makeText(context, "ɾť", Toast.LENGTH_SHORT).show(); + IphoneAlertDialog.showCustomMessage(context, "ȷɾ", "ȷɾ"); + } + }); + + //ǰť + listItemView.taskPullBtn.setOnClickListener(new OnClickListener() { + + public void onClick(View v) { + // TODO Auto-generated method stub + Toast.makeText(context, "ǰť", Toast.LENGTH_SHORT).show(); + + } + }); + + return convertView; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/alarm/Alarm.java b/代码/TimeBetter-master/src/com/timebetter/alarm/Alarm.java new file mode 100644 index 0000000..979da8d --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/alarm/Alarm.java @@ -0,0 +1,146 @@ +package com.timebetter.alarm; + +import java.util.Calendar; + +import android.app.AlarmManager; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.util.Log; + +import com.timebetter.activity.R; +import com.timebetter.activity.TaskActivity; +import com.timebetter.bean.TaskBean; +import com.timebetter.date.DateUtils; +import com.timebetter.receiver.PlanBetterReceiver; + +public class Alarm { + + public static final String HOUR = "alarm_hour"; + public static final String MINUTE = "alarm_minute"; + public static final String ID = "alarm_id"; + public static final String DATETIME = "alarm_datetime"; + public static final String ALARM_REGISTRATION_DETAIL_ACTION = "com.planbetter.activity.ALARM_REGISTRATION_DETAIL"; + public static final String ALARM_REGISTRATION_SIMPLE_ACTION = "com.planbetter.activity.ALARM_REGISTRATION_SIMPLE"; + public static final String ALARM_CANCEL_ACTION = "com.planbetter.activity.ALARM_CANCEL"; + public static final String ALARM_REGISTRATION_BUNDLE_TAG = "alarm_registration"; + public static final String ALARM_CANCEL_BUNDLE_TAG = "alarm_cancel"; + + public static final String ALARM_STATE_ICON_STORAGE = "alarm_state_icon"; + + public static void enableAlarm(Context context, Intent intent, String action) { + AlarmManager alarmManager = (AlarmManager) context + .getSystemService(Context.ALARM_SERVICE); + if (action.equals(ALARM_REGISTRATION_DETAIL_ACTION)) { + Bundle bundle = intent + .getBundleExtra(ALARM_REGISTRATION_BUNDLE_TAG); + Intent alarmIntent = new Intent( + PlanBetterReceiver.ALARM_ALERT_ACTION); + alarmIntent.putExtra(TaskBean.ID, bundle.getInt(Alarm.ID)); + Calendar alarmCalendar = Calendar.getInstance(); + alarmCalendar.setTimeInMillis(System.currentTimeMillis()); + alarmCalendar.set(Calendar.HOUR_OF_DAY, bundle.getInt(Alarm.HOUR)); + alarmCalendar.set(Calendar.MINUTE, bundle.getInt(Alarm.MINUTE)); + alarmCalendar.set(Calendar.SECOND, 0); + alarmCalendar.set(Calendar.MILLISECOND, 0); + PendingIntent alarmPendingIntent = PendingIntent.getBroadcast( + context, bundle.getInt(Alarm.ID), alarmIntent, 0); + alarmManager.set(AlarmManager.RTC_WAKEUP, + alarmCalendar.getTimeInMillis(), alarmPendingIntent); + } else if (action.equals(ALARM_REGISTRATION_SIMPLE_ACTION)) { + Bundle bundle = intent + .getBundleExtra(ALARM_REGISTRATION_BUNDLE_TAG); + Intent alarmIntent = new Intent( + PlanBetterReceiver.ALARM_ALERT_ACTION); + alarmIntent.putExtra(TaskBean.ID, bundle.getInt(Alarm.ID)); + int[] val = DateUtils.getYearMonthDayHourAndMinuteByDateTime(bundle + .getString(Alarm.DATETIME)); + Calendar alarmCalendar = Calendar.getInstance(); + alarmCalendar.setTimeInMillis(System.currentTimeMillis()); + alarmCalendar.set(Calendar.YEAR, val[0]); + alarmCalendar.set(Calendar.MONTH, val[1] - 1); + alarmCalendar.set(Calendar.DAY_OF_MONTH, val[2]); + alarmCalendar.set(Calendar.HOUR_OF_DAY, val[3]); + alarmCalendar.set(Calendar.MINUTE, val[4]); + alarmCalendar.set(Calendar.SECOND, 0); + alarmCalendar.set(Calendar.MILLISECOND, 0); + PendingIntent alarmPendingIntent = PendingIntent.getBroadcast( + context, bundle.getInt(Alarm.ID), alarmIntent, 0); + alarmManager.set(AlarmManager.RTC_WAKEUP, + alarmCalendar.getTimeInMillis(), alarmPendingIntent); + + } + increaseAlarmIconSize(context); + setStatusBarIcon(context,true); + } + + private static SharedPreferences getSharedPreferences(Context ctx) { + return PreferenceManager.getDefaultSharedPreferences(ctx); + } + + public static void resetAlarmIconSize(Context context) { + Editor editor = getSharedPreferences(context).edit(); + editor.putInt(ALARM_STATE_ICON_STORAGE, 0); + editor.commit(); + } + + private static void increaseAlarmIconSize(Context context) { + int alarmSize = getSharedPreferences(context).getInt(ALARM_STATE_ICON_STORAGE, 0); + alarmSize ++; + Editor editor = getSharedPreferences(context).edit(); + editor.putInt(ALARM_STATE_ICON_STORAGE, alarmSize); + editor.commit(); + } + + private static void decreaseAlarmIconSize(Context context) { + int alarmSize = getSharedPreferences(context).getInt(ALARM_STATE_ICON_STORAGE, 0); + alarmSize --; + Editor editor = getSharedPreferences(context).edit(); + editor.putInt(ALARM_STATE_ICON_STORAGE, alarmSize); + editor.commit(); + } + + private static boolean checkAlarmIconAvailable(Context context) { + return (getSharedPreferences(context).getInt(ALARM_STATE_ICON_STORAGE, 0)>0); + } + + private static void setAlarmIcon(Context context) { + setStatusBarIcon(context, checkAlarmIconAvailable(context)); + } + + public static void setStatusBarIcon(Context context, boolean enabled) { + Notification n = new Notification(); + Intent viewAlarm = new Intent(context, TaskActivity.class); + PendingIntent intent = PendingIntent.getActivity(context,0, viewAlarm, 0); + n.icon=R.drawable.ic_clock_alarm_selected; + n.setLatestEventInfo(context, "",context.getString(R.string.alarm_notify_text),intent); + n.flags |= Notification.FLAG_SHOW_LIGHTS| Notification.FLAG_ONGOING_EVENT; + n.defaults |= Notification.DEFAULT_LIGHTS; + + NotificationManager nm =(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); + if(enabled) + nm.notify(1216, n); + else + nm.cancel(1216); + } + + public static void disableAlarm(Context context, Intent intent) { + AlarmManager alarmManager = (AlarmManager) context + .getSystemService(Context.ALARM_SERVICE); + int taskId = intent.getIntExtra(Alarm.ID, 0); + Log.d("debug","taskId = "+taskId); + PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(context, + taskId, new Intent( + PlanBetterReceiver.ALARM_ALERT_ACTION), 0); + alarmManager.cancel(alarmPendingIntent); + + decreaseAlarmIconSize(context); + setAlarmIcon(context); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/bean/GoalBean.java b/代码/TimeBetter-master/src/com/timebetter/bean/GoalBean.java new file mode 100644 index 0000000..0c7d09d --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/bean/GoalBean.java @@ -0,0 +1,59 @@ +package com.timebetter.bean; + +public class GoalBean { + + public static String TABLE_NAME = "goal"; + public static String ID = "goal_id"; + public static String DATE = "goal_date"; + public static String GOAL_CONTENT = "goal_content"; + public static String GOAL_FLAG = "goal_flag"; + + private int goalId; + private String goalDate; + private String goalCotent; + private int goalFlag; + + public int getGoalId() { + return goalId; + } + + public void setGoalId(int goalId) { + this.goalId = goalId; + } + + public String getGoalDate() { + return goalDate; + } + + public void setGoalDate(String goalDate) { + this.goalDate = goalDate; + } + + public String getGoalCotent() { + return goalCotent; + } + + public void setGoalCotent(String goalCotent) { + this.goalCotent = goalCotent; + } + + public int getGoalFlag() { + return goalFlag; + } + + public void setGoalFlag(int goalFlag) { + this.goalFlag = goalFlag; + } + + public GoalBean(int goalId, String goalDate, String goalCotent, int goalFlag) { + this.goalId = goalId; + this.goalDate = goalDate; + this.goalCotent = goalCotent; + this.goalFlag = goalFlag; + } + + public GoalBean() { + + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/bean/HeartMessage.java b/代码/TimeBetter-master/src/com/timebetter/bean/HeartMessage.java new file mode 100644 index 0000000..88357bd --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/bean/HeartMessage.java @@ -0,0 +1,78 @@ +package com.timebetter.bean; + +import android.database.Cursor; + +import com.timebetter.date.DateUtils; + +public class HeartMessage { + + public static String TABLE_NAME = "heart"; + public static String ID = "heart_id"; + public static String DATE = "heart_date"; + public static String HEART_CONTENT = "heart_content"; + + public static final int MESSAGE_FROM = 0; + public static final int MESSAGE_TO = 1; + + private int heartId; + private String heartDate; + private int direction; + + public HeartMessage() { + + } + + public static HeartMessage generateHeartMessage(Cursor cursor) { + HeartMessage hm = new HeartMessage(); + hm.setDirection(MESSAGE_FROM); + hm.setHeartContent(cursor.getString(cursor.getColumnIndex(HEART_CONTENT))); + hm.setHeartDate(cursor.getString(cursor.getColumnIndex(DATE))); + hm.setHeartId(cursor.getInt(cursor.getColumnIndex(ID))); + return hm; + } + + public HeartMessage(int heartId, String heartDate, String heartContent, int direction) { + this.heartId = heartId; + this.heartDate = heartDate; + this.heartContent = heartContent; + this.direction = direction; + } + + public int getDirection() { + return direction; + } + + public void setDirection(int direction) { + this.direction = direction; + } + + private String heartContent; + + public int getHeartId() { + return heartId; + } + + public void setHeartId(int heartId) { + this.heartId = heartId; + } + + public String getHeartDate() { + return heartDate; + } + + public void setHeartDate(String heartDate) { + this.heartDate = heartDate; + } + + public String getHeartContent() { + return heartContent; + } + + public void setHeartContent(String heartContent) { + this.heartContent = heartContent; + } + + public String getContent() { + return DateUtils.getHeartMessageTimeByDateTime(heartDate)+"\n"+heartContent; + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/bean/SummaryBean.java b/代码/TimeBetter-master/src/com/timebetter/bean/SummaryBean.java new file mode 100644 index 0000000..ae73ca2 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/bean/SummaryBean.java @@ -0,0 +1,60 @@ +package com.timebetter.bean; + +public class SummaryBean { + + public static String TABLE_NAME = "summary"; + public static String ID = "summray_id"; + public static String SCORE_RANK = "score_rank"; + public static String MOOD = "mood"; + public static String DATE = "summary_date"; + + private int summaryId; + private int scoreRank; + private String mood; + private String summaryDate; + + public SummaryBean() { + + } + + public SummaryBean(int summaryId, int scoreRank, String mood, + String summaryDate) { + this.summaryId = summaryId; + this.scoreRank = scoreRank; + this.mood = mood; + this.summaryDate = summaryDate; + } + + public int getSummaryId() { + return summaryId; + } + + public void setSummaryId(int summaryId) { + this.summaryId = summaryId; + } + + public int getScoreRank() { + return scoreRank; + } + + public void setScoreRank(int scoreRank) { + this.scoreRank = scoreRank; + } + + public String getMood() { + return mood; + } + + public void setMood(String mood) { + this.mood = mood; + } + + public String getSummaryDate() { + return summaryDate; + } + + public void setSummaryDate(String summaryDate) { + this.summaryDate = summaryDate; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/bean/TaskBean.java b/代码/TimeBetter-master/src/com/timebetter/bean/TaskBean.java new file mode 100644 index 0000000..d9767ff --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/bean/TaskBean.java @@ -0,0 +1,162 @@ +package com.timebetter.bean; + +import java.util.HashMap; +import java.util.Map; + +import android.database.Cursor; + +public class TaskBean { + + public static final String TABLE_NAME = "task"; + public static final String ID = "task_id"; + public static final String DATETIME = "task_datetime"; + public static final String TASK_NAME = "task_name"; + public static final String POSITION_NAME = "position_name"; + public static final String TIME_ALERT_FLAG = "time_alert"; + public static final String PRIORITY = "task_priority"; + public static final String IF_COMPLETE = "if_complete"; + public static final String REPEAT_DAYS = "repeat_days"; + public static final String IF_FUTURE = "if_future"; + public static final String PARENT = "parent"; + + public static final String CURVIEWID = "curviewid"; + + private int taskId; + private String taskDateTime; + private String taskName; + private String positionName; + private int timeAlertFlag; + private int taskPriority; + private int ifComplete; + private int repeatDays; + private int parent; + private int ifFuture; + + public int getIfFuture() { + return ifFuture; + } + + public void setIfFuture(int ifFuture) { + this.ifFuture = ifFuture; + } + + public int getParent() { + return parent; + } + + public void setParent(int parent) { + this.parent = parent; + } + + public TaskBean() { + + } + + public static Map generateTask(Cursor cursor) { + + Map map = new HashMap(); + + int id = cursor.getInt(cursor.getColumnIndex(ID)); + map.put(ID, id+""); + String taskName = cursor.getString(cursor.getColumnIndex(TASK_NAME)); + map.put(TASK_NAME, taskName); + String datetime = cursor.getString(cursor.getColumnIndex(DATETIME)); + map.put(DATETIME, datetime); + String positionName = cursor.getString(cursor.getColumnIndex(POSITION_NAME)); + map.put(POSITION_NAME, positionName); + int priority = cursor.getInt(cursor.getColumnIndex(PRIORITY)); + map.put(PRIORITY, priority+""); + int timeAlertFlag = cursor.getInt(cursor.getColumnIndex(TIME_ALERT_FLAG)); + map.put(TIME_ALERT_FLAG, timeAlertFlag+""); + int ifComplete = cursor.getInt(cursor.getColumnIndex(IF_COMPLETE)); + map.put(IF_COMPLETE, ifComplete+""); + int repeatDays = cursor.getInt(cursor.getColumnIndex(REPEAT_DAYS)); + map.put(REPEAT_DAYS, repeatDays+""); + int parent = cursor.getInt(cursor.getColumnIndex(PARENT)); + map.put(PARENT, parent+""); + int ifFuture = cursor.getInt(cursor.getColumnIndex(IF_FUTURE)); + map.put(IF_FUTURE, ifFuture+""); + + return map; + } + + public TaskBean(int taskId, String taskDateTime, String taskName, + String positionName, int timeAlertFlag, + int taskPriority, int ifComplete, int repeatDays, int parent, int ifFuture) { + this.taskId = taskId; + this.taskDateTime = taskDateTime; + this.taskName = taskName; + this.positionName = positionName; + this.timeAlertFlag = timeAlertFlag; + this.taskPriority = taskPriority; + this.ifComplete = ifComplete; + this.repeatDays = repeatDays; + this.parent = parent; + this.ifFuture = ifFuture; + } + + public int getRepeatDays() { + return repeatDays; + } + + public void setRepeatDays(int repeatDays) { + this.repeatDays = repeatDays; + } + + public int getTaskId() { + return taskId; + } + + public void setTaskId(int taskId) { + this.taskId = taskId; + } + + public String getTaskDateTime() { + return taskDateTime; + } + + public void setTaskDateTime(String taskDateTime) { + this.taskDateTime = taskDateTime; + } + + public String getTaskName() { + return taskName; + } + + public void setTaskName(String taskName) { + this.taskName = taskName; + } + + public String getPositionName() { + return positionName; + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public int getTimeAlertFlag() { + return timeAlertFlag; + } + + public void setTimeAlertFlag(int timeAlertFlag) { + this.timeAlertFlag = timeAlertFlag; + } + + public int getTaskPriority() { + return taskPriority; + } + + public void setTaskPriority(int taskPriority) { + this.taskPriority = taskPriority; + } + + public int getIfComplete() { + return ifComplete; + } + + public void setIfComplete(int ifComplete) { + this.ifComplete = ifComplete; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/DayStyle.java b/代码/TimeBetter-master/src/com/timebetter/constant/DayStyle.java new file mode 100644 index 0000000..81b3f7d --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/DayStyle.java @@ -0,0 +1,118 @@ +package com.timebetter.constant; + +import java.util.*; + +public class DayStyle { + // methods + + private static String[] getWeekDayNames() { + String[] vec = new String[10]; + vec[Calendar.SUNDAY] = ""; + vec[Calendar.MONDAY] = "һ"; + vec[Calendar.TUESDAY] = ""; + vec[Calendar.WEDNESDAY] = ""; + vec[Calendar.THURSDAY] = ""; + vec[Calendar.FRIDAY] = ""; + vec[Calendar.SATURDAY] = ""; + + return vec; + } + + public static String getWeekDayName(int iDay) { + return vecStrWeekDayNames[iDay]; + } + + // fields + private final static String[] vecStrWeekDayNames = getWeekDayNames(); + + // fields + /*public final static int iColorFrameHeader = 0xff666666; + public final static int iColorFrameHeaderHoliday = 0xff707070; + public final static int iColorTextHeader = 0xffcccccc; + public final static int iColorTextHeaderHoliday = 0xffd0d0d0; + + public final static int iColorText = 0xffdddddd; + public final static int iColorBkg = 0xff888888; + public final static int iColorTextHoliday = 0xfff0f0f0; + public final static int iColorBkgHoliday = 0xffaaaaaa; + + public final static int iColorTextToday = 0xff002200; + public final static int iColorBkgToday = 0xff88bb88; + + public final static int iColorTextSelected = 0xff001122; + public final static int iColorBkgSelectedLight = 0xffbbddff; + public final static int iColorBkgSelectedDark = 0xff225599; + + public final static int iColorTextFocused = 0xff221100; + public final static int iColorBkgFocusLight = 0xffffddbb; + public final static int iColorBkgFocusDark = 0xffaa5500;*/ + + public final static int iColorFrameHeader = 0xffff00;//0xff4169E1;/*M-Fcolor 0xff4169E1*/ + public final static int iColorFrameHeaderHoliday = 0xffff00;/*S_S color*/ + public final static int iColorTextHeader = 0xff4169E1; + public final static int iColorTextHeaderHoliday = 0xff4169E1; + + public final static int iColorText = 0xff000000; + public final static int iColorBkg = 0x111111;// 0xff00BFFF;//ɫ + public final static int iColorTextHoliday = 0xff000000; + public final static int iColorBkgHoliday = 0x111111;//0xff9933FF;//ɫ + + public final static int iColorTextToday = 0xffE066FF; + public final static int iColorBkgToday = 0xffE0EEE0;//0xffff0000;//ɫ + + public final static int iColorTextSelected = 0xff4169E1; + public final static int iColorBkgSelectedLight = 0xffFFE4B5;//0xffff0099;//ɫ + public final static int iColorBkgSelectedDark = 0xffFFE4B5;//0xffff33CC;//dzɫ + + public final static int iColorTextFocused = 0xff221100; + public final static int iColorBkgFocusLight = 0x111111;//0xff00ff00;//ɫ + public final static int iColorBkgFocusDark = 0x111111;//0xff66ff66;//dzɫ + + + // methods + public static int getColorFrameHeader(boolean bHoliday) { + if (bHoliday) + return iColorFrameHeaderHoliday; + return iColorFrameHeader; + } + + + public static int getColorTextHeader(boolean bHoliday) { + if (bHoliday) + return iColorTextHeaderHoliday; + return iColorTextHeader; + } + + public static int getColorText(boolean bHoliday, boolean bToday) { + if (bToday) + return iColorTextToday; + if (bHoliday) + return iColorTextHoliday; + return iColorText; + } + + public static int getColorBkg(boolean bHoliday, boolean bToday) { + if (bToday) + return iColorBkgToday; + if (bHoliday) + return iColorBkgHoliday; + return iColorBkg; + } + + public static int getWeekDay(int index, int iFirstDayOfWeek) { + int iWeekDay = -1; + + if (iFirstDayOfWeek == Calendar.MONDAY) { + iWeekDay = index + Calendar.MONDAY; + if (iWeekDay > Calendar.SATURDAY) + iWeekDay = Calendar.SUNDAY; + } + + if (iFirstDayOfWeek == Calendar.SUNDAY) { + iWeekDay = index + Calendar.SUNDAY; + } + + return iWeekDay; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/GMailConsts.java b/代码/TimeBetter-master/src/com/timebetter/constant/GMailConsts.java new file mode 100644 index 0000000..39799cf --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/GMailConsts.java @@ -0,0 +1,8 @@ +package com.timebetter.constant; + +public class GMailConsts { + + public static final String TAG = "GmailSync"; + public static final String IMAP_URI = "imap+ssl+://%s:%s@imap.gmail.com:993"; + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/GoalConstant.java b/代码/TimeBetter-master/src/com/timebetter/constant/GoalConstant.java new file mode 100644 index 0000000..ef4ebbc --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/GoalConstant.java @@ -0,0 +1,10 @@ +package com.timebetter.constant; + +public class GoalConstant { + + public static final int RANK_FIRST = 1; + public static final int RANK_SECOND = 2; + public static final int RANK_THIRD = 3; + + public static final int FORMER_GOAL = 0; +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/MenuItemId.java b/代码/TimeBetter-master/src/com/timebetter/constant/MenuItemId.java new file mode 100644 index 0000000..5953e2d --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/MenuItemId.java @@ -0,0 +1,27 @@ +package com.timebetter.constant; + +/** + * + * @author Kelvin + * + */ +public class MenuItemId { + + /** + * + */ + public static final int MENU_ITEM_TASK = 1; + public static final int MENU_ITEM_TIME = 2; + public static final int MENU_ITEM_LIMIT = 3; + public static final int MENU_ITEM_LONG = 4; +// public static final int MENU_ITEM_MYPOSITION= 5; + public static final int MENU_ITEM_SETUP = 6; + public static final int MENU_ITEM_HELP = 7; + public static final int MENU_ITEM_ABOUT = 8; +// public static final int MENU_ITEM_EXIT = 9; + + public static final int TASK_ITEM_LONG_CLICK_MENU_EDIT = 1; + public static final int TASK_ITEM_LONG_CLICK_MENU_DELETE = 2; + public static final int TASK_ITEM_LONG_CLICK_MENU_PULL = 3; + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/MotionEventConstant.java b/代码/TimeBetter-master/src/com/timebetter/constant/MotionEventConstant.java new file mode 100644 index 0000000..c09c3c1 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/MotionEventConstant.java @@ -0,0 +1,15 @@ +package com.timebetter.constant; + +public class MotionEventConstant { + + private static final int FLING_MIN_DISTANCE = 120; + private static final int FLING_MIN_VELOCITY = 0; + + public static int getFlingMinDistance() { + return FLING_MIN_DISTANCE; + } + + public static int getFlingMinVelocity() { + return FLING_MIN_VELOCITY; + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/constant/TaskConstant.java b/代码/TimeBetter-master/src/com/timebetter/constant/TaskConstant.java new file mode 100644 index 0000000..d212ba6 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/constant/TaskConstant.java @@ -0,0 +1,21 @@ +package com.timebetter.constant; + +public class TaskConstant { + public static final int RANK_FIRST = 4; + public static final int RANK_SECOND = 3; + public static final int RANK_THIRD = 2; + public static final int RANK_FOURTH = 1; + + public static final int TIME_ALERT = 1; + public static final int NO_TIME_ALERT = 0; + + public static final int TASK_NOT_COMPLETE = 0; + public static final int TASK_COMPLETE = 1; + + public static final int INIT_REPEAT_DAYS = 1; + + public static final int NOT_FUTURE = 0; + public static final int IS_FUTURE = 1; + + public static final int IS_PARENT = 0; +} diff --git a/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseHelper.java b/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseHelper.java new file mode 100644 index 0000000..53471e3 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseHelper.java @@ -0,0 +1,93 @@ +package com.timebetter.dao; + +import com.timebetter.bean.GoalBean; +import com.timebetter.bean.HeartMessage; +import com.timebetter.bean.SummaryBean; +import com.timebetter.bean.TaskBean; + +import android.content.Context; +import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabase.CursorFactory; +import android.database.sqlite.SQLiteOpenHelper; + +public class DatabaseHelper extends SQLiteOpenHelper { + + private static int DATABASE_VERSION = 1; //ݿ汾 + + private static String DATABASE_NAME = "planbetter"; //ݿ + + // + private static String CREATE_TASK_TABLE_SQL = "CREATE TABLE IF NOT EXISTS " + TaskBean.TABLE_NAME + "(" + + TaskBean.ID + " INTEGER PRIMARY KEY," + + TaskBean.DATETIME + " TEXT," + + TaskBean.TASK_NAME + " TEXT," + + TaskBean.POSITION_NAME + " TEXT," + + TaskBean.TIME_ALERT_FLAG + " INTEGER," + + TaskBean.PRIORITY + " INTEGER," + + TaskBean.IF_COMPLETE + " INTEGER," + + TaskBean.REPEAT_DAYS + " INTEGER," + + TaskBean.IF_FUTURE+ " INTEGER," + + TaskBean.PARENT +" INTEGER)"; + + //ɾ + private static String DROP_TASK_TABLE_SQL = "DROP TABLE IF EXISTS " + TaskBean.TABLE_NAME; + + //ܽ + private static String CREATE_SUMMARY_TABLE_SQL = "CREATE TABLE IF NOT EXISTS " + SummaryBean.TABLE_NAME + "(" + + SummaryBean.ID + " INTEGER PRIMARY KEY," + + SummaryBean.DATE + " TEXT," + + SummaryBean.SCORE_RANK + " INTEGER," + + SummaryBean.MOOD + " TEXT)"; + + //ɾܽ + private static String DROP_SUMMARY_TABLE_SQL = "DROP TABLE IF EXISTS " + SummaryBean.TABLE_NAME; + + //Ŀ + private static String CREATE_GOAL_TABLE_SQL = "CREATE TABLE IF NOT EXISTS " + GoalBean.TABLE_NAME + "(" + + GoalBean.ID + " INTEGER PRIMARY KEY," + + GoalBean.DATE + " TEXT," + + GoalBean.GOAL_CONTENT + " TEXT," + + GoalBean.GOAL_FLAG + " INTEGER)"; + + //ɾĿ + private static String DROP_GOAL_TABLE_SQL = "DROP TABLE IF EXISTS " + GoalBean.TABLE_NAME; + + // + private static String CREATE_HEART_TABLE_SQL = "CREATE TABLE IF NOT EXISTS " + HeartMessage.TABLE_NAME + "(" + + HeartMessage.ID + " INTEGER PRIMARY KEY," + + HeartMessage.DATE + " TEXT," + + HeartMessage.HEART_CONTENT + " TEXT)"; + + //ɾ + private static String DROP_HEART_TABLE_SQL = "DROP TABLE IF EXISTS " + HeartMessage.TABLE_NAME; + + public DatabaseHelper(Context context, String name, CursorFactory factory, + int version) { + super(context, name, factory, version); + // TODO Auto-generated constructor stub + } + + public DatabaseHelper(Context context) { + this(context, DATABASE_NAME, null, DATABASE_VERSION); + } + + @Override + public void onCreate(SQLiteDatabase db) { + // TODO Auto-generated method stub + db.execSQL(CREATE_TASK_TABLE_SQL); // + db.execSQL(CREATE_GOAL_TABLE_SQL); //Ŀ + db.execSQL(CREATE_HEART_TABLE_SQL); // + db.execSQL(CREATE_SUMMARY_TABLE_SQL); //ܽ + } + + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + // TODO Auto-generated method stub + db.execSQL(DROP_TASK_TABLE_SQL); //ɾ + db.execSQL(DROP_SUMMARY_TABLE_SQL); //ɾܽ + db.execSQL(DROP_GOAL_TABLE_SQL); //ɾĿ + db.execSQL(DROP_HEART_TABLE_SQL); //ɾ + onCreate(db); + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseUtil.java b/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseUtil.java new file mode 100644 index 0000000..4af4345 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/dao/DatabaseUtil.java @@ -0,0 +1,61 @@ +package com.timebetter.dao; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.database.sqlite.SQLiteDatabase; + +public class DatabaseUtil { + + private static SQLiteDatabase db = null; + private static DatabaseHelper helper = null; + + + + //ֶ + public static long insert(Context context, String tableName, String id, ContentValues values) { + helper = new DatabaseHelper(context); + db = helper.getWritableDatabase(); + long rows = db.insert(tableName,id,values); + closeDatabase(); + return rows; + } + + //hֶ + public static int delete(Context context, String tableName, String where, String[] whereArgs) { + helper = new DatabaseHelper(context); + db = helper.getWritableDatabase(); + int rows = db.delete(tableName,where,whereArgs); + closeDatabase(); + return rows; + } + + //ʹSQLɾֶ + public static void delete(Context context, String sql) { + helper = new DatabaseHelper(context); + db = helper.getWritableDatabase(); + db.execSQL(sql); + closeDatabase(); + } + + //޸ֶ + public static int update(Context context, String tableName, ContentValues values, String where, String[] whereArgs) { + helper = new DatabaseHelper(context); + db = helper.getWritableDatabase(); + int rows = db.update(tableName,values,where,whereArgs); + closeDatabase(); + return rows; + } + + //ѯ + public static Cursor query(Context context, String table, + String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) { + helper = new DatabaseHelper(context); + db = helper.getReadableDatabase(); + return db.query(table,columns,selection,selectionArgs,groupBy,having,orderBy); + } + + public static void closeDatabase() { + db.close(); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/date/DateUtils.java b/代码/TimeBetter-master/src/com/timebetter/date/DateUtils.java new file mode 100644 index 0000000..c3cf7b4 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/date/DateUtils.java @@ -0,0 +1,418 @@ +package com.timebetter.date; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +public class DateUtils { + + public static final String TODAY = "today"; + public static final String YESTERDAY = "yesterday"; + public static final String TOMORROW = "tomorrow"; + + public static String MIDDLE = "12:00"; + + public static boolean checkTimePassOrNot(String datetime) throws ParseException { + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date = f.parse(datetime); + Date now = new Date(System.currentTimeMillis()); + if(date.before(now) || sdf.format(date).equals(sdf.format(now))) { + return true; + } else { + return false; + } + } + + public static boolean checkTimeAlertable(int hourOfDay, int minute) { + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + int curHour = calendar.get(Calendar.HOUR_OF_DAY); + int curMinute = calendar.get(Calendar.MINUTE); + if(hourOfDay < curHour || (hourOfDay == curHour && curMinute>= minute)) { + return false; + } + return true; + } + + public static boolean checkTimeAlertable(String datetime) throws ParseException { + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date date = f.parse(datetime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); + int minute = calendar.get(Calendar.MINUTE); + + Calendar now = Calendar.getInstance(); + now.setTimeInMillis(System.currentTimeMillis()); + int curHour = now.get(Calendar.HOUR_OF_DAY); + int curMinute = now.get(Calendar.MINUTE); + if(hourOfDay < curHour || (hourOfDay == curHour && curMinute>= minute)) { + return false; + } + return true; + } + + public static String yesterday() { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, -1); + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH) + 1; + int day = calendar.get(Calendar.DAY_OF_MONTH); + + return formatDate(year, month, day); + } + + public static String calcDatetime(String datetime, int days) throws ParseException { + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Date date = f.parse(datetime); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.DAY_OF_MONTH, days); + date = calendar.getTime(); + return f.format(date); + } + + public static String getWeekDay(String DateStr) { + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); + + Date date = null; + int weekDay = 0; + try { + date = f.parse(DateStr);// String תΪϸʽ + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + weekDay = calendar.get(Calendar.DAY_OF_WEEK); + System.out.println(weekDay); + } catch (Exception e) { + e.printStackTrace(); + } + + // System.out.println(":"+DateStr+" "+weekDay); + String weekday1 = ""; + if (weekDay == 1) + weekday1 = ""; + else if (weekDay == 2) + weekday1 = "һ"; + else if (weekDay == 3) + weekday1 = "ܶ"; + else if (weekDay == 4) + weekday1 = ""; + else if (weekDay == 5) + weekday1 = ""; + else if (weekDay == 6) + weekday1 = ""; + else if (weekDay == 7) + weekday1 = ""; + + return weekday1; + } + + public static String formatTime(int hourOfDay, int minute) { + String time = ""; + if (hourOfDay < 10) { + time += ("0" + hourOfDay); + } else { + time += hourOfDay; + } + if (minute < 10) { + time += (":0" + minute); + } else { + time += (":" + minute); + } + return time; + } + + public static String formatDate(int year, int month, int day) { + String date = year + "-"; + if (month < 10) { + date += ("0" + month); + } else { + date += month; + } + if (day < 10) { + date += ("-0" + day); + } else { + date += ("-" + day); + } + return date; + } + + public static String getHeartMessageTimeByDateTime(String datetime) { + int[] yearMonthDayHourAndMinute = getYearMonthDayHourMinuteAndSecondByDateTime(datetime); + StringBuilder sb = new StringBuilder(); + sb.append(yearMonthDayHourAndMinute[0]+""); + sb.append(yearMonthDayHourAndMinute[1]>=10?yearMonthDayHourAndMinute[1]+"":"0"+yearMonthDayHourAndMinute[1]+""); + sb.append(yearMonthDayHourAndMinute[2]>=10?yearMonthDayHourAndMinute[2]+"":"0"+yearMonthDayHourAndMinute[2]+""); + sb.append(yearMonthDayHourAndMinute[3]>=10?yearMonthDayHourAndMinute[3]+":":"0"+yearMonthDayHourAndMinute[3]+":"); + sb.append(yearMonthDayHourAndMinute[4]>=10?yearMonthDayHourAndMinute[4]+":":"0"+yearMonthDayHourAndMinute[4]+":"); + sb.append(yearMonthDayHourAndMinute[5]>=10?yearMonthDayHourAndMinute[5]:"0"+yearMonthDayHourAndMinute[5]); + return sb.toString(); + } + + public static int[] getYearMonthDayHourMinuteAndSecondByDateTime(String datetime) { + int[] yearMonthDayHourAndMinute = new int[6]; + String[] spliteOnce = datetime.split(" ", 2); + String[] spliteDate = spliteOnce[0].split("\\-"); + String[] spliteTime = spliteOnce[1].split("\\:"); + yearMonthDayHourAndMinute[0] = Integer.parseInt(spliteDate[0]); + yearMonthDayHourAndMinute[1] = Integer.parseInt(spliteDate[1]); + yearMonthDayHourAndMinute[2] = Integer.parseInt(spliteDate[2]); + yearMonthDayHourAndMinute[3] = Integer.parseInt(spliteTime[0]); + yearMonthDayHourAndMinute[4] = Integer.parseInt(spliteTime[1]); + yearMonthDayHourAndMinute[5] = Integer.parseInt(spliteTime[2]); + return yearMonthDayHourAndMinute; + } + + public static int[] getYearMonthDayHourAndMinuteByDateTime(String datetime) { + int[] yearMonthDayHourAndMinute = new int[5]; + String[] spliteOnce = datetime.split(" ", 2); + String[] spliteDate = spliteOnce[0].split("\\-"); + String[] spliteTime = spliteOnce[1].split("\\:"); + yearMonthDayHourAndMinute[0] = Integer.parseInt(spliteDate[0]); + yearMonthDayHourAndMinute[1] = Integer.parseInt(spliteDate[1]); + yearMonthDayHourAndMinute[2] = Integer.parseInt(spliteDate[2]); + yearMonthDayHourAndMinute[3] = Integer.parseInt(spliteTime[0]); + yearMonthDayHourAndMinute[4] = Integer.parseInt(spliteTime[1]); + return yearMonthDayHourAndMinute; + } + + public static int[] getYearMonthAndDayByDateTime(String datetime) { + String[] split = datetime.split(" ", 2)[0].split("\\-"); + int[] yearMonthAndDay = new int[3]; + yearMonthAndDay[0] = Integer.parseInt(split[0]); + yearMonthAndDay[1] = Integer.parseInt(split[1]); + yearMonthAndDay[2] = Integer.parseInt(split[2]); + return yearMonthAndDay; + } + + public static int[] getHourAndMinuteByDateTime(String datetime) { + String[] split = datetime.split(" ", 2)[1].split("\\:"); + int[] hourAndMinute = new int[2]; + hourAndMinute[0] = Integer.parseInt(split[0]); + hourAndMinute[1] = Integer.parseInt(split[1]); + return hourAndMinute; + } + + public static int[] getNowHourAndMinute() { + int[] nowHourAndMinute = new int[2]; + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + nowHourAndMinute[0] = calendar.get(Calendar.HOUR_OF_DAY); + nowHourAndMinute[1] = calendar.get(Calendar.MINUTE); + return nowHourAndMinute; + } + + public static String now() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Date now = new Date(System.currentTimeMillis()); + return format.format(now); + } + + public static String nowDetail() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date now = new Date(System.currentTimeMillis()); + return format.format(now); + } + + public static String getDateByRepeatDays(int days) { + String now = ""; + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, days - 1); + int year = calendar.get(Calendar.YEAR); + now += (year + ""); + int month = calendar.get(Calendar.MONTH) + 1; + now += (month + ""); + int day = calendar.get(Calendar.DAY_OF_MONTH); + now += (day + ""); + return now; + } + + public static int[] getNowDate(){ + int[] nowYearMonthDay = new int[3]; + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + nowYearMonthDay[0] = calendar.get(Calendar.YEAR); + nowYearMonthDay[1] = calendar.get(Calendar.MONTH)+1; + nowYearMonthDay[2] = calendar.get(Calendar.DAY_OF_MONTH); + return nowYearMonthDay; + } + + public static int[] getTomorrowDate(){ + int[] tomorrowYearMonthDay = new int[3]; + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(System.currentTimeMillis()); + calendar.add(Calendar.DAY_OF_MONTH, 1); + tomorrowYearMonthDay[0] = calendar.get(Calendar.YEAR); + tomorrowYearMonthDay[1] = calendar.get(Calendar.MONTH)+1; + tomorrowYearMonthDay[2] = calendar.get(Calendar.DAY_OF_MONTH); + return tomorrowYearMonthDay; + } + + public static int getDifferDays(int year, int month, int days) + { + + String datetime = formatDate(year, month, days); + + int differ = 0; + try { + differ = DateUtils.getDifferDays(datetime); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return differ; + } + + public static int[] getDayInfoByRepeatDays(int days) { + int[] dayInfo = new int[3]; + + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, days - 1); + int year = calendar.get(Calendar.YEAR); + dayInfo[0] = year; + int month = calendar.get(Calendar.MONTH); + dayInfo[1] = month; + int day = calendar.get(Calendar.DAY_OF_MONTH); + dayInfo[2] = day; + + return dayInfo; + } + + public static String getDayByRepeatDays(int days) { + return "" + days + ""; + } + + public static int getDifferDays(String endDateStr) throws ParseException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date endDate = sdf.parse(endDateStr); + GregorianCalendar start = new GregorianCalendar(); + GregorianCalendar end = new GregorianCalendar(); + start.setTime(new Date()); + end.setTime(endDate); + return getDays(start, end); + } + + private static int getDays(GregorianCalendar g1, GregorianCalendar g2) { + int elapsed = 0; + boolean flag = true; + GregorianCalendar gc1, gc2; + + g1.clear(Calendar.MILLISECOND); + g1.clear(Calendar.SECOND); + g1.clear(Calendar.MINUTE); + g1.clear(Calendar.HOUR_OF_DAY); + g2.clear(Calendar.MILLISECOND); + g2.clear(Calendar.SECOND); + g2.clear(Calendar.MINUTE); + g2.clear(Calendar.HOUR_OF_DAY); + + if (g2.after(g1)) { + gc2 = (GregorianCalendar) g2.clone(); + gc1 = (GregorianCalendar) g1.clone(); + } else { + flag = false; + gc2 = (GregorianCalendar) g1.clone(); + gc1 = (GregorianCalendar) g2.clone(); + } + while (gc1.before(gc2)) { + gc1.add(Calendar.DATE, 1); + elapsed++; + } + return flag ? elapsed : (-elapsed); + } + + public static String getTomorrowWidgetTimeDetail(int days) { + String time = ""; + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DAY_OF_MONTH, days); + int year = calendar.get(Calendar.YEAR); + time += (year + "/"); + int month = calendar.get(Calendar.MONTH) + 1; + time += (month + "/"); + int day = calendar.get(Calendar.DAY_OF_MONTH); + time += (day + ""); + int weekday = calendar.get(Calendar.DAY_OF_WEEK); + switch (weekday) { + case Calendar.MONDAY: + time += ",һ"; + break; + case Calendar.TUESDAY: + time += ",ܶ"; + break; + case Calendar.WEDNESDAY: + time += ","; + break; + case Calendar.THURSDAY: + time += ","; + break; + case Calendar.FRIDAY: + time += ","; + break; + case Calendar.SATURDAY: + time += ","; + break; + case Calendar.SUNDAY: + time += ","; + break; + } + return time; + } + + public static String timeDetail(String time) { + String now = ""; + Calendar calendar = Calendar.getInstance(); + if (time.equals(TOMORROW)) { + calendar.add(Calendar.DAY_OF_MONTH, 1); + } else if (time.equals(YESTERDAY)) { + calendar.add(Calendar.DAY_OF_MONTH, -1); + } + int year = calendar.get(Calendar.YEAR); + now += (year + ""); + int month = calendar.get(Calendar.MONTH) + 1; + now += (month + ""); + int day = calendar.get(Calendar.DAY_OF_MONTH); + now += (day + ""); + int weekday = calendar.get(Calendar.DAY_OF_WEEK); + switch (weekday) { + case Calendar.MONDAY: + now += "һ"; + break; + case Calendar.TUESDAY: + now += "ڶ"; + break; + case Calendar.WEDNESDAY: + now += ""; + break; + case Calendar.THURSDAY: + now += ""; + break; + case Calendar.FRIDAY: + now += ""; + break; + case Calendar.SATURDAY: + now += ""; + break; + case Calendar.SUNDAY: + now += ""; + break; + } + return now; + } + + public static String getTaskTime(String datetime) { + String[] splitStr = datetime.split(" ", 2); + if (splitStr[1].equals(MIDDLE)) { + return "12:00"; + } else { + String[] time = splitStr[1].split(":"); + if (Integer.parseInt(time[0]) >= 12) { + return "" + splitStr[1]; + } else { + return "" + splitStr[1]; + } + } + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/mail/DataForm.java b/代码/TimeBetter-master/src/com/timebetter/mail/DataForm.java new file mode 100644 index 0000000..4ebb81b --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/mail/DataForm.java @@ -0,0 +1,230 @@ +package com.timebetter.mail; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import android.content.Context; +import android.database.Cursor; + +import com.timebetter.bean.GoalBean; +import com.timebetter.bean.HeartMessage; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.GoalConstant; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; + +public class DataForm { + private static List> ItemList; + + private static final int SEND_TODAY_TASK = 1; + private static final int SEND_HISTORY_TASK = 2; + private static final int SEND_FUTURE_TASK = 3; + private static final int SEND_GOAL = 4; + private static final int SEND_HEART_MESSAGE = 5; + + public static String getSubject(int flag) + { + if(flag == SEND_TODAY_TASK) + { + return "͵"; + } + else if(flag == SEND_HISTORY_TASK) + { + return "ʷ"; + } + else if(flag == SEND_FUTURE_TASK) + { + return "͵"; + } + else if(flag == SEND_GOAL) + return "Ŀ"; + else if(flag == SEND_HEART_MESSAGE) + return ""; + else + return "òƳˡ"; + + } + + public static String getContent(Context context, int flag) + { + + if(flag == SEND_TODAY_TASK) + { + initTodayTaskListItem(context); + return getTaskMessage(); + } + else if(flag == SEND_HISTORY_TASK) + { + initHistoryTaskListItem(context); + return getTaskMessage(); + } + else if(flag == SEND_FUTURE_TASK) + { + initFutureTaskListItem(context); + return getTaskMessage(); + } + else if(flag == SEND_GOAL) + return getGoalMessage(context); + else if(flag == SEND_HEART_MESSAGE) + return getHeartMessage(context); + else + return "òƳˡ"; + + } + + private static void initTodayTaskListItem(Context context) { + ItemList = new ArrayList>(); + // ѯݿ,ȡϢ + Cursor todayTaskCur = DatabaseUtil.query(context, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " LIKE ?", + new String[] { DateUtils.now() + "%" }, null, null, TaskBean.ID + + " ASC"); + + // Ϣ + + for (todayTaskCur.moveToFirst(); !todayTaskCur.isAfterLast(); todayTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(todayTaskCur); + ItemList.add(map); + } + DatabaseUtil.closeDatabase(); + } + + private static void initHistoryTaskListItem(Context context) { + ItemList = new ArrayList>(); + // ѯݿ,ȡϢ + Cursor historyTaskCur = DatabaseUtil.query(context, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " NOT LIKE ? AND "+TaskBean.IF_FUTURE+" = ?", + new String[] { DateUtils.now() + "%", TaskConstant.NOT_FUTURE + "" }, null, null, TaskBean.ID + + " ASC"); + + for (historyTaskCur.moveToFirst(); !historyTaskCur.isAfterLast(); historyTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(historyTaskCur); + ItemList.add(map); + } + DatabaseUtil.closeDatabase(); + } + + private static void initFutureTaskListItem(Context context) { + ItemList = new ArrayList>(); + // ѯݿ,ȡϢ + Cursor futureTaskCur = DatabaseUtil.query(context, + TaskBean.TABLE_NAME, null, TaskBean.IF_FUTURE + " = ? AND "+TaskBean.PARENT+" = ?", + new String[] { TaskConstant.IS_FUTURE+"",TaskConstant.IS_PARENT+"" }, null, null, TaskBean.ID + + " ASC"); + for (futureTaskCur.moveToFirst(); !futureTaskCur.isAfterLast(); futureTaskCur + .moveToNext()) { + Map map = TaskBean.generateTask(futureTaskCur); + ItemList.add(map); + } + DatabaseUtil.closeDatabase(); + } + + private static String getTaskMessage() + { + String content = ""; + for(int i=1; i<=ItemList.size(); i++) + { + Map map = ItemList.get(i-1); + String taskname = (String) map.get(TaskBean.TASK_NAME); + String time = (String) map.get(TaskBean.DATETIME); + String position = (String)map.get(TaskBean.POSITION_NAME); + int flag = Integer.parseInt(map.get(TaskBean.IF_COMPLETE).toString()); + + String tmp = null; + if(flag == TaskConstant.TASK_COMPLETE) + tmp = i + "ƣ"+taskname+"\tʱ䣺"+time+"\tλã"+(position.equals("")?"δ֪":position)+"\t\n"; + else if(flag == TaskConstant.TASK_NOT_COMPLETE) + tmp = i + " ƣ"+taskname+"\tʱ䣺"+time+"\tλã"+(position.equals("")?"δ֪":position)+"\tδ\n"; + + content = content + tmp; + } + if(content.equals("")) + content = "û"; + return content; + } + + private static String getHeartMessage(Context context) + { + List messages = new ArrayList(); + Cursor databaseCur = DatabaseUtil.query(context, HeartMessage.TABLE_NAME, + null, null, null, null, null, HeartMessage.ID+" ASC"); + for(databaseCur.moveToFirst(); !databaseCur.isAfterLast();databaseCur.moveToNext()) { + HeartMessage hm = HeartMessage.generateHeartMessage(databaseCur); + messages.add(hm); + } + DatabaseUtil.closeDatabase(); + + String content = ""; + for(int i=1; i<=messages.size(); i++) + { + HeartMessage map = messages.get(i-1); + String time = (String) map.getHeartDate(); + String heartcontent = (String) map.getHeartContent(); + + String tmp = i + " ʱ䣺"+time+ "\tݣ"+heartcontent+"\n"; + content = content + tmp; + } + if(content.equals("")) + content = "û"; + return content; + } + + + private static String getGoalMessage(Context context) + { + ItemList = new ArrayList>(); + String firstGoal = ""; + String secondGoal = ""; + String thirdGoal = ""; + + Cursor goalCur = DatabaseUtil.query(context , GoalBean.TABLE_NAME, new String[]{GoalBean.GOAL_CONTENT,GoalBean.GOAL_FLAG}, + GoalBean.GOAL_FLAG+"!="+GoalConstant.FORMER_GOAL, null, null, null, GoalBean.GOAL_FLAG+" ASC"); + + int x = 0; + for(goalCur.moveToFirst();!goalCur.isAfterLast();goalCur.moveToNext()) { + + switch(goalCur.getInt(goalCur.getColumnIndex(GoalBean.GOAL_FLAG))) { + case GoalConstant.RANK_FIRST: + firstGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + case GoalConstant.RANK_SECOND: + secondGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + case GoalConstant.RANK_THIRD: + thirdGoal = goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT)); + break; + case GoalConstant.FORMER_GOAL: + Map map = new HashMap(); + map.put(GoalBean.GOAL_CONTENT, + goalCur.getString(goalCur.getColumnIndex(GoalBean.GOAL_CONTENT))); + map.put(GoalBean.DATE, goalCur.getString(goalCur.getColumnIndex(GoalBean.DATE))); + map.put(GoalBean.ID, goalCur.getInt(goalCur.getColumnIndex(GoalBean.ID))); + map.put(GoalBean.GOAL_FLAG, + goalCur.getInt(goalCur.getColumnIndex(GoalBean.GOAL_FLAG))); + ItemList.add(x, map); + x++; + } + } + DatabaseUtil.closeDatabase(); + + String content = "һĿ꣺"+(firstGoal.equals("")?"û":firstGoal)+"\nڶĿ꣺" + +(secondGoal.equals("")?"û":secondGoal)+"\nĿ꣺"+(thirdGoal.equals("")?"û":thirdGoal)+"\nʷĿ꣺"; + for(int i=1; i<=ItemList.size(); i++) + { + Map map = ItemList.get(i); + String goalcontent = (String)map.get(GoalBean.GOAL_CONTENT); + String date = (String)map.get(GoalBean.DATE); + + String tmp = i + " ʱ䣺"+date+ "\t"+goalcontent+"\n"; + content = content + tmp; + } + if(ItemList.size() == 0) + content += "û"; + return content; + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/mail/GMailService.java b/代码/TimeBetter-master/src/com/timebetter/mail/GMailService.java new file mode 100644 index 0000000..bd3382c --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/mail/GMailService.java @@ -0,0 +1,330 @@ +package com.timebetter.mail; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.net.wifi.WifiManager; +import android.net.wifi.WifiManager.WifiLock; +import android.os.IBinder; +import android.os.PowerManager; +import android.os.PowerManager.WakeLock; +import android.os.Process; +import android.util.Log; + +import com.android.email.mail.Folder; +import com.android.email.mail.Folder.FolderType; +import com.android.email.mail.Folder.OpenMode; +import com.android.email.mail.Address; +import com.android.email.mail.Message; +import com.android.email.mail.Message.RecipientType; +import com.android.email.mail.MessagingException; +import com.android.email.mail.internet.MimeMessage; +import com.android.email.mail.internet.TextBody; +import com.android.email.mail.store.ImapStore; +import com.timebetter.activity.R; +import com.timebetter.constant.GMailConsts; + +public class GMailService extends Service { + private static boolean sIsRunning = false; + + private static GMailSyncState sState = GMailSyncState.IDLE; + + private static int sItemsToSync; + private static int sCurrentSyncedItems; + private static String sLastError; + private static StateChangeListener sStateChangeListener; + private static WakeLock sWakeLock; + private static WifiLock sWifiLock; + public static boolean sCanceled; + + public enum GMailSyncState { + IDLE, CALC, LOGIN, SYNC, AUTH_FAILED, GENERAL_ERROR, CANCELED; + } + + @Override + public IBinder onBind(Intent arg0) { + return null; + } + + public static void acquireWakeLock(Context ctx) { + if (sWakeLock == null) { + PowerManager pMgr = (PowerManager) ctx + .getSystemService(POWER_SERVICE); + sWakeLock = pMgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, + "SmsSyncService.sync() wakelock."); + + WifiManager wMgr = (WifiManager) ctx.getSystemService(WIFI_SERVICE); + sWifiLock = wMgr.createWifiLock("GMail Backup"); + } + sWakeLock.acquire(); + sWifiLock.acquire(); + } + + public static void releaseWakeLock(Context ctx) { + sWakeLock.release(); + sWifiLock.release(); + } + + @Override + // TODO(chstuder): Clean this flow up a bit and split it into multiple + // methods. Make clean distinction between onStart(...) and backup(...). + public void onStart(final Intent intent, int startId) { + super.onStart(intent, startId); + + synchronized (this.getClass()) { + // Only start a sync if there's no other sync going on at this time. + if (!sIsRunning) { + acquireWakeLock(this); + sIsRunning = true; + // Start sync in new thread. + new Thread() { + public void run() { + + Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); + try { + + backup(); + + } catch (GeneralErrorException e) { + Log.i(GMailConsts.TAG, "", e); + sLastError = e.getLocalizedMessage(); + updateState(GMailSyncState.GENERAL_ERROR); + } catch (AuthenticationErrorException e) { + Log.i(GMailConsts.TAG, "", e); + sLastError = e.getLocalizedMessage(); + updateState(GMailSyncState.AUTH_FAILED); + } finally { + stopSelf(); + + sIsRunning = false; + releaseWakeLock(GMailService.this); + } + } + }.start(); + } else { + Log.d(GMailConsts.TAG, + "SmsSyncService.onStart(): Already running."); + } + } + } + + public void backup() throws GeneralErrorException, + AuthenticationErrorException { + Log.i(GMailConsts.TAG, "Starting backup..."); + sCanceled = false; + + if (!PrefStore.isLoginInformationSet(this)) { + throw new GeneralErrorException(this, + R.string.err_sync_requires_login_info, null); + } + + String username = PrefStore.getLoginUsername(this); + String password = PrefStore.getLoginPassword(this); + int flag = PrefStore.getMaxItemsPerSync(this); + + updateState(GMailSyncState.CALC); + + sItemsToSync = 1; + sCurrentSyncedItems = 0; + + Log.d(GMailConsts.TAG, "Total messages to backup: " + sItemsToSync); + + updateState(GMailSyncState.LOGIN); + + /* ½䣬ļ */ + ImapStore imapStore; + Folder folder; + boolean folderExists; + String label = PrefStore.getImapFolder(this); + try { + imapStore = new ImapStore(String.format(GMailConsts.IMAP_URI, + URLEncoder.encode(username), URLEncoder.encode(password) + .replace("+", "%20"))); + folder = imapStore.getFolder(label); + folderExists = folder.exists(); + if (!folderExists) { + Log.i(GMailConsts.TAG, "Label '" + label + + "' does not exist yet. Creating."); + folder.create(FolderType.HOLDS_MESSAGES); + } + folder.open(OpenMode.READ_WRITE);// ȷҪļ + } catch (MessagingException e) { + throw new AuthenticationErrorException(e); + } + + List messages = new ArrayList(); + + try { + while (true) { + // Cancel sync if requested by the user. + if (sCanceled) { + Log.i(GMailConsts.TAG, "Backup canceled by user."); + updateState(GMailSyncState.CANCELED); + break; + } + updateState(GMailSyncState.SYNC); + + if (sCurrentSyncedItems >= sItemsToSync) { + Log.i(GMailConsts.TAG, "Sync done: " + sCurrentSyncedItems + " items uploaded."); + PrefStore.setLastSync(GMailService.this); + updateState(GMailSyncState.IDLE); + folder.close(true); + break; + } + Message msg = new MimeMessage(); + + String sub = DataForm.getSubject(flag); + String body = DataForm.getContent(this, flag); + msg.setSubject("PlanBetter backup:" + sub); + TextBody tbody = new TextBody(body); + Address mUserAddress = new Address(username); + msg.setFrom(mUserAddress); + msg.setRecipient(RecipientType.TO, mUserAddress); + msg.setSentDate(new Date()); + msg.setBody(tbody); + messages.add(msg); + + folder.appendMessages(messages.toArray(new Message[messages + .size()])); + updateState(GMailSyncState.SYNC); + sCurrentSyncedItems += 1; + + Log.d(GMailConsts.TAG, "Sending " + body.length() + + " messages to server."); + } + } catch (MessagingException e) { + throw new GeneralErrorException(this, + R.string.err_communication_error, e); + } finally { + + } + } + + public static void cancel() { + if (GMailService.sIsRunning) { + GMailService.sCanceled = true; + } + } + + // Statistics accessible from other classes. + + /** + * Returns whether there is currently a backup going on or not. + * + */ + public static boolean isWorking() { + return sIsRunning; + } + + /** + * Returns the current state of the service. Also see + * {@link #setStateChangeListener(StateChangeListener)} to get notified when + * the state changes. + */ + public static GMailSyncState getState() { + return sState; + } + + /** + * Returns a description of the last error. Only valid if + * {@link #getState()} == {@link GMailSyncState#GENERAL_ERROR}. + */ + public static String getErrorDescription() { + return (sState == GMailSyncState.GENERAL_ERROR) ? sLastError : null; + } + + /** + * Returns the number of messages that require sync during the current + * cycle. + */ + public static int getItemsToSyncCount() { + return sItemsToSync; + } + + /** + * Registers a {@link StateChangeListener} that is notified whenever the + * state of the service changes. Note that at most one listener can be + * registered and you need to call {@link #unsetStateChangeListener()} in + * between calls to this method. + * + * @see #getState() + * @see #unsetStateChangeListener() + */ + public static void setStateChangeListener(StateChangeListener listener) { + if (sStateChangeListener != null) { + throw new IllegalStateException( + "setStateChangeListener(...) called when there" + + " was still some other listener " + + "registered. Use unsetStateChangeListener() first."); + } + sStateChangeListener = listener; + } + + /** + * Unregisters the currently registered {@link StateChangeListener}. + * + * @see #setStateChangeListener(StateChangeListener) + */ + public static void unsetStateChangeListener() { + sStateChangeListener = null; + } + + /** + * Internal method that needs to be called whenever the state of the service + * changes. + */ + public static void updateState(GMailSyncState newState) { + GMailSyncState old = sState; + sState = newState; + if (sStateChangeListener != null) { + sStateChangeListener.stateChanged(old, newState); + } + } + + /** + * A state change listener interface that provides a callback that is called + * whenever the state of the {@link SmsSyncService} changes. + * + * @see SmsSyncService#setStateChangeListener(StateChangeListener) + */ + public interface StateChangeListener { + /** + * Called whenever the sync state of the service changed. + */ + public void stateChanged(GMailSyncState oldState, + GMailSyncState newState); + } + + /** + * Exception indicating an error while synchronizing. + */ + public static class GeneralErrorException extends Exception { + private static final long serialVersionUID = 1L; + + public GeneralErrorException(String msg, Throwable t) { + super(msg, t); + } + + public GeneralErrorException(Context ctx, int msgId, Throwable t) { + super(ctx.getString(msgId), t); + } + } + + public static class AuthenticationErrorException extends Exception { + private static final long serialVersionUID = 1L; + + public AuthenticationErrorException(Throwable t) { + super(t.getLocalizedMessage(), t); + } + } + + public static int getCurrentSyncedItems() { + // TODO Auto-generated method stub + return sCurrentSyncedItems; + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/mail/PrefStore.java b/代码/TimeBetter-master/src/com/timebetter/mail/PrefStore.java new file mode 100644 index 0000000..2703d76 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/mail/PrefStore.java @@ -0,0 +1,161 @@ +/* Copyright (c) 2009 Christoph Studer + * + * 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.timebetter.mail; + +import android.content.Context; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.preference.PreferenceManager; + +public class PrefStore { + public static final String PREF_LOGIN_USER = "login_user"; + public static final String PREF_LOGIN_PASSWORD = "login_password"; + + static final String PREF_REFERENECE_UID = "reference_uid"; + public static final String PREF_IMAP_FOLDER = "imap_folder"; + + static final String PREF_INCOMING_TIMEOUT_SECONDS = "incoming_timeout_seconds"; + static final String PREF_REGULAR_TIMEOUT_SECONDS = "regular_timeout_seconds"; + + static final String PREF_LAST_SYNC = "last_sync"; + + public static final String PREF_MAX_ITEMS_PER_SYNC = "max_items_per_sync"; + static final String PREF_MARK_AS_READ = "mark_as_read"; + + static final String DEFAULT_IMAP_FOLDER = "PlanBetter"; + + + /** Default value for {@link PrefStore#PREF_INCOMING_TIMEOUT_SECONDS}. */ + static final int DEFAULT_INCOMING_TIMEOUT_SECONDS = 20; + + /** Default value for {@link PrefStore#PREF_REGULAR_TIMEOUT_SECONDS}. */ + static final int DEFAULT_REGULAR_TIMEOUT_SECONDS = 30 * 60; // 30 minutes + + /** Default value for {@link #PREF_LAST_SYNC}. */ + public static final long DEFAULT_LAST_SYNC = -1; + + /** Default value for {@link #PREF_MAX_ITEMS_PER_SYNC}. */ + static final String DEFAULT_MAX_ITEMS_PER_SYNC = "100"; + + /** Default value for {@link #PREF_MARK_AS_READ}. */ + static final boolean DEFAULT_MARK_AS_READ = false; + + public static SharedPreferences getSharedPreferences(Context ctx) { + return PreferenceManager.getDefaultSharedPreferences(ctx); + } + + + public static String getLoginUsername(Context ctx) { + return getSharedPreferences(ctx).getString(PREF_LOGIN_USER, null); + } + + public static String getLoginPassword(Context ctx) { + return getSharedPreferences(ctx).getString(PREF_LOGIN_PASSWORD, null); + } + + public static boolean isLoginUsernameSet(Context ctx) { + return getLoginUsername(ctx) != null; + } + + public static boolean isLoginInformationSet(Context ctx) { + return isLoginUsernameSet(ctx) && getLoginPassword(ctx) != null; + } + + public static String getReferenceUid(Context ctx) { + return getSharedPreferences(ctx).getString(PREF_REFERENECE_UID, null); + } + + public static void setReferenceUid(Context ctx, String referenceUid) { + Editor editor = getSharedPreferences(ctx).edit(); + editor.putString(PREF_REFERENECE_UID, referenceUid); + editor.commit(); + } + + public static String getImapFolder(Context ctx) { + return getSharedPreferences(ctx).getString(PREF_IMAP_FOLDER, DEFAULT_IMAP_FOLDER); + } + + public static boolean isImapFolderSet(Context ctx) { + return getSharedPreferences(ctx).contains(PREF_IMAP_FOLDER); + } + + public static int getMaxItemsPerSync(Context ctx) { + String str = getSharedPreferences(ctx).getString(PREF_MAX_ITEMS_PER_SYNC, + DEFAULT_MAX_ITEMS_PER_SYNC); + return Integer.valueOf(str); + } + + /** + * Returns whether an IMAP folder is valid. This is the case if the name + * only contains unaccented latin letters [a-zA-Z]. + */ + public static boolean isValidImapFolder(String imapFolder) { + for (int i = 0; i < imapFolder.length(); i++) { + char currChar = imapFolder.charAt(i); + if (!((currChar >= 'a' && currChar <= 'z') + || (currChar >= 'A' && currChar <= 'Z'))) { + return false; + } + } + return true; + } + + public static void setImapFolder(Context ctx, String imapFolder) { + Editor editor = getSharedPreferences(ctx).edit(); + editor.putString(PREF_IMAP_FOLDER, imapFolder); + editor.commit(); + } + + + public static int getIncomingTimeoutSecs(Context ctx) { + return getSharedPreferences(ctx).getInt(PREF_INCOMING_TIMEOUT_SECONDS, + DEFAULT_INCOMING_TIMEOUT_SECONDS); + } + + public static int getRegularTimeoutSecs(Context ctx) { + return getSharedPreferences(ctx).getInt(PREF_REGULAR_TIMEOUT_SECONDS, + DEFAULT_REGULAR_TIMEOUT_SECONDS); + } + + public static long getLastSync(Context ctx) { + return getSharedPreferences(ctx).getLong(PREF_LAST_SYNC, DEFAULT_LAST_SYNC); + } + + public static void setLastSync(Context ctx) { + Editor editor = getSharedPreferences(ctx).edit(); + editor.putLong(PREF_LAST_SYNC, System.currentTimeMillis()); + editor.commit(); + } + + public static boolean getMarkAsRead(Context ctx) { + return getSharedPreferences(ctx).getBoolean(PREF_MARK_AS_READ, DEFAULT_MARK_AS_READ); + } + + public static void setMarkAsRead(Context ctx, boolean markAsRead) { + Editor editor = getSharedPreferences(ctx).edit(); + editor.putBoolean(PREF_MARK_AS_READ, markAsRead); + editor.commit(); + } + + + public static void clearSyncData(Context ctx) { + Editor editor = getSharedPreferences(ctx).edit(); + editor.remove(PREF_LOGIN_PASSWORD); + editor.remove(PREF_LAST_SYNC); + editor.commit(); + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/receiver/AlarmReceiver.java b/代码/TimeBetter-master/src/com/timebetter/receiver/AlarmReceiver.java new file mode 100644 index 0000000..d6a6273 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/receiver/AlarmReceiver.java @@ -0,0 +1,27 @@ +package com.timebetter.receiver; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; + +import com.timebetter.alarm.Alarm; + + +public class AlarmReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + // TODO Auto-generated method stub + String action = intent.getAction(); + if(action != null) { + if(action.equals(Alarm.ALARM_REGISTRATION_DETAIL_ACTION)) { + Alarm.enableAlarm(context, intent, action); + } else if(action.equals(Alarm.ALARM_REGISTRATION_SIMPLE_ACTION)) { + Alarm.enableAlarm(context, intent, action); + } else if(action.equals(Alarm.ALARM_CANCEL_ACTION)) { + Alarm.disableAlarm(context, intent); + } + } + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/receiver/PlanBetterReceiver.java b/代码/TimeBetter-master/src/com/timebetter/receiver/PlanBetterReceiver.java new file mode 100644 index 0000000..114a929 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/receiver/PlanBetterReceiver.java @@ -0,0 +1,134 @@ +package com.timebetter.receiver; + +import java.text.ParseException; + +import android.content.BroadcastReceiver; +import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + +import com.timebetter.activity.TaskAlertActivity; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; +import com.timebetter.service.PlanBetterInit; + +public class PlanBetterReceiver extends BroadcastReceiver { + + public static final String ALARM_ALERT_ACTION = "com.planbetter.activity.ALARM_ALERT"; + public static final String INSERT_DATA_ACTION = "com.planbetter.activity.INSERT_DATA"; + public static final String DATE_CHANGED = "android.intent.action.DATE_CHANGED"; + public static final String BOOT_COMPLETE = "android.intent.action.BOOT_COMPLETED"; + public static final String TIME_SET_CHANGED = "android.intent.action.TIME_SET"; + public static final String INSERT_DATA_AFTER_MODIFY = "com.planbetter.activity.INSERT_DATA_AFTER_MODIFY"; + public static final String INSERT_DATA_INTENT_BUNDLE_TAG = "insert_data"; + public static final String INSERT_DATA_AFTER_MODIFY_INTENT_BUNDLE_TAG = "insert_data_after_modify"; + + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action != null) { + if (action.equals(ALARM_ALERT_ACTION)) { + Intent at_intent = new Intent(context, TaskAlertActivity.class); + at_intent.putExtra(TaskBean.ID, + intent.getIntExtra(TaskBean.ID, 1)); + at_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(at_intent); + } else if (action.equals(INSERT_DATA_ACTION)) { + Bundle bundle = intent + .getBundleExtra(INSERT_DATA_INTENT_BUNDLE_TAG); + int repeatDays = bundle.getInt(TaskBean.REPEAT_DAYS); + String taskContentStr = bundle.getString(TaskBean.TASK_NAME); + String taskPositionStr = bundle + .getString(TaskBean.POSITION_NAME); + int timeAlertValue = bundle.getInt(TaskBean.TIME_ALERT_FLAG); + int priority = bundle.getInt(TaskBean.PRIORITY); + String datetime = bundle.getString(TaskBean.DATETIME); + int id = bundle.getInt(TaskBean.PARENT); + // ѭʣڻ + for (int n = 1; n < repeatDays; n++) { + // ʱ + try { + ContentValues values = new ContentValues(); + + values.put(TaskBean.TASK_NAME, taskContentStr); + values.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + values.put(TaskBean.POSITION_NAME, taskPositionStr); + values.put(TaskBean.TIME_ALERT_FLAG, timeAlertValue); + values.put(TaskBean.PRIORITY, priority); + + values.put(TaskBean.IF_FUTURE, TaskConstant.IS_FUTURE); + + values.put(TaskBean.DATETIME, + DateUtils.calcDatetime(datetime, n)); + + values.put(TaskBean.REPEAT_DAYS, repeatDays - n); + + values.put(TaskBean.PARENT, id); + + DatabaseUtil.insert(context, TaskBean.TABLE_NAME, + TaskBean.ID, values); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } else if (action.equals(DATE_CHANGED) + || action.equals(BOOT_COMPLETE) || action.equals(TIME_SET_CHANGED)) { + // ڷ仯 + // ʼ,ˢwidget + Log.d("debug", "ʼ"); + Intent init = new Intent(context, PlanBetterInit.class); + context.startService(init); + } else if (action.equals(INSERT_DATA_AFTER_MODIFY)) { + Bundle bundle = intent + .getBundleExtra(INSERT_DATA_AFTER_MODIFY_INTENT_BUNDLE_TAG); + int repeatDays = bundle.getInt(TaskBean.REPEAT_DAYS); + String taskContentStr = bundle.getString(TaskBean.TASK_NAME); + String taskPositionStr = bundle + .getString(TaskBean.POSITION_NAME); + int timeAlertValue = bundle.getInt(TaskBean.TIME_ALERT_FLAG); + int priority = bundle.getInt(TaskBean.PRIORITY); + String datetime = bundle.getString(TaskBean.DATETIME); + int parent = bundle.getInt(TaskBean.PARENT); + int curViewId = bundle.getInt(TaskBean.CURVIEWID); + // » + for (int n = 1; n < repeatDays; n++) { + // ʱ + try { + + ContentValues tmpValues = new ContentValues(); + + tmpValues.put(TaskBean.TASK_NAME, taskContentStr); + tmpValues.put(TaskBean.IF_COMPLETE, + TaskConstant.TASK_NOT_COMPLETE); + tmpValues.put(TaskBean.POSITION_NAME, taskPositionStr); + tmpValues.put(TaskBean.TIME_ALERT_FLAG, timeAlertValue); + tmpValues.put(TaskBean.PRIORITY, priority); + tmpValues.put(TaskBean.IF_FUTURE, TaskConstant.IS_FUTURE); + + tmpValues.put(TaskBean.DATETIME, + DateUtils.calcDatetime(datetime, n)); + tmpValues.put(TaskBean.REPEAT_DAYS, repeatDays - n); + if (parent == TaskConstant.IS_PARENT) { + tmpValues.put(TaskBean.PARENT, curViewId); + } else { + tmpValues.put(TaskBean.PARENT, parent); + } + + DatabaseUtil.insert(context, + TaskBean.TABLE_NAME, TaskBean.ID, tmpValues); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/service/AlertService.java b/代码/TimeBetter-master/src/com/timebetter/service/AlertService.java new file mode 100644 index 0000000..336f0ff --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/service/AlertService.java @@ -0,0 +1,115 @@ +package com.timebetter.service; + +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.os.Binder; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; +import android.os.Vibrator; +import android.telephony.PhoneStateListener; +import android.telephony.TelephonyManager; + + +public class AlertService extends Service { + + private Vibrator mVibrator; + private TelephonyManager mTelephonyManager; + private int mInitialCallState; + private static final long[] sVibratePattern = new long[] { 500, 500 }; + private static final int ALARM_TIMEOUT_SECONDS = 10 * 60; + private static final int KILLER = 1000; + private boolean mPlaying = false; + + private LocalBinder myBinder = new LocalBinder(); + + public class LocalBinder extends Binder { + public AlertService getService() { + return AlertService.this; + } + } + + @Override + public IBinder onBind(Intent arg0) { + // TODO Auto-generated method stub + return myBinder; + } + + @Override + public void onCreate() { + // TODO Auto-generated method stub + super.onCreate(); + mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + mTelephonyManager.listen(mPhoneStateListener, + PhoneStateListener.LISTEN_CALL_STATE); +// AlarmAlertWakeLock.acquireCpuWakeLock(this); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + // TODO Auto-generated method stub + if(intent == null) { + stopSelf(); + return START_NOT_STICKY; + } + playAlarm(); + mInitialCallState = mTelephonyManager.getCallState(); + return START_STICKY; + } + + private void playAlarm() { + mPlaying = true; + mVibrator.vibrate(sVibratePattern, 0); + enableKiller(); + } + + private void enableKiller() { + mHandler.sendMessageDelayed(mHandler.obtainMessage(KILLER), + 1000 * ALARM_TIMEOUT_SECONDS); + } + + private Handler mHandler = new Handler() { + + @Override + public void handleMessage(Message msg) { + // TODO Auto-generated method stub + switch(msg.what) { + case KILLER: + stopSelf(); + break; + } + } + + }; + + private PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + @Override + public void onCallStateChanged(int state, String ignored) { + if (state != TelephonyManager.CALL_STATE_IDLE + && state != mInitialCallState) { + stopSelf(); + } + } + }; + + @Override + public void onDestroy() { + stop(); + mTelephonyManager.listen(mPhoneStateListener, 0); +// AlarmAlertWakeLock.releaseCpuLock(); + } + + private void stop() { + if(mPlaying) { + mPlaying = false; + mVibrator.cancel(); + } + disableKiller(); + } + + private void disableKiller() { + mHandler.removeMessages(KILLER); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/service/PlanBetterInit.java b/代码/TimeBetter-master/src/com/timebetter/service/PlanBetterInit.java new file mode 100644 index 0000000..7972751 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/service/PlanBetterInit.java @@ -0,0 +1,168 @@ +package com.timebetter.service; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Iterator; +import java.util.List; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.database.Cursor; +import android.os.Binder; +import android.os.Bundle; +import android.os.IBinder; +import android.util.Log; + +import com.timebetter.alarm.Alarm; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; +import com.timebetter.receiver.PlanBetterReceiver; +import com.timebetter.widget.TodayTaskWidget; +import com.timebetter.widget.TomorrowTaskWidgetService; + +public class PlanBetterInit extends Service { + + private LocalBinder myBinder = new LocalBinder(); + + public class LocalBinder extends Binder { + public PlanBetterInit getService() { + return PlanBetterInit.this; + } + } + + @Override + public IBinder onBind(Intent intent) { + // TODO Auto-generated method stub + return myBinder; + } + + + @Override + public void onStart(Intent intent, int startId) { + // TODO Auto-generated method stub + super.onStart(intent, startId); + //ˢݿϢ + //ļ¼ѯǷҪ޸is_futureֶ + //ȡҪ޸is_futureֶεid + try { + initTaskInfo(); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + registerAlarm(this); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + sendBroadcastToTodayWidget(); + startServiceToFreshTomorrowWidget(); + //ע + setMyDateChangedAlarm(); + stopSelf(startId); + } + + private void setMyDateChangedAlarm() { + Calendar cal = Calendar.getInstance(); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + cal.add(Calendar.DAY_OF_MONTH, 1); + AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); + Intent intent = new Intent(PlanBetterReceiver.DATE_CHANGED); + PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); + am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender); + } + + private void startServiceToFreshTomorrowWidget() { + Intent intent = new Intent(this, TomorrowTaskWidgetService.class); + startService(intent); + } + + private void sendBroadcastToTodayWidget() { + Intent bcast = new Intent(this, TodayTaskWidget.class); + bcast.setAction(TodayTaskWidget.ACTION_NEXT_TIP); + sendBroadcast(bcast); + } + + private void initTaskInfo() throws ParseException { + List taskId = getNeedModifyTaskId(); + Iterator iterator = taskId.iterator(); + while(iterator.hasNext()) { + int id = iterator.next(); + modifyTaskInfo(id); + } + } + + private void modifyTaskInfo(int taskId) { + ContentValues values = new ContentValues(); + values.put(TaskBean.IF_FUTURE, TaskConstant.NOT_FUTURE); + DatabaseUtil.update(this, TaskBean.TABLE_NAME, values, TaskBean.ID+"="+taskId, null); + } + + private List getNeedModifyTaskId() throws ParseException { + Log.d("debug", "getNeedModifyTaskId()"); + List taskId = new ArrayList(); + Cursor cursor = DatabaseUtil.query(this, TaskBean.TABLE_NAME, new String[]{TaskBean.ID, TaskBean.DATETIME, TaskBean.IF_FUTURE}, + TaskBean.IF_FUTURE+"="+TaskConstant.IS_FUTURE, null, null, null, TaskBean.ID+" ASC"); + for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()) { + String datetime = cursor.getString(cursor.getColumnIndex(TaskBean.DATETIME)); + int ifFuture = cursor.getInt(cursor.getColumnIndex(TaskBean.IF_FUTURE)); + int id = cursor.getInt(cursor.getColumnIndex(TaskBean.ID)); + Log.d("debug","idΪ"+id+" ifFuture="+ifFuture); + //Ƚ + if(DateUtils.checkTimePassOrNot(datetime) && ifFuture == TaskConstant.IS_FUTURE) { + Log.d("debug", "Ҫ޸ĵId"+id); + //Ҫ޸ + taskId.add(id); + } + } + DatabaseUtil.closeDatabase(); + return taskId; + } + + private void registerAlarm(Context context) throws ParseException { + + Alarm.resetAlarmIconSize(context); + + // ѯݿ,ȡϢ + Cursor todayTaskCur = DatabaseUtil.query(context, + TaskBean.TABLE_NAME, new String[]{TaskBean.ID, TaskBean.TIME_ALERT_FLAG, TaskBean.DATETIME}, TaskBean.DATETIME + " LIKE ?", + new String[] { DateUtils.now() + "%" }, null, null, TaskBean.ID + + " ASC"); + + // Ϣ + + for (todayTaskCur.moveToFirst(); !todayTaskCur.isAfterLast(); todayTaskCur + .moveToNext()) { + int taskId = todayTaskCur.getInt(0); + int alarmTag = todayTaskCur.getInt(1); + String datetime = todayTaskCur.getString(2); + if(alarmTag == TaskConstant.TIME_ALERT) { + if(DateUtils.checkTimeAlertable(datetime)) { + registerAlarm(taskId, datetime); + } + } + } + DatabaseUtil.closeDatabase(); + + } + + private void registerAlarm(int id, String datetime) throws ParseException { + Intent intent = new Intent(Alarm.ALARM_REGISTRATION_SIMPLE_ACTION); + Bundle bundle = new Bundle(); + bundle.putInt(Alarm.ID, id); + bundle.putString(Alarm.DATETIME, datetime); + intent.putExtra(Alarm.ALARM_REGISTRATION_BUNDLE_TAG, bundle); + sendBroadcast(intent); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/view/AlwaysMarqueeTextView.java b/代码/TimeBetter-master/src/com/timebetter/view/AlwaysMarqueeTextView.java new file mode 100644 index 0000000..f8c8904 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/view/AlwaysMarqueeTextView.java @@ -0,0 +1,30 @@ +package com.timebetter.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.TextView; + +public class AlwaysMarqueeTextView extends TextView { + + public AlwaysMarqueeTextView(Context context) { + super(context); + } + + public AlwaysMarqueeTextView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public AlwaysMarqueeTextView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public boolean isFocused() { +// Paint paint = new Paint(); +// paint.setTextSize(getTextSize()); +// if(paint.measureText(getText().toString()) > getTextSize()) { +// return true; +// } + return true; + } + +} diff --git a/代码/TimeBetter-master/src/com/timebetter/view/CoverFlow.java b/代码/TimeBetter-master/src/com/timebetter/view/CoverFlow.java new file mode 100644 index 0000000..fd760e8 --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/view/CoverFlow.java @@ -0,0 +1,160 @@ +package com.timebetter.view; + +import android.content.Context; +import android.graphics.Camera; +import android.graphics.Matrix; +import android.util.AttributeSet; +import android.view.View; +import android.view.animation.Transformation; +import android.widget.Gallery; +import android.widget.ImageView; + +public class CoverFlow extends Gallery { + + private Camera mCamera = new Camera(); + private int mMaxRotationAngle = 50; + private int mMaxZoom = -500; + private int mCoveflowCenter; + private boolean mAlphaMode = true; + private boolean mCircleMode = false; + + public CoverFlow(Context context) { + super(context); + this.setStaticTransformationsEnabled(true); + } + + public CoverFlow(Context context, AttributeSet attrs) { + super(context, attrs); + this.setStaticTransformationsEnabled(true); + } + + public CoverFlow(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + this.setStaticTransformationsEnabled(true); + } + + public int getMaxRotationAngle() { + return mMaxRotationAngle; + } + + public void setMaxRotationAngle(int maxRotationAngle) { + mMaxRotationAngle = maxRotationAngle; + } + + public boolean getCircleMode() { + return mCircleMode; + } + + public void setCircleMode(boolean isCircle) { + mCircleMode = isCircle; + } + + public boolean getAlphaMode() { + return mAlphaMode; + } + + public void setAlphaMode(boolean isAlpha) { + mAlphaMode = isAlpha; + } + + public int getMaxZoom() { + return mMaxZoom; + } + + public void setMaxZoom(int maxZoom) { + mMaxZoom = maxZoom; + } + + private int getCenterOfCoverflow() { + return (getWidth() - getPaddingLeft() - getPaddingRight()) / 2 + + getPaddingLeft(); + } + + private static int getCenterOfView(View view) { + return view.getLeft() + view.getWidth() / 2; + } + + @Override + protected boolean getChildStaticTransformation(View child, Transformation t) { + final int childCenter = getCenterOfView(child); + final int childWidth = child.getWidth(); + int rotationAngle = 0; + t.clear(); + t.setTransformationType(Transformation.TYPE_MATRIX); + if (childCenter == mCoveflowCenter) { + transformImageBitmap((ImageView) child, t, 0, 0); + } else { + rotationAngle = (int) (((float) (mCoveflowCenter - childCenter) / childWidth) * mMaxRotationAngle); + if (Math.abs(rotationAngle) > mMaxRotationAngle) { + rotationAngle = (rotationAngle < 0) ? -mMaxRotationAngle + : mMaxRotationAngle; + } + transformImageBitmap( + (ImageView) child, + t, + rotationAngle, + (int) Math.floor((mCoveflowCenter - childCenter) + / (childWidth == 0 ? 1 : childWidth))); + } + return true; + } + + /** + * This is called during layout when the size of this view has changed. If + * you were just added to the view hierarchy, you're called with the old + * values of 0. + * + * @param w + * Current width of this view. + * @param h + * Current height of this view. + * @param oldw + * Old width of this view. + * @param oldh + * Old height of this view. + */ + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + mCoveflowCenter = getCenterOfCoverflow(); + super.onSizeChanged(w, h, oldw, oldh); + } + + /** + * Transform the Image Bitmap by the Angle passed + * + * @param imageView + * ImageView the ImageView whose bitmap we want to rotate + * @param t + * transformation + * @param rotationAngle + * the Angle by which to rotate the Bitmap + */ + private void transformImageBitmap(ImageView child, Transformation t, + int rotationAngle, int d) { + mCamera.save(); + final Matrix imageMatrix = t.getMatrix(); + final int imageHeight = child.getLayoutParams().height; + final int imageWidth = child.getLayoutParams().width; + final int rotation = Math.abs(rotationAngle); + mCamera.translate(0.0f, 0.0f, 100.0f); + // As the angle of the view gets less, zoom in + if (rotation <= mMaxRotationAngle) { + float zoomAmount = (float) (mMaxZoom + (rotation * 1.5)); + mCamera.translate(0.0f, 0.0f, zoomAmount); + if (mCircleMode) { + if (rotation < 40) + mCamera.translate(0.0f, 155, 0.0f); + else + mCamera.translate(0.0f, (255 - rotation * 2.5f), 0.0f); + } + if (mAlphaMode) { + ((ImageView) (child)).setAlpha((int) (255 - rotation * 2.5)); + } + } + mCamera.rotateY(rotationAngle); + mCamera.getMatrix(imageMatrix); + + imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2)); + imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2)); + mCamera.restore(); + } +} diff --git a/代码/TimeBetter-master/src/com/timebetter/view/DateWidgetDayCell.java b/代码/TimeBetter-master/src/com/timebetter/view/DateWidgetDayCell.java new file mode 100644 index 0000000..5677e9c --- /dev/null +++ b/代码/TimeBetter-master/src/com/timebetter/view/DateWidgetDayCell.java @@ -0,0 +1,281 @@ +package com.timebetter.view; + +import java.util.Calendar; + +import android.content.Context; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.LinearGradient; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.RectF; +import android.graphics.Shader; +import android.util.Log; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.widget.LinearLayout.LayoutParams; + +import com.timebetter.activity.R; +import com.timebetter.bean.TaskBean; +import com.timebetter.constant.DayStyle; +import com.timebetter.constant.TaskConstant; +import com.timebetter.dao.DatabaseUtil; +import com.timebetter.date.DateUtils; + + +public class DateWidgetDayCell extends View { + // types + public interface OnItemClick { + public void OnClick(DateWidgetDayCell item); + } + + public static int ANIM_ALPHA_DURATION = 100; + // fields + private int fTextSize = 22;//22޸12 + private boolean dataflag = false; + private int iDateYear = 0; + private int iDateMonth = 0; + private int iDateDay = 0; + + // fields + private OnItemClick itemClick = null; + private Paint pt = new Paint(); + private RectF rect = new RectF(); + private String sDate = ""; + + // fields + private boolean bSelected = false; + private boolean bIsActiveMonth = false; + private boolean bToday = false; + private boolean bHoliday = false; + private boolean bTouchedDown = false; + private Context mcontext; + + // methods + public DateWidgetDayCell(Context context, int iWidth, int iHeight) { + super(context); + setFocusable(true); + setLayoutParams(new LayoutParams(iWidth, iHeight)); + + mcontext = context; + + fTextSize = iWidth/2; + } + + public boolean getSelected() { + return this.bSelected; + } + + public void setSelected(boolean bEnable) { + if (this.bSelected != bEnable) { + this.bSelected = bEnable; + this.invalidate(); + } + } + + public void setData(int iYear, int iMonth, int iDay, boolean bToday, + boolean bHoliday, int iActiveMonth) { + iDateYear = iYear; + iDateMonth = iMonth; + iDateDay = iDay; + + this.sDate = Integer.toString(iDateDay); + this.bIsActiveMonth = (iDateMonth == iActiveMonth); + this.bToday = bToday; + this.bHoliday = bHoliday; + this.dataflag = checkData(iYear, iMonth, iDay); + } + + public void setItemClick(OnItemClick itemClick) { + this.itemClick = itemClick; + } + + private int getTextHeight() { + return (int) (-pt.ascent() + pt.descent()); + } + + public boolean onKeyDown(int keyCode, KeyEvent event) { + boolean bResult = super.onKeyDown(keyCode, event); + if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER) + || (keyCode == KeyEvent.KEYCODE_ENTER)) { + doItemClick(); + } + return bResult; + } + + public boolean onKeyUp(int keyCode, KeyEvent event) { + boolean bResult = super.onKeyUp(keyCode, event); + return bResult; + } + + public void doItemClick() { + if (itemClick != null) + itemClick.OnClick(this); + } + + protected void onFocusChanged(boolean gainFocus, int direction, + Rect previouslyFocusedRect) { + super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); + invalidate(); + } + + public Calendar getDate() { + Calendar calDate = Calendar.getInstance(); + calDate.clear(); + calDate.set(Calendar.YEAR, iDateYear); + calDate.set(Calendar.MONTH, iDateMonth); + calDate.set(Calendar.DAY_OF_MONTH, iDateDay); + return calDate; + } + + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + // init rectangles + rect.set(0, 0, this.getWidth(), this.getHeight()); + rect.inset(1, 1); + + // drawing + final boolean bFocused = IsViewFocused(); + + drawDayView(canvas, bFocused); + drawDayNumber(canvas, bFocused); + } + + private void drawDayView(Canvas canvas, boolean bFocused) { + if(bIsActiveMonth) { + if (bSelected || bFocused) { + LinearGradient lGradBkg = null; + + if (bFocused) { + lGradBkg = new LinearGradient(rect.left, 0, rect.right, 0, + DayStyle.iColorBkgFocusDark, + DayStyle.iColorBkgFocusLight, Shader.TileMode.CLAMP); + } + + if (bSelected) { + lGradBkg = new LinearGradient(rect.left, 0, rect.right, 0, + DayStyle.iColorBkgSelectedDark, + DayStyle.iColorBkgSelectedLight, Shader.TileMode.CLAMP); + } + + if (lGradBkg != null) { + pt.setShader(lGradBkg); + canvas.drawRect(rect, pt); + } + + pt.setShader(null); + + } else { + + pt.setColor(DayStyle.getColorBkg(bHoliday, bToday)); + + /*if (!bIsActiveMonth)//ǵ + pt.setAlpha(iAlphaInactiveMonth);*/ + canvas.drawRect(rect, pt); + } + } else { + pt.setShader(null); + } + } + + public void drawDayNumber(Canvas canvas, boolean bFocused) { + // draw day number + pt.setTypeface(null); + pt.setAntiAlias(true); + pt.setShader(null); + pt.setFakeBoldText(true); + pt.setTextSize(fTextSize); + + pt.setUnderlineText(false); + if (bToday) + pt.setUnderlineText(true); + + int iTextPosX = (int) rect.right - (int) pt.measureText(sDate); + int iTextPosY = (int) rect.bottom + (int) (-pt.ascent()) + - getTextHeight(); + + iTextPosX -= ((int) rect.width() >> 1) + - ((int) pt.measureText(sDate) >> 1); + iTextPosY -= ((int) rect.height() >> 1) - (getTextHeight() >> 1); + + // draw text + + if (bIsActiveMonth) + { + if (bSelected || bFocused) { + if (bSelected) + pt.setColor(DayStyle.iColorTextSelected); + if (bFocused) + pt.setColor(DayStyle.iColorTextFocused); + } else { + pt.setColor(DayStyle.getColorText(bHoliday, bToday)); + } + if(dataflag) + { + Bitmap bitmap = BitmapFactory.decodeResource( + mcontext.getResources(), R.drawable.history_flag); + canvas.drawBitmap(bitmap, 4, 8, pt); + } + canvas.drawText(sDate, iTextPosX, iTextPosY+8, pt); + pt.setUnderlineText(false); + } + } + + + public boolean IsViewFocused() { + return (this.isFocused() || bTouchedDown); + } + + public boolean onTouchEvent(MotionEvent event) { + boolean bHandled = false; + if (event.getAction() == MotionEvent.ACTION_DOWN) { + bHandled = true; + bTouchedDown = true; + invalidate(); + startAlphaAnimIn(DateWidgetDayCell.this); + } + if (event.getAction() == MotionEvent.ACTION_CANCEL) { + bHandled = true; + bTouchedDown = false; + invalidate(); + } + if (event.getAction() == MotionEvent.ACTION_UP) { + bHandled = true; + bTouchedDown = false; + invalidate(); + doItemClick(); + } + return bHandled; + } + + public static void startAlphaAnimIn(View view) { + AlphaAnimation anim = new AlphaAnimation(0.5F, 1); + anim.setDuration(ANIM_ALPHA_DURATION); + anim.startNow(); + view.startAnimation(anim); + } + + private boolean checkData(int year, int month, int day) + { + boolean hasData = false; + String date = DateUtils.formatDate(year, month+1, day); + + Cursor todayTaskCur = DatabaseUtil.query(mcontext, + TaskBean.TABLE_NAME, null, TaskBean.DATETIME + " LIKE ? AND "+TaskBean.IF_FUTURE+" = ?", + new String[] { date + "%", TaskConstant.NOT_FUTURE+"" }, null, null, null); + + // Ϣ + todayTaskCur.moveToFirst(); + hasData = !todayTaskCur.isAfterLast(); + DatabaseUtil.closeDatabase(); + + Log.d("debug", date+hasData); + return hasData; + } + +}