diff --git a/res/values/strings.xml b/res/values/strings.xml index 1b67bcb..841edba 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -15,5 +15,6 @@ UNCCGameDay unccharlotte Gameday.sqlite + GamedayPreferences diff --git a/src/com/uncc/gameday/alerts/Alert.java b/src/com/uncc/gameday/alerts/Alert.java index 8e7b083..b81e72c 100644 --- a/src/com/uncc/gameday/alerts/Alert.java +++ b/src/com/uncc/gameday/alerts/Alert.java @@ -6,6 +6,7 @@ public class Alert { private Date alarmDate; private String message; + private boolean shown; public Date getAlarmDate() { return alarmDate; @@ -20,5 +21,11 @@ public class Alert { public void setMessage(String message) { this.message = message; } + public boolean isShown() { + return shown; + } + public void setShown(boolean shown) { + this.shown = shown; + } } diff --git a/src/com/uncc/gameday/alerts/AlertDB.java b/src/com/uncc/gameday/alerts/AlertDB.java index e8879c2..5b6ac00 100644 --- a/src/com/uncc/gameday/alerts/AlertDB.java +++ b/src/com/uncc/gameday/alerts/AlertDB.java @@ -19,21 +19,11 @@ public class AlertDB { public void insertAlert(Alert alert) { // Add a new date to the database } - - public void insertAlertRead(Alert alert) { - // Add a new date to the database that should not be alerted. - // This way, you can display it in the recent alerts list, but - // not show it to the user. - } - + public void insertAlerts(List alarmDates) { // Add multiple new dates to the database } - public void insertAlertsRead(List alarmDates) { - // Add multiple new dates to the database, and mark them as read. - } - public List fetchUnreadAlerts() { // Get a list of all currently unread alerts diff --git a/src/com/uncc/gameday/alerts/AlertFetcher.java b/src/com/uncc/gameday/alerts/AlertFetcher.java index bcfbdd4..2b3486c 100644 --- a/src/com/uncc/gameday/alerts/AlertFetcher.java +++ b/src/com/uncc/gameday/alerts/AlertFetcher.java @@ -9,6 +9,7 @@ import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import android.content.Context; +import android.content.SharedPreferences; import android.widget.Toast; import com.uncc.gameday.R; @@ -19,24 +20,24 @@ public class AlertFetcher { private int maxTweets = 5; public void fetchAlerts(Context ctx) { - /* This method needs to be re-written to use better logic. */ - - /* // Fetch all alerts. Responsible for discovering what sources need to be fetched. - if (((CheckBox)findViewById(R.id.alerts_check_timed)).isChecked()) + // Note we have to use the SharedPreferences so that we have preferences no matter what activity + // sent us this context + SharedPreferences settings = ctx.getSharedPreferences(ctx.getString(R.string.preferences_file), 0); // MODE_PRIVATE + + if (settings.getBoolean("ALERT_TIMED", false)) // Fetch timed alerts - this.fetchTimedAlerts(); - else if (((CheckBox)findViewById(R.id.alerts_check_organizations)).isChecked()) + this.fetchTimedAlerts(ctx); + else if (settings.getBoolean("ALERT_ORGANIZATION", false)) // Fetch organization alerts - this.fetchOrganizationAlerts(); - else if (((CheckBox)findViewById(R.id.alerts_check_university)).isChecked()) + this.fetchOrganizationAlerts(ctx); + else if (settings.getBoolean("ALERT_UNIVERSITY", false)) // Fetch university alerts - this.fetchUniversityAlerts(); + this.fetchUniversityAlerts(ctx); // And always fetch alerts made by us. Period. - this.fetchGamedayAlerts(); - */ + this.fetchGamedayAlerts(ctx); } private void fetchTimedAlerts(Context ctx) {