-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from jianzhaojohn/develop
develop to master for beta release
- Loading branch information
Showing
25 changed files
with
482 additions
and
61 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,12 @@ | |
* I want to be stimulated by my Habit Rabbit. | ||
* Habit Rabbit will guilt me into keeping to my habits by accusing me of "murdering" my virtual rabbits if I do not do what I promised I would. | ||
|
||
## Landing Page | ||
https://habit-rabbit.000webhostapp.com/ | ||
|
||
## Beta Release | ||
https://youtu.be/Xox4mv7I9XQ | ||
|
||
|
||
## Project Description: | ||
|
||
|
@@ -20,22 +26,34 @@ Users will be able to | |
* create/login | ||
* input, remove and edit habits | ||
* view habits in an agenda layout | ||
* view Rabbit Hutch, which is filled with rabbits as you complete a habit, but kills the rabbits when you don’t (and notifies the user that they murdered their rabbits) | ||
* view Rabbit Hutch, which is contain a cute rabit as you complete the habit, but kills the rabbit when you don’t (and notify user if theri rabit dies) | ||
* show the habit history in a graph view form (so user can clearly see how they did in past) | ||
|
||
### Add-on features | ||
* sync with other apps to be kept accountable (such as Fitbit, MyFitnessPal, etc) | ||
* push selected habits to google calendar | ||
* add “friends” who will be able to shame them when they falsely enter that they did something that they didn’t | ||
* bet money,using paypal, that they will complete all their habits for a given period of time. If they fail, the money is donated to a charity of their choice. | ||
|
||
### How to use our app | ||
|
||
when you first open up our app, you will see the login page pops up. you have 2 opetions here: first login with your existing account. second, creating an account. To create a account you simplly click on the register button and this will lead you to the registration page. there is 2 limits on creating account: for user name it must contain "@" and for passwords it has to have at least 4 characters. | ||
After you done with register you can back to login page and login there. When you login, you will see our main page which contain only one rabit house. you can go to another page using the "hunberger" button ont he top left and top right. | ||
|
||
In habit page, you can add and create new habit (just click on the button on the buttom right) and in the Agenda page you can see all your habit in a list view. Those data is update whenever you open you app (we update them through our database). | ||
|
||
you can check the habit when you finish them and we will record how you did in a period and display them in a graph view (just click on the habit in habit page for detail). this give user a clearly view how they do in past to build up their habits. | ||
|
||
Lastly, our notification works when you open the app and only when you open the app (we are thinking to make it run in background, but not sure if that is too "expensive" in resource for our app. So still thinking). | ||
|
||
### How to Run | ||
|
||
Test e-mail: [email protected] | ||
Test password: test | ||
|
||
You need these to log in once you have run the app. | ||
|
||
#### If you have an android device with android version 7.0 (API 24) or above: | ||
#### If you have an android device with android with API level 25 or above (to work properly): | ||
|
||
1. Download the apk with your android device using the link provided below. | ||
2. https://drive.google.com/file/d/0B5mPzcwLTPnPQ1VfbldDUHU5eXhTazFzVC1NWUJSQmUtaUpn/view?usp=sharing | ||
|
@@ -64,3 +82,4 @@ https://youtu.be/g607Lzud3Ss | |
|
||
## Alpha Release | ||
https://youtu.be/jdsvigK7bPs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
...rc/main/java/comjianzhaojohnhabit_rabbit/httpsgithub/habit_rabbit/HabitCheckReciever.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package comjianzhaojohnhabit_rabbit.httpsgithub.habit_rabbit; | ||
|
||
import android.app.AlarmManager; | ||
import android.app.Notification; | ||
import android.app.NotificationManager; | ||
import android.app.PendingIntent; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.util.Log; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Hashtable; | ||
|
||
|
||
public class HabitCheckReciever extends BroadcastReceiver { | ||
private static boolean timerOn = false; | ||
private static SharedPreferences sharedPref; | ||
private static SharedPreferences.Editor editor; | ||
private static Context shared_context; | ||
private static PendingIntent pendingIntent; | ||
private static NotificationHelper notificationHelper; | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Log.d("alarm", "reciever"); | ||
checkHabits(); | ||
} | ||
|
||
public static boolean isTimerOn() { return timerOn; } | ||
public void setTimerOn(){timerOn = true; } | ||
|
||
public static void setShared_context(Context context){ | ||
shared_context = context; | ||
sharedPref = shared_context.getSharedPreferences("UserInfo", Context.MODE_PRIVATE); | ||
editor = sharedPref.edit(); | ||
notificationHelper = new NotificationHelper(shared_context); | ||
} | ||
|
||
|
||
public static boolean rabbitIsAlive() { | ||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
int complete = 0; | ||
Calendar today = Calendar.getInstance(); | ||
if (HabitList.HABITS_list != null) { | ||
for (Habit x : HabitList.HABITS_list) { | ||
Hashtable<String, Integer> rc = x.getRecords(); | ||
String period = x.getPeriod(); | ||
Calendar startDate = Calendar.getInstance(); | ||
startDate.clear(); | ||
startDate.setTime(x.getStartDate()); | ||
if (period.equals("week") && today.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { | ||
Calendar yesterday = Calendar.getInstance(); | ||
if (startDate.get(Calendar.YEAR) == yesterday.get(Calendar.YEAR) && | ||
startDate.get(Calendar.WEEK_OF_YEAR) == yesterday.get(Calendar.WEEK_OF_YEAR)) | ||
break; | ||
yesterday.add(Calendar.DATE, -8); | ||
yesterday.set(Calendar.DAY_OF_WEEK, 1); | ||
for (int i = 0; i < 7; i++) { | ||
String dateString = dateFormat.format(yesterday.getTime()); | ||
if (rc.contains(dateString)) { | ||
complete += rc.get(dateString); | ||
} | ||
yesterday.add(Calendar.DATE, 1); | ||
} | ||
} else if (period.equals("month") && today.get(Calendar.DAY_OF_MONTH) == 1) { | ||
Calendar yesterday = Calendar.getInstance(); | ||
if (startDate.get(Calendar.YEAR) == yesterday.get(Calendar.YEAR) && | ||
startDate.get(Calendar.MONTH) == yesterday.get(Calendar.MONTH)) | ||
break; | ||
yesterday.add(Calendar.MONTH, -1); | ||
yesterday.set(Calendar.DAY_OF_MONTH, 1); | ||
Calendar calendar = Calendar.getInstance(); | ||
calendar.clear(); | ||
calendar.setTime(yesterday.getTime()); | ||
for (calendar.setTime(yesterday.getTime()); calendar.get(Calendar.MONTH) == yesterday.get(Calendar.MONTH); calendar.add(Calendar.DATE, 1)) { | ||
String dateString = dateFormat.format(calendar.getTime()); | ||
if (rc.contains(dateString)) { | ||
complete += rc.get(dateString); | ||
} | ||
yesterday.add(Calendar.DATE, 1); | ||
} | ||
} else { | ||
Calendar yesterday = Calendar.getInstance(); | ||
if (startDate.get(Calendar.DATE) == yesterday.get(Calendar.DATE)) | ||
break; | ||
yesterday.add(Calendar.DATE, -1); | ||
String dateString = dateFormat.format(yesterday.getTime()); | ||
if (rc.contains(dateString)) { | ||
complete = rc.get(dateString); | ||
} | ||
} | ||
if (complete < x.getTimesPerPeriod()) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
|
||
public static void checkHabits(){ | ||
editor.putInt("DayOfYear",Calendar.getInstance().get(Calendar.DAY_OF_YEAR)); | ||
editor.apply(); | ||
|
||
boolean rabbitAlive = rabbitIsAlive(); | ||
Log.d("alarm","checking rabbit state"); | ||
String notificationMessage; | ||
if (!rabbitAlive){ | ||
notificationMessage = "MURDERER. Because you failed to complete your habits for today, your rabbit is going to die. His blood is on your hands!"; | ||
} | ||
else { | ||
notificationMessage = "You done good"; | ||
} | ||
notificationHelper.sendNotification(notificationMessage); | ||
|
||
editor.putBoolean("RabbitAlive",rabbitAlive); | ||
editor.apply(); | ||
//TODO send to notification helper | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.