diff --git a/.gitignore b/.gitignore
index 7307e71..dbba6d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,229 +1,10 @@
-#################
-## Android
-#################
-
-gen/
-out/
-
-#################
-## Android Studio/Intellij
-#################
-
-.idea
-*.iml
-
-#################
-## Eclipse
-#################
-
-*.pydevproject
-.project
-.metadata
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.classpath
-.settings/
-.loadpath
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# CDT-specific
-.cproject
-
-# PDT-specific
-.buildpath
-
-
-#################
-## Visual Studio
-#################
-
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
-*.user
-*.sln.docstates
-
-# Build results
-
-[Dd]ebug/
-[Rr]elease/
-x64/
-build/
-[Bb]in/
-[Oo]bj/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-*_i.c
-*_p.c
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.log
-*.scc
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-*.ncrunch*
-.*crunch*.local.xml
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.Publish.xml
-*.pubxml
-
-# NuGet Packages Directory
-## TODO: If you have NuGet Package Restore enabled, uncomment the next line
-#packages/
-
-# Windows Azure Build Output
-csx
-*.build.csdef
-
-# Windows Store app package directory
-AppPackages/
-
-# Others
-sql/
-*.Cache
-ClientBin/
-[Ss]tyle[Cc]op.*
-~$*
-*~
-*.dbmdl
-*.[Pp]ublish.xml
-*.pfx
-*.publishsettings
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file to a newer
-# Visual Studio version. Backup files are not needed, because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-App_Data/*.mdf
-App_Data/*.ldf
-
-#############
-## Windows detritus
-#############
-
-# Windows image file caches
-Thumbs.db
-ehthumbs.db
-
-# Folder config file
-Desktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Mac crap
+.gradle
+/local.properties
+/.idea/workspace.xml
.DS_Store
+/build.gradle
+/project.properties
+/gradlew
+/gradlew.bat
-
-#############
-## Python
-#############
-
-*.py[co]
-
-# Packages
-*.egg
-*.egg-info
-dist/
-build/
-eggs/
-parts/
-var/
-sdist/
-develop-eggs/
-.installed.cfg
-
-# Installer logs
-pip-log.txt
-
-# Unit test / coverage reports
-.coverage
-.tox
-
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
+.idea
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..01b420f
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+ClassNote
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..217af47
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..26aaedc
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..b153e48
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..948386a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..c80f219
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
deleted file mode 100644
index 437d64b..0000000
--- a/AndroidManifest.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/ClassNote.iml b/ClassNote.iml
new file mode 100644
index 0000000..d9c631d
--- /dev/null
+++ b/ClassNote.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..80eec1a
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,16 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.9.+'
+ }
+}
+
+allprojects {
+ repositories {
+ mavenCentral()
+ }
+}
diff --git a/classnote/.gitignore b/classnote/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/classnote/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/classnote/build.gradle b/classnote/build.gradle
new file mode 100644
index 0000000..e343e94
--- /dev/null
+++ b/classnote/build.gradle
@@ -0,0 +1,26 @@
+apply plugin: 'android'
+
+android {
+ compileSdkVersion 19
+ buildToolsVersion "19.0.1"
+
+ defaultConfig {
+ minSdkVersion 8
+ targetSdkVersion 19
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ runProguard false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+ }
+ }
+}
+
+dependencies {
+ compile 'com.android.support:support-v4:19.0.1'
+ compile 'com.android.support:appcompat-v7:19.0.1'
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+ compile files('libs/android-async-http-1.4.4.jar')
+}
diff --git a/classnote/classnote.iml b/classnote/classnote.iml
new file mode 100644
index 0000000..8b13d6e
--- /dev/null
+++ b/classnote/classnote.iml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/libs/android-async-http-1.4.4.jar b/classnote/libs/android-async-http-1.4.4.jar
new file mode 100644
index 0000000..75af701
Binary files /dev/null and b/classnote/libs/android-async-http-1.4.4.jar differ
diff --git a/classnote/proguard-rules.txt b/classnote/proguard-rules.txt
new file mode 100644
index 0000000..b7ef581
--- /dev/null
+++ b/classnote/proguard-rules.txt
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in C:/Program Files (x86)/Android/android-studio1/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
\ No newline at end of file
diff --git a/classnote/src/main/AndroidManifest.xml b/classnote/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..7d793d7
--- /dev/null
+++ b/classnote/src/main/AndroidManifest.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/auth/AuthenticationService.java b/classnote/src/main/java/com/hellabreakfast/classnote/auth/AuthenticationService.java
new file mode 100644
index 0000000..311fc42
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/auth/AuthenticationService.java
@@ -0,0 +1,17 @@
+package com.hellabreakfast.classnote.auth;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+/**
+ * This class is necessary for the AccountManager integration
+ */
+public class AuthenticationService extends Service {
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return new GatechAccountAuthenticator(this).getIBinder();
+ }
+
+}
\ No newline at end of file
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/auth/GatechAccountAuthenticator.java b/classnote/src/main/java/com/hellabreakfast/classnote/auth/GatechAccountAuthenticator.java
new file mode 100644
index 0000000..ee091ef
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/auth/GatechAccountAuthenticator.java
@@ -0,0 +1,73 @@
+package com.hellabreakfast.classnote.auth;
+
+import android.accounts.AbstractAccountAuthenticator;
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorResponse;
+import android.accounts.AccountManager;
+import android.accounts.NetworkErrorException;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.hellabreakfast.classnote.ui.UpdatePasswordActivity;
+
+/**
+ * This class is necessary for the AccountManager integration
+ */
+public class GatechAccountAuthenticator extends AbstractAccountAuthenticator {
+
+ public static String ACCOUNT_TYPE = "edu.gatech.classnote";
+ Context mContext;
+
+ public GatechAccountAuthenticator(Context context) {
+ super(context);
+ this.mContext = context;
+ }
+
+ @Override
+ public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
+ return null;
+ }
+
+ @Override
+ public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
+ throws NetworkErrorException {
+
+ final Bundle result;
+ final Intent intent;
+
+ intent = new Intent(this.mContext, UpdatePasswordActivity.class);
+ intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
+
+ result = new Bundle();
+ result.putParcelable(AccountManager.KEY_INTENT, intent);
+
+ return result;
+ }
+
+ @Override
+ public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException {
+ return null;
+ }
+
+ @Override
+ public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
+ return null;
+ }
+
+ @Override
+ public String getAuthTokenLabel(String authTokenType) {
+ return null;
+ }
+
+ @Override
+ public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
+ return null;
+ }
+
+ @Override
+ public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException {
+ return null;
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/Announcement.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/Announcement.java
new file mode 100644
index 0000000..3b953ab
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/Announcement.java
@@ -0,0 +1,103 @@
+package com.hellabreakfast.classnote.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * An Announcement is one of the T-Square, from-teacher notifications that are not actually assignments
+ * but should be visible within the list function, thus it implements DataItem so we know we can
+ * show it in our upcoming list
+ */
+public class Announcement implements Comparable, Serializable {
+
+ public String name;
+ public String author;
+ public String description;
+ public Boolean isRead;
+ public Date dueDate;
+ public Course course;
+ public String id;
+
+ public Announcement(String id, String name, String author, String description, Boolean isRead, Date dueDate) {
+ this.id = id;
+ this.name = name;
+ this.author = author;
+ this.description = description;
+ this.isRead = isRead;
+ this.dueDate = dueDate;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+
+ public Boolean getIsRead() {
+ return isRead;
+ }
+
+
+ public Date getDueDate() {
+ return dueDate;
+ }
+
+
+ public Course getCourse() {
+ return course;
+ }
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+
+ public void setIsRead(Boolean isRead) {
+ this.isRead = isRead;
+ }
+
+
+ public void setDueDate(Date dueDate) {
+ this.dueDate = dueDate;
+ }
+
+
+ public void setCourse(Course course) {
+ this.course = course;
+ }
+
+ @Override
+ public int compareTo(Announcement announcement) {
+ return dueDate.compareTo(announcement.dueDate);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ return object instanceof Announcement && ((Announcement)object).getId().equals(this.getId());
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/Assignment.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/Assignment.java
new file mode 100644
index 0000000..7f9b31a
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/Assignment.java
@@ -0,0 +1,27 @@
+package com.hellabreakfast.classnote.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * An assignment is a normal, t-square assignment that will be shown in the assignments list
+ * and be able to be added to the final grade of the course
+ */
+public class Assignment extends GradedWork implements Comparable, Serializable {
+ private String id;
+
+ public Assignment(String id, String name, String description, Boolean isRead, Date dueDate) {
+ super(name, description, isRead, dueDate, 0,0,0,0);
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public int compareTo(Assignment assignment) {
+ return dueDate.compareTo(assignment.dueDate);
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/AsyncResultHandler.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/AsyncResultHandler.java
new file mode 100644
index 0000000..25b6781
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/AsyncResultHandler.java
@@ -0,0 +1,8 @@
+package com.hellabreakfast.classnote.model;
+
+public interface AsyncResultHandler {
+
+ public void onSuccess();
+ public void onFailure();
+
+}
diff --git a/src/com/rumbleworks/classnote/Course.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/Course.java
similarity index 51%
rename from src/com/rumbleworks/classnote/Course.java
rename to classnote/src/main/java/com/hellabreakfast/classnote/model/Course.java
index 461b7f2..d8f306e 100644
--- a/src/com/rumbleworks/classnote/Course.java
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/Course.java
@@ -1,5 +1,6 @@
-package com.rumbleworks.classnote;
+package com.hellabreakfast.classnote.model;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -9,38 +10,35 @@
* one for objects that inherit from GradedWork (tests and assignments)
* and the other for Announcements from the professor
*/
+public class Course implements Serializable {
+
+ private String title, siteId;
-public class Course {
- private String courseName;
- private String courseSchool;
- private int courseNumber;
-
private ArrayList assignmentList;
private ArrayList announcementList;
- public Course(String courseName, String courseSchool, int courseNumber) {
- this.courseName = courseName;
- this.courseSchool = courseSchool;
- this.courseNumber = courseNumber;
-
+ public Course(String title, String siteId) {
+ this.title = title;
+ this.siteId = siteId;
+
this.assignmentList = new ArrayList();
this.announcementList = new ArrayList();
}
- public String getCourseId() {
- return courseSchool+" "+courseNumber;
+ public String getTitle() {
+ return title;
}
- public String getCourseName() {
- return courseName;
+ public void setTitle(String title) {
+ this.title = title;
}
- public String getCourseSchool() {
- return courseSchool;
+ public String getSiteId() {
+ return siteId;
}
- public int getCourseNumber() {
- return courseNumber;
+ public void setSiteId(String siteId) {
+ this.siteId = siteId;
}
public List getAssignmentList() {
@@ -52,12 +50,24 @@ public List getAnnouncementList() {
}
public void addAssignment(Assignment assignment) {
+ if (assignment.getId() != null) {
+ for (Assignment a : assignmentList) {
+ if (a.getId().equals(assignment.getId())) return;
+ }
+ }
+ assignment.setCourse(this);
assignmentList.add(assignment);
}
public void addAnnouncement(Announcement announcement) {
+ announcement.setCourse(this);
announcementList.add(announcement);
}
-
+ public boolean hasAnnouncement(Announcement announcement) {
+ if (announcementList.contains(announcement))
+ return true;
+ else
+ return false;
+ }
}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/Datamart.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/Datamart.java
new file mode 100644
index 0000000..dbdbca2
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/Datamart.java
@@ -0,0 +1,263 @@
+package com.hellabreakfast.classnote.model;
+
+import android.app.Activity;
+
+import com.hellabreakfast.classnote.ui.ClassNoteApp;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Observable;
+
+/**
+ * The datamart is a singleton object that contains all data in our application. It is serializable
+ * so it can be saved to disk.
+ */
+public class Datamart extends Observable implements Serializable {
+
+ static String SAVE_FILE_NAME = "datamart-classnote";
+
+ static Datamart instance;
+
+ private ArrayList courseList;
+
+ private Date lastRefreshed;
+
+ private String username;
+
+ private boolean offline;
+
+ private boolean[] visited = { false, false, false, false, false, true, true };
+ private int currentScreen = 0;
+
+ public Datamart() {
+ courseList = new ArrayList();
+ }
+
+ /**
+ * @return whether a user is logged in
+ */
+ public static boolean isLoggedIn() {
+ return getInstance().getUsername() != null;
+ }
+
+ /**
+ * @return the singleton instance of the Datamart
+ */
+ public static Datamart getInstance() {
+ if (instance == null) {
+ instance = load();
+ if (instance == null || !(instance instanceof Datamart)) {
+ instance = new Datamart();
+ }
+ }
+ return instance;
+ }
+
+ /**
+ * deletes the instance from the disk. (used for logout)
+ */
+ public static void clearInstance() {
+ ClassNoteApp.getApplication().deleteFile(SAVE_FILE_NAME);
+ instance = null;
+ }
+
+ /**
+ * saves the instance to disk.
+ */
+ public void save() {
+ this.setChanged();
+ this.notifyObservers();
+ ObjectOutputStream objectOut = null;
+ try {
+
+ FileOutputStream fileOut = ClassNoteApp.getApplication().getApplicationContext().openFileOutput(SAVE_FILE_NAME, Activity.MODE_PRIVATE);
+
+ objectOut = new ObjectOutputStream(fileOut);
+ objectOut.writeObject(this);
+ fileOut.getFD().sync();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (objectOut != null) {
+ try {
+ objectOut.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
+
+ /**
+ * @return loads the model from disk and returns it
+ */
+ public static Datamart load() {
+ ObjectInputStream objectIn = null;
+ Object object = null;
+ try {
+ ClassNoteApp application = ClassNoteApp.getApplication();
+ FileInputStream fileIn = application.getApplicationContext().openFileInput(SAVE_FILE_NAME);
+ objectIn = new ObjectInputStream(fileIn);
+ object = objectIn.readObject();
+
+ } catch (FileNotFoundException e) {
+ // Do nothing
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } finally {
+ if (objectIn != null) {
+ try {
+ objectIn.close();
+ } catch (IOException e) {
+ // do nowt
+ }
+ }
+ }
+ return (Datamart)object;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @return the titles for the courses
+ */
+ public List getCourseTitles() {
+ ArrayList courseTitles = new ArrayList();
+ for (Course c : courseList) {
+ courseTitles.add(c.getTitle());
+ }
+ return courseTitles;
+ }
+
+ /**
+ * @param title
+ * @return the course object with the specified title
+ */
+ public Course getCourseByTitle(String title) {
+ for (Course c : courseList) {
+ if (c.getTitle().equals(title)) return c;
+ }
+ return null;
+ }
+
+ /**
+ * Getter for the announcements through the course
+ * @return
+ */
+ public List getAllAnnouncements() {
+ List list = new LinkedList();
+ for (Course c : getCourseList()) {
+ list.addAll(c.getAnnouncementList());
+ }
+ return list;
+ }
+
+ /**
+ * Getter for the assignments through the course
+ * @return
+ */
+ public List getAllAssignments() {
+ List list = new LinkedList();
+ for (Course c : getCourseList()) {
+ list.addAll(c.getAssignmentList());
+ }
+ return list;
+ }
+
+ /**
+ * Getter for upcoming assignments through the course
+ * @return
+ */
+ public List getUpcomingAssignments() {
+ List list = new LinkedList();
+ for (Course c : getCourseList()) {
+ for (Assignment a : c.getAssignmentList()) {
+ if (a != null && a.getDueDate().after(new Date())) {
+ list.add(a);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Getter for past assignments through the course
+ * @return
+ */
+ public List getPastAssignments() {
+ List list = new LinkedList();
+ for (Course c : getCourseList()) {
+ for (Assignment a : c.getAssignmentList()) {
+ if (a != null && a.getDueDate().before(new Date())) {
+ list.add(a);
+ }
+ }
+ }
+ return list;
+ }
+
+
+ public List getCourseList() {
+ return courseList;
+ }
+
+ /**
+ * adds the course to the datamart
+ * @param c The course to add
+ */
+ public void addCourse(Course c) {
+ for (Course course : courseList) {
+ if (course.getSiteId().equals(c.getSiteId())) return;
+ }
+ courseList.add(c);
+ }
+
+ public boolean[] getVisited() {
+ return visited;
+ }
+ public void setVisited( int index, boolean value ) {
+ visited[ index ] = value;
+ save();
+ }
+
+
+ public int getCurrentScreen() {
+ return currentScreen;
+ }
+ public void setCurrentScreen( int currentScreen ) {
+
+ this.currentScreen = currentScreen;
+ }
+
+ public boolean isOffline() {
+ return offline;
+ }
+
+ public void setOffline(boolean offline) {
+ this.offline = offline;
+ }
+
+ public Date getLastRefreshed() {
+ return lastRefreshed;
+ }
+
+ public void setLastRefreshed(Date lastRefreshed) {
+ this.lastRefreshed = lastRefreshed;
+ }
+}
diff --git a/src/com/rumbleworks/classnote/GradedWork.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/GradedWork.java
similarity index 72%
rename from src/com/rumbleworks/classnote/GradedWork.java
rename to classnote/src/main/java/com/hellabreakfast/classnote/model/GradedWork.java
index 7653dba..aa73559 100644
--- a/src/com/rumbleworks/classnote/GradedWork.java
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/GradedWork.java
@@ -1,26 +1,26 @@
-package com.rumbleworks.classnote;
+package com.hellabreakfast.classnote.model;
+import java.io.Serializable;
import java.util.Date;
-public class GradedWork {
+public class GradedWork implements Serializable {
public String name;
public String description;
public Boolean isRead;
public Date dueDate;
- public String courseId;
+ public Course course;
public double pointsEarned;
public double pointsPossible;
public double overallScore;
public double percentageOfFinal;
- public GradedWork(String name, String description, Boolean isRead, Date dueDate, String courseId, double pointsEarned, double pointsPossible, double overallScore, double percentageOfFinal) {
+ public GradedWork(String name, String description, Boolean isRead, Date dueDate, double pointsEarned, double pointsPossible, double overallScore, double percentageOfFinal) {
this.name = name;
this.description = description;
this.isRead = isRead;
this.dueDate = dueDate;
- this.courseId = courseId;
this.pointsEarned = pointsEarned;
this.pointsPossible = pointsPossible;
this.overallScore = overallScore;
@@ -29,31 +29,27 @@ public GradedWork(String name, String description, Boolean isRead, Date dueDate,
public String getName() {
- // TODO Auto-generated method stub
return name;
}
public String getDescription() {
- // TODO Auto-generated method stub
return description;
}
public Boolean getIsRead() {
- // TODO Auto-generated method stub
return isRead;
}
public Date getDueDate() {
- // TODO Auto-generated method stub
return dueDate;
}
- public String getCourseId() {
- return courseId;
+ public Course getCourse() {
+ return course;
}
@@ -77,28 +73,24 @@ public void setDueDate(Date dueDate) {
}
- public void setCourseId(String courseId) {
- this.courseId = courseId;
+ public void setCourse(Course course) {
+ this.course = course;
}
public double getPointsEarned() {
- // TODO Auto-generated method stub
return pointsEarned;
}
public double getPointsPossible() {
- // TODO Auto-generated method stub
return pointsPossible;
}
public double getOverallScore() {
- // TODO Auto-generated method stub
return overallScore;
}
public double getPercentageOfFinal() {
- // TODO Auto-generated method stub
return percentageOfFinal;
}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/TSquareAPI.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/TSquareAPI.java
new file mode 100644
index 0000000..52019d7
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/TSquareAPI.java
@@ -0,0 +1,232 @@
+package com.hellabreakfast.classnote.model;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Intent;
+import android.text.Html;
+import android.util.Log;
+
+import com.loopj.android.http.AsyncHttpClient;
+import com.loopj.android.http.AsyncHttpResponseHandler;
+import com.loopj.android.http.RequestParams;
+import com.hellabreakfast.classnote.ui.ClassNoteApp;
+import com.hellabreakfast.classnote.auth.GatechAccountAuthenticator;
+import com.hellabreakfast.classnote.ui.UpdatePasswordActivity;
+
+import org.apache.http.impl.client.BasicCookieStore;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Date;
+
+/**
+ * This class handles all of our interaction with the T-Square API thorugh static methods that login and refresh data.
+ */
+public class TSquareAPI {
+ // This cookie store holds the cookie that we get back when we login.
+ public static BasicCookieStore cookieStore = new BasicCookieStore();
+ public static final String BASE_URL = "https://t-square.gatech.edu/direct";
+
+ /**
+ * Send a POST request to /direct/session with the specified credentials. Call the appropriate method of the handler on completion.
+ *
+ * @param username
+ * @param password
+ * @param handler The handler to be called with a success or failure message
+ */
+ public static void login(final String username, final String password, final AsyncResultHandler handler) {
+ // Create a new HttpClient and Post Header
+ AsyncHttpClient client = new AsyncHttpClient();
+ client.setCookieStore(TSquareAPI.cookieStore);
+ client.post(TSquareAPI.BASE_URL+"/session", new RequestParams("_username", username, "_password", password), new AsyncHttpResponseHandler() {
+ public void onSuccess(int statusCode, org.apache.http.Header[] headers, byte[] responseBody) {
+ if (statusCode == 201) {
+ if (handler != null) handler.onSuccess();
+ Datamart.getInstance().setUsername(username);
+ Datamart.getInstance().setOffline(false);
+ } else {
+ if (handler != null) handler.onFailure();
+ }
+ }
+ });
+ }
+
+ /**
+ * Loops through the courses and refreshes the list of announcements for each course and inserts the new data into the Datamart
+ */
+ public static void refreshAnnouncements() {
+ for (Course c : Datamart.getInstance().getCourseList()) {
+ AsyncHttpClient client = new AsyncHttpClient();
+ client.setCookieStore(TSquareAPI.cookieStore);
+
+ //Execute get request using asynchttpclient for announcements 50 days old and 20 in number
+ final Course course = c;
+ client.get(TSquareAPI.BASE_URL + "/announcement/site/"+c.getSiteId()+".json", new AsyncHttpResponseHandler() {
+
+ @Override
+ public void onSuccess(int statusCode, org.apache.http.Header[] headers, byte[] responseBody) {
+ try {
+ JSONObject res = new JSONObject(new String(responseBody));
+ JSONArray ann = res.getJSONArray("announcement_collection");
+ int len = ann.length();
+
+ //Need to trim the message to remove tags
+ for (int i = 0; i < len; i++) {
+ Announcement announcement = new Announcement(
+ ann.getJSONObject(i).getString("id"),
+ ann.getJSONObject(i).getString("title"),
+ ann.getJSONObject(i).getString("createdByDisplayName"),
+ (stripHtml(ann.getJSONObject(i).getString("body"))),
+ false,
+ new Date(ann.getJSONObject(i).getLong("createdOn")));
+ if (!course.hasAnnouncement(announcement)) {
+ course.addAnnouncement(announcement);
+ }
+ }
+ Datamart.getInstance().save();
+ } catch (JSONException e) {
+
+ }
+ }
+
+ });
+ }
+ }
+
+ /**
+ * Loops through the courses and refreshes the list of assignments for each course and inserts the new data into the Datamart
+ */
+ public static void refreshAssignments() {
+ for (Course c : Datamart.getInstance().getCourseList()) {
+ AsyncHttpClient client = new AsyncHttpClient();
+ client.setCookieStore(TSquareAPI.cookieStore);
+
+ //Execute get request using asynchttpclient for announcements 50 days old and 20 in number
+ final Course course = c;
+ client.get(TSquareAPI.BASE_URL + "/assignment/site/"+c.getSiteId()+".json", new AsyncHttpResponseHandler() {
+ @Override
+ public void onSuccess(int statusCode, org.apache.http.Header[] headers, byte[] responseBody) {
+ try {
+ if (statusCode != 200) return;
+ JSONObject res = new JSONObject(new String(responseBody));
+ JSONArray assArray = res.getJSONArray("assignment_collection");
+ for (int i = 0; i < assArray.length(); i++) {
+ JSONObject assObject = assArray.optJSONObject(i);
+ JSONObject dueDateObject = assObject.optJSONObject("dueTime");
+ Date dueDate = null;
+ if (dueDateObject != null) {
+ long dueDateInt = dueDateObject.optLong("time");
+ dueDate = dueDateInt > 0 ? new Date(dueDateInt) : null;
+ }
+ JSONObject content = assObject.optJSONObject("content");
+ //Log.d("Content: ", content.toString());
+
+ Assignment assignment = new Assignment(assObject.optString("id"),assObject.optString("title"),stripHtml(content.optString("instructions")),false, dueDate);
+
+ course.addAssignment(assignment);
+ }
+ Datamart.getInstance().save();
+ } catch (JSONException e) {}
+ }
+ });
+ }
+ }
+
+
+ /**
+ * First refresh the list of courses from T-Square (making sure to only get courses for this semester), and then refresh the assignments and announcements.
+ */
+ public static void refreshAll() {
+ AsyncHttpClient client = new AsyncHttpClient();
+ client.setCookieStore(TSquareAPI.cookieStore);
+
+ //Execute get request using asynchttpclient for announcements 50 days old and 20 in number
+ client.get(TSquareAPI.BASE_URL + "/site.json", new AsyncHttpResponseHandler() {
+
+ @Override
+ public void onSuccess(int statusCode, org.apache.http.Header[] headers, byte[] responseBody) {
+ try {
+ JSONObject siteObject = new JSONObject(new String(responseBody));
+ JSONArray siteArray = siteObject.getJSONArray("site_collection");
+
+ if (siteArray.length() == 0) {
+ tryReauth();
+ return;
+ }
+
+ //Need to trim the message to remove tags
+ for (int i = 0; i < siteArray.length(); i++) {
+ JSONObject site = siteArray.optJSONObject(i);
+ JSONObject props = site.optJSONObject("props");
+ if (props == null) {
+ System.out.println("no props");
+ continue;
+ }
+ String term = props.optString("term");
+ if (term == null || !term.equals("SPRING 2014")) {
+ System.out.println("wrong term");
+ continue;
+ }
+
+ Course c = new Course(site.optString("title"), site.optString("entityId"));
+ Datamart.getInstance().addCourse(c);
+ }
+ Datamart.getInstance().setLastRefreshed(new Date());
+ Datamart.getInstance().save();
+
+ TSquareAPI.refreshAnnouncements();
+ TSquareAPI.refreshAssignments();
+ }
+ catch (JSONException e) {
+
+ }
+ }
+
+ });
+ }
+
+ /**
+ * This method is called if our cookie expires. It retrieves the password from the AccountManager
+ * and logs in again to get a new cookie. Once it gets the cookie, it refreshes.
+ */
+ public static void tryReauth() {
+ try {
+ AccountManager accountManager = AccountManager.get(ClassNoteApp.getApplication().getApplicationContext());
+ Account account = new Account(Datamart.getInstance().getUsername(), GatechAccountAuthenticator.ACCOUNT_TYPE);
+ String password = accountManager.getPassword(account);
+ login(Datamart.getInstance().getUsername(), password, new AsyncResultHandler() {
+ @Override
+ public void onSuccess() {
+ refreshAll();
+ }
+
+ @Override
+ public void onFailure() {
+ requirePasswordUpdateToRefresh();
+ }
+ });
+ } catch (Exception e) {
+ requirePasswordUpdateToRefresh();
+ }
+ }
+
+ /**
+ * Start the password update activity (because the user has changed their T-Square password)
+ */
+ public static void requirePasswordUpdateToRefresh() {
+ Intent intent = new Intent(ClassNoteApp.getApplication().getApplicationContext(), UpdatePasswordActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ ClassNoteApp.getApplication().startActivity(intent);
+ }
+
+ /**
+ * Stripping html tags from the message
+ * @param html
+ * @return
+ */
+ public static String stripHtml(String html) {
+ return Html.fromHtml(html).toString();
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/model/Test.java b/classnote/src/main/java/com/hellabreakfast/classnote/model/Test.java
new file mode 100644
index 0000000..f882049
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/model/Test.java
@@ -0,0 +1,10 @@
+package com.hellabreakfast.classnote.model;
+
+import java.util.Date;
+
+public class Test extends GradedWork {
+
+ public Test(String name, String description, Boolean isRead, Date dueDate, double pointsEarned, double pointsPossible, double overallScore, double percentageOfFinal ) {
+ super(name, description, isRead, dueDate, pointsEarned, pointsPossible, overallScore, percentageOfFinal );
+ }
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/AddAssignmentFragment.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AddAssignmentFragment.java
new file mode 100644
index 0000000..2189435
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AddAssignmentFragment.java
@@ -0,0 +1,73 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.TimePicker;
+
+import com.hellabreakfast.classnote.model.Assignment;
+import com.hellabreakfast.classnote.model.Course;
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+public class AddAssignmentFragment extends Fragment {
+ /**
+ * The fragment argument representing the section number for this
+ * fragment.
+ */
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ private Spinner courseSpinner;
+ private EditText titleField, descField;
+ private DatePicker datePicker;
+ private TimePicker timePicker;
+
+
+ public AddAssignmentFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_add_assignment, container, false);
+
+ courseSpinner = (Spinner)rootView.findViewById(R.id.courseSpinner);
+ courseSpinner.setAdapter(new ArrayAdapter(getActivity().getApplicationContext(), android.R.layout.simple_spinner_item, Datamart.getInstance().getCourseTitles()));
+
+ titleField = (EditText)rootView.findViewById(R.id.titleField);
+ descField = (EditText)rootView.findViewById(R.id.descField);
+ datePicker = (DatePicker)rootView.findViewById(R.id.datePicker);
+ timePicker = (TimePicker)rootView.findViewById(R.id.timePicker);
+
+ Button saveButton = (Button)rootView.findViewById(R.id.saveAssignmentButton);
+ saveButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Calendar date = new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute());
+ Course c = Datamart.getInstance().getCourseByTitle((String)courseSpinner.getSelectedItem());
+ Assignment assignment = new Assignment(null, titleField.getText().toString(), descField.getText().toString(), true, date.getTime());
+ c.addAssignment(assignment);
+
+ InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(descField.getWindowToken(), 0);
+
+ ((MainActivity) getActivity() ).onNavigationDrawerItemSelected(1);
+ }
+ });
+
+ return rootView;
+ }
+}
\ No newline at end of file
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementAdapter.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementAdapter.java
new file mode 100644
index 0000000..33ca620
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementAdapter.java
@@ -0,0 +1,74 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import com.hellabreakfast.classnote.model.Announcement;
+import com.hellabreakfast.classnote.R;
+
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * This class takes in a list of Announcements and uses it to populate a ListView
+ */
+public class AnnouncementAdapter extends BaseAdapter {
+ private List list;
+ private Activity activity;
+ private SimpleDateFormat dateFormat;
+
+ public AnnouncementAdapter(List list, Activity activity) {
+ this.setList(list);
+ this.activity = activity;
+ dateFormat = new SimpleDateFormat("MMMM dd h:mm a");
+ }
+
+ /**
+ * Sets the list to use for the ListView, sorting it in reverse order (by posted date).
+ * @param list
+ */
+ public void setList(List list) {
+ Collections.sort(list);
+ Collections.reverse(list);
+ this.list = list;
+ }
+
+ @Override
+ public int getCount() {
+ return list.size();
+ }
+
+ @Override
+ public Object getItem(int i) {
+ return list.get(i);
+ }
+
+ @Override
+ public long getItemId(int i) {
+ return 0;
+ }
+
+ @Override
+ public View getView(int i, View view, ViewGroup viewGroup) {
+ if (view == null) {
+ LayoutInflater vi;
+ vi = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = vi.inflate(R.layout.list_item_announcement, null);
+ }
+
+ Announcement announcement = (Announcement) getItem(i);
+ TextView courseTitleText = (TextView) view.findViewById(R.id.courseTitle);
+ TextView titleText = (TextView) view.findViewById(R.id.assignmentTitle);
+ TextView dueDateText = (TextView) view.findViewById(R.id.assignmentDueDate);
+ courseTitleText.setText(announcement.getCourse().getTitle());
+ titleText.setText(announcement.getName());
+ dueDateText.setText(dateFormat.format(announcement.getDueDate()));
+ return view;
+ }
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementDetailActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementDetailActivity.java
new file mode 100644
index 0000000..5b252e4
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementDetailActivity.java
@@ -0,0 +1,36 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+import com.hellabreakfast.classnote.model.Announcement;
+import com.hellabreakfast.classnote.R;
+
+import java.text.SimpleDateFormat;
+
+/**
+ * Activity to display all details about an announcement
+ */
+public class AnnouncementDetailActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_announcement_details);
+ setTitle("Announcement");
+ Announcement a = (Announcement)getIntent().getSerializableExtra("ANNOUNCEMENT");
+ TextView title = (TextView)findViewById(R.id.announcement_details_title);
+ TextView author = (TextView)findViewById(R.id.announcement_details_author);
+ TextView courseName = (TextView)findViewById(R.id.announcement_details_class);
+ TextView description = (TextView)findViewById(R.id.announcement_details_description);
+ TextView dueDate = (TextView)findViewById(R.id.announcement_details_date);
+ title.setText(a.getName());
+ author.setText("By "+a.getAuthor());
+ courseName.setText(a.getCourse().getTitle());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d h:mm a");
+ dueDate.setText("Posted: "+dateFormat.format(a.getDueDate())+"\n");
+ description.setText(a.getDescription());
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementListFragment.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementListFragment.java
new file mode 100644
index 0000000..39b6188
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AnnouncementListFragment.java
@@ -0,0 +1,58 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+import com.hellabreakfast.classnote.model.Announcement;
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+
+import java.util.Observable;
+import java.util.Observer;
+
+public class AnnouncementListFragment extends ListFragment implements Observer {
+ /**
+ * The fragment argument representing the section number for this
+ * fragment.
+ */
+ public static final String ARG_SECTION_NUMBER = "section_number";
+
+ public AnnouncementListFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_announcement_list, container, false);
+
+ setListAdapter(new AnnouncementAdapter(Datamart.getInstance().getAllAnnouncements(), getActivity()));
+ return rootView;
+ }
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Datamart.getInstance().addObserver(this);
+ }
+
+ public void onDestroy() {
+ super.onDestroy();
+ Datamart.getInstance().deleteObserver(this);
+ }
+
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ AnnouncementAdapter adapter = (AnnouncementAdapter)getListAdapter();
+ Announcement a = (Announcement)adapter.getItem(position);
+ Intent i = new Intent(this.getActivity(), AnnouncementDetailActivity.class);
+ i.putExtra("ANNOUNCEMENT", a);
+ startActivity(i);
+ }
+
+ public void update(Observable observable, Object data) {
+ setListAdapter(new AnnouncementAdapter(Datamart.getInstance().getAllAnnouncements(), getActivity()));
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/AssignmentAdapter.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentAdapter.java
similarity index 72%
rename from src/com/rumbleworks/classnote/AssignmentAdapter.java
rename to classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentAdapter.java
index c9f2592..2a57638 100644
--- a/src/com/rumbleworks/classnote/AssignmentAdapter.java
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentAdapter.java
@@ -1,4 +1,4 @@
-package com.rumbleworks.classnote;
+package com.hellabreakfast.classnote.ui;
import android.app.Activity;
import android.content.Context;
@@ -8,27 +8,34 @@
import android.widget.BaseAdapter;
import android.widget.TextView;
-import org.w3c.dom.Text;
+import com.hellabreakfast.classnote.model.Assignment;
+import com.hellabreakfast.classnote.R;
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
+/**
+ * This class takes in a list of Assignments and uses it to populate a ListView
+ */
public class AssignmentAdapter extends BaseAdapter {
private List list;
private Activity activity;
private SimpleDateFormat dateFormat;
public AssignmentAdapter(List list, Activity activity) {
- this.list = list;
+ this.setList(list);
this.activity = activity;
- dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm");
+ dateFormat = new SimpleDateFormat("MMMM d h:mm a");
}
+ /**
+ * Sets the list to use for the ListView, sorting it in order (by due date).
+ * @param list
+ */
public void setList(List list) {
Collections.sort(list);
+ //Collections.reverse(list);
this.list = list;
}
@@ -56,8 +63,10 @@ public View getView(int i, View view, ViewGroup viewGroup) {
}
Assignment assignment = (Assignment) getItem(i);
+ TextView courseTitleText = (TextView) view.findViewById(R.id.courseTitle);
TextView titleText = (TextView) view.findViewById(R.id.assignmentTitle);
TextView dueDateText = (TextView) view.findViewById(R.id.assignmentDueDate);
+ courseTitleText.setText(assignment.getCourse().getTitle());
titleText.setText(assignment.getName());
dueDateText.setText(dateFormat.format(assignment.getDueDate()));
return view;
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentDetailActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentDetailActivity.java
new file mode 100644
index 0000000..c249e6e
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/AssignmentDetailActivity.java
@@ -0,0 +1,35 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+import com.hellabreakfast.classnote.model.Assignment;
+import com.hellabreakfast.classnote.R;
+
+import java.text.SimpleDateFormat;
+
+/**
+ * Activity to display all details about an assignment
+ */
+
+public class AssignmentDetailActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_assignment_details);
+ setTitle("Assignment");
+ Assignment a = (Assignment) getIntent().getSerializableExtra("ASSIGNMENT");
+ TextView courseName = (TextView)findViewById(R.id.assignment_details_class);
+ TextView title = (TextView)findViewById(R.id.assignment_details_title);
+ TextView description = (TextView)findViewById(R.id.assignment_details_description);
+ TextView dueDate = (TextView)findViewById(R.id.assignment_details_date);
+ courseName.setText(a.getCourse().getTitle());
+ title.setText(a.getName());
+ SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d h:mm a");
+ dueDate.setText("Due: "+dateFormat.format(a.getDueDate())+"\n");
+ description.setText(a.getDescription());
+ }
+
+}
diff --git a/src/com/rumbleworks/classnote/ClassNoteApp.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/ClassNoteApp.java
similarity index 59%
rename from src/com/rumbleworks/classnote/ClassNoteApp.java
rename to classnote/src/main/java/com/hellabreakfast/classnote/ui/ClassNoteApp.java
index ae5bbb4..67f0d04 100644
--- a/src/com/rumbleworks/classnote/ClassNoteApp.java
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/ClassNoteApp.java
@@ -1,7 +1,10 @@
-package com.rumbleworks.classnote;
+package com.hellabreakfast.classnote.ui;
import android.app.Application;
-import android.content.Context;
+
+/**
+ * This class subclasses the android Application class and makes it into a singleton class so we can access it from anywhere in our code.
+ */
public class ClassNoteApp extends Application {
@@ -14,5 +17,4 @@ public ClassNoteApp() {
public static ClassNoteApp getApplication() {
return instance;
}
-
}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/CurrentAssignmentListFragment.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/CurrentAssignmentListFragment.java
new file mode 100644
index 0000000..6291f19
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/CurrentAssignmentListFragment.java
@@ -0,0 +1,68 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+import com.hellabreakfast.classnote.model.Assignment;
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+
+import java.util.Observable;
+import java.util.Observer;
+
+/**
+ * The fragment for displaying current assignments (i.e. the ones with a due date in the future).
+ * This class is an observer of the Datamart and updates its content when the Datamart updates.
+ */
+public class CurrentAssignmentListFragment extends ListFragment implements Observer {
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ AssignmentAdapter assignmentAdapter = (AssignmentAdapter)this.getListAdapter();
+ assignmentAdapter.setList(Datamart.getInstance().getUpcomingAssignments());
+ assignmentAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_assignment_list, container, false);
+
+ this.setListAdapter(new AssignmentAdapter(Datamart.getInstance().getUpcomingAssignments(), this.getActivity()));
+
+ return rootView;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Datamart.getInstance().addObserver(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ Datamart.getInstance().deleteObserver(this);
+ }
+
+ @Override
+ public void update(Observable observable, Object data) {
+ this.setListAdapter(new AssignmentAdapter(Datamart.getInstance().getUpcomingAssignments(), this.getActivity()));
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ AssignmentAdapter adapter = (AssignmentAdapter)getListAdapter();
+ Assignment a = (Assignment)adapter.getItem(position);
+ Intent i = new Intent(this.getActivity(), AssignmentDetailActivity.class);
+ i.putExtra("ASSIGNMENT", a);
+ startActivity(i);
+ }
+
+}
\ No newline at end of file
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/HelpOverlayActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/HelpOverlayActivity.java
new file mode 100644
index 0000000..aa6f1af
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/HelpOverlayActivity.java
@@ -0,0 +1,51 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.support.v7.app.ActionBarActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
+
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+
+/**
+ * This activity shows the help overlay for the current screen in a transparent view over the screen.
+ */
+public class HelpOverlayActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_help_overlay);
+
+ String title = getIntent().getStringExtra("title");
+ if (title != null) setTitle(title);
+
+ int currentScreen = Datamart.getInstance().getCurrentScreen();
+
+ TextView textView1 = (TextView) findViewById(R.id.textView1);
+ TextView textView2 = (TextView) findViewById(R.id.textView2);
+ TextView textView3 = (TextView) findViewById(R.id.textView3);
+ TextView textView4 = (TextView) findViewById(R.id.textView4);
+ TextView textView5 = (TextView) findViewById(R.id.textView5);
+
+ String[][] helpArray = {
+ getResources().getStringArray(R.array.help_items_announcements),
+ getResources().getStringArray(R.array.help_items_assignments),
+ getResources().getStringArray(R.array.help_items_assignments),
+ getResources().getStringArray(R.array.help_items_add_assignment)
+ };
+ textView1.setText( helpArray[currentScreen][0] );
+ textView2.setText( helpArray[currentScreen][1] );
+ textView3.setText( helpArray[currentScreen][2] );
+ textView4.setText( helpArray[currentScreen][3] );
+ textView5.setText( helpArray[currentScreen][4] );
+ }
+
+ /**
+ * The user tapped to dismiss, so finish the activity.
+ */
+ public void understood(View view){
+ finish();
+ }
+}
\ No newline at end of file
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/LoginActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/LoginActivity.java
new file mode 100644
index 0000000..114e4ef
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/LoginActivity.java
@@ -0,0 +1,82 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorActivity;
+import android.accounts.AccountManager;
+import android.os.Bundle;
+import android.content.Intent;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.hellabreakfast.classnote.model.AsyncResultHandler;
+import com.hellabreakfast.classnote.R;
+import com.hellabreakfast.classnote.model.TSquareAPI;
+import com.hellabreakfast.classnote.auth.GatechAccountAuthenticator;
+
+/**
+ * The activity that accepts the user's username and password and allows them to get to the
+ * main application if the login is correct.
+ */
+public class LoginActivity extends AccountAuthenticatorActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_login);
+ }
+
+ /**
+ * This method is called when the login button is clicked. It attempts login, and either
+ * starts the MainActivity or displays an error based on the result.
+ * @param view
+ */
+ public void login(View view) {
+ EditText usernameField = (EditText)findViewById(R.id.usernameField);
+ EditText passwordField = (EditText)findViewById(R.id.passwordField);
+ final String username = usernameField.getText().toString();
+ final String password = passwordField.getText().toString();
+
+
+ TSquareAPI.login(usernameField.getText().toString(), passwordField.getText().toString(), new AsyncResultHandler() {
+ @Override
+ public void onSuccess() {
+
+ String accountType = GatechAccountAuthenticator.ACCOUNT_TYPE;
+ AccountManager accMgr = AccountManager.get(LoginActivity.this);
+ final Account account = new Account(username, accountType);
+ accMgr.addAccountExplicitly(account, password, null);
+
+ // Now we tell our caller, could be the Android Account Manager or even our own application
+ // that the process was successful
+
+ final Intent intent = new Intent();
+ intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, username);
+ intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
+ intent.putExtra(AccountManager.KEY_AUTHTOKEN, accountType);
+ LoginActivity.this.setAccountAuthenticatorResult(intent.getExtras());
+ LoginActivity.this.setResult(RESULT_OK, intent);
+
+
+ Intent mainIntent = new Intent();
+ mainIntent.setClass(LoginActivity.this, MainActivity.class);
+
+ startActivity(mainIntent);
+ finish();
+ }
+
+ @Override
+ public void onFailure() {
+ LoginActivity.this.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Toast toast = Toast.makeText(LoginActivity.this, "Invalid Username or Password", Toast.LENGTH_LONG);
+ toast.show();
+ }
+ });
+ }
+ });
+
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/MainActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/MainActivity.java
new file mode 100644
index 0000000..f8dc3d4
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/MainActivity.java
@@ -0,0 +1,163 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.content.Intent;
+import android.support.v4.app.Fragment;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.app.ActionBar;
+import android.support.v4.app.FragmentManager;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.support.v4.widget.DrawerLayout;
+
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+import com.hellabreakfast.classnote.model.TSquareAPI;
+
+import java.util.Date;
+
+
+/**
+ * This activity holds all of the primary fragments and the navigation drawer.
+ */
+public class MainActivity extends ActionBarActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks {
+
+ /**
+ * Fragment managing the behaviors, interactions and presentation of the navigation drawer.
+ */
+ private NavigationDrawerFragment mNavigationDrawerFragment;
+
+ /**
+ * Used to store the last screen title. For use in {@link #restoreActionBar()}.
+ */
+ private CharSequence mTitle;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ mNavigationDrawerFragment = (NavigationDrawerFragment)
+ getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
+
+ // Set up the drawer.
+ mNavigationDrawerFragment.setUp(
+ R.id.navigation_drawer,
+ (DrawerLayout) findViewById(R.id.drawer_layout));
+ this.requireLogin();
+ }
+
+ /**
+ * Checks to see if the user is logged in, and if not, start up the LoginActivity.
+ */
+ private void requireLogin() {
+ if (!Datamart.isLoggedIn()) {
+ finish();
+ Intent intent = new Intent();
+ intent.setClass(MainActivity.this, LoginActivity.class);
+
+ startActivity(intent);
+ finish();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Date now = new Date();
+ Date lastRefreshed = Datamart.getInstance().getLastRefreshed();
+ if (!Datamart.getInstance().isOffline() && (lastRefreshed == null || lastRefreshed.before(new Date(now.getTime()-1000*60*15)))) { // if more than 15 mins ago
+ TSquareAPI.refreshAll();
+ }
+ }
+
+ @Override
+ public void onNavigationDrawerItemSelected(int position) {
+ // update the main content by replacing fragments
+ FragmentManager fragmentManager = getSupportFragmentManager();
+
+ Fragment fragment = null;
+ switch (position) {
+ case 0:
+ fragment = new AnnouncementListFragment();
+ mTitle = "Announcements";
+ break;
+ case 1:
+ fragment = new CurrentAssignmentListFragment();
+ mTitle = "Current Assignments";
+ break;
+ case 2:
+ fragment = new PastAssignmentListFragment();
+ mTitle = "Past Assignments";
+ break;
+ case 3:
+ fragment = new AddAssignmentFragment();
+ mTitle = "New Assignment";
+ break;
+ }
+ if (fragment == null) return;
+ fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
+ Datamart.getInstance().setCurrentScreen(position);
+ if (Datamart.getInstance().getVisited()[position] == false) {
+ this.showHelp();
+ }
+ }
+
+ /**
+ * Put the action bar back after selecting an item from the navigation drawer.
+ */
+ public void restoreActionBar() {
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setTitle(mTitle);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if (!mNavigationDrawerFragment.isDrawerOpen()) {
+ // Only show items in the action bar relevant to this screen
+ // if the drawer is not showing. Otherwise, let the drawer
+ // decide what to show in the action bar.
+ getMenuInflater().inflate(R.menu.main, menu);
+ restoreActionBar();
+ return true;
+ }
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle action bar item clicks here. The action bar will
+ // automatically handle clicks on the Home/Up button, so long
+ // as you specify a parent activity in AndroidManifest.xml.
+ int id = item.getItemId();
+ if (id == R.id.action_refresh) {
+ TSquareAPI.refreshAll();
+ return true;
+ }
+ if (id == R.id.action_help) {
+ this.showHelp();
+ return true;
+ }
+ if (id == R.id.action_logout) {
+ Datamart.clearInstance();
+ this.requireLogin();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * Loads up the help activity for the current screen
+ */
+ public void showHelp() {
+ Datamart.getInstance().setVisited(Datamart.getInstance().getCurrentScreen(), true);
+ Intent intent = new Intent();
+ intent.setClass(this, HelpOverlayActivity.class);
+ intent.putExtra("title", getSupportActionBar().getTitle());
+ startActivity(intent);
+ }
+
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/NavigationDrawerFragment.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/NavigationDrawerFragment.java
new file mode 100644
index 0000000..4dba81d
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/NavigationDrawerFragment.java
@@ -0,0 +1,278 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.support.v7.app.ActionBarActivity;
+import android.app.Activity;
+import android.support.v7.app.ActionBar;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.ActionBarDrawerToggle;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import com.hellabreakfast.classnote.R;
+
+/**
+ * Fragment used for managing interactions for and presentation of a navigation drawer.
+ * See the
+ * design guidelines for a complete explanation of the behaviors implemented here.
+ */
+public class NavigationDrawerFragment extends Fragment {
+
+ /**
+ * Remember the position of the selected item.
+ */
+ private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position";
+
+ /**
+ * Per the design guidelines, you should show the drawer on launch until the user manually
+ * expands it. This shared preference tracks this.
+ */
+ private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned";
+
+ /**
+ * A pointer to the current callbacks instance (the Activity).
+ */
+ private NavigationDrawerCallbacks mCallbacks;
+
+ /**
+ * Helper component that ties the action bar to the navigation drawer.
+ */
+ private ActionBarDrawerToggle mDrawerToggle;
+
+ private DrawerLayout mDrawerLayout;
+ private ListView mDrawerListView;
+ private View mFragmentContainerView;
+
+ private int mCurrentSelectedPosition = 0;
+ private boolean mFromSavedInstanceState;
+ private boolean mUserLearnedDrawer;
+
+ public NavigationDrawerFragment() {
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Read in the flag indicating whether or not the user has demonstrated awareness of the
+ // drawer. See PREF_USER_LEARNED_DRAWER for details.
+ SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false);
+
+ if (savedInstanceState != null) {
+ mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
+ mFromSavedInstanceState = true;
+ }
+
+ // Select either the default item (0) or the last selected item.
+ selectItem(mCurrentSelectedPosition);
+ }
+
+ @Override
+ public void onActivityCreated (Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ // Indicate that this fragment would like to influence the set of actions in the action bar.
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ mDrawerListView = (ListView) inflater.inflate(
+ R.layout.fragment_navigation_drawer, container, false);
+ mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ selectItem(position);
+ }
+ });
+ mDrawerListView.setAdapter(new ArrayAdapter(
+ getActionBar().getThemedContext(),
+ android.R.layout.simple_list_item_1,
+ android.R.id.text1,
+ new String[]{
+ "Announcements",
+ "Current Assignments",
+ "Past Assignments",
+ "New Assignment"
+ }));
+ mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
+ return mDrawerListView;
+ }
+
+ public boolean isDrawerOpen() {
+ return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView);
+ }
+
+ /**
+ * Users of this fragment must call this method to set up the navigation drawer interactions.
+ *
+ * @param fragmentId The android:id of this fragment in its activity's layout.
+ * @param drawerLayout The DrawerLayout containing this fragment's UI.
+ */
+ public void setUp(int fragmentId, DrawerLayout drawerLayout) {
+ mFragmentContainerView = getActivity().findViewById(fragmentId);
+ mDrawerLayout = drawerLayout;
+
+ // set a custom shadow that overlays the main content when the drawer opens
+ mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
+ // set up the drawer's list view with items and click listener
+
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+ actionBar.setHomeButtonEnabled(true);
+
+ // ActionBarDrawerToggle ties together the the proper interactions
+ // between the navigation drawer and the action bar app icon.
+ mDrawerToggle = new ActionBarDrawerToggle(
+ getActivity(), /* host Activity */
+ mDrawerLayout, /* DrawerLayout object */
+ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
+ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
+ R.string.navigation_drawer_close /* "close drawer" description for accessibility */
+ ) {
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ super.onDrawerClosed(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+
+ getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ super.onDrawerOpened(drawerView);
+ if (!isAdded()) {
+ return;
+ }
+
+ if (!mUserLearnedDrawer) {
+ // The user manually opened the drawer; store this flag to prevent auto-showing
+ // the navigation drawer automatically in the future.
+ mUserLearnedDrawer = true;
+ SharedPreferences sp = PreferenceManager
+ .getDefaultSharedPreferences(getActivity());
+ sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).commit();
+ }
+
+ getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu()
+ }
+ };
+
+ // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
+ // per the navigation drawer design guidelines.
+ if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
+ mDrawerLayout.openDrawer(mFragmentContainerView);
+ }
+
+ // Defer code dependent on restoration of previous instance state.
+ mDrawerLayout.post(new Runnable() {
+ @Override
+ public void run() {
+ mDrawerToggle.syncState();
+ }
+ });
+
+ mDrawerLayout.setDrawerListener(mDrawerToggle);
+ }
+
+ private void selectItem(int position) {
+ mCurrentSelectedPosition = position;
+ if (mDrawerListView != null) {
+ mDrawerListView.setItemChecked(position, true);
+ }
+ if (mDrawerLayout != null) {
+ mDrawerLayout.closeDrawer(mFragmentContainerView);
+ }
+ if (mCallbacks != null) {
+ mCallbacks.onNavigationDrawerItemSelected(position);
+ }
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ try {
+ mCallbacks = (NavigationDrawerCallbacks) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException("Activity must implement NavigationDrawerCallbacks.");
+ }
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ mCallbacks = null;
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ // Forward the new configuration the drawer toggle component.
+ mDrawerToggle.onConfigurationChanged(newConfig);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ // If the drawer is open, show the global app actions in the action bar. See also
+ // showGlobalContextActionBar, which controls the top-left area of the action bar.
+ if (mDrawerLayout != null && isDrawerOpen()) {
+ inflater.inflate(R.menu.main, menu);
+ showGlobalContextActionBar();
+ }
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (mDrawerToggle.onOptionsItemSelected(item)) {
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ /**
+ * Per the navigation drawer design guidelines, updates the action bar to show the global app
+ * 'context', rather than just what's in the current screen.
+ */
+ private void showGlobalContextActionBar() {
+ ActionBar actionBar = getActionBar();
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ actionBar.setTitle(R.string.app_name);
+ }
+
+ private ActionBar getActionBar() {
+ return ((ActionBarActivity) getActivity()).getSupportActionBar();
+ }
+
+ /**
+ * Callbacks interface that all activities using this fragment must implement.
+ */
+ public static interface NavigationDrawerCallbacks {
+ /**
+ * Called when an item in the navigation drawer is selected.
+ */
+ void onNavigationDrawerItemSelected(int position);
+ }
+}
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/PastAssignmentListFragment.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/PastAssignmentListFragment.java
new file mode 100644
index 0000000..0b189e0
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/PastAssignmentListFragment.java
@@ -0,0 +1,68 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+import com.hellabreakfast.classnote.model.Assignment;
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+
+import java.util.Observable;
+import java.util.Observer;
+
+/**
+ * The fragment for displaying past assignments (i.e. the ones with a due date in the past).
+ * This class is an observer of the Datamart and updates its content when the Datamart updates.
+ */
+public class PastAssignmentListFragment extends ListFragment implements Observer {
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ AssignmentAdapter assignmentAdapter = (AssignmentAdapter)this.getListAdapter();
+ assignmentAdapter.setList(Datamart.getInstance().getPastAssignments());
+ assignmentAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_assignment_list, container, false);
+
+ this.setListAdapter(new AssignmentAdapter(Datamart.getInstance().getPastAssignments(), this.getActivity()));
+
+ return rootView;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Datamart.getInstance().addObserver(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ Datamart.getInstance().deleteObserver(this);
+ }
+
+ @Override
+ public void update(Observable observable, Object data) {
+ this.setListAdapter(new AssignmentAdapter(Datamart.getInstance().getPastAssignments(), this.getActivity()));
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ AssignmentAdapter adapter = (AssignmentAdapter)getListAdapter();
+ Assignment a = (Assignment)adapter.getItem(position);
+ Intent i = new Intent(this.getActivity(), AssignmentDetailActivity.class);
+ i.putExtra("ASSIGNMENT", a);
+ startActivity(i);
+ }
+
+}
\ No newline at end of file
diff --git a/classnote/src/main/java/com/hellabreakfast/classnote/ui/UpdatePasswordActivity.java b/classnote/src/main/java/com/hellabreakfast/classnote/ui/UpdatePasswordActivity.java
new file mode 100644
index 0000000..e604921
--- /dev/null
+++ b/classnote/src/main/java/com/hellabreakfast/classnote/ui/UpdatePasswordActivity.java
@@ -0,0 +1,101 @@
+package com.hellabreakfast.classnote.ui;
+
+import android.accounts.Account;
+import android.accounts.AccountAuthenticatorActivity;
+import android.accounts.AccountManager;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.InputType;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.hellabreakfast.classnote.model.AsyncResultHandler;
+import com.hellabreakfast.classnote.model.Datamart;
+import com.hellabreakfast.classnote.R;
+import com.hellabreakfast.classnote.model.TSquareAPI;
+import com.hellabreakfast.classnote.auth.GatechAccountAuthenticator;
+
+/**
+ * This activity is used for the user to update their password, when it is changed on their GT account.
+ */
+public class UpdatePasswordActivity extends AccountAuthenticatorActivity {
+ private EditText passwordField;
+ private ProgressDialog progressDialog;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_update_password);
+ passwordField = new EditText(this);
+ passwordField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ passwordField.setHint("Password");
+ AlertDialog dialog = new AlertDialog.Builder(this)
+ .setTitle("T-Square Password Invalid")
+ .setMessage("Enter your correct T-Square password to refresh")
+ .setView(passwordField)
+ .setPositiveButton("Refresh", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ attemptLogin();
+ }
+ })
+ .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ })
+ .create();
+ dialog.show();
+ }
+
+ /**
+ * Attempts to login with the entered password. On success, dismiss this activity. Otherwise,
+ * display an error and ask for the password again.
+ */
+ public void attemptLogin() {
+ progressDialog = ProgressDialog.show(this, "Verifying Password", null, true, true, new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ progressDialog.dismiss();
+ Datamart.getInstance().setOffline(true);
+ finish();
+ }
+ });
+ final String username = Datamart.getInstance().getUsername();
+ final String password = passwordField.getText().toString();
+
+ TSquareAPI.login(username, password, new AsyncResultHandler() {
+ @Override
+ public void onSuccess() {
+
+ String accountType = GatechAccountAuthenticator.ACCOUNT_TYPE;
+ AccountManager accMgr = AccountManager.get(UpdatePasswordActivity.this);
+ final Account account = new Account(username, accountType);
+ accMgr.setPassword(account, password);
+
+ final Intent intent = new Intent();
+ intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, username);
+ intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
+ intent.putExtra(AccountManager.KEY_AUTHTOKEN, accountType);
+ UpdatePasswordActivity.this.setAccountAuthenticatorResult(intent.getExtras());
+ UpdatePasswordActivity.this.setResult(RESULT_OK, intent);
+
+ finish();
+ }
+
+ @Override
+ public void onFailure() {
+ progressDialog.dismiss();
+ Toast toast = Toast.makeText(UpdatePasswordActivity.this, "Invalid Username or Password", Toast.LENGTH_LONG);
+ toast.show();
+ }
+ });
+
+ }
+
+}
diff --git a/classnote/src/main/res/drawable-hdpi/drawer_shadow.9.png b/classnote/src/main/res/drawable-hdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..236bff5
Binary files /dev/null and b/classnote/src/main/res/drawable-hdpi/drawer_shadow.9.png differ
diff --git a/classnote/src/main/res/drawable-hdpi/ic_drawer.png b/classnote/src/main/res/drawable-hdpi/ic_drawer.png
new file mode 100644
index 0000000..c59f601
Binary files /dev/null and b/classnote/src/main/res/drawable-hdpi/ic_drawer.png differ
diff --git a/classnote/src/main/res/drawable-hdpi/ic_launcher.png b/classnote/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..f0659b1
Binary files /dev/null and b/classnote/src/main/res/drawable-hdpi/ic_launcher.png differ
diff --git a/res/drawable-hdpi/ic_launcher.png b/classnote/src/main/res/drawable-hdpi/ic_launcher2.png
similarity index 100%
rename from res/drawable-hdpi/ic_launcher.png
rename to classnote/src/main/res/drawable-hdpi/ic_launcher2.png
diff --git a/classnote/src/main/res/drawable-mdpi/drawer_shadow.9.png b/classnote/src/main/res/drawable-mdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..ffe3a28
Binary files /dev/null and b/classnote/src/main/res/drawable-mdpi/drawer_shadow.9.png differ
diff --git a/classnote/src/main/res/drawable-mdpi/ic_drawer.png b/classnote/src/main/res/drawable-mdpi/ic_drawer.png
new file mode 100644
index 0000000..1ed2c56
Binary files /dev/null and b/classnote/src/main/res/drawable-mdpi/ic_drawer.png differ
diff --git a/classnote/src/main/res/drawable-mdpi/ic_launcher.png b/classnote/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..5b8d5d6
Binary files /dev/null and b/classnote/src/main/res/drawable-mdpi/ic_launcher.png differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/classnote/src/main/res/drawable-mdpi/ic_launcher2.png
similarity index 100%
rename from res/drawable-mdpi/ic_launcher.png
rename to classnote/src/main/res/drawable-mdpi/ic_launcher2.png
diff --git a/classnote/src/main/res/drawable-xhdpi/drawer_shadow.9.png b/classnote/src/main/res/drawable-xhdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..fabe9d9
Binary files /dev/null and b/classnote/src/main/res/drawable-xhdpi/drawer_shadow.9.png differ
diff --git a/classnote/src/main/res/drawable-xhdpi/ic_drawer.png b/classnote/src/main/res/drawable-xhdpi/ic_drawer.png
new file mode 100644
index 0000000..a5fa74d
Binary files /dev/null and b/classnote/src/main/res/drawable-xhdpi/ic_drawer.png differ
diff --git a/classnote/src/main/res/drawable-xhdpi/ic_launcher.png b/classnote/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..45443dc
Binary files /dev/null and b/classnote/src/main/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/classnote/src/main/res/drawable-xhdpi/ic_launcher2.png
similarity index 100%
rename from res/drawable-xhdpi/ic_launcher.png
rename to classnote/src/main/res/drawable-xhdpi/ic_launcher2.png
diff --git a/classnote/src/main/res/drawable-xxhdpi/drawer_shadow.9.png b/classnote/src/main/res/drawable-xxhdpi/drawer_shadow.9.png
new file mode 100644
index 0000000..b91e9d7
Binary files /dev/null and b/classnote/src/main/res/drawable-xxhdpi/drawer_shadow.9.png differ
diff --git a/classnote/src/main/res/drawable-xxhdpi/ic_drawer.png b/classnote/src/main/res/drawable-xxhdpi/ic_drawer.png
new file mode 100644
index 0000000..9c4685d
Binary files /dev/null and b/classnote/src/main/res/drawable-xxhdpi/ic_drawer.png differ
diff --git a/classnote/src/main/res/drawable-xxhdpi/ic_launcher.png b/classnote/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..a2f06c5
Binary files /dev/null and b/classnote/src/main/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/classnote/src/main/res/drawable-xxhdpi/ic_launcher2.png
similarity index 100%
rename from res/drawable-xxhdpi/ic_launcher.png
rename to classnote/src/main/res/drawable-xxhdpi/ic_launcher2.png
diff --git a/classnote/src/main/res/layout/activity_announcement_details.xml b/classnote/src/main/res/layout/activity_announcement_details.xml
new file mode 100644
index 0000000..999a223
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_announcement_details.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/res/layout/activity_assignment_details.xml b/classnote/src/main/res/layout/activity_assignment_details.xml
new file mode 100644
index 0000000..f8da9f5
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_assignment_details.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/res/layout/activity_help_overlay.xml b/classnote/src/main/res/layout/activity_help_overlay.xml
new file mode 100644
index 0000000..72a1db2
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_help_overlay.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/res/layout/activity_login.xml b/classnote/src/main/res/layout/activity_login.xml
new file mode 100644
index 0000000..283faed
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_login.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/classnote/src/main/res/layout/activity_main.xml b/classnote/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..82e664d
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_main.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/res/layout/activity_update_password.xml b/classnote/src/main/res/layout/activity_update_password.xml
new file mode 100644
index 0000000..155d9b9
--- /dev/null
+++ b/classnote/src/main/res/layout/activity_update_password.xml
@@ -0,0 +1,10 @@
+
+
+
\ No newline at end of file
diff --git a/classnote/src/main/res/layout/fragment_add_assignment.xml b/classnote/src/main/res/layout/fragment_add_assignment.xml
new file mode 100644
index 0000000..45d6f10
--- /dev/null
+++ b/classnote/src/main/res/layout/fragment_add_assignment.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/classnote/src/main/res/layout/fragment_announcement_list.xml b/classnote/src/main/res/layout/fragment_announcement_list.xml
new file mode 100644
index 0000000..f8112a4
--- /dev/null
+++ b/classnote/src/main/res/layout/fragment_announcement_list.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/res/layout/fragment_assignment_list.xml b/classnote/src/main/res/layout/fragment_assignment_list.xml
similarity index 92%
rename from res/layout/fragment_assignment_list.xml
rename to classnote/src/main/res/layout/fragment_assignment_list.xml
index a3a5623..d7067bd 100644
--- a/res/layout/fragment_assignment_list.xml
+++ b/classnote/src/main/res/layout/fragment_assignment_list.xml
@@ -12,7 +12,7 @@
diff --git a/classnote/src/main/res/layout/fragment_navigation_drawer.xml b/classnote/src/main/res/layout/fragment_navigation_drawer.xml
new file mode 100644
index 0000000..080723e
--- /dev/null
+++ b/classnote/src/main/res/layout/fragment_navigation_drawer.xml
@@ -0,0 +1,9 @@
+
diff --git a/classnote/src/main/res/layout/list_item_announcement.xml b/classnote/src/main/res/layout/list_item_announcement.xml
new file mode 100644
index 0000000..e883eb5
--- /dev/null
+++ b/classnote/src/main/res/layout/list_item_announcement.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/list_item_assignment.xml b/classnote/src/main/res/layout/list_item_assignment.xml
similarity index 55%
rename from res/layout/list_item_assignment.xml
rename to classnote/src/main/res/layout/list_item_assignment.xml
index 358b8fa..e883eb5 100644
--- a/res/layout/list_item_assignment.xml
+++ b/classnote/src/main/res/layout/list_item_assignment.xml
@@ -10,16 +10,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
- android:text="test"
- android:textSize="22dp"
+ android:text="LCC-4811-JD2"
+ android:textSize="14sp"
+ android:textColor="#333333"
+ android:id="@+id/courseTitle"/>
+
+
\ No newline at end of file
diff --git a/classnote/src/main/res/menu/main.xml b/classnote/src/main/res/menu/main.xml
new file mode 100644
index 0000000..093b918
--- /dev/null
+++ b/classnote/src/main/res/menu/main.xml
@@ -0,0 +1,16 @@
+
diff --git a/res/values-large/styles.xml b/classnote/src/main/res/values-large/styles.xml
similarity index 100%
rename from res/values-large/styles.xml
rename to classnote/src/main/res/values-large/styles.xml
diff --git a/res/values-sw600dp/dimens.xml b/classnote/src/main/res/values-sw600dp/dimens.xml
similarity index 96%
rename from res/values-sw600dp/dimens.xml
rename to classnote/src/main/res/values-sw600dp/dimens.xml
index c876987..44f01db 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/classnote/src/main/res/values-sw600dp/dimens.xml
@@ -1,8 +1,8 @@
-
-
-
-
-
+ screen margins) for sw600dp devices (e.g. 7" tablets) here.
+ -->
+
+
diff --git a/res/values-sw720dp-land/dimens.xml b/classnote/src/main/res/values-sw720dp-land/dimens.xml
similarity index 97%
rename from res/values-sw720dp-land/dimens.xml
rename to classnote/src/main/res/values-sw720dp-land/dimens.xml
index 0df3067..61e3fa8 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/classnote/src/main/res/values-sw720dp-land/dimens.xml
@@ -1,9 +1,9 @@
-
-
-
- 128dp
-
-
+ screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+ -->
+ 128dp
+
+
diff --git a/res/values-v11/styles.xml b/classnote/src/main/res/values-v11/styles.xml
similarity index 97%
rename from res/values-v11/styles.xml
rename to classnote/src/main/res/values-v11/styles.xml
index e3ef53d..3c02242 100644
--- a/res/values-v11/styles.xml
+++ b/classnote/src/main/res/values-v11/styles.xml
@@ -1,11 +1,11 @@
-
-
-
-
-
-
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+
+
+
diff --git a/res/values-v14/styles.xml b/classnote/src/main/res/values-v14/styles.xml
similarity index 97%
rename from res/values-v14/styles.xml
rename to classnote/src/main/res/values-v14/styles.xml
index 94dd245..a91fd03 100644
--- a/res/values-v14/styles.xml
+++ b/classnote/src/main/res/values-v14/styles.xml
@@ -1,12 +1,12 @@
-
-
-
-
-
-
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+
+
+
diff --git a/classnote/src/main/res/values-w820dp/dimens.xml b/classnote/src/main/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..63fc816
--- /dev/null
+++ b/classnote/src/main/res/values-w820dp/dimens.xml
@@ -0,0 +1,6 @@
+
+
+ 64dp
+
diff --git a/classnote/src/main/res/values/color.xml b/classnote/src/main/res/values/color.xml
new file mode 100644
index 0000000..72203a6
--- /dev/null
+++ b/classnote/src/main/res/values/color.xml
@@ -0,0 +1,149 @@
+
+
+
+ #B000244D
+ #00244D
+
+
+#C0000000
+#FFFFFF
+#FFFFF0
+#FFFFE0
+#FFFF00
+#FFFAFA
+#FFFAF0
+#FFFACD
+#FFF8DC
+#FFF5EE
+#FFF0F5
+#FFEFD5
+#FFEBCD
+#FFE4E1
+#FFE4C4
+#FFE4B5
+#FFDEAD
+#FFDAB9
+#FFD700
+#FFC0CB
+#FFB6C1
+#FFA500
+#FFA07A
+#FF8C00
+#FF7F50
+#FF69B4
+#FF6347
+#FF4500
+#FF1493
+#FF00FF
+#FF00FF
+#FF0000
+#FDF5E6
+#FAFAD2
+#FAF0E6
+#FAEBD7
+#FA8072
+#F8F8FF
+#F5FFFA
+#F5F5F5
+#F5F5DC
+#F5DEB3
+#F4A460
+#F0FFFF
+#F0FFF0
+#F0F8FF
+#F0E68C
+#F08080
+#EEE8AA
+#EE82EE
+#E9967A
+#E6E6FA
+#E0FFFF
+#DEB887
+#DDA0DD
+#DCDCDC
+#DC143C
+#DB7093
+#DAA520
+#DA70D6
+#D8BFD8
+#D3D3D3
+#D2B48C
+#D2691E
+#CD853F
+#CD5C5C
+#C71585
+#C0C0C0
+#BDB76B
+#BC8F8F
+#BA55D3
+#B8860B
+#B22222
+#B0E0E6
+#B0C4DE
+#AFEEEE
+#ADFF2F
+#ADD8E6
+#A9A9A9
+#A52A2A
+#A0522D
+#9ACD32
+#9932CC
+#98FB98
+#9400D3
+#9370DB
+#90EE90
+#8FBC8F
+#8B4513
+#8B008B
+#8B0000
+#8A2BE2
+#87CEFA
+#87CEEB
+#808080
+#808000
+#800080
+#800000
+#7FFFD4
+#7FFF00
+#7CFC00
+#7B68EE
+#778899
+#708090
+#6B8E23
+#6A5ACD
+#696969
+#66CDAA
+#6495ED
+#5F9EA0
+#556B2F
+#4B0082
+#48D1CC
+#483D8B
+#4682B4
+#4169E1
+#40E0D0
+#3CB371
+#32CD32
+#2F4F4F
+#2E8B57
+#228B22
+#20B2AA
+#1E90FF
+#191970
+#00FFFF
+#00FFFF
+#00FF7F
+#00FF00
+#00FA9A
+#00CED1
+#00BFFF
+#008B8B
+#008080
+#008000
+#006400
+#0000FF
+#0000CD
+#00008B
+#000080
+#000000
+
\ No newline at end of file
diff --git a/res/values/dimens.xml b/classnote/src/main/res/values/dimens.xml
similarity index 69%
rename from res/values/dimens.xml
rename to classnote/src/main/res/values/dimens.xml
index 55c1e59..a776bac 100644
--- a/res/values/dimens.xml
+++ b/classnote/src/main/res/values/dimens.xml
@@ -1,7 +1,9 @@
+
16dp
16dp
+ 240dp
diff --git a/classnote/src/main/res/values/strings.xml b/classnote/src/main/res/values/strings.xml
new file mode 100644
index 0000000..64b3d7f
--- /dev/null
+++ b/classnote/src/main/res/values/strings.xml
@@ -0,0 +1,41 @@
+
+
+
+ ClassNote
+
+ Username
+ Password
+ Login
+
+ No Assignments
+
+ Course
+ Title
+ Description
+ Due Date
+ Save Assignment
+
+ Open navigation drawer
+ Close navigation drawer
+
+ - Tap the top left of the screen or swipe from the left to open the menu for the application
+ - All announcements are present on this page and are sorted from most to least recent
+
+
+ - Tap anywhere to dismiss instructions
+
+
+ - Open the navigation drawer to add new assignments
+ - Tap on an assignment to view in more detail
+
+
+ - Tap anywhere to dismiss instructions
+
+
+ - Tap a day to create a new assignment due on that date
+ - Slide up or down to go from one month to another
+
+
+ - Tap anywhere to dismiss instructions
+
+
\ No newline at end of file
diff --git a/res/values/styles.xml b/classnote/src/main/res/values/styles.xml
similarity index 66%
rename from res/values/styles.xml
rename to classnote/src/main/res/values/styles.xml
index 6a1df6c..bafc9e4 100644
--- a/res/values/styles.xml
+++ b/classnote/src/main/res/values/styles.xml
@@ -1,39 +1,42 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/classnote/src/main/res/xml/authenticator.xml b/classnote/src/main/res/xml/authenticator.xml
new file mode 100644
index 0000000..06a77fa
--- /dev/null
+++ b/classnote/src/main/res/xml/authenticator.xml
@@ -0,0 +1,8 @@
+
+
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..5d08ba7
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,18 @@
+# Project-wide Gradle settings.
+
+# IDE (e.g. Android Studio) users:
+# Settings specified in this file will override any Gradle settings
+# configured through the IDE.
+
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..1091aae
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Mar 25 23:13:24 EDT 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..91a7e26
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..8a0b282
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
deleted file mode 100644
index a18cbb4..0000000
Binary files a/ic_launcher-web.png and /dev/null differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
deleted file mode 100644
index 9056828..0000000
Binary files a/libs/android-support-v4.jar and /dev/null differ
diff --git a/res/layout/activity_add_assignment.xml b/res/layout/activity_add_assignment.xml
deleted file mode 100644
index 0d7f1d5..0000000
--- a/res/layout/activity_add_assignment.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
deleted file mode 100644
index 0914cb4..0000000
--- a/res/layout/activity_main.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
diff --git a/res/layout/activity_update.xml b/res/layout/activity_update.xml
deleted file mode 100644
index b103f1e..0000000
--- a/res/layout/activity_update.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/fragment_announcement_list.xml b/res/layout/fragment_announcement_list.xml
deleted file mode 100644
index 773b20d..0000000
--- a/res/layout/fragment_announcement_list.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
diff --git a/res/layout/fragment_assignment_calendar.xml b/res/layout/fragment_assignment_calendar.xml
deleted file mode 100644
index a203ef3..0000000
--- a/res/layout/fragment_assignment_calendar.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/layout/fragment_gradebook.xml b/res/layout/fragment_gradebook.xml
deleted file mode 100644
index 7f54d93..0000000
--- a/res/layout/fragment_gradebook.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/menu/add_assignment.xml b/res/menu/add_assignment.xml
deleted file mode 100644
index c002028..0000000
--- a/res/menu/add_assignment.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/res/menu/main.xml b/res/menu/main.xml
deleted file mode 100644
index 113fd29..0000000
--- a/res/menu/main.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
diff --git a/res/menu/update.xml b/res/menu/update.xml
deleted file mode 100644
index c002028..0000000
--- a/res/menu/update.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/res/values/strings.xml b/res/values/strings.xml
deleted file mode 100644
index 66b1226..0000000
--- a/res/values/strings.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- ClassNote
- Settings
- Section 1
- Section 2
- Section 3
- UpdateActivity
- Hello world!
- Update from T-Square
- View Cached Assignments
- Username
- Password
- Add
-
-
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..3a446ae
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+include ':classnote'
diff --git a/src/com/rumbleworks/classnote/AddAssignmentActivity.java b/src/com/rumbleworks/classnote/AddAssignmentActivity.java
deleted file mode 100644
index 9e39f11..0000000
--- a/src/com/rumbleworks/classnote/AddAssignmentActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-import android.view.Menu;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.DatePicker;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.TimePicker;
-
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-public class AddAssignmentActivity extends Activity {
-
- private Spinner courseSpinner;
- private EditText titleField, descField;
- private DatePicker datePicker;
- private TimePicker timePicker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_assignment);
-
- courseSpinner = (Spinner)findViewById(R.id.courseSpinner);
- courseSpinner.setAdapter(new ArrayAdapter(AddAssignmentActivity.this, android.R.layout.simple_spinner_item, Datamart.getInstance().getCourseIds()));
-
- titleField = (EditText)findViewById(R.id.titleField);
- descField = (EditText)findViewById(R.id.descField);
- datePicker = (DatePicker)findViewById(R.id.datePicker);
- timePicker = (TimePicker)findViewById(R.id.timePicker);
-
- Button saveButton = (Button)findViewById(R.id.saveAssignmentButton);
- saveButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Calendar date = new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute());
- Assignment assignment = new Assignment(titleField.getText().toString(), descField.getText().toString(), true, date.getTime(), (String)courseSpinner.getSelectedItem(), -1, -1, -1, -1);
- AddAssignmentActivity.this.finish();
- }
- });
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.add_assignment, menu);
- return true;
- }
-
-}
diff --git a/src/com/rumbleworks/classnote/Announcement.java b/src/com/rumbleworks/classnote/Announcement.java
deleted file mode 100644
index e0fc286..0000000
--- a/src/com/rumbleworks/classnote/Announcement.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.rumbleworks.classnote;
-
-import java.util.Date;
-
-/**
- * An Announcement is one of the T-Square, from-teacher notifications that are not actually assignments
- * but should be visible within the list function, thus it implements DataItem so we know we can
- * show it in our upcoming list
- */
-
-public class Announcement {
-
- public String name;
- public String description;
- public Boolean isRead;
- public Date dueDate;
- public int courseNumber;
-
- public Announcement(String name, String description, Boolean isRead, Date dueDate, int courseNumber) {
- this.name = name;
- this.description = description;
- this.isRead = isRead;
- this.dueDate = dueDate;
- this.courseNumber = courseNumber;
- }
-
- public String getName() {
- // TODO Auto-generated method stub
- return name;
- }
-
- public String getDescription() {
- // TODO Auto-generated method stub
- return description;
- }
-
-
- public Boolean getIsRead() {
- // TODO Auto-generated method stub
- return isRead;
- }
-
-
- public Date getDueDate() {
- // TODO Auto-generated method stub
- return dueDate;
- }
-
-
- public int getCourseNumber() {
- // TODO Auto-generated method stub
- return courseNumber;
- }
-
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- public void setIsRead(Boolean isRead) {
- this.isRead = isRead;
- }
-
-
- public void setDueDate(Date dueDate) {
- this.dueDate = dueDate;
- }
-
-
- public void setCourseNumber(int courseNumber) {
- this.courseNumber = courseNumber;
- }
-
-}
diff --git a/src/com/rumbleworks/classnote/AnnouncementListFragment.java b/src/com/rumbleworks/classnote/AnnouncementListFragment.java
deleted file mode 100644
index 23fadaf..0000000
--- a/src/com/rumbleworks/classnote/AnnouncementListFragment.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class AnnouncementListFragment extends Fragment {
- /**
- * The fragment argument representing the section number for this
- * fragment.
- */
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- public AnnouncementListFragment() {
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_announcement_list, container, false);
- //TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
- //dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
- //View topLevelLayout = rootfindViewById(R.id.top_layout);
- //topLevelLayout.setVisibility(View.INVISIBLE);
- return rootView;
- }
-}
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/Assignment.java b/src/com/rumbleworks/classnote/Assignment.java
deleted file mode 100644
index f3b6872..0000000
--- a/src/com/rumbleworks/classnote/Assignment.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.rumbleworks.classnote;
-
-import java.util.Date;
-
-/**
- * An assignment is a normal, t-square assignment that will be shown in the assignments list
- * and be able to be added to the final grade of the course
- */
-
-public class Assignment extends GradedWork implements Comparable {
-
- public Assignment(String name, String description, Boolean isRead, Date dueDate, String courseId, double pointsEarned, double pointsPossible, double overallScore, double percentageOfFinal) {
- super(name, description, isRead, dueDate, courseId, pointsEarned, pointsPossible, overallScore, percentageOfFinal);
- Course c = Datamart.getInstance().getCourseById(courseId);
- if (c == null) throw new IllegalArgumentException("Invalid course ID");
- c.addAssignment(this);
- }
-
- @Override
- public int compareTo(Assignment assignment) {
- return dueDate.compareTo(assignment.dueDate);
- }
-
-}
diff --git a/src/com/rumbleworks/classnote/AssignmentCalendarFragment.java b/src/com/rumbleworks/classnote/AssignmentCalendarFragment.java
deleted file mode 100644
index 6af5881..0000000
--- a/src/com/rumbleworks/classnote/AssignmentCalendarFragment.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class AssignmentCalendarFragment extends Fragment {
- /**
- * The fragment argument representing the section number for this
- * fragment.
- */
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- public AssignmentCalendarFragment() {
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_assignment_calendar, container, false);
- //TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
- //dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
- return rootView;
- }
-}
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/AssignmentListFragment.java b/src/com/rumbleworks/classnote/AssignmentListFragment.java
deleted file mode 100644
index 70e1b61..0000000
--- a/src/com/rumbleworks/classnote/AssignmentListFragment.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.os.Bundle;
-import android.provider.ContactsContract;
-import android.support.v4.app.ListFragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class AssignmentListFragment extends ListFragment {
- /**
- * The fragment argument representing the section number for this
- * fragment.
- */
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- public AssignmentListFragment() {
-
- }
-
-
- public void onResume() {
- super.onResume();
- AssignmentAdapter assignmentAdapter = (AssignmentAdapter)this.getListAdapter();
- assignmentAdapter.setList(Datamart.getInstance().getUpcomingAssignments());
- assignmentAdapter.notifyDataSetChanged();
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_assignment_list, container, false);
-
- this.setListAdapter(new AssignmentAdapter(Datamart.getInstance().getUpcomingAssignments(), this.getActivity()));
-
- return rootView;
- }
-
-
-}
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/Datamart.java b/src/com/rumbleworks/classnote/Datamart.java
deleted file mode 100644
index b9094d5..0000000
--- a/src/com/rumbleworks/classnote/Datamart.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.rumbleworks.classnote;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-public class Datamart {
-
- static Datamart instance;
-
- private ArrayList courseList;
-
- public Datamart() {
- courseList = new ArrayList();
- courseList.add(new Course("Junior Design 2", "CS", 3802));
- courseList.add(new Course("Intro to Networking", "CS", 3251));
- courseList.add(new Course("Art History II", "COA", 2242));
- }
-
- public static Datamart getInstance() {
- if (instance == null) {
- instance = new Datamart();
- }
- return instance;
- }
-
- public List getCourseIds() {
- ArrayList courseIds = new ArrayList();
- for (Course c : courseList) {
- courseIds.add(c.getCourseId());
- }
- return courseIds;
- }
-
- public Course getCourseById(String courseId) {
- for (Course c : courseList) {
- if (c.getCourseId().equals(courseId)) return c;
- }
- return null;
- }
-
- public List getAllAssignments() {
- List list = new LinkedList();
- for (Course c : getCourseList()) {
- list.addAll(c.getAssignmentList());
- }
- return list;
- }
-
- public List getUpcomingAssignments() {
- List list = new LinkedList();
- for (Course c : getCourseList()) {
- for (Assignment a : c.getAssignmentList()) {
- if (a.getDueDate().after(new Date())) {
- list.add(a);
- }
- }
- }
- return list;
- }
-
- public List getCourseList() {
- return courseList;
- }
-
- public void addCourse(Course c) {
- courseList.add(c);
- }
-}
diff --git a/src/com/rumbleworks/classnote/GradebookFragment.java b/src/com/rumbleworks/classnote/GradebookFragment.java
deleted file mode 100644
index 788a410..0000000
--- a/src/com/rumbleworks/classnote/GradebookFragment.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-public class GradebookFragment extends Fragment {
- /**
- * The fragment argument representing the section number for this
- * fragment.
- */
- public static final String ARG_SECTION_NUMBER = "section_number";
-
- public GradebookFragment() {
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View rootView = inflater.inflate(R.layout.fragment_gradebook, container, false);
- //TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
- //dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
- return rootView;
- }
-}
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/JsonHttpResponseHandler.java b/src/com/rumbleworks/classnote/JsonHttpResponseHandler.java
deleted file mode 100644
index dc67c0a..0000000
--- a/src/com/rumbleworks/classnote/JsonHttpResponseHandler.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.rumbleworks.classnote;
-
-import org.json.JSONObject;
-
-public interface JsonHttpResponseHandler {
-
- public void onSuccess(JSONObject object);
- public void onFailure();
-
-}
diff --git a/src/com/rumbleworks/classnote/MainActivity.java b/src/com/rumbleworks/classnote/MainActivity.java
deleted file mode 100644
index 799ad1c..0000000
--- a/src/com/rumbleworks/classnote/MainActivity.java
+++ /dev/null
@@ -1,229 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.app.ActionBar;
-import android.app.Dialog;
-import android.app.FragmentTransaction;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-//import android.support.v4.app.NavUtils;
-import android.support.v4.view.ViewPager;
-//import android.view.Gravity;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.FrameLayout;
-//import android.view.MenuItem;
-
-
-public class MainActivity extends FragmentActivity implements ActionBar.TabListener {
-
- /**
- * The {@link android.support.v4.view.PagerAdapter} that will provide
- * fragments for each of the sect
- * {@link android.support.v4.app.FragmentPagerAdapter} derivative, which
- * will keep every loaded fragment in memory. If this becomes too memory
- * intensive, it may be best to switch to a
- * {@link android.support.v4.app.FragmentStatePagerAdapter}.
- */
- SectionsPagerAdapter mSectionsPagerAdapter;
-
- /**
- * The {@link ViewPager} that will host the section contents.
- */
- ViewPager mViewPager;
- FrameLayout mFrame;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- Intent oldIntent = getIntent();
- String username = oldIntent.getExtras().getString("username");
- Log.v("cat", "cat " + username);
-
- //arrayList = oldIntent.getCharSequenceArrayListExtra("arrayList");
-
-
- // Set up the action bar.
- final ActionBar actionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
-
- // Create the adapter that will return a fragment for each of the three
- // primary sections of the app.
- mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
-
- // Set up the ViewPager with the sections adapter.
- mViewPager = (ViewPager) findViewById(R.id.pager);
- mViewPager.setAdapter(mSectionsPagerAdapter);
-
- // When swiping between different sections, select the corresponding
- // tab. We can also use ActionBar.Tab#select() to do this if we have
- // a reference to the Tab.
- mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(int position) {
- actionBar.setSelectedNavigationItem(position);
- }
- });
-
- // For each of the sections in the app, add a tab to the action bar.
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- // Create a tab with text corresponding to the page title defined by
- // the adapter. Also specify this Activity object, which implements
- // the TabListener interface, as the callback (listener) for when
- // this tab is selected.
- actionBar.addTab(
- actionBar.newTab()
- .setText(mSectionsPagerAdapter.getPageTitle(i))
- .setTabListener(this));
- }
-
-
- /**
- * This part implements the overlay using a dialog
- */
- Dialog overlayInfo = new Dialog(MainActivity.this);
- // Making sure there's no title.
- overlayInfo.requestWindowFeature(Window.FEATURE_NO_TITLE);
- // Making dialog content transparent.
- overlayInfo.getWindow().setBackgroundDrawable(
- new ColorDrawable(Color.TRANSPARENT));
- // Removing window dim normally visible when dialog are shown.
- overlayInfo.getWindow().clearFlags(
- WindowManager.LayoutParams.FLAG_DIM_BEHIND);
- // Setting position of content, relative to window.
- WindowManager.LayoutParams params = overlayInfo.getWindow().getAttributes();
- params.gravity = Gravity.TOP | Gravity.LEFT;
- params.x = 100;
- params.y = 20;
- // If user taps anywhere on the screen, dialog will be cancelled.
- overlayInfo.setCancelable(true);
- // Setting the content using prepared XML layout file.
-
- //overlayInfo.setContentView(R.layout.overlay);
-
- overlayInfo.show();
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.action_add_assignment) {
- Intent intent = new Intent(this, AddAssignmentActivity.class);
- startActivity(intent);
- return true;
- }
- return false;
- }
-
- @Override
- public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- // When the given tab is selected, switch to the corresponding page in
- // the ViewPager.
- mViewPager.setCurrentItem(tab.getPosition());
- }
-
- @Override
- public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- }
-
- @Override
- public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- }
-
- /**
- * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
- * one of the sections/tabs/pages.
- */
- public class SectionsPagerAdapter extends FragmentPagerAdapter {
-
- public SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
- }
-
- @Override
- public Fragment getItem(int position) {
- // getItem is called to instantiate the fragment for the given page.
- // Return a DummySectionFragment (defined as a static inner class
- // below) with the page number as its lone argument.
- Fragment fragment = null;
- Bundle args = new Bundle();
-
- if ( position == 0 ) {
- fragment = new AssignmentListFragment();
- args.putInt(AssignmentListFragment.ARG_SECTION_NUMBER, position + 1);
- }
- if ( position == 1 ) {
- fragment = new AssignmentCalendarFragment();
- args.putInt(AssignmentCalendarFragment.ARG_SECTION_NUMBER, position + 1);
- }
- if ( position == 2 ) {
- fragment = new AnnouncementListFragment();
- args.putInt(AnnouncementListFragment.ARG_SECTION_NUMBER, position + 1);
- }
- if ( position == 3 ) {
- fragment = new GradebookFragment();
- args.putInt(GradebookFragment.ARG_SECTION_NUMBER, position + 1);
- }
- fragment.setArguments(args);
- return fragment;
- }
-
- @Override
- public int getCount() {
- // Show 3 total pages.
- return 4;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- //Locale l = Locale.getDefault();
- switch (position) {
- case 0:
- return "Upcoming Assignments";
- case 1:
- return "Calendar";
- case 2:
- return "Announcements";
- case 3:
- return "Gradebook";
- }
- return null;
- }
- }
-
- @Override
- public void onBackPressed() {
- //start activity here
- Intent intent = new Intent();
-
- intent.setClass(MainActivity.this, UpdateActivity.class);
-
- startActivity(intent);
- finish();
-
- super.onBackPressed();
-
- }
-
-}
diff --git a/src/com/rumbleworks/classnote/TSquareAPI.java b/src/com/rumbleworks/classnote/TSquareAPI.java
deleted file mode 100644
index 2755d43..0000000
--- a/src/com/rumbleworks/classnote/TSquareAPI.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package com.rumbleworks.classnote;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class TSquareAPI {
- public static BasicCookieStore cookieStore = new BasicCookieStore();
- private static final String BASE_URL = "https://t-square.gatech.edu/direct";
-
- public static void login(final String username, final String password, final JsonHttpResponseHandler handler) {
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- // Create a new HttpClient and Post Header
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("https://t-square.gatech.edu/direct/session");
- HttpContext httpContext = new BasicHttpContext();
-
- httpContext.setAttribute(ClientContext.COOKIE_STORE, TSquareAPI.cookieStore);
-
- // Add your data
- List nameValuePairs = new ArrayList(2);
- nameValuePairs.add(new BasicNameValuePair("_username", username));
- nameValuePairs.add(new BasicNameValuePair("_password", password));
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
-
- // Execute HTTP Post Request
- HttpResponse response = httpclient.execute(httppost, httpContext);
- String responseStr = EntityUtils.toString(response.getEntity());
- if (response.getStatusLine().getStatusCode() == 201) {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("session_id", responseStr);
- if (handler != null) {
- handler.onSuccess(jsonObject);
- }
- } else {
- if (handler != null) handler.onFailure();
- }
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- } catch (IOException e) {
- // TODO Auto-generated catch block
- } catch (JSONException e) {}
- }
- });
- thread.start();
- }
-
- // eventually use this to see if the users session has expired
- public static void getSession(final JsonHttpResponseHandler handler) {
- get("/session", handler);
- }
-
- public static void get(final String resource, final JsonHttpResponseHandler handler) {
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- HttpClient httpClient = new DefaultHttpClient();
- HttpContext httpContext = new BasicHttpContext();
-
- httpContext.setAttribute(ClientContext.COOKIE_STORE, TSquareAPI.cookieStore);
-
- HttpRequestBase request = new HttpGet(BASE_URL+resource+".json");
- HttpResponse response = httpClient.execute(request, httpContext);
- String responseStr = EntityUtils.toString(response.getEntity());
- if (response.getStatusLine().getStatusCode() >= 200 && response.getStatusLine().getStatusCode() < 300) {
- if (handler != null) {
- JSONObject jsonObject = new JSONObject(responseStr);
- handler.onSuccess(jsonObject);
- }
- } else {
- if (handler != null) handler.onFailure();
- }
- } catch (Exception e) {}
-
- }
- });
- thread.start();
- }
-}
-
-
-//https://t-square.gatech.edu/direct/site/gtc-0bb4-a1ee-5d18-a027-8c20b42c1703/.json
-//gets a json format of all classes i have ever been in
-
-//https://t-square.gatech.edu/portal/tool/3f4094d2-857f-4585-8e1d-b153a8690724?itemReference=/announcement/msg/gtc-cb8b-5158-5600-8483-86ad218d680a/main/
\ No newline at end of file
diff --git a/src/com/rumbleworks/classnote/Test.java b/src/com/rumbleworks/classnote/Test.java
deleted file mode 100644
index 3eff9fd..0000000
--- a/src/com/rumbleworks/classnote/Test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.rumbleworks.classnote;
-
-import java.util.Date;
-
-public class Test extends GradedWork {
-
- public Test(String name, String description, Boolean isRead, Date dueDate, String courseId, double pointsEarned, double pointsPossible, double overallScore, double percentageOfFinal ) {
- super(name, description, isRead, dueDate, courseId, pointsEarned, pointsPossible, overallScore, percentageOfFinal );
- }
-}
diff --git a/src/com/rumbleworks/classnote/UpdateActivity.java b/src/com/rumbleworks/classnote/UpdateActivity.java
deleted file mode 100644
index 9721a47..0000000
--- a/src/com/rumbleworks/classnote/UpdateActivity.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.rumbleworks.classnote;
-
-import android.os.Bundle;
-import android.app.Activity;
-import android.content.Intent;
-import android.view.Menu;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.Toast;
-
-import org.json.JSONObject;
-
-public class UpdateActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_update);
-
-
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.update, menu);
- return true;
- }
-
- public void login( View view ) {
- EditText usernameField = (EditText)findViewById(R.id.usernameField);
- EditText passwordField = (EditText)findViewById(R.id.passwordField);
- final String username = usernameField.getText().toString();
-
- TSquareAPI.login(usernameField.getText().toString(), passwordField.getText().toString(), new JsonHttpResponseHandler() {
- @Override
- public void onSuccess(JSONObject object) {
- Intent intent = new Intent();
- intent.putExtra("username", username);
- intent.setClass(UpdateActivity.this, MainActivity.class);
-
- startActivity(intent);
- finish();
- }
-
- @Override
- public void onFailure() {
- UpdateActivity.this.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Toast toast = Toast.makeText(UpdateActivity.this, "Invalid Username or Password", Toast.LENGTH_LONG);
- toast.show();
- }
- });
- }
- });
-
- }
-
-}