diff --git a/PayBack - CEN3031 Scrum.xlsx b/PayBack - CEN3031 Scrum.xlsx
index 3695ac5..2423bce 100644
Binary files a/PayBack - CEN3031 Scrum.xlsx and b/PayBack - CEN3031 Scrum.xlsx differ
diff --git a/PayBack/AndroidManifest.xml b/PayBack/AndroidManifest.xml
index 71f45cb..95f2e60 100644
--- a/PayBack/AndroidManifest.xml
+++ b/PayBack/AndroidManifest.xml
@@ -7,7 +7,7 @@
-
+
@@ -30,83 +30,109 @@
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait" >
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait" >
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait"
+ android:windowSoftInputMode="adjustPan">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/AppTheme"
+ android:screenOrientation="portrait">
+ android:theme="@style/DefaultAppTheme"
+ android:screenOrientation="portrait">
+ android:label="@string/title_activity_title"
+ android:screenOrientation="portrait">
-
+ android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
+ android:screenOrientation="portrait" >
+
+
+
+
+
+
+
+
+
+
diff --git a/PayBack/libs/achartengine-0.7.0.jar b/PayBack/libs/achartengine-0.7.0.jar
new file mode 100644
index 0000000..f9e3b83
Binary files /dev/null and b/PayBack/libs/achartengine-0.7.0.jar differ
diff --git a/PayBack/project.properties b/PayBack/project.properties
index b9df4ba..85f532c 100644
--- a/PayBack/project.properties
+++ b/PayBack/project.properties
@@ -11,5 +11,5 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-13
+target=android-10
android.library.reference.1=../../Test/gridlayout_v7
diff --git a/PayBack/res/layout/activity_contact.xml b/PayBack/res/layout/activity_contact.xml
index bc9f73d..f0fab84 100644
--- a/PayBack/res/layout/activity_contact.xml
+++ b/PayBack/res/layout/activity_contact.xml
@@ -3,23 +3,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activitybackground"
- android:gravity="right"
+ android:gravity="center|bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
+ android:scrollbars="vertical"
tools:context=".ContactActivity" >
-
-
-
-
+ android:text="@string/transaction2_newContact"
+ android:textSize="32dp" />
-
+
-
-
+ android:smoothScrollbar="true" />
+ android:text="@string/Home"
+ android:textSize="32dp" />
+
diff --git a/PayBack/res/layout/activity_login.xml b/PayBack/res/layout/activity_login.xml
index 7311d45..4fd9191 100644
--- a/PayBack/res/layout/activity_login.xml
+++ b/PayBack/res/layout/activity_login.xml
@@ -1,9 +1,6 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_main.xml b/PayBack/res/layout/activity_main.xml
index 2b77887..f274fd9 100644
--- a/PayBack/res/layout/activity_main.xml
+++ b/PayBack/res/layout/activity_main.xml
@@ -1,7 +1,7 @@
-
-
-
+ android:layout_weight="18" >
+ android:minWidth="143dp"
+ android:onClick="Contact"
+ android:text="@string/title_activity_contact" />
+ android:text="Notifications"
+ android:textSize="12dp" />
-
+
+ android:text="Statistics" />
@@ -100,6 +107,7 @@
android:id="@+id/devB"
android:layout_width="match_parent"
android:layout_height="fill_parent"
+ android:layout_weight="18"
android:height="85dp"
android:minHeight="85dp"
android:onClick="MainLogout"
diff --git a/PayBack/res/layout/activity_noti_footer.xml b/PayBack/res/layout/activity_noti_footer.xml
new file mode 100644
index 0000000..1a60c62
--- /dev/null
+++ b/PayBack/res/layout/activity_noti_footer.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_noti_row_layout.xml b/PayBack/res/layout/activity_noti_row_layout.xml
new file mode 100644
index 0000000..d719ceb
--- /dev/null
+++ b/PayBack/res/layout/activity_noti_row_layout.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_notification.xml b/PayBack/res/layout/activity_notification.xml
index 24a58b2..7fdffc2 100644
--- a/PayBack/res/layout/activity_notification.xml
+++ b/PayBack/res/layout/activity_notification.xml
@@ -1,17 +1,11 @@
-
-
-
-
-
+/>
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_resolve_transaction.xml b/PayBack/res/layout/activity_resolve_transaction.xml
index f0650d9..134bb3b 100644
--- a/PayBack/res/layout/activity_resolve_transaction.xml
+++ b/PayBack/res/layout/activity_resolve_transaction.xml
@@ -11,7 +11,6 @@
+ android:layout_height="wrap_content" />
diff --git a/PayBack/res/layout/activity_resolve_transaction1.xml b/PayBack/res/layout/activity_resolve_transaction1.xml
new file mode 100644
index 0000000..00b11b9
--- /dev/null
+++ b/PayBack/res/layout/activity_resolve_transaction1.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_settings.xml b/PayBack/res/layout/activity_settings.xml
index c710a92..2c9adde 100644
--- a/PayBack/res/layout/activity_settings.xml
+++ b/PayBack/res/layout/activity_settings.xml
@@ -2,6 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@drawable/activitybackground"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
@@ -14,16 +15,37 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
- android:text="@string/Cancel" />
+ android:text="@string/Previous"
+ android:onClick="showMainMenu" />
+ android:layout_alignParentRight="true"
+ android:layout_alignParentTop="true"
+ android:text="@string/change_password"
+ android:onClick="showEditPassword" />
+
+
+
+
diff --git a/PayBack/res/layout/activity_statistic.xml b/PayBack/res/layout/activity_statistic.xml
index 8211d56..02d233f 100644
--- a/PayBack/res/layout/activity_statistic.xml
+++ b/PayBack/res/layout/activity_statistic.xml
@@ -2,16 +2,115 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@drawable/activitybackground"
+ android:gravity="center_vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
- android:background="@drawable/activitybackground"
tools:context=".StatisticActivity" >
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_alignParentBottom="true"
+ android:layout_alignRight="@+id/linearLayout1"
+ android:layout_marginBottom="27dp"
+ android:layout_marginRight="22dp"
+ android:onClick="showMainMenu"
+ android:text="Back" />
-
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_transaction1.xml b/PayBack/res/layout/activity_transaction1.xml
index c832f8d..c69355a 100644
--- a/PayBack/res/layout/activity_transaction1.xml
+++ b/PayBack/res/layout/activity_transaction1.xml
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_alignParentBottom="true"
+ android:gravity="center_horizontal"
+ android:orientation="vertical" >
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_transaction2_expandablecontactlist_main.xml b/PayBack/res/layout/activity_transaction2_expandablecontactlist_main.xml
index 9ab683e..c467e21 100644
--- a/PayBack/res/layout/activity_transaction2_expandablecontactlist_main.xml
+++ b/PayBack/res/layout/activity_transaction2_expandablecontactlist_main.xml
@@ -33,14 +33,6 @@
android:layout_weight="0"
android:orientation="horizontal" >
-
-
-
-
+ -->
diff --git a/PayBack/res/layout/activity_transaction4.xml b/PayBack/res/layout/activity_transaction4.xml
index 143d4d6..85f78c5 100644
--- a/PayBack/res/layout/activity_transaction4.xml
+++ b/PayBack/res/layout/activity_transaction4.xml
@@ -2,8 +2,9 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:background="@drawable/activitybackground"
+ android:gravity="top"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
@@ -15,16 +16,26 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
+ android:gravity="top"
android:orientation="vertical" >
+
+
+
-
+
-
-
+
+
@@ -19,28 +19,26 @@
android:orientation="horizontal"
android:paddingLeft="@dimen/activity_horizontal_margin" >
-
-
+ android:inputType="number"
+ android:singleLine="true"
+ android:imeOptions="actionDone" >
-
+
+
\ No newline at end of file
diff --git a/PayBack/res/layout/activity_transaction5.xml b/PayBack/res/layout/activity_transaction5.xml
index f82639a..561b8ee 100644
--- a/PayBack/res/layout/activity_transaction5.xml
+++ b/PayBack/res/layout/activity_transaction5.xml
@@ -17,23 +17,13 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/White" />
-
-
diff --git a/PayBack/res/layout/custom_title_bar.xml b/PayBack/res/layout/custom_title_bar.xml
index 92a0ccc..876099b 100644
--- a/PayBack/res/layout/custom_title_bar.xml
+++ b/PayBack/res/layout/custom_title_bar.xml
@@ -33,11 +33,19 @@
tools:ignore="InefficientWeight,ContentDescription" />
+
+
diff --git a/PayBack/res/layout/dialog_settings_name.xml b/PayBack/res/layout/dialog_settings_name.xml
new file mode 100644
index 0000000..7b3cb71
--- /dev/null
+++ b/PayBack/res/layout/dialog_settings_name.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PayBack/res/layout/dialog_settings_password.xml b/PayBack/res/layout/dialog_settings_password.xml
new file mode 100644
index 0000000..49dceb3
--- /dev/null
+++ b/PayBack/res/layout/dialog_settings_password.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PayBack/res/layout/textview.xml b/PayBack/res/layout/textview.xml
new file mode 100644
index 0000000..975a7c0
--- /dev/null
+++ b/PayBack/res/layout/textview.xml
@@ -0,0 +1,18 @@
+
+
+
+
diff --git a/PayBack/res/menu/main.xml b/PayBack/res/menu/main.xml
index 5e4b11a..3811431 100644
--- a/PayBack/res/menu/main.xml
+++ b/PayBack/res/menu/main.xml
@@ -3,6 +3,6 @@
+ android:title="@string/Logout"/>
diff --git a/PayBack/res/values/arrays.xml b/PayBack/res/values/arrays.xml
index 375eab5..347aa37 100644
--- a/PayBack/res/values/arrays.xml
+++ b/PayBack/res/values/arrays.xml
@@ -1,9 +1,6 @@
- -
- User Info
-
-
Delete Contact
diff --git a/PayBack/res/values/strings.xml b/PayBack/res/values/strings.xml
index ab8569f..c5c709a 100644
--- a/PayBack/res/values/strings.xml
+++ b/PayBack/res/values/strings.xml
@@ -23,7 +23,7 @@
Lender\'s Share
Split Evenly
Custom Value
- Borrower\'s Share
+ Transaction allotment
Summary
Home
Next
@@ -58,5 +58,10 @@
Save Changes
Delete Contact
PageName
+ Resolve A Transaction
+ Developer Mode
+ Remember Me?
+ Delete
+
diff --git a/PayBack/res/values/strings_activity_settings.xml b/PayBack/res/values/strings_activity_settings.xml
index 0ae05f8..b0fac0f 100644
--- a/PayBack/res/values/strings_activity_settings.xml
+++ b/PayBack/res/values/strings_activity_settings.xml
@@ -1,7 +1,10 @@
+
-
+ Edit Password
+ Edit Email
+ Edit Display Name
General
@@ -51,5 +54,7 @@
Ringtone
Silent
Vibrate
+ First Name:
+ Last Name:
diff --git a/PayBack/src/com/example/payback/AccessNet.java b/PayBack/src/com/example/payback/AccessNet.java
index 1ae005d..fa6ebd0 100644
--- a/PayBack/src/com/example/payback/AccessNet.java
+++ b/PayBack/src/com/example/payback/AccessNet.java
@@ -13,13 +13,237 @@
import java.net.MalformedURLException;
import java.net.URL;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-
class AccessNet{
+ public static boolean AccountLogin(String Email, String Password) throws InterruptedException{
+ String status ="fail";
+ boolean retval = false;
+ Logger CONLOG = Logger.getLogger(AccessNet.class .getName());
+
+ String params = "userEmail="+Email+"&password="+Password;
+ String urlstub = "db_verify_login.php";
+ //if you go around renaming these urlstubs the app will not work and Hohyun will hate you.
+ CONLOG.info("Attempting to call server at: "+urlstub+", "+params);
+ status = simpleServerCall(urlstub, params);
+ //CONLOG.info("Server Returned "+status);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval = true;
+ return retval;
+ }
+
+ public static boolean AccountCreation(String Email, String Password, String FName, String LName) throws InterruptedException{
+ boolean retval = false;
+ String params = "fname="+FName+"&lname="+LName+"&email="+Email+"&password="+Password;
+ String status = "fail";
+ String urlstub = "db_account_create.php";
+ //calling server
+ status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean AddFriend(String femail, String uemail, String password) throws InterruptedException{
+ boolean retval = false;
+ String params = "friendEmail="+femail+"&userEmail="+uemail+"&password="+password;
+ String status = "fail";
+ String urlstub = "db_friendof_create.php";
+ //calling server
+ status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean DeleteFriend(String femail, String uemail, String password) throws InterruptedException, JSONException{
+ boolean retval = false;
+ String params = "userEmail="+uemail+"&password="+password+"&friendEmail="+femail;
+ String urlstub = "db_friendof_deleteOne.php";
+ //calling server
+ String status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean DeleteAccount(String uemail, String password) throws InterruptedException, JSONException{
+ //$attribute decides the function taken. Currently there are three functions:
+ //trans: Deletes tuples that match LenderID and user $email where Borrower = $value
+ //note: Deletes tuples that match ReceiveID and user $email where Send == $value
+ //account: Deletes tuple for account. Account tuple will be gone permanently after action.
+ String value = "null" , attribute = "account";
+ boolean retval = false;
+ String params = "email="+uemail+"&password="+password+"&attribute="+attribute+"&value"+value;
+
+ String urlstub = "DeleteTuple.php";
+ //calling server
+ JSONObject status = jsonServerCall(urlstub, params);
+ if(status.has("1")||status.has("true")||status.has("success"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean DeleteTrans(String femail, String uemail, String password) throws InterruptedException, JSONException{
+ //$attribute decides the function taken. Currently there are three functions:
+ //trans: Deletes tuples that match LenderID and user $email where Borrower = $value
+ //note: Deletes tuples that match ReceiveID and user $email where Send == $value
+ //account: Deletes tuple for account. Account tuple will be gone permanently after action.
+ String attribute = "trans";
+ boolean retval = false;
+ String params = "email="+uemail+"&password="+password+"&attribute="+attribute+"&value"+femail;
+ //String status = "fail";
+ String urlstub = "DeleteTuple.php";
+ //calling server
+ JSONObject status = jsonServerCall(urlstub, params);
+ if(status.has("1")||status.has("true")||status.has("success"))
+ retval=true;
+ return retval;
+ }
- public String simpleServerCall(String urlstub, String params) throws InterruptedException{
+ public static boolean AddTrans(String uemail, String password, int amount, String description, String lemail, String bemail) throws InterruptedException, JSONException{
+ Logger TRANLOG = Logger.getLogger(AccessNet.class .getName());
+ TRANLOG.setLevel(Level.INFO);
+ boolean retval = false;
+ String params = "email="+uemail+"&password="+password+"&amount="+amount+"&description="+description+"&lenderEmail="+lemail+"&borrowerEmail="+bemail;
+ String urlstub = "db_transaction_create.php";
+ String status = "fail";
+ //calling server
+ status = jsonServerCall(urlstub, params).getString("result");
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ TRANLOG.info("AddTrans was " + retval);
+ return retval;
+ }
+
+ public static boolean AddNotif(String uemail, String password, String description, String targetEmail) throws InterruptedException, JSONException{
+ boolean retval = false;
+ String params = "userEmail="+uemail+"&password="+password+"&sendInfo="+description+"&receiveEmail="+targetEmail;
+ String urlstub = "db_notif_create.php";
+ //calling server
+ JSONObject obj = jsonServerCall(urlstub, params);
+ if(obj.get("result").toString().equalsIgnoreCase("1"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean DeleteAllNotif(String uemail, String password) throws InterruptedException, JSONException{
+ boolean retval = false;
+ Logger DELLOG = Logger.getLogger(AccessNet.class .getName());
+ DELLOG.setLevel(Level.INFO);
+ String params = "userEmail="+uemail+"&password="+password;
+ String urlstub = "db_notif_deleteAll.php";
+ //calling server
+
+ DELLOG.info("Starting Delete All Note");
+ String status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ return retval;
+ }
+
+ public static boolean DeleteOneNotif(String uemail, String password, String nID) throws InterruptedException, JSONException{
+ boolean retval = false;
+ Logger DELLOG = Logger.getLogger(AccessNet.class .getName());
+ DELLOG.setLevel(Level.INFO);
+ String params = "userEmail="+uemail+"&password="+password+"¬eID="+nID;
+ String urlstub = "db_notif_deleteOne.php";
+ //calling server
+ DELLOG.info("Starting Delete one Note");
+ String status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true"))
+ retval=true;
+ return retval;
+ }
+
+ public static JSONObject lookupFriends(String uemail, String password) throws InterruptedException, JSONException{
+ String params = "userEmail="+uemail+"&password="+password;
+ String urlstub = "db_friendof_selectAll.php";
+ return jsonServerCall(urlstub, params);
+ }
+
+ public static JSONObject lookupTransLender(String uemail, String password) throws InterruptedException, JSONException{
+ return lookupTrans(uemail,password,"userAsLender");
+ }
+ public static JSONObject lookupTransBorrower(String uemail, String password) throws InterruptedException, JSONException{
+ return lookupTrans(uemail,password,"userAsBorrower");
+ }
+ public static JSONObject lookupTrans(String uemail, String password, String attribute) throws InterruptedException, JSONException{
+ String params = "userEmail="+uemail+"&password="+password+"&lookupWith="+attribute;
+ String urlstub = "db_transaction_lookup.php";
+ return jsonServerCall(urlstub, params);
+ }
+
+ public static JSONObject lookupNotifsDate(String uemail, String password, String date) throws InterruptedException, JSONException{
+ return lookupNotifs(uemail, password, "date", date);
+ }
+ public static JSONObject lookupNotifsEmailSent(String uemail, String password, String semail ) throws InterruptedException, JSONException{
+ return lookupNotifs(uemail, password, "emailsent", semail);
+ }
+ public static JSONObject lookupEmailIn(String uemail, String password) throws InterruptedException, JSONException{
+ return lookupNotifs(uemail, password, "emailin", uemail);
+
+ }
+// public static JSONObject lookupNotifsEmailIn(String uemail, String password) throws InterruptedException, JSONException{
+// return lookupNotifs(uemail, password, "emailin");
+// }
+ public static JSONObject lookupNotifs(String uemail, String password, String attribute, String value) throws InterruptedException, JSONException{
+ String params = "email="+uemail+"&password="+password+"&attribute="+attribute+"&value="+value;
+ String urlstub = "db_notif_lookup.php";
+ return jsonServerCall(urlstub, params);
+ }
+ public static JSONObject lookupAllNotifs(String uemail, String password) throws InterruptedException, JSONException{
+ String params = "userEmail="+uemail+"&password="+password;
+ String urlstub = "db_notif_selectAll.php";
+ return jsonServerCall(urlstub, params);
+ }
+ public static boolean noteFlagger(String uemail, String password, String noteID, String setFlag) throws InterruptedException, JSONException{
+ boolean retval = false;
+ String params = "userEmail="+uemail+"&password="+password+"¬eID="+noteID+"&setFlag="+setFlag;//setFlag must be "read" or "unread"
+ String urlstub = "db_notif_updateFlag.php";
+ JSONObject obj = jsonServerCall(urlstub, params);
+ if(obj.get("result").toString().equalsIgnoreCase("1"))
+ retval=true;
+ return retval;//jsonServerCall(urlstub, params);
+ }
+ public static boolean transFlagger(String uemail, String password, String transID, String setFlag) throws InterruptedException, JSONException{
+ boolean retval = false;
+ String params = "userEmail="+uemail+"&password="+password+"&transID="+transID+"&setFlag="+setFlag;//setFlag must be "read" or "unread"
+ String urlstub = "db_notif_updateFlag.php";
+ JSONObject obj = jsonServerCall(urlstub, params);
+ if(obj.get("result").toString().equalsIgnoreCase("1"))
+ retval=true;
+ return retval;//jsonServerCall(urlstub, params);
+ }
+
+ public static boolean modifyUserEmail(String uemail, String password, String value) throws InterruptedException{
+ return modifyUser(uemail,password,value,"email");
+ }
+ public static boolean modifyUserPassword(String uemail, String password, String value) throws InterruptedException{
+ return modifyUser(uemail,password,value,"password");
+ }
+ public static boolean modifyUserFirstName(String uemail, String password, String value) throws InterruptedException{
+ return modifyUser(uemail,password,value,"fname");
+ }
+ public static boolean modifyUserLastName(String uemail, String password, String value) throws InterruptedException{
+ return modifyUser(uemail,password,value,"lname");
+ }
+ public static boolean modifyUser(String uemail, String password, String value, String attribute) throws InterruptedException{
+ boolean retval = false;
+ String params = "userEmail="+uemail+"&password="+password+"&attribute="+attribute+"&value="+value;
+ String urlstub = "db_account_userModify.php";
+ String status = "fail";
+ //calling server
+ status = simpleServerCall(urlstub, params);
+ if(status.equalsIgnoreCase("success")||status.equalsIgnoreCase("1")||status.equalsIgnoreCase("true")) {
+ retval=true;
+ }
+ return retval;
+ }
+
+ public static String simpleServerCall(String urlstub, String params) throws InterruptedException{
Logger AXNLOG = Logger.getLogger(AccessNet.class .getName());
AXNLOG.setLevel(Level.INFO);
String url = "http://chase.mamatey.com/PayBack/"+urlstub;
@@ -66,10 +290,10 @@ public synchronized void run(){
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
line = reader.readLine();
- if(line.equalsIgnoreCase("1")||line.equalsIgnoreCase("true")||line.equalsIgnoreCase("success")||line.equalsIgnoreCase("Login and query success"))
+ if(line.equalsIgnoreCase("1")||line.equalsIgnoreCase("true")||line.equalsIgnoreCase("success")||line.equalsIgnoreCase("Login and query success")||line.equalsIgnoreCase("{\"result\":1,\"message\":\"Sign-in successful\"}")||line.equalsIgnoreCase("{\"result\":1,\"message\":\"Contact added successfully\"}"))
items[0]="success";
CANLOG.info("Data in: "+line);
-
+
reader.close();
CANLOG.info("Data receive success!");
} catch (IOException e){
@@ -98,7 +322,7 @@ public synchronized void run(){
return items[0];
}
- public JSONObject jsonServerCall(String urlstub, String params) throws InterruptedException, JSONException{
+ public static JSONObject jsonServerCall(String urlstub, String params) throws InterruptedException, JSONException{
Logger AXNLOG = Logger.getLogger(AccessNet.class .getName());
AXNLOG.setLevel(Level.INFO);
String url = "http://chase.mamatey.com/PayBack/"+urlstub;
@@ -107,6 +331,7 @@ public JSONObject jsonServerCall(String urlstub, String params) throws Interrupt
items[0] = "400 Bad Request";
items[1] = params;
final JSONObject[] retval = new JSONObject[1];
+ retval[0] = new JSONObject();
retval[0].put("ServerResponse", 400);
final CountDownLatch latch = new CountDownLatch(1);
@@ -154,6 +379,7 @@ public synchronized void run(){
try {
retval[0] = new JSONObject(line);
items[0] = "success data received";
+ CANLOG.info("Data in: "+line);
} catch (JSONException e) {
CANLOG.warning("JSONException on receive from server: "+connection.getResponseMessage());
e.printStackTrace();
diff --git a/PayBack/src/com/example/payback/BarGraph.java b/PayBack/src/com/example/payback/BarGraph.java
new file mode 100644
index 0000000..1a86bcb
--- /dev/null
+++ b/PayBack/src/com/example/payback/BarGraph.java
@@ -0,0 +1,59 @@
+package com.example.payback;
+
+import org.achartengine.ChartFactory;
+import org.achartengine.chart.BarChart.Type;
+import org.achartengine.model.CategorySeries;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+
+public class BarGraph {
+
+ public Intent getTestIntent(Context context)
+ {
+ // Bar 1
+ int[] y = { 124, 135, 443, 456, 234, 123, 342, 134, 123, 643, 234, 274 };
+ CategorySeries series = new CategorySeries("Demo Bar Graph 1");
+ for (int i = 0; i < y.length; i++) {
+ series.add("Bar " + (i+1), y[i]);
+ }
+
+ // Bar 2
+ int[] y2 = { 224, 235, 243, 256, 234, 223, 242, 234, 223, 243, 234, 274 };
+ CategorySeries series2 = new CategorySeries("Demo Bar Graph 2");
+ for (int i = 0; i < y.length; i++) {
+ series2.add("Bar " + (i+1), y2[i]);
+ }
+
+ XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
+ dataset.addSeries(series.toXYSeries());
+ dataset.addSeries(series2.toXYSeries());
+
+ // This is how the "Graph" itself will look like
+ XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
+ mRenderer.setChartTitle("Demo Graph Title");
+ mRenderer.setXTitle("X VALUES");
+ mRenderer.setYTitle("Y VALUES");
+ mRenderer.setAxesColor(Color.GREEN);
+ mRenderer.setLabelsColor(Color.RED);
+ // Customize bar 1
+ XYSeriesRenderer renderer = new XYSeriesRenderer();
+ renderer.setDisplayChartValues(true);
+ renderer.setChartValuesSpacing((float) 0.5);
+ mRenderer.addSeriesRenderer(renderer);
+ // Customize bar 2
+ XYSeriesRenderer renderer2 = new XYSeriesRenderer();
+ renderer.setColor(Color.CYAN);
+ renderer.setDisplayChartValues(true);
+ renderer.setChartValuesSpacing((float) 0.5);
+ mRenderer.addSeriesRenderer(renderer2);
+
+ Intent intent = ChartFactory.getBarChartIntent(context, dataset,mRenderer, Type.DEFAULT);
+ return intent;
+ }
+
+}
diff --git a/PayBack/src/com/example/payback/ContactActivity.java b/PayBack/src/com/example/payback/ContactActivity.java
index 8f8a69f..3a1bc90 100644
--- a/PayBack/src/com/example/payback/ContactActivity.java
+++ b/PayBack/src/com/example/payback/ContactActivity.java
@@ -1,14 +1,21 @@
package com.example.payback;
import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.os.Bundle;
+import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
-import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -16,76 +23,41 @@
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
-import android.widget.TextView;
import android.widget.Toast;
-public class ContactActivity extends TitleActivity {
-
+public class ContactActivity extends TitleActivity
+{
private ListView contactlistview;
private ArrayList friendList;
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Contact List",R.layout.activity_contact);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
contactlistview = (ListView) findViewById(R.id.listofselected);
friendList = buildFriendList();
- ArrayAdapter adapter = new ArrayAdapter(this,R.layout.activity_contact_iteminlist, friendList);
+ ArrayAdapter adapter = new ArrayAdapter(this,R.layout.textview, friendList);
contactlistview.setAdapter(adapter);
registerForContextMenu(contactlistview);
- /*
- contactlistview.setOnItemLongClickListener(new OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> parentList, View view,
- int position, long rowId) {
- // TODO Auto-generated method stub
- return false;
- }
- });
- */
+
}
private ArrayList buildFriendList() {
ArrayList list = new ArrayList();
-
- //dummy friends
- Friend test1 = new Friend("Price", "Gutierrez","test@yahoo.com");
- Friend test2 = new Friend("Vanna", "Mccullough");
- Friend test3 = new Friend("Wyatt", "Paul");
- Friend test4 = new Friend("Thaddeus", "Robbins");
- Friend test5 = new Friend("Rooney", "Dejesus");
- Friend test6 = new Friend("Xavier", "Wolfe");
- Friend test7 = new Friend("Byron", "Raymond");
- Friend test8 = new Friend("Quinn", "Whitfield","test2@yahoo.com");
- Friend test9 = new Friend("Farrah", "Moon");
- Friend test10 = new Friend("Ainsley", "Whitehead");
- Friend test11 = new Friend("Josephine", "Patton");
- Friend test12 = new Friend("Mariko", "Patton");
- Friend test13 = new Friend("Raphael", "Fitzgerald");
- Friend test14 = new Friend("Deacon", "Daniels");
- Friend test15 = new Friend("Delilah", "Fletcher");
- Friend test16 = new Friend("Robin", "Andrews");
- Friend test17 = new Friend("Melvin", "Price");
-
- for(int x = 0; x < 2;x++){
- list.add(test1.toString());
- list.add(test2.toString());
- list.add(test3.toString());
- list.add(test4.toString());
- list.add(test5.toString());
- list.add(test6.toString());
- list.add(test7.toString());
- list.add(test8.toString());
- list.add(test9.toString());
- list.add(test10.toString());
- list.add(test11.toString());
- list.add(test12.toString());
- list.add(test13.toString());
- list.add(test14.toString());
- list.add(test15.toString());
- list.add(test16.toString());
- list.add(test17.toString());
+ ArrayList userfriends = user.getFriends();
+ for(int i =0; i < userfriends.size(); i++){
+ list.add(userfriends.get(i).toString());
}
return list;
@@ -101,7 +73,7 @@ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo men
for (int i = 0; i");
matcher = pattern.matcher(email);
- if(email.isEmpty()){
+ if(email.isEmpty())
+ {
Toast.makeText(getApplicationContext(), "Email field is empty", Toast.LENGTH_SHORT).show();
- }else if(password.isEmpty()){
+ }
+ else if(password.isEmpty())
+ {
Toast.makeText(getApplicationContext(), "Password field is empty", Toast.LENGTH_SHORT).show();
- }else if(!matcher.matches()){
+ }
+ else if(!matcher.matches())
+ {
Toast.makeText(getApplicationContext(), "Email: \""+email+"\" is not a valid email address!", Toast.LENGTH_SHORT).show();
- }else{
-
- String status ="fail";
- AccessNet caller = new AccessNet();
-
- String params = "email="+email+"&password="+password;
- String urlstub = "AccountLogin.php";
-
- CONLOG.info("Attempting to call server at: "+urlstub+", "+params);
- status = caller.simpleServerCall(urlstub, params);
+ }
+ else
+ {
+ if(AccessNet.AccountLogin(email,password)){
+ if (((CheckBox)findViewById(R.id.rememberLogin)).isChecked())
+ rememberLogin();
+ else
+ removeLoginFile();
+
- if(status.equalsIgnoreCase("success")){
CONLOG.info("Server call successful and logged in!");
Intent intent = new Intent(this, MainActivity.class);
- Toast.makeText(getApplicationContext(),"Welcome", Toast.LENGTH_SHORT).show();
+
+ //user is declared in TitleActivity, which every activity extends
+ user = new User(email, password);
+ /*
+ JSONObject friends = AccessNet.lookupFriends(email,password);
+ user.setFriends(user.parseFriends(friends));
+
+ JSONObject transAsBorrower = AccessNet.lookupTransBorrower(user.getEmail(), user.getPassword());
+ JSONObject transAsLender = AccessNet.lookupTransLender(user.getEmail(), user.getPassword());
+
+ if(transAsBorrower.get("result").toString().equalsIgnoreCase("1"))
+ {
+ user.setTransBorrowList(transAsBorrower,user.getEmail());
+ }
+ if(transAsLender.get("result").toString().equalsIgnoreCase("1"))
+ {
+ user.setTransLendList(transAsLender,user.getEmail());
+ }
+ */
+ refreshServerData();
+ /*
+ ArrayList dummy = new ArrayList();
+ dummy.add(new Friend());
+
+ if(friends.getString("NULL").equalsIgnoreCase("false"))
+ user.setFriends(dummy);
+ else
+ user.setFriends(parseFriends(friends));
+ */
startActivity(intent);
+ Toast.makeText(getApplicationContext(),"Welcome", Toast.LENGTH_SHORT).show();
this.finish();
- }else{
+ }
+
+ else
+ {
CONLOG.info("Server call successful but user failed login.");
Toast.makeText(getApplicationContext(),"Incorrect username or password", Toast.LENGTH_SHORT).show();
+ spin.setVisibility(View.GONE);
+ button.setVisibility(View.VISIBLE);
}
}
}
-
- public void CreateAccount(View view) {
- Intent intent = new Intent(getApplicationContext(), CreateAccountActivity.class);
- startActivity(intent);
- this.finish();
+ public void removeLoginFile()
+ {
+ File inputFile = new File(getApplicationContext().getFilesDir(),"login_info");
+ if(inputFile.exists())
+ {
+ getApplicationContext().deleteFile("login_info");
+ }
+ }
+ public void checkCache() throws IOException
+ {
+ File inputFile = new File(getApplicationContext().getFilesDir(),"login_info");
+ String fileData = "";
+ if(inputFile.exists()){
+
+ FileInputStream fis = new FileInputStream(inputFile);
+ int content;
+
+ while(( content = fis.read()) != -1 )
+ {
+ fileData+=(char)content;
+ }
+ fis.close();
+
+ CheckBox rememberLogin = (CheckBox)findViewById(R.id.rememberLogin);
+ EditText email = (EditText)findViewById(R.id.email);
+ EditText password = (EditText)findViewById(R.id.password);
+ rememberLogin.setChecked(true);
+ email.setText(fileData.substring(0,fileData.indexOf(" ")));
+ password.setText(fileData.substring(fileData.indexOf(" ")+1,fileData.length()));
+ }
}
- public void bypass(View view) {
- Intent intent = new Intent(getApplicationContext(), MainActivity.class);
+ public void rememberLogin() throws IOException
+ {
+ String filename = "login_info";
+ String storeData = "";
+
+ String email = ((EditText)findViewById(R.id.email)).getText().toString();
+ String password = ((EditText)findViewById(R.id.password)).getText().toString();
+ storeData = email + " " + password;
+
+ FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
+ fos.write(storeData.getBytes());
+ fos.close();
+ }
+
+ public void CreateAccount(View view)
+ {
+ Intent intent = new Intent(getApplicationContext(), CreateAccountActivity.class);
startActivity(intent);
this.finish();
- }
+ }
}
diff --git a/PayBack/src/com/example/payback/MainActivity.java b/PayBack/src/com/example/payback/MainActivity.java
index f0cc503..b261f64 100644
--- a/PayBack/src/com/example/payback/MainActivity.java
+++ b/PayBack/src/com/example/payback/MainActivity.java
@@ -1,64 +1,124 @@
package com.example.payback;
-import android.os.Bundle;
+
+import java.util.ArrayList;
import android.content.Intent;
+import android.os.Bundle;
+import android.view.Menu;
import android.view.View;
+import android.widget.TextView;
-public class MainActivity extends TitleActivity{
+public class MainActivity extends TitleActivity
+{
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
modifyTitle("Main Menu",R.layout.activity_main);
-
+ int count = 0;
+ for(Notification n : user.getNotifications())
+ {
+ if(!n.isRead())
+ count++;
+ }
+ TextView notTitle = (TextView) findViewById(R.id.NotificationB);
+ notTitle.setText("Notifications (" + count + " new)");
+ Intent broadcastIntent = new Intent();
+ broadcastIntent.setAction("com.Payback.StayLoggedIn_Intent");
+ sendBroadcast(broadcastIntent);
+ }
+ /*
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
}
+ */
+ @Override
+ public void onBackPressed()
+ {
+ finish();
+ System.exit(0);
+ }
+
public void CreateTrsn(View view)
- {
+ {
+ int transCostInt = 0;
+ String transCommentString = "";
+ ArrayList transselected = new ArrayList();
+ int translenderamountInt = 0;
+ ArrayList lendsharelist = new ArrayList();
+ boolean button1Selected = true;
+ boolean button2Selected = false;
+
Intent intent = new Intent(this, Transaction1Activity.class);
+ Bundle Bundle = new Bundle();
+
+ Bundle.putInt("Transaction1transCost", transCostInt);
+ Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", transselected);
+ Bundle.putInt("Transaction3lenderamount", translenderamountInt);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+
+ intent.putExtras(Bundle);
startActivity(intent);
+ finish();
}
public void ResolveTrsn(View view)
{
Intent intent = new Intent(this, ResolveTransactionActivity.class);
startActivity(intent);
+ finish();
}
public void Contact(View view)
{
Intent intent = new Intent(this, ContactActivity.class);
startActivity(intent);
+ finish();
}
public void ManageGroup(View view)
{
Intent intent = new Intent(this, ManageGroupActivity.class);
startActivity(intent);
+ finish();
}
public void Notification(View view)
{
Intent intent = new Intent(this, NotificationActivity.class);
startActivity(intent);
+ finish();
}
public void Statistic(View view)
{
Intent intent = new Intent(this, StatisticActivity.class);
startActivity(intent);
+ finish();
}
public void MainLogout(View view)
{
- Intent intent = new Intent(this, LoginActivity.class);
- startActivity(intent);
- this.finish();
+ Intent broadcastIntent = new Intent();
+ broadcastIntent.setAction("com.Payback.Logout_Intent");
+ sendBroadcast(broadcastIntent);
+
+ this.finish(); //activity is done and should be closed
+ System.exit(0);
}
public void Setting(View view)
{
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
+ finish();
}
}
diff --git a/PayBack/src/com/example/payback/ManageGroupActivity.java b/PayBack/src/com/example/payback/ManageGroupActivity.java
index 4f42910..1de55b0 100644
--- a/PayBack/src/com/example/payback/ManageGroupActivity.java
+++ b/PayBack/src/com/example/payback/ManageGroupActivity.java
@@ -1,21 +1,25 @@
package com.example.payback;
+import android.app.Activity;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
-public class ManageGroupActivity extends TitleActivity {
+public class ManageGroupActivity extends TitleActivity
+{
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Manage Groups",R.layout.activity_manage_group);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
}
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.manage_group, menu);
- return true;
- }
-
}
diff --git a/PayBack/src/com/example/payback/MustLogoutReceiver.java b/PayBack/src/com/example/payback/MustLogoutReceiver.java
new file mode 100644
index 0000000..558b878
--- /dev/null
+++ b/PayBack/src/com/example/payback/MustLogoutReceiver.java
@@ -0,0 +1,41 @@
+package com.example.payback;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+public class MustLogoutReceiver extends BroadcastReceiver
+{
+ static Activity activityInstance;
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+
+ Activity a = PageKillReceiver.getActivityInstance(); //Gets the activity to kill
+
+ //Toast.makeText(context, "Test Toast", Toast.LENGTH_LONG).show();
+ //Acts like a print statement when testing
+
+ Intent intentToStart = new Intent(a.getApplicationContext(), MainActivity.class);
+ a.startActivity(intentToStart);
+
+ a.finish(); //Kills the activity
+ }
+
+ public MustLogoutReceiver()
+ {
+ }
+
+ public void setActivityInstance(Activity ai)
+ {
+ activityInstance = ai;
+ }
+
+ public static Activity getActivityInstance()
+ {
+ return activityInstance;
+ }
+}
diff --git a/PayBack/src/com/example/payback/NoBackingReceiver.java b/PayBack/src/com/example/payback/NoBackingReceiver.java
new file mode 100644
index 0000000..edd184c
--- /dev/null
+++ b/PayBack/src/com/example/payback/NoBackingReceiver.java
@@ -0,0 +1,41 @@
+package com.example.payback;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+public class NoBackingReceiver extends BroadcastReceiver
+{
+ static Activity activityInstance;
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+
+ Activity a = PageKillReceiver.getActivityInstance(); //Gets the activity to kill
+
+ //Toast.makeText(context, "Test Toast", Toast.LENGTH_LONG).show();
+ //Acts like a print statement when testing
+
+ Intent intentToStart = new Intent(a.getApplicationContext(), MainActivity.class);
+ a.startActivity(intentToStart);
+
+ a.finish(); //Kills the activity
+ }
+
+ public NoBackingReceiver()
+ {
+ }
+
+ public void setActivityInstance(Activity ai)
+ {
+ activityInstance = ai;
+ }
+
+ public static Activity getActivityInstance()
+ {
+ return activityInstance;
+ }
+}
diff --git a/PayBack/src/com/example/payback/Notification.java b/PayBack/src/com/example/payback/Notification.java
index 58c1d28..6fac9ac 100644
--- a/PayBack/src/com/example/payback/Notification.java
+++ b/PayBack/src/com/example/payback/Notification.java
@@ -1,5 +1,193 @@
package com.example.payback;
-public class Notification {
+import java.util.Calendar;
+
+public class Notification implements Comparable{
+ private String fromEmail;
+ private String toEmail;
+ private String message;
+ private String date; //new format: "2013-12-12 12:29:56"
+ //old format: "Nov 17 2013, 12:19 AM"
+ private boolean read;
+ private String notid;
+
+ Notification (String from, String to, String message, String dateToParse)
+ {
+ this.fromEmail = from;
+ this.toEmail = to;
+ this.message = message;
+ this.setRead(false);
+ // 0123456789012345
+ // "2013-01-08 01:53:36"
+ }
+
+
+ Notification (String from, String to, String message)
+ {
+ this.fromEmail = from;
+ this.toEmail = to;
+ this.message = message;
+ //this.date = currDateToString();
+ this.date = "2013-12-12 12:29:56";
+ this.setRead(false);
+
+ }
+ Notification(){}
+
+ //Used to create a chronological order of dates, like the following:
+ //"2012-12-12 12:29:56"
+ //"2013-12-12 12:29:56"
+ //...
+ public int compareTo(Notification other) //chronological order
+ {
+ String d1 = date;
+ String d2 = other.date;
+ d1 = d1.replace('-', ' ');
+ d1 = d1.replace(':', ' ');
+ d2 = d2.replace('-', ' ');
+ d2 = d2.replace(':', ' ');
+ String[] d1s = d1.split(" ");
+ String[] d2s = d2.split(" ");
+ for(int i = 0; i < d1s.length; i++)
+ {
+ int x = Integer.parseInt(d1s[i]);
+ int y = Integer.parseInt(d2s[i]);
+ if(x > y)
+ return 1;
+ else if(x < y)
+ return -1;
+ }
+
+ return 0; //equivalent dates
+ }
+
+ /*
+ static String parseDateToString(String input)
+ {
+ StringBuilder sb = new StringBuilder("");
+ String month;
+ String moInput = input.substring(5,7);
+ switch(Integer.parseInt(moInput))
+ {
+ case 0: month = "Jan"; break;
+ case 1: month = "Feb"; break;
+ case 2: month = "Mar"; break;
+ case 3: month = "Apr"; break;
+ case 4: month = "May"; break;
+ case 5: month = "Jun"; break;
+ case 6: month = "Jul"; break;
+ case 7: month = "Aug"; break;
+ case 8: month = "Sep"; break;
+ case 9: month = "Oct"; break;
+ case 10: month = "Nov"; break;
+ case 11: month = "Dec"; break;
+ default: throw new IllegalArgumentException("Month broken");
+ }
+ sb.append(month + " ");
+ sb.append(Integer.parseInt(input.substring(8,10)) + " ");
+ sb.append(input.substring(0,4) + ", ");
+
+ boolean am = true;
+ int hour = Integer.parseInt(input.substring(11,13));
+ if(hour == 12)
+ {
+ am = false;
+ }
+ else if(hour > 12)
+ {
+ am = false;
+ hour -= 12;
+ }
+ else if(hour == 0)
+ {
+ hour = 12;
+ }
+ int min = Integer.parseInt(input.substring(14, 16));
+ if(am)
+ sb.append(hour + ":" + min + " " + "AM");
+ else
+ sb.append(hour + ":" + min + " " + "PM");
+
+
+
+ return sb.toString();
+ }
+ */
+ static String currDateToString()
+ {
+ Calendar c = Calendar.getInstance();
+ String min = c.get(Calendar.MINUTE) + "";
+ if(min.length() == 1) //changes 3 into 03
+ min = "0" + min;
+ int hour = c.get(Calendar.HOUR);
+ if (hour == 0)
+ hour = 12;
+ String am_pm = (c.get(Calendar.AM_PM) == 0) ? "AM" : "PM";
+ String month;
+ switch(c.get(Calendar.MONTH))
+ {
+ case 0: month = "Jan"; break;
+ case 1: month = "Feb"; break;
+ case 2: month = "Mar"; break;
+ case 3: month = "Apr"; break;
+ case 4: month = "May"; break;
+ case 5: month = "Jun"; break;
+ case 6: month = "Jul"; break;
+ case 7: month = "Aug"; break;
+ case 8: month = "Sep"; break;
+ case 9: month = "Oct"; break;
+ case 10: month = "Nov"; break;
+ case 11: month = "Dec"; break;
+ default: throw new IllegalArgumentException("Month broken");
+ }
+ String s = (month + " " + c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.YEAR) + ", " + hour + ":" + min + " " + am_pm);
+ //Should return a string that looks like "Nov 17 2013, 12:19 AM"
+ return s;
+ }
+
+ public String getFromEmail() {
+ return fromEmail;
+ }
+ public void setFromEmail(String from) {
+ this.fromEmail = from;
+ }
+ public String getToEmail() {
+ return toEmail;
+ }
+ public void setToEmail(String to) {
+ this.toEmail = to;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+ public String getDate() {
+ return date;
+ }
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+
+ public boolean isRead() {
+ return read;
+ }
+
+
+ public void setRead(boolean read) {
+ this.read = read;
+ }
+
+
+ public String getNotid() {
+ return notid;
+ }
+
+
+ public void setNotid(String notid) {
+ this.notid = notid;
+ }
}
diff --git a/PayBack/src/com/example/payback/NotificationActivity.java b/PayBack/src/com/example/payback/NotificationActivity.java
index 1ffd360..3096823 100644
--- a/PayBack/src/com/example/payback/NotificationActivity.java
+++ b/PayBack/src/com/example/payback/NotificationActivity.java
@@ -1,21 +1,187 @@
package com.example.payback;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import org.json.JSONException;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Color;
import android.os.Bundle;
-import android.view.Menu;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.example.payback.Notification;
+import com.example.payback.PageKillReceiver;
+import com.example.payback.TitleActivity;
+
-public class NotificationActivity extends TitleActivity {
+public class NotificationActivity extends TitleActivity
+{
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
+
+ static final boolean DEMO = false;
+ static ArrayList cbs;
+ ListView listview;
+ ArrayList nots;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Notifications",R.layout.activity_notification);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
+
+ try {
+ user.setNotifications(user.parseNotifs(AccessNet.lookupAllNotifs(user.getEmail(),user.getPassword()),user.getEmail()));
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ nots = user.getNotifications();
+
+ listview = (ListView) findViewById(R.id.listview);
+
+ if(DEMO)
+ {
+ nots.add(new Notification("Santa C.", "Will", "Santa added you as a friend."));
+ nots.add(new Notification("Nigerian P.", "Will", "Nigerian has sent you notice of a pending transaction."));
+ nots.add(new Notification("Nigerian P.", "Will", "Nigerian has sent you notice of a pending transaction."));
+ nots.add(new Notification("Nigerian P.", "Will", "Nigerian has sent you notice of a pending transaction."));
+ nots.add(new Notification("Nigerian P.", "Will", "Nigerian has sent you notice of a pending transaction."));
+
+ }
+
+ //final StableArrayAdapter adapter = new StableArrayAdapter(this,android.R.layout.simple_list_item_1, al);
+
+ View v = getLayoutInflater().inflate(R.layout.activity_noti_footer, null);
+ listview.addFooterView(v); //for the delete button
+
+ Collections.sort(nots);
+ Collections.reverse(nots);
+ cbs = new ArrayList();
+ NotiAdapter na = new NotiAdapter(this, android.R.layout.simple_list_item_1, nots, cbs);
+ listview.setAdapter(na);
+ setContentView(listview);
+ }
+ public void goBack(View view)
+ {
+ Intent intent = new Intent(this, MainActivity.class);
+ startActivity(intent);
+ this.finish();
+ }
+ public void deleteThese(View v)
+ {
+ for(int i = cbs.size() - 1; i >= 0; i--) //backwards so that our ordering doesn't get screwed up
+ {
+ if(cbs.get(i).isChecked()){
+ try {
+ AccessNet.DeleteOneNotif(user.getEmail(), user.getPassword(),nots.get(i).getNotid());
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ nots.remove(i);
+ }
+ }
+ cbs = new ArrayList();
+ NotiAdapter na = new NotiAdapter(this, android.R.layout.simple_list_item_1, nots, cbs);
+ listview.setAdapter(na);
+ setContentView(listview);
+ //TODO: delete all of the checked notifications server-side
+ }
+ static void markAsRead(Notification n)
+ {
+ try {
+ AccessNet.noteFlagger(user.getEmail(), user.getPassword(), n.getNotid(), "read");
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.notification, menu);
- return true;
+}
+
+class NotiAdapter extends ArrayAdapter
+{
+ private final Context context;
+ private final ArrayList al;
+ private ArrayList cbs;
+ View rowView;
+ public NotiAdapter (Context context, int textViewResourceId, ArrayList al, ArrayList cbs)
+ {
+ super(context, R.layout.activity_notification, al);
+ this.context = context;
+ this.al = al;
+ this.cbs = cbs;
}
+
+ @Override
+ public View getView(final int position, View convertView, ViewGroup parent)
+ {
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ rowView = inflater.inflate(R.layout.activity_noti_row_layout, parent, false);
+ TextView from = (TextView) rowView.findViewById(R.id.from);
+ TextView date = (TextView) rowView.findViewById(R.id.date);
+ TextView message = (TextView) rowView.findViewById(R.id.secondLine);
+ cbs.add((CheckBox) rowView.findViewById(R.id.check));
+
+ if(!al.get(position).isRead()) //unread messages are yellow
+ {
+ from.setTextColor(Color.YELLOW);
+ date.setTextColor(Color.YELLOW);
+ message.setTextColor(Color.YELLOW);
+ }
+
+ //TODO: set the following text to the person's first name and last name with a server call, instead of just their email
+ from.setText(al.get(position).getFromEmail());
+ date.setText(al.get(position).getDate());
+ message.setText(al.get(position).getMessage());
+
+ if(!al.get(position).isRead()) //add a listener if it hasn't been read
+ {
+ rowView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) //mark as read
+ {
+
+ TextView fromInner = (TextView) v.findViewById(R.id.from);
+ fromInner.setTextColor(Color.WHITE);
+
+ TextView dateInner = (TextView) v.findViewById(R.id.date);
+ dateInner.setTextColor(Color.WHITE);
+ TextView messageInner = (TextView) v.findViewById(R.id.secondLine);
+ messageInner.setTextColor(Color.WHITE);
+
+ NotificationActivity.markAsRead(al.get(position));
+ //TODO: update the server so that this notification is now read
+ }
+ });
+ }
+
+ return rowView;
+ }
}
diff --git a/PayBack/src/com/example/payback/PageKillReceiver.java b/PayBack/src/com/example/payback/PageKillReceiver.java
new file mode 100644
index 0000000..3c9c6a9
--- /dev/null
+++ b/PayBack/src/com/example/payback/PageKillReceiver.java
@@ -0,0 +1,41 @@
+package com.example.payback;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class PageKillReceiver extends BroadcastReceiver
+{
+ static Activity activityInstance;
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+
+ Activity a = PageKillReceiver.getActivityInstance(); //Gets the activity to kill
+
+// Toast.makeText(context, "Test Toast", Toast.LENGTH_LONG).show();
+ //Acts like a print statement when testing
+
+ Intent intentToStart = new Intent(a.getApplicationContext(), LoginActivity.class);
+ a.startActivity(intentToStart);
+
+ a.finish(); //Kills the activity
+ }
+
+ public PageKillReceiver()
+ {
+ }
+
+ public void setActivityInstance(Activity ai)
+ {
+ activityInstance = ai;
+ }
+
+ public static Activity getActivityInstance()
+ {
+ return activityInstance;
+ }
+
+}
diff --git a/PayBack/src/com/example/payback/PieGraph.java b/PayBack/src/com/example/payback/PieGraph.java
new file mode 100644
index 0000000..5dc34d6
--- /dev/null
+++ b/PayBack/src/com/example/payback/PieGraph.java
@@ -0,0 +1,85 @@
+package com.example.payback;
+
+import org.achartengine.ChartFactory;
+import org.achartengine.GraphicalView;
+import org.achartengine.model.CategorySeries;
+import org.achartengine.renderer.DefaultRenderer;
+import org.achartengine.renderer.SimpleSeriesRenderer;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+
+public class PieGraph {
+
+ public Intent getTestIntent(Context context) {
+
+ int[] values = { 1, 2, 3, 4, 5 };
+ CategorySeries series = new CategorySeries("Pie Graph");
+ int k = 0;
+ for (int value : values) {
+ series.add("Section " + ++k, value);
+ }
+
+ int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
+
+ DefaultRenderer renderer = new DefaultRenderer();
+ for (int color : colors) {
+ SimpleSeriesRenderer r = new SimpleSeriesRenderer();
+ r.setColor(color);
+ renderer.addSeriesRenderer(r);
+ }
+ renderer.setChartTitle("Pie Chart Demo");
+ renderer.setChartTitleTextSize(7);
+ renderer.setZoomButtonsVisible(true);
+
+ Intent intent = ChartFactory.getPieChartIntent(context, series, renderer, "Pie");
+ return intent;
+ }
+
+ public GraphicalView getTestView(Context context) {
+
+ int[] values = { 1, 2, 3, 4, 5 };
+ CategorySeries series = new CategorySeries("Pie Graph");
+ int k = 0;
+ for (int value : values) {
+ series.add("Section " + ++k, value);
+ }
+
+ int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.MAGENTA, Color.YELLOW, Color.CYAN };
+
+ DefaultRenderer renderer = new DefaultRenderer();
+ for (int color : colors) {
+ SimpleSeriesRenderer r = new SimpleSeriesRenderer();
+ r.setColor(color);
+ renderer.addSeriesRenderer(r);
+ }
+ renderer.setChartTitle("Pie Chart Demo");
+ renderer.setChartTitleTextSize(7);
+ renderer.setZoomButtonsVisible(true);
+
+ return ChartFactory.getPieChartView(context, series, renderer);
+ }
+
+ public GraphicalView getTwoSectionView(Context context, double standingPayables, double standingReceivables) {
+
+ CategorySeries series = new CategorySeries("Payables and Receivables");
+ series.add("Payables", standingPayables);
+ series.add("Receivables", standingReceivables);
+
+ int[] colors = new int[] { Color.RED, Color.BLUE };
+
+ DefaultRenderer renderer = new DefaultRenderer();
+ for (int color : colors) {
+ SimpleSeriesRenderer r = new SimpleSeriesRenderer();
+ r.setColor(color);
+ renderer.addSeriesRenderer(r);
+ }
+ renderer.setChartTitleTextSize(12);
+ renderer.setLabelsTextSize(12);
+ renderer.setPanEnabled(false);
+ renderer.setZoomButtonsVisible(false);
+
+ return ChartFactory.getPieChartView(context, series, renderer);
+ }
+}
diff --git a/PayBack/src/com/example/payback/ResolveTransactionActivity.java b/PayBack/src/com/example/payback/ResolveTransactionActivity.java
index ec46018..d2e746d 100644
--- a/PayBack/src/com/example/payback/ResolveTransactionActivity.java
+++ b/PayBack/src/com/example/payback/ResolveTransactionActivity.java
@@ -1,21 +1,153 @@
+//CREDIT TO Will Macfarlane for the template used in Notification.
package com.example.payback;
+import java.util.ArrayList;
+
+import org.json.JSONException;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.IntentFilter;
+import android.graphics.Color;
+import android.graphics.Paint;
import android.os.Bundle;
+import android.view.ContextMenu;
+import android.view.LayoutInflater;
import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.Toast;
-public class ResolveTransactionActivity extends TitleActivity {
-
+public class ResolveTransactionActivity extends TitleActivity
+{
+ static final boolean DEMO = true;
+
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
+
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- modifyTitle("Resolve Transaction",R.layout.activity_resolve_transaction);
- }
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ modifyTitle("Resolve Transactions",R.layout.activity_resolve_transaction1);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
+
+ final ListView listview = (ListView) findViewById(R.id.listview);
+ ArrayList list = new ArrayList();
+
+ for(int i = 0; i adapter, View arg1,
+ int position, long arg3) {
+ BaseTransaction t = (BaseTransaction) adapter.getItemAtPosition(position);
+ if(t.getResolved()){
+ t.setResolved(false);
+ try {
+ AccessNet.transFlagger(user.getEmail(), user.getPassword(), t.getID(), "resolved");
+ refreshTrans();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ refresh();
+ }
+ else{
+ t.setResolved(true);
+ }
+
+
+ }
+ });
+ setContentView(listview);
+
+ }
+ }
-}
+ class TransAdapter extends ArrayAdapter
+ {
+ private final Context context;
+ private final ArrayList al;
+ public TransAdapter (Context context, int textViewResourceId, ArrayList al)
+ {
+ super(context, R.layout.activity_resolve_transaction1, al);
+ this.context = context;
+ this.al = al;
+ }
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+ LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View rowView = inflater.inflate(R.layout.activity_noti_row_layout, parent, false);
+ TextView from = (TextView) rowView.findViewById(R.id.from);
+ TextView date = (TextView) rowView.findViewById(R.id.date);
+ TextView message = (TextView) rowView.findViewById(R.id.secondLine);
+
+ if(al.get(position).getLenderEmail().toString().equalsIgnoreCase(TitleActivity.user.getEmail())){
+ from.setText("Amount: $" + al.get(position).getAmount() + " With: " + al.get(position).getBorrowerEmail());
+ from.setTextColor(Color.GREEN);
+ date.setTextColor(Color.GREEN);
+ message.setTextColor(Color.GREEN);
+ }
+ else{
+ from.setText("Amount: $" + al.get(position).getAmount() + " With: " + al.get(position).getLenderEmail());
+ from.setTextColor(Color.RED);
+ date.setTextColor(Color.RED);
+ message.setTextColor(Color.RED);
+ }
+ date.setText(al.get(position).getTransDate());
+ if(al.get(position).getComment().toString().equalsIgnoreCase("")){
+ message.setText(al.get(position).getComment());
+ }
+ else
+ message.setText("No message for transaction!");
+ message.setText(al.get(position).getComment());
+ if(al.get(position).getResolved()){
+ from.setPaintFlags(from.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ date.setPaintFlags(date.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ message.setPaintFlags(message.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
+ }
+
+ return rowView;
+ }
+ }
\ No newline at end of file
diff --git a/PayBack/src/com/example/payback/ScatterGraph.java b/PayBack/src/com/example/payback/ScatterGraph.java
new file mode 100644
index 0000000..4b2ad71
--- /dev/null
+++ b/PayBack/src/com/example/payback/ScatterGraph.java
@@ -0,0 +1,53 @@
+package com.example.payback;
+
+import org.achartengine.ChartFactory;
+import org.achartengine.chart.PointStyle;
+import org.achartengine.model.XYMultipleSeriesDataset;
+import org.achartengine.model.XYSeries;
+import org.achartengine.renderer.XYMultipleSeriesRenderer;
+import org.achartengine.renderer.XYSeriesRenderer;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+
+public class ScatterGraph{
+
+ public Intent getTestIntent(Context context) {
+ // Data 1
+ int[] x = {1, 2, 3, 4, 5, 6 ,7, 8 ,9, 10};
+ double[] values = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6 ,7.7, 8.8 ,9.9, 10.1};
+ XYSeries series = new XYSeries("Series 1");
+ for (int k = 0; k < x.length; k++) {
+ series.add(x[k], values[k]);
+ }
+ // Data 1
+ int[] x2 = {1, 2, 3, 4, 5, 6 ,7, 8 ,9, 10};
+ double[] values2 = {2.4, 3.5, 6.7, 3.5, 4.57, 6.7 ,9.7, 10.8 ,11.9, 14.1};
+ XYSeries series2 = new XYSeries("Series 2");
+ for (int k = 0; k < x2.length; k++) {
+ series2.add(x2[k], values2[k]);
+ }
+ XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
+ dataset.addSeries(series);
+ dataset.addSeries(series2);
+
+
+ // Customization for data 1
+ XYSeriesRenderer renderer = new XYSeriesRenderer();
+ renderer.setColor(Color.WHITE);
+ renderer.setPointStyle(PointStyle.DIAMOND);
+ renderer.setLineWidth(6);
+ // Customization for data 2
+ XYSeriesRenderer renderer2 = new XYSeriesRenderer();
+ renderer2.setColor(Color.YELLOW);
+ renderer2.setPointStyle(PointStyle.SQUARE);
+ renderer2.setLineWidth(6);
+ // Customization
+ XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
+ mRenderer.addSeriesRenderer(renderer);
+ mRenderer.addSeriesRenderer(renderer2);
+
+ return ChartFactory.getScatterChartIntent(context, dataset, mRenderer);
+ }
+
+}
diff --git a/PayBack/src/com/example/payback/SettingsActivity.java b/PayBack/src/com/example/payback/SettingsActivity.java
index 2e326c8..61aba0f 100644
--- a/PayBack/src/com/example/payback/SettingsActivity.java
+++ b/PayBack/src/com/example/payback/SettingsActivity.java
@@ -1,21 +1,260 @@
package com.example.payback;
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import android.app.Activity;
+import android.content.IntentFilter;
import android.os.Bundle;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.text.InputType;
import android.view.Menu;
+import android.view.View;
+import android.view.LayoutInflater;
+import android.content.Intent;
+import android.content.DialogInterface;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
-public class SettingsActivity extends TitleActivity {
+public class SettingsActivity extends TitleActivity
+{
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Settings",R.layout.activity_settings);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.settings, menu);
- return true;
+ public void showEditPassword(View view) {
+ LayoutInflater inflater = this.getLayoutInflater();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ final View dialoglayout = inflater.inflate(R.layout.dialog_settings_password, null);
+ builder.setTitle("Edit Password")
+ .setView(dialoglayout)
+ .setPositiveButton(R.string.back, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //Toast.makeText(getApplicationContext(),"Back", Toast.LENGTH_SHORT).show();
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(R.string.save_changes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //Toast.makeText(getApplicationContext(), "Password Changed", Toast.LENGTH_SHORT).show();
+ editPassword(dialoglayout);
+ }
+ });
+
+ TextView o = (TextView) dialoglayout.findViewById(R.id.oldPassView);
+ o.setText("Old Password:");
+ TextView n = (TextView) dialoglayout.findViewById(R.id.newPassView);
+ n.setText("New Password:");
+ TextView c = (TextView) dialoglayout.findViewById(R.id.confirmPassView);
+ c.setText("Confirm New Password:");
+
+ Dialog dialog = builder.create();
+ dialog.show();
+ }
+
+ public void editPassword(View layout) {
+ EditText oldview = (EditText) layout.findViewById(R.id.oldPass);
+ String oldPassText = oldview.getText().toString();
+
+ EditText newview = (EditText) layout.findViewById(R.id.newPass);
+ String newPassText = newview.getText().toString();
+
+ EditText confirmview = (EditText) layout.findViewById(R.id.confirmPass);
+ String confirmPassText = confirmview.getText().toString();
+
+ if(newPassText.length() >= 8) {
+ if(newPassText.equals(confirmPassText)) {
+ try {
+ boolean success = AccessNet.modifyUserPassword(user.getEmail(), oldPassText, newPassText);
+ if(success) {
+ Toast.makeText(getApplicationContext(), "Password changed!", Toast.LENGTH_SHORT).show();
+ user.setPassword(newPassText);
+
+ File inputFile = new File(getApplicationContext().getFilesDir(),"login_info");
+ if(inputFile.exists())
+ {
+ getApplicationContext().deleteFile("login_info");
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "Incorrect Password!", Toast.LENGTH_SHORT).show();
+ }
+ } catch (InterruptedException e) {
+ Toast.makeText(getApplicationContext(), "Problem with server connection", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "Passwords don't match!", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "New password must be at least 8 characters!", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ public void showEditEmail(View view) {
+ LayoutInflater inflater = this.getLayoutInflater();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+
+ final View dialogLayout = inflater.inflate(R.layout.dialog_settings_password, null);
+
+ builder.setTitle("Edit Email")
+ .setView(dialogLayout)
+ .setPositiveButton(R.string.back, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //Toast.makeText(getApplicationContext(),"Back", Toast.LENGTH_SHORT).show();
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(R.string.save_changes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //Toast.makeText(getApplicationContext(), "Email Changed", Toast.LENGTH_SHORT).show();
+ editEmail(dialogLayout);
+ }
+ });
+
+ TextView o = (TextView) dialogLayout.findViewById(R.id.oldPassView);
+ o.setText("Old Email:");
+ TextView n = (TextView) dialogLayout.findViewById(R.id.newPassView);
+ n.setText("New Email:");
+ TextView c = (TextView) dialogLayout.findViewById(R.id.confirmPassView);
+ c.setText("Confirm New Email:");
+
+ EditText o2 = (EditText) dialogLayout.findViewById(R.id.oldPass);
+ o2.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
+ EditText n2= (EditText) dialogLayout.findViewById(R.id.newPass);
+ n2.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
+ EditText c2 = (EditText) dialogLayout.findViewById(R.id.confirmPass);
+ c2.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
+
+ Dialog dialog = builder.create();
+ dialog.show();
+ }
+
+ public void editEmail(View layout) {
+ EditText oldEmail = (EditText) layout.findViewById(R.id.oldPass);
+ String oldEmailText = oldEmail.getText().toString();
+
+ EditText newEmail = (EditText) layout.findViewById(R.id.newPass);
+ String newEmailText = newEmail.getText().toString();
+
+ EditText confirmEmail = (EditText) layout.findViewById(R.id.confirmPass);
+ String confirmEmailText = confirmEmail.getText().toString();
+
+ if(oldEmailText.equals(user.getEmail())) {
+ if(newEmailText.equals(confirmEmailText)) {
+ if(verifyEmail(newEmailText)) {
+ try {
+ boolean success = AccessNet.modifyUserEmail(oldEmailText, user.getPassword(), newEmailText);
+ if(success) {
+ Toast.makeText(getApplicationContext(), "Email changed!", Toast.LENGTH_SHORT).show();
+ user.setEmail(newEmailText);
+ } else {
+ //this should never happen
+ Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_SHORT).show();
+ }
+ } catch (InterruptedException e) {
+ Toast.makeText(getApplicationContext(), "Error connecting to server", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "Invalid email!", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "Emails don't match!", Toast.LENGTH_SHORT).show();
+ }
+ } else {
+ Toast.makeText(getApplicationContext(), "Incorrect email!", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ public boolean verifyEmail(String email) {
+ final String EMAIL_PATTERN =
+ "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$";
+ final Pattern pattern = Pattern.compile(EMAIL_PATTERN);
+ final Matcher matcher = pattern.matcher(email);
+
+ return matcher.matches();
+ }
+
+ public void showEditDisplayName(View view) {
+ LayoutInflater inflater = this.getLayoutInflater();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+
+ final View dialogLayout = inflater.inflate(R.layout.dialog_settings_name, null);
+
+ builder.setTitle("Edit Name")
+ .setView(dialogLayout)
+ .setPositiveButton(R.string.back, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // Toast.makeText(getApplicationContext(),"Back", Toast.LENGTH_SHORT).show();
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(R.string.save_changes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ //Toast.makeText(getApplicationContext(), "Name Changed", Toast.LENGTH_SHORT).show();
+ editName(dialogLayout);
+ }
+ });
+ Dialog dialog = builder.create();
+ dialog.show();
+ }
+
+ public void editName(View layout) {
+ EditText fName = (EditText) layout.findViewById(R.id.firstName);
+ String fNameText = fName.getText().toString();
+
+ EditText lName = (EditText) layout.findViewById(R.id.lastName);
+ String lNameText = lName.getText().toString();
+
+ if(fNameText.isEmpty() && lNameText.isEmpty()) {
+ Toast.makeText(getApplicationContext(), "No new values were provided", Toast.LENGTH_SHORT).show();
+ } else {
+ try {
+ boolean success1 = false, success2 = false;
+
+ if(!fNameText.isEmpty()) {
+ success1 = AccessNet.modifyUserFirstName(user.getEmail(), user.getPassword(), fNameText);
+ if(success1) {
+ user.setfName(fNameText);
+ } else {
+ Toast.makeText(getApplicationContext(), "Error editing display name", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ if(!lNameText.isEmpty()) {
+ success2 = AccessNet.modifyUserLastName(user.getEmail(), user.getPassword(), lNameText);
+ if(success2) {
+ user.setlName(lNameText);
+ } else {
+ Toast.makeText(getApplicationContext(), "Error editing display name", Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ if(success1 || success2) {
+ Toast.makeText(getApplicationContext(), "Display name changed", Toast.LENGTH_SHORT).show();
+ }
+ } catch (InterruptedException e) {
+ Toast.makeText(getApplicationContext(), "Error connecting to server", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }
+
+ public void showMainMenu(View view) {
+ Intent intent = new Intent(this, MainActivity.class);
+ startActivity(intent);
+ this.finish();
}
-
}
diff --git a/PayBack/src/com/example/payback/ShortcutsActivity.java b/PayBack/src/com/example/payback/ShortcutsActivity.java
index e382aed..e1ef1d4 100644
--- a/PayBack/src/com/example/payback/ShortcutsActivity.java
+++ b/PayBack/src/com/example/payback/ShortcutsActivity.java
@@ -1,28 +1,35 @@
package com.example.payback;
+import java.util.ArrayList;
+
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
+import android.content.IntentFilter;
import android.view.Menu;
import android.view.View;
-public class ShortcutsActivity extends Activity {
+public class ShortcutsActivity extends Activity
+{
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shortcuts);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.shortcuts, menu);
- return true;
- }
public void Return(View view)
{
- finish();
+ this.finish();
}
public void showMainMenu(View view)
{
@@ -32,7 +39,26 @@ public void showMainMenu(View view)
}
public void showCreateTransaction(View view)
{
+ int transCostInt = 0;
+ String transCommentString = "";
+ ArrayList transselected = new ArrayList();
+ int translenderamountInt = 0;
+ ArrayList lendsharelist = new ArrayList();
+ boolean button1Selected = true;
+ boolean button2Selected = false;
+
Intent intent = new Intent(this, Transaction1Activity.class);
+ Bundle Bundle = new Bundle();
+
+ Bundle.putInt("Transaction1transCost", transCostInt);
+ Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", transselected);
+ Bundle.putInt("Transaction3lenderamount", translenderamountInt);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+
+ intent.putExtras(Bundle);
startActivity(intent);
this.finish();
}
@@ -41,7 +67,8 @@ public void showContacts(View view)
Intent intent = new Intent(this, ContactActivity.class);
startActivity(intent);
this.finish();
- }public void showLogout(View view)
+ }
+ public void showLogout(View view)
{
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
diff --git a/PayBack/src/com/example/payback/StatisticActivity.java b/PayBack/src/com/example/payback/StatisticActivity.java
index d55af69..58dcc06 100644
--- a/PayBack/src/com/example/payback/StatisticActivity.java
+++ b/PayBack/src/com/example/payback/StatisticActivity.java
@@ -1,21 +1,242 @@
package com.example.payback;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.achartengine.GraphicalView;
+import org.achartengine.model.TimeSeries;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
-public class StatisticActivity extends TitleActivity {
+public class StatisticActivity extends TitleActivity
+{
+ static Activity activityInstance; //these are variables
+ static PageKillReceiver pkr; //used for PageKillReceiver.java
+ static IntentFilter filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Transaction Statistics",R.layout.activity_statistic);
+
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filter = new IntentFilter();
+ filter.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filter);
+
+ displayValue();
+
}
+
+ public void displayValue ()
+ {
+ ArrayList transBorrow = user.getTransBorrow();
+ ArrayList transLend = user.getTransLend();
+
+ double currentPayable = getcurrentPayable(transBorrow);
+ double currentReceivable = getcurrentReceivable(transLend);
+//
+ double totalPayable = getTotalPayable(transBorrow);
+ double totalReceivable = getTotalReceivable(transLend);
+
+ int numTransaction = transBorrow.size();
+
+
+ //Append value to textview
+ TextView numTransactionTextView = (TextView) findViewById(R.id.numTransaction);
+ numTransactionTextView.append(Integer.toString(numTransaction));
+ TextView currentPayableTextView = (TextView) findViewById(R.id.currentPayable);
+ currentPayableTextView.append(String.format("$%.2f", currentPayable));
+ TextView currentReceivableTextView = (TextView) findViewById(R.id.currentReceivable);
+ currentReceivableTextView.append(String.format("$%.2f", currentReceivable));
+ TextView TotalPayableTextView = (TextView) findViewById(R.id.totalPayable);
+ TotalPayableTextView.append(String.format("$%.2f", totalPayable));
+ TextView TotalReceivableTextView = (TextView) findViewById(R.id.totalReceivable);
+ TotalReceivableTextView.append(String.format("$%.2f", totalReceivable));
+
+ //Display Pie Graph
+ PieGraph pie = new PieGraph();
+ GraphicalView gView = pie.getTwoSectionView(this, totalPayable, totalReceivable);
+ LinearLayout chartView = (LinearLayout) findViewById(R.id.chart);
+ chartView.addView(gView);
+ }
+
+ public double getcurrentPayable (ArrayList transBorrow)
+ {
+ double currentPayable = 0;
+ for(int i = 0; i < transBorrow.size(); i++)
+ {
+ if(!transBorrow.get(i).getResolved())
+ currentPayable += transBorrow.get(i).getAmount();
+ }
+
+ return currentPayable;
+ }
+
+ public double getcurrentReceivable (ArrayList transLend)
+ {
+ double currentReceivable = 0;
+ for(int i = 0; i < transLend.size(); i++)
+ {
+ if(!transLend.get(i).getResolved())
+ currentReceivable += transLend.get(i).getAmount();
+ }
+
+ return currentReceivable;
+ }
+
+ public double getTotalPayable (ArrayList transBorrow)
+ {
+ double totalPayable = 0;
+ for(int i = 0; i < transBorrow.size(); i++)
+ {
+ totalPayable += transBorrow.get(i).getAmount();
+ }
+
+ return totalPayable;
+ }
+
+ public double getTotalReceivable (ArrayList transLend)
+ {
+ double totalReceivable = 0;
+ Iterator i1 = transLend.iterator();
+ while(i1.hasNext())
+ {
+ totalReceivable += i1.next().getAmount();
+ }
+
+ return totalReceivable;
+ }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.statistic, menu);
- return true;
+
+ public void displayTransactionsHistory (View view)
+ {
+ LineGraph line = new LineGraph();
+ TimeSeries payableSeries = getPayableSeries("Payable");
+ TimeSeries receivableSeries = getReceivableSeries("Receivable");
+
+ //Open a new activity to display the graph
+ Intent lineIntent = line.getTwoLineIntent(this, payableSeries, receivableSeries, "Transactions History");
+ startActivity(lineIntent);
+ }
+
+ public TimeSeries getPayableSeries (String seriesName)
+ {
+ ArrayList transBorrow = user.getTransBorrow();
+
+// int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
+// double[] y = { 30, 34, 45, 57, 77, 89, 100, 111 ,123 ,145 }; // y values!
+
+ int[] x = getPayableX(transBorrow); // x values!
+ double[] y = getPayableY(transBorrow); // y values!
+
+ TimeSeries series = new TimeSeries(seriesName);
+ for( int i = 0; i < x.length; i++)
+ {
+ series.add(x[i], y[i]);
+ }
+
+ return series;
+ }
+
+ public int[] getPayableX(ArrayList transBorrow)
+ {
+ int numTransaction = transBorrow.size();
+
+ /*creating the x axis*/
+ int[] x = new int[numTransaction];
+ for(int i = 0; i < numTransaction; i++)
+ {
+ x[i] = i+1;
+ }
+
+ return x;
+ }
+
+ public double[] getPayableY(ArrayList transBorrow)
+ {
+ int numTransaction = transBorrow.size();
+
+ /*creating the y axis*/
+ double[] y = new double[numTransaction];
+ for(int i = 0; i < numTransaction; i++)
+ {
+ if(i == 0)
+ {
+ y[i] = transBorrow.get(i).getAmount();
+ }
+ else
+ y[i] = transBorrow.get(i).getAmount() + y[i-1];
+ }
+
+ return y;
+ }
+
+ public TimeSeries getReceivableSeries (String seriesName)
+ {
+ ArrayList transBorrow = user.getTransBorrow();
+ ArrayList transLend = user.getTransLend();
+
+// int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // x values!
+// int[] y = { 145, 123, 111, 100, 89, 77, 57, 45, 34, 30}; // y values!
+
+ int[] x = getReceivableX(transLend); // x values!
+ double[] y = getReceivableY(transLend); // y values!
+
+ TimeSeries series = new TimeSeries(seriesName);
+ for( int i = 0; i < x.length; i++)
+ {
+ series.add(x[i], y[i]);
+ }
+
+ return series;
+ }
+
+ public int[] getReceivableX(ArrayList transLend)
+ {
+ int numTransaction = transLend.size();
+
+ /*creating the x axis*/
+ int[] x = new int[numTransaction];
+ for(int i = 0; i < numTransaction; i++)
+ {
+ x[i] = i+1;
+ }
+
+ return x;
+ }
+
+ public double[] getReceivableY(ArrayList transLend)
+ {
+ int numTransaction = transLend.size();
+
+ /*creating the y axis*/
+ double[] y = new double[numTransaction];
+ for(int i = 0; i < numTransaction; i++)
+ {
+ if(i == 0)
+ {
+ y[i] = transLend.get(i).getAmount();
+ }
+ else
+ y[i] = transLend.get(i).getAmount() + y[i-1];
+ }
+
+ return y;
+ }
+
+ public void showMainMenu(View view) {
+ Intent intent = new Intent(this, MainActivity.class);
+ startActivity(intent);
+ this.finish();
}
}
diff --git a/PayBack/src/com/example/payback/TitleActivity.java b/PayBack/src/com/example/payback/TitleActivity.java
index 7464dcd..2aabe1c 100644
--- a/PayBack/src/com/example/payback/TitleActivity.java
+++ b/PayBack/src/com/example/payback/TitleActivity.java
@@ -1,6 +1,9 @@
package com.example.payback;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.app.Activity;
import android.app.Service;
import android.content.Intent;
@@ -10,121 +13,57 @@
import android.widget.TextView;
public class TitleActivity extends Activity {
-
+ protected static User user;
private static final int MY_REQUEST_CODE = 0;
public final boolean success = false;
- public void modifyTitle(String name, int layout) {
+
+ public void modifyTitle(String name, int layout)
+ {
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(layout);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
TextView header = (TextView) getWindow().findViewById(R.id.titleNameView);
header.setText(name);
}
-
public void ShowShortcuts(View view)
{
Intent intent = new Intent(this, ShortcutsActivity.class);
- startActivityForResult(intent, MY_REQUEST_CODE);
- this.finish();
+ startActivity(intent);
}
-
- public void hideSoftKeyboard(View view) {
+ public void hideSoftKeyboard(View view)
+ {
((InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(), 0);
}
-
-
- /*
- public boolean checkAlpha(){
- //check for textbox to only have Letters
+ public void refresh(){
+ finish();
+ startActivity(getIntent());
}
- public boolean checkEmail(){
- //check for textbox to have valid email format --> XX@yy.com
+ public void refreshTrans() throws JSONException, InterruptedException{
+ JSONObject obj = AccessNet.lookupTransBorrower(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setTransBorrowList(user.makeTransBorrowList(obj,user.getEmail()));
+ }
+ obj = AccessNet.lookupTransLender(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setTransLendList(user.makeTransLendList(obj,user.getEmail()));
+ }
}
- public boolean checkNumber(){
- //check for textbox to only have numbers
- }
- public boolean checkPassword(){
- //check for textbox to have >6 characters
- //must contain 3 categories of character types:
- //i.e letter,number,symbol,uppercaseLetter,etc.
+ public void refreshServerData() throws InterruptedException, JSONException{
+ JSONObject obj = AccessNet.lookupFriends(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setFriends(user.parseFriends(obj));
+ }
+ obj = AccessNet.lookupTransBorrower(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setTransBorrowList(user.makeTransBorrowList(obj,user.getEmail()));
+ }
+ obj = AccessNet.lookupTransLender(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setTransLendList(user.makeTransLendList(obj,user.getEmail()));
+ }
+ obj = AccessNet.lookupAllNotifs(user.getEmail(),user.getPassword());
+ if(obj.get("result").toString().equalsIgnoreCase("1")){
+ user.setNotifications(user.parseNotifs(obj,user.getEmail()));
+ }
}
- */
-
-
-
-
-
- /*
- public boolean sendServer(final String className, final String parameters, final String urlName){
- Logger CONLOG = Logger.getLogger(className);
- CONLOG.setLevel(Level.INFO);
- final boolean success[] = new boolean[1];
- final CountDownLatch latch = new CountDownLatch(1);
-
- new Thread (new Runnable() {
- @Override
- public void run(){
- //view.invalidate();//uncommenting this will render the button into an app crasher
- Logger CANLOG = Logger.getLogger(className);
- CANLOG.setLevel(Level.INFO);
- URL url = null;
- try {
- url = new URL(urlName);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- CANLOG.info("Able to set url and params: "+parameters);
- HttpURLConnection connection;
- try {
- connection = (HttpURLConnection) url.openConnection();
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setInstanceFollowRedirects(false);
- connection.setRequestMethod("POST");
- connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- connection.setRequestProperty("charset", "utf-8");
- connection.setRequestProperty("Content-Length", "" + Integer.toString(parameters.getBytes().length));
- connection.setUseCaches (false);
- CANLOG.info("Able to set HTTP: "+connection);
-
- try{
- DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
- wr.writeBytes(parameters);
- wr.flush();
- wr.close();
- CANLOG.info("Data send success!");
- } catch (IOException e){
- CANLOG.warning("IOException on HTTP connection send to server: "+connection.getResponseMessage());
- e.printStackTrace();
- }
-
- try{
- String line;
- BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
-
- /*while ((line = reader.readLine()) != null) {
- //System.out.println(line);
- CANLOG.info("Data in: "+line);
- //Toast.makeText(getApplicationContext(), line, Toast.LENGTH_SHORT).show();
- }/
- line = reader.readLine();
- if(line.equalsIgnoreCase("1"));
- success[0] = true;
- CANLOG.info("Data in: "+line);
- reader.close();
- CANLOG.info("Data receive success!");
- } catch (IOException e){
- CANLOG.warning("IOException on HTTP connection receive from server: "+connection.getResponseMessage());
- e.printStackTrace();
- }
- connection.disconnect();
- } catch (IOException e) {
- CANLOG.warning("IOException on HTTP connection creation");
- e.printStackTrace();
- }
- }
- //latch.countDown();
- }).start();
- return success[0];
- }*/
}
diff --git a/PayBack/src/com/example/payback/Transaction.java b/PayBack/src/com/example/payback/Transaction.java
index d10e88f..fdc5f2d 100644
--- a/PayBack/src/com/example/payback/Transaction.java
+++ b/PayBack/src/com/example/payback/Transaction.java
@@ -2,40 +2,173 @@
import java.util.*;
-public class Transaction {
+abstract class Transaction {
- int lenderId, borrowerId;
+ String lenderEmail, borrowerEmail;
+ double amount;
+ String comment;
+ String transDate;
+ String ID;
+ boolean resolved;
+}
+class BaseTransaction extends Transaction{
+
+ String lenderEmail, borrowerEmail;
double amount;
String comment;
- Transaction() {
- this.lenderId = 0;
- this.borrowerId = 0;
+ BaseTransaction() {
+ this.lenderEmail = "";
+ this.borrowerEmail = "";
this.amount = 0;
this.comment = "";
+ this.resolved = false;
+ this.transDate = "";
}
- Transaction(int lenderId, int borrowerId, double amount, String comment)
+ BaseTransaction(String lenderEmail, String borrowerEmail, double amount, String comment)
{
- this.lenderId = lenderId;
- this.borrowerId = borrowerId;
+ this.lenderEmail = lenderEmail;
+ this.borrowerEmail = borrowerEmail;
+ this.amount = amount;
+ this.comment = comment;
+ }
+ BaseTransaction(String lenderEmail, String borrowerEmail, double amount, String comment, boolean resolved, String transDate, String ID)
+ {
+ this.lenderEmail = lenderEmail;
+ this.borrowerEmail = borrowerEmail;
+ this.amount = amount;
+ this.comment = comment;
+ this.resolved = resolved;
+ this.transDate = transDate;
+ this.ID = ID;
+ }
+ public String getLenderEmail() {
+ return lenderEmail;
+ }
+ public void setLenderEmail(String lenderEmail) {
+ this.lenderEmail = lenderEmail;
+ }
+ public String getTransDate() {
+ return transDate;
+ }
+ public void setTransDate(String transDate) {
+ this.transDate = transDate;
+ }
+ public String getBorrowerEmail() {
+ return borrowerEmail;
+ }
+ public void setBorrowerEmail(String borrowerEmail) {
+ this.borrowerEmail = borrowerEmail;
+ }
+ public double getAmount() {
+ return amount;
+ }
+ public void setAmount(double amount) {
this.amount = amount;
+ }
+ public String getComment() {
+ return comment;
+ }
+ public void setComment(String comment) {
this.comment = comment;
}
+ public String getID() {
+ return ID;
+ }
+ public void setID(String ID) {
+ this.ID = ID;
+ }
- //Example for outside code: t.sendTransToServer();
- void sendTransactionToServer()
+ public boolean getResolved() {
+ return resolved;
+ }
+ public void setResolved(boolean resolved) {
+ this.resolved = resolved;
+ }
+}
+class ResolveTransaction extends Transaction{
+ private double amount;
+ private String message;
+ private String date; //format: "Nov 17 2013, 12:19 AM"
+
+
+ ResolveTransaction (double amount, String message)
{
- //json + sql magic
+ this.amount = amount;
+ this.message = message;
+ this.date = currDateToString();
+ this.resolved = false;
+ }
+ ResolveTransaction (String amount, String message)
+ {
+ this.amount = Double.parseDouble(amount);
+ this.message = message;
+ this.date = currDateToString();
+ this.resolved = false;
+ }
+ static String currDateToString()
+ {
+ Calendar c = Calendar.getInstance();
+ String min = c.get(Calendar.MINUTE) + "";
+ if(min.length() == 1) //changes 3 into 03
+ min = "0" + min;
+ int hour = c.get(Calendar.HOUR);
+ if (hour == 0)
+ hour = 12;
+ String am_pm = (c.get(Calendar.AM_PM) == 0) ? "AM" : "PM";
+ String month;
+ switch(c.get(Calendar.MONTH))
+ {
+ case 0: month = "Jan"; break;
+ case 1: month = "Feb"; break;
+ case 2: month = "Mar"; break;
+ case 3: month = "Apr"; break;
+ case 4: month = "May"; break;
+ case 5: month = "Jun"; break;
+ case 6: month = "Jul"; break;
+ case 7: month = "Aug"; break;
+ case 8: month = "Sep"; break;
+ case 9: month = "Oct"; break;
+ case 10: month = "Nov"; break;
+ case 11: month = "Dec"; break;
+ default: throw new IllegalArgumentException("Month broken");
+ }
+ String s = (month + " " + c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.YEAR) + ", " + hour + ":" + min + " " + am_pm);
+ //Should return a string that looks like "Nov 17 2013, 12:19 AM"
+ return s;
}
- //Example for outside code: Transaction t = getTransFromServer(wmacfarlane@ufl.edu, arnav@ufl.edu)
- static ArrayList getTransactionsFromServer(String lenderEmail, String borrowerEmail)
+ public double getAmount() {
+ return amount;
+ }
+ public void setAmount(double amount) {
+ this.amount = amount;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public String getDate() {
+ return date;
+ }
+ public void setDate(String date) {
+ this.date = date;
+ }
+ //TODO:
+ public void sendToServer() //send this transaction to server. Server needs to grab the "to" field and send it to them
+ {
+
+ }
+ //TODO:
+ public static ArrayList updateTransactions(String email)
{
- //json + sql magic
- ArrayList a = new ArrayList();
- //a.add(T1);
- //a.add(T2);
- //...
- return a; //dummy code to silence errors
+ ArrayList trans = new ArrayList ();
+ //populates this user's notifications arraylist
+ return trans;
+
}
}
diff --git a/PayBack/src/com/example/payback/Transaction1Activity.java b/PayBack/src/com/example/payback/Transaction1Activity.java
index e88bad7..b9e3561 100644
--- a/PayBack/src/com/example/payback/Transaction1Activity.java
+++ b/PayBack/src/com/example/payback/Transaction1Activity.java
@@ -1,8 +1,11 @@
package com.example.payback;
import java.text.DecimalFormat;
+import java.util.ArrayList;
import android.annotation.SuppressLint;
+import android.app.Activity;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Editable;
@@ -11,8 +14,17 @@
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
+import android.widget.RadioButton;
-public class Transaction1Activity extends TitleActivity {
+public class Transaction1Activity extends TitleActivity
+{
+ boolean button1Selected;
+ boolean button2Selected;
+ static Activity activityInstance;
+ static PageKillReceiver pkr; //these are the variables
+ static IntentFilter filterPKR; //used for PageKillReceiver.java
+ static NoBackingReceiver nbr; //these are the variables
+ static IntentFilter filterNBR; //used for NoBackingReceiver.java
@SuppressLint("CutPasteId")
@Override
@@ -20,11 +32,62 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Create Transaction",R.layout.activity_transaction1);
+
+ activityInstance = this;
+
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filterPKR = new IntentFilter();
+ filterPKR.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filterPKR);
+
+ nbr = new NoBackingReceiver(); nbr.setActivityInstance(activityInstance);
+ filterNBR = new IntentFilter();
+ filterNBR.addAction("com.Payback.MainActivity_Intent");
+ registerReceiver(nbr, filterNBR);
+
+
+ RadioButton radio1 = (RadioButton) findViewById(R.id.radioauto);
+ RadioButton radio2 = (RadioButton) findViewById(R.id.radioman);
+
+ Bundle oldbundle = getIntent().getExtras();
+ boolean button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ boolean button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
+
+ radio1.setChecked(button1Selected);
+ radio2.setChecked(button2Selected);
+
EditText text = (EditText)findViewById(R.id.editText1);
+
+ int transCostInt = oldbundle.getInt("Transaction1transCost");
+ String transCoststring;
+ if(transCostInt == 0){
+ transCoststring = "";
+ }
+ else{
+ DecimalFormat dec = new DecimalFormat("0.00");
+ transCoststring = Integer.toString(transCostInt);
+ Float in=Float.parseFloat(transCoststring);
+ float percen = in/100;
+
+ text.setText("$"+dec.format(percen));
+ text.setSelection(text.getText().length());
+
+ Button button=(Button) findViewById(R.id.tran1buttonnext);
+ button.setEnabled(true);
+ }
+
+ String transCommentString = oldbundle.getString("Transaction1transComment");
+
+ EditText text2 = (EditText)findViewById(R.id.editText2);
+ text2.setText(transCommentString);
+
+
+
+
text.requestFocus();
text.setRawInputType(Configuration.KEYBOARD_12KEY);
-
+
text.addTextChangedListener(new TextWatcher(){
EditText text = (EditText)findViewById(R.id.editText1);
DecimalFormat dec = new DecimalFormat("0.00");
@@ -61,13 +124,6 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
});
}
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.transaction1, menu);
- return true;
- }
private boolean checkEditText(EditText edit) {
String stringnumber = edit.getText().toString().substring(1);
@@ -87,31 +143,92 @@ void updateButtonState() {
button.setEnabled(true);
}
+ public void onRadioButtonClicked(View view)
+ {
+// Bundle oldbundle = getIntent().getExtras();
+// int transCostInt = oldbundle.getInt("Transaction1transCost");
+// int numContacts = oldbundle.getParcelableArrayList("Transaction2selected").size();
+// int lenderShare = transCostInt/(numContacts+1);
+// String evenLenderShare = Integer.toString(lenderShare);
+//
+// evenLenderShare = "$" + evenLenderShare;
+// int elsLength = evenLenderShare.length();
+// String lenderText = evenLenderShare.substring(0, elsLength-2) + "." + evenLenderShare.substring(elsLength-2, elsLength);
+
+ boolean checked = ((RadioButton) view).isChecked();
+
+ switch(view.getId())
+ {
+ case R.id.radioauto:
+ if (checked)
+ {
+// EditText transCost = (EditText)findViewById(R.id.lenderamount);
+// transCost.setText(lenderText);
+
+ button1Selected = true;
+ button2Selected = false;
+ }
+ break;
+ case R.id.radioman:
+ if (checked)
+ {
+ //There's a bug where if you hit manual and then type it'll change the front rather then the back
+ //For example. hit manual. edittext = $0.00. hit "1". expected is $0.01. actually is $10.00.
+// EditText transCost = (EditText)findViewById(R.id.lenderamount);
+// transCost.setText("$0.00");
+
+ button1Selected = false;
+ button2Selected = true;
+ }
+ break;
+ }
+ }
+
public void showMainMenu(View view)
{
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
+ finish();
}
public void showTrans2(View view)
{
+ Bundle oldbundle = getIntent().getExtras();
+
EditText transCost = (EditText)findViewById(R.id.editText1);
EditText transComment = (EditText)findViewById(R.id.editText2);
String stringnumber = transCost.getText().toString().substring(1);
Float floatnumber = Float.parseFloat(stringnumber);
int transCostInt = (int) (floatnumber * 100F);
-
+
String transCommentString = transComment.getText().toString();
+
+ ArrayList transselected = oldbundle.getParcelableArrayList("Transaction2selected");
+ int translenderamountInt = oldbundle.getInt("Transaction3lenderamount");
+ ArrayList lendsharelist = oldbundle.getIntegerArrayList("Transaction3borroweramountlist");
+
+ if(!(button1Selected ^ button2Selected)){
+ button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
+ }
+
Intent intent = new Intent(getApplicationContext(), Transaction2Activity.class);
Bundle Bundle = new Bundle();
Bundle.putInt("Transaction1transCost", transCostInt);
Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", transselected);
+ Bundle.putInt("Transaction3lenderamount", translenderamountInt);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+
intent.putExtras(Bundle);
startActivity(intent);
+ finish();
}
}
diff --git a/PayBack/src/com/example/payback/Transaction2Activity.java b/PayBack/src/com/example/payback/Transaction2Activity.java
index a06af3a..3107862 100644
--- a/PayBack/src/com/example/payback/Transaction2Activity.java
+++ b/PayBack/src/com/example/payback/Transaction2Activity.java
@@ -4,7 +4,9 @@
import java.util.HashMap;
import java.util.List;
import android.os.Bundle;
+import android.app.Activity;
import android.content.Intent;
+import android.content.IntentFilter;
import android.view.Menu;
import android.view.View;
import android.widget.ExpandableListView;
@@ -15,6 +17,12 @@ public class Transaction2Activity extends TitleActivity {
private List listHeader;
private HashMap> listChild;
+ static Activity activityInstance;
+ static PageKillReceiver pkr; //these are the variables
+ static IntentFilter filterPKR; //used for PageKillReceiver.java
+ static NoBackingReceiver nbr; //these are the variables
+ static IntentFilter filterNBR; //used for NoBackingReceiver.java
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -24,81 +32,37 @@ protected void onCreate(Bundle savedInstanceState) {
modifyTitle("Create Transaction",R.layout.activity_transaction2_expandablecontactlist_main);
ExpandableListView expListView = (ExpandableListView) findViewById(R.id.expandlistView);
- createData();
+ activityInstance = this;
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filterPKR = new IntentFilter();
+ filterPKR.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filterPKR);
+
+ nbr = new NoBackingReceiver(); nbr.setActivityInstance(activityInstance);
+ filterNBR = new IntentFilter();
+ filterNBR.addAction("com.Payback.MainActivity_Intent");
+ registerReceiver(nbr, filterNBR);
+
+ createData();
+
final Transaction2Activity_expandablecontactlist_adapter listAdapter = new Transaction2Activity_expandablecontactlist_adapter(this, listHeader, listChild);
expListView.setAdapter(listAdapter);
-
+ expListView.expandGroup(0);
}
public void createData() {
listHeader = new ArrayList();
listChild = new HashMap>();
-
- //test friends
- Friend tests1 = new Friend("Place", "Ment");
- Friend tests2 = new Friend("For", "Later");
- Friend tests3 = new Friend("Sprints", "Lname");
- Friend test1 = new Friend("Price", "Gutierrez");
- Friend test2 = new Friend("Vanna", "Mccullough");
- Friend test3 = new Friend("Wyatt", "Paul");
- Friend test4 = new Friend("Thaddeus", "Robbins");
- Friend test5 = new Friend("Rooney", "Dejesus");
- Friend test6 = new Friend("Xavier", "Wolfe");
- Friend test7 = new Friend("Byron", "Raymond");
- Friend test8 = new Friend("Quinn", "Whitfield");
- Friend test9 = new Friend("Farrah", "Moon");
- Friend test10 = new Friend("Ainsley", "Whitehead");
- Friend test11 = new Friend("Josephine", "Patton");
- Friend test12 = new Friend("Mariko", "Patton");
- Friend test13 = new Friend("Raphael", "Fitzgerald");
- Friend test14 = new Friend("Deacon", "Daniels");
- Friend test15 = new Friend("Delilah", "Fletcher");
- Friend test16 = new Friend("Robin", "Andrews");
- Friend test17 = new Friend("Melvin", "Price");
-
-
- listHeader.add("Groups");
- List child0 = new ArrayList();
-
- child0.add(tests1);
- child0.add(tests2);
- child0.add(tests3);
-
- listChild.put(listHeader.get(0), child0);
listHeader.add("Individual");
- List child1 = new ArrayList();
+ List child1 = user.getFriends();
- child1.add(test1);
- child1.add(test2);
- child1.add(test3);
- child1.add(test4);
- child1.add(test5);
- child1.add(test6);
- child1.add(test7);
- child1.add(test8);
- child1.add(test9);
- child1.add(test10);
- child1.add(test11);
- child1.add(test12);
- child1.add(test13);
- child1.add(test14);
- child1.add(test15);
- child1.add(test16);
- child1.add(test17);
-
- listChild.put(listHeader.get(1), child1);
+ listChild.put(listHeader.get(0), child1);
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.transaction2, menu);
- return true;
- }
public void showCreateContact(View view)
{
@@ -122,18 +86,42 @@ public void checktomoveontotrans3(View view){
}
}
- public void showTrans3(View view)
- {
- Bundle oldbundle = getIntent().getExtras();
+ public void showTrans1(View view)
+ {
+ Bundle oldbundle = getIntent().getExtras();
+
int transCostInt = oldbundle.getInt("Transaction1transCost");
- String transCommentString = oldbundle.getString("Transaction1transComment");
-
- Intent intent = new Intent(this, Transaction3Activity.class);
+ String transCommentString = oldbundle.getString("Transaction1transComment");
+ ArrayList transselected = oldbundle.getParcelableArrayList("Transaction2selected");
+ int translenderamountInt = oldbundle.getInt("Transaction3lenderamount");
+ ArrayList lendsharelist = oldbundle.getIntegerArrayList("Transaction3borroweramountlist");
+ boolean button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ boolean button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
+
+ Intent intent = new Intent(this, Transaction1Activity.class);
Bundle Bundle = new Bundle();
Bundle.putInt("Transaction1transCost", transCostInt);
Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", transselected);
+ Bundle.putInt("Transaction3lenderamount", translenderamountInt);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+ intent.putExtras(Bundle);
+ startActivity(intent);
+ finish();
+ }
+
+ public void showTrans3(View view)
+ {
+ Bundle oldbundle = getIntent().getExtras();
+ int transCostInt = oldbundle.getInt("Transaction1transCost");
+ String transCommentString = oldbundle.getString("Transaction1transComment");
+ ArrayList lendsharelist = new ArrayList();
+ boolean button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ boolean button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
ArrayList selectedContacts = new ArrayList();
for(int i = 0; i < listHeader.size(); i++){
String currentheader = listHeader.get(i);
@@ -143,17 +131,53 @@ public void showTrans3(View view)
}
}
}
-
- Bundle.putParcelableArrayList("Transaction2selected", selectedContacts);
+ int numContacts = selectedContacts.size();
+ int lenderShare = transCostInt/(numContacts+1);
+ int totaltrans = lenderShare;
+ for(int i = 0; i < numContacts; i ++){
+ lendsharelist.add(lenderShare);
+ totaltrans = totaltrans + lenderShare;
+ }
+ if(totaltrans != transCostInt){
+ lenderShare = lenderShare + (transCostInt - totaltrans);
+ }
+
+
+
+ if(button1Selected){
+ Intent intent = new Intent(this, Transaction5Activity.class);
+ Bundle Bundle = new Bundle();
+
+ Bundle.putInt("Transaction1transCost", transCostInt);
+ Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", selectedContacts);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putInt("Transaction3lenderamount", lenderShare);
- intent.putExtras(Bundle);
- startActivity(intent);
+ intent.putExtras(Bundle);
+ startActivity(intent);
+ }
+ else if(button2Selected)
+ {
+ Intent intent = new Intent(this, Transaction4Activity.class);
+ Bundle Bundle = new Bundle();
+
+ Bundle.putInt("Transaction1transCost", transCostInt);
+ Bundle.putString("Transaction1transComment", transCommentString);
+ Bundle.putParcelableArrayList("Transaction2selected", selectedContacts);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putInt("Transaction3lenderamount", lenderShare);
+
+ intent.putExtras(Bundle);
+ startActivity(intent);
+ }
+ finish();
}
- public void showTrans1(View view)
- {
- Intent intent = new Intent(this, Transaction1Activity.class);
- startActivity(intent);
- }
+
}
diff --git a/PayBack/src/com/example/payback/Transaction3Activity.java b/PayBack/src/com/example/payback/Transaction3Activity.java
index 38bbe01..d80c2c7 100644
--- a/PayBack/src/com/example/payback/Transaction3Activity.java
+++ b/PayBack/src/com/example/payback/Transaction3Activity.java
@@ -1,126 +1,64 @@
package com.example.payback;
-import java.text.DecimalFormat;
import java.util.ArrayList;
import android.os.Bundle;
-import android.annotation.SuppressLint;
import android.content.Intent;
-import android.content.res.Configuration;
-import android.text.Editable;
-import android.text.TextWatcher;
+import android.app.Activity;
+import android.content.IntentFilter;
import android.view.Menu;
import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
import android.widget.RadioButton;
-import android.widget.Toast;
public class Transaction3Activity extends TitleActivity {
+ boolean button1Selected;
+ boolean button2Selected;
- private boolean button1Selected = false;
- private boolean button2Selected = true;
+ static Activity activityInstance;
+ static PageKillReceiver pkr; //these are the variables
+ static IntentFilter filterPKR; //used for PageKillReceiver.java
+ static NoBackingReceiver nbr; //these are the variables
+ static IntentFilter filterNBR; //used for NoBackingReceiver.java
+
- @SuppressLint("CutPasteId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
modifyTitle("Lender's Share",R.layout.activity_transaction3);
-
- EditText transCost = (EditText) findViewById(R.id.lenderamount);
- EditText text = (EditText) findViewById(R.id.lenderamount);
-
- text.setRawInputType(Configuration.KEYBOARD_12KEY);
-
- text.addTextChangedListener(new TextWatcher(){
- EditText text = (EditText)findViewById(R.id.lenderamount);
- DecimalFormat dec = new DecimalFormat("0.00");
- public void afterTextChanged(Editable arg0) {
- }
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- if(!s.toString().matches("^\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?$"))
- {
- String userInput= ""+ s.toString().replaceAll("[^\\d]", "");
- if (userInput.length() > 0) {
- Float in=Float.parseFloat(userInput);
- float percen = in/100;
- text.setText("$"+dec.format(percen));
- text.setSelection(text.getText().length());
- }
- }
- }
- });
-
- transCost.addTextChangedListener(new TextWatcher() {
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- updateButtonState();
- }
+ RadioButton radio1 = (RadioButton) findViewById(R.id.radio1);
+ RadioButton radio2 = (RadioButton) findViewById(R.id.radio2);
- @Override
- public void afterTextChanged(Editable s) {
- }
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- });
- }
+ Bundle oldbundle = getIntent().getExtras();
+ boolean button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ boolean button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
- private boolean checkEditText(EditText edit) {
- String stringnumber = edit.getText().toString().substring(1);
- Float floatnumber = Float.parseFloat(stringnumber);
- int intnumber = (int) (floatnumber * 100F);
- return intnumber < 0;
- }
-
- void updateButtonState() {
- EditText transCost= (EditText) findViewById(R.id.lenderamount);
+ radio1.setChecked(button1Selected);
+ radio2.setChecked(button2Selected);
+
+ activityInstance = this;
- Button button=(Button) findViewById(R.id.tran3buttonnext);
+ pkr = new PageKillReceiver(); pkr.setActivityInstance(activityInstance);
+ filterPKR = new IntentFilter();
+ filterPKR.addAction("com.Payback.Logout_Intent");
+ registerReceiver(pkr, filterPKR);
- if(checkEditText(transCost))
- button.setEnabled(false);
- else
- button.setEnabled(true);
+ nbr = new NoBackingReceiver(); nbr.setActivityInstance(activityInstance);
+ filterNBR = new IntentFilter();
+ filterNBR.addAction("com.Payback.MainActivity_Intent");
+ registerReceiver(nbr, filterNBR);
}
-
- /*public void onRadioButtonClick(View view){
- RadioButton button = (RadioButton) view;
- if ( button.getId() == R.id.radio1) {
- button1Selected = true;
- button2Selected = false;
- }
-
- else if (button.getId() == R.id.radio2) {
- button1Selected = false;
- button2Selected = true;
- }
-
- }*/
-
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.transaction3, menu);
- return true;
- }
-
public void onRadioButtonClicked(View view)
{
- Bundle oldbundle = getIntent().getExtras();
- int transCostInt = oldbundle.getInt("Transaction1transCost");
- int numContacts = oldbundle.getParcelableArrayList("Transaction2selected").size();
- int lenderShare = transCostInt/(numContacts+1);
- String evenLenderShare = Integer.toString(lenderShare);
-
- evenLenderShare = "$" + evenLenderShare;
- int elsLength = evenLenderShare.length();
- String lenderText = evenLenderShare.substring(0, elsLength-2) + "." + evenLenderShare.substring(elsLength-2, elsLength);
+// Bundle oldbundle = getIntent().getExtras();
+// int transCostInt = oldbundle.getInt("Transaction1transCost");
+// int numContacts = oldbundle.getParcelableArrayList("Transaction2selected").size();
+// int lenderShare = transCostInt/(numContacts+1);
+// String evenLenderShare = Integer.toString(lenderShare);
+//
+// evenLenderShare = "$" + evenLenderShare;
+// int elsLength = evenLenderShare.length();
+// String lenderText = evenLenderShare.substring(0, elsLength-2) + "." + evenLenderShare.substring(elsLength-2, elsLength);
boolean checked = ((RadioButton) view).isChecked();
@@ -129,8 +67,8 @@ public void onRadioButtonClicked(View view)
case R.id.radio1:
if (checked)
{
- EditText transCost = (EditText)findViewById(R.id.lenderamount);
- transCost.setText(lenderText);
+// EditText transCost = (EditText)findViewById(R.id.lenderamount);
+// transCost.setText(lenderText);
button1Selected = true;
button2Selected = false;
@@ -141,8 +79,8 @@ public void onRadioButtonClicked(View view)
{
//There's a bug where if you hit manual and then type it'll change the front rather then the back
//For example. hit manual. edittext = $0.00. hit "1". expected is $0.01. actually is $10.00.
- EditText transCost = (EditText)findViewById(R.id.lenderamount);
- transCost.setText("$0.00");
+// EditText transCost = (EditText)findViewById(R.id.lenderamount);
+// transCost.setText("$0.00");
button1Selected = false;
button2Selected = true;
@@ -150,39 +88,39 @@ public void onRadioButtonClicked(View view)
break;
}
}
- public void checktomoveontotrans4(View view){
- Bundle oldbundle = getIntent().getExtras();
- int transCostInt = oldbundle.getInt("Transaction1transCost");
-
- EditText translenderamount = (EditText)findViewById(R.id.lenderamount);
- String stringnumber = translenderamount.getText().toString().substring(1);
- Float floatnumber = Float.parseFloat(stringnumber);
- int translenderamountInt = (int) (floatnumber * 100F);
-
- if(translenderamountInt <= transCostInt){
- showTrans4or5(view);
- }
- else{
- Toast.makeText(getApplicationContext(), "Lent amount is greater then the transaction", Toast.LENGTH_SHORT).show();
- }
-
- }
+
public void showTrans2(View view)
{
Intent intent = new Intent(this, Transaction2Activity.class);
+
+
Bundle oldbundle = getIntent().getExtras();
int transCostInt = oldbundle.getInt("Transaction1transCost");
String transCommentString = oldbundle.getString("Transaction1transComment");
+ ArrayList transselected = oldbundle.getParcelableArrayList("Transaction2selected");
+ int translenderamountInt = oldbundle.getInt("Transaction3lenderamount");
+ ArrayList lendsharelist = oldbundle.getIntegerArrayList("Transaction3borroweramountlist");
+ if(!(button1Selected ^ button2Selected)){
+ button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
+ }
+
Bundle Bundle = new Bundle();
+
Bundle.putInt("Transaction1transCost", transCostInt);
Bundle.putString("Transaction1transComment", transCommentString);
-
+ Bundle.putParcelableArrayList("Transaction2selected", transselected);
+ Bundle.putInt("Transaction3lenderamount", translenderamountInt);
+ Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putBoolean("Transaction3button1Selected", button1Selected);
+ Bundle.putBoolean("Transaction3button2Selected", button2Selected);
+
intent.putExtras(Bundle);
startActivity(intent);
-
+ finish();
}
public void showTrans4or5(View view)
@@ -195,6 +133,11 @@ public void showTrans4or5(View view)
ArrayList lendsharelist = new ArrayList();
+ if(!(button1Selected ^ button2Selected)){
+ button1Selected = oldbundle.getBoolean("Transaction3button1Selected");
+ button2Selected = oldbundle.getBoolean("Transaction3button2Selected");
+ }
+
if(button1Selected){
Intent intent = new Intent(this, Transaction5Activity.class);
Bundle Bundle = new Bundle();
@@ -208,16 +151,23 @@ public void showTrans4or5(View view)
int numContacts = oldbundle.getParcelableArrayList("Transaction2selected").size();
int lenderShare = transCostInt/(numContacts+1);
+ int totaltrans = lenderShare;
for(int i = 0; i < numContacts; i ++){
lendsharelist.add(lenderShare);
+ totaltrans = totaltrans + lenderShare;
+ }
+ if(totaltrans != transCostInt){
+ lenderShare = lenderShare + (transCostInt - totaltrans);
}
+
Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
Bundle.putInt("Transaction3lenderamount", lenderShare);
intent.putExtras(Bundle);
startActivity(intent);
}
- else if(button2Selected){
+ else if(button2Selected)
+ {
Intent intent = new Intent(this, Transaction4Activity.class);
Bundle Bundle = new Bundle();
@@ -227,24 +177,23 @@ else if(button2Selected){
Bundle.putBoolean("Transaction3button1Selected", button1Selected);
Bundle.putBoolean("Transaction3button2Selected", button2Selected);
- EditText translenderamount = (EditText)findViewById(R.id.lenderamount);
- String stringnumber = translenderamount.getText().toString().substring(1);
- Float floatnumber = Float.parseFloat(stringnumber);
- int translenderamountInt = (int) (floatnumber * 100F);
- Bundle.putInt("Transaction3lenderamount", translenderamountInt);
-
int numContacts = oldbundle.getParcelableArrayList("Transaction2selected").size();
- int lenderShare = (transCostInt-translenderamountInt)/(numContacts);
+ int lenderShare = transCostInt/(numContacts+1);
+ int totaltrans = lenderShare;
for(int i = 0; i < numContacts; i ++){
lendsharelist.add(lenderShare);
+ totaltrans = totaltrans + lenderShare;
+ }
+ if(totaltrans != transCostInt){
+ lenderShare = lenderShare + (transCostInt - totaltrans);
}
Bundle.putIntegerArrayList("Transaction3borroweramountlist", lendsharelist);
+ Bundle.putInt("Transaction3lenderamount", lenderShare);
-
intent.putExtras(Bundle);
startActivity(intent);
}
-
+ finish();
}
diff --git a/PayBack/src/com/example/payback/Transaction4Activity.java b/PayBack/src/com/example/payback/Transaction4Activity.java
index 38576f4..5c68765 100644
--- a/PayBack/src/com/example/payback/Transaction4Activity.java
+++ b/PayBack/src/com/example/payback/Transaction4Activity.java
@@ -1,11 +1,14 @@
package com.example.payback;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
-import android.os.Bundle;
+import android.app.Activity;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
@@ -13,105 +16,160 @@
import android.widget.TextView;
import android.widget.Toast;
-public class Transaction4Activity extends TitleActivity {
-
- ListView listView;
- EditText editing;
+public class Transaction4Activity extends TitleActivity
+{
+ ListView listView; //shows items in a vertically scrolling list
+ EditText editing;
TextView text;
- ArrayList