diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..9f31724
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/DNSapp.apk b/bin/DNSapp.apk
new file mode 100644
index 0000000..42d16c2
Binary files /dev/null and b/bin/DNSapp.apk differ
diff --git a/bin/classes.dex b/bin/classes.dex
new file mode 100644
index 0000000..113e1fa
Binary files /dev/null and b/bin/classes.dex differ
diff --git a/bin/com/studentersamfundet/app/DataHandler.class b/bin/com/studentersamfundet/app/DataHandler.class
new file mode 100644
index 0000000..9172afb
Binary files /dev/null and b/bin/com/studentersamfundet/app/DataHandler.class differ
diff --git a/bin/com/studentersamfundet/app/DnsActivity.class b/bin/com/studentersamfundet/app/DnsActivity.class
new file mode 100644
index 0000000..9d40e94
Binary files /dev/null and b/bin/com/studentersamfundet/app/DnsActivity.class differ
diff --git a/bin/com/studentersamfundet/app/Event.class b/bin/com/studentersamfundet/app/Event.class
new file mode 100644
index 0000000..4fb1822
Binary files /dev/null and b/bin/com/studentersamfundet/app/Event.class differ
diff --git a/bin/com/studentersamfundet/app/FeedFetcher.class b/bin/com/studentersamfundet/app/FeedFetcher.class
new file mode 100644
index 0000000..01e3af2
Binary files /dev/null and b/bin/com/studentersamfundet/app/FeedFetcher.class differ
diff --git a/bin/com/studentersamfundet/app/ProgramList.class b/bin/com/studentersamfundet/app/ProgramList.class
new file mode 100644
index 0000000..c2c3e45
Binary files /dev/null and b/bin/com/studentersamfundet/app/ProgramList.class differ
diff --git a/bin/com/studentersamfundet/app/R$attr.class b/bin/com/studentersamfundet/app/R$attr.class
new file mode 100644
index 0000000..3616b76
Binary files /dev/null and b/bin/com/studentersamfundet/app/R$attr.class differ
diff --git a/bin/com/studentersamfundet/app/R$drawable.class b/bin/com/studentersamfundet/app/R$drawable.class
new file mode 100644
index 0000000..5862244
Binary files /dev/null and b/bin/com/studentersamfundet/app/R$drawable.class differ
diff --git a/bin/com/studentersamfundet/app/R$id.class b/bin/com/studentersamfundet/app/R$id.class
new file mode 100644
index 0000000..1342de8
Binary files /dev/null and b/bin/com/studentersamfundet/app/R$id.class differ
diff --git a/bin/com/studentersamfundet/app/R$layout.class b/bin/com/studentersamfundet/app/R$layout.class
new file mode 100644
index 0000000..81a9132
Binary files /dev/null and b/bin/com/studentersamfundet/app/R$layout.class differ
diff --git a/bin/com/studentersamfundet/app/R$string.class b/bin/com/studentersamfundet/app/R$string.class
new file mode 100644
index 0000000..5798c58
Binary files /dev/null and b/bin/com/studentersamfundet/app/R$string.class differ
diff --git a/bin/com/studentersamfundet/app/R.class b/bin/com/studentersamfundet/app/R.class
new file mode 100644
index 0000000..f6a3fd9
Binary files /dev/null and b/bin/com/studentersamfundet/app/R.class differ
diff --git a/bin/com/studentersamfundet/app/XmlParser.class b/bin/com/studentersamfundet/app/XmlParser.class
new file mode 100644
index 0000000..d18b4dc
Binary files /dev/null and b/bin/com/studentersamfundet/app/XmlParser.class differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
new file mode 100644
index 0000000..0b1612f
Binary files /dev/null and b/bin/resources.ap_ differ
diff --git a/default.properties b/default.properties
new file mode 100644
index 0000000..e2e8061
--- /dev/null
+++ b/default.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/proguard.cfg b/proguard.cfg
new file mode 100644
index 0000000..12dd039
--- /dev/null
+++ b/proguard.cfg
@@ -0,0 +1,36 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+-keepclasseswithmembernames class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/res/drawable-hdpi/dnstest.png b/res/drawable-hdpi/dnstest.png
new file mode 100644
index 0000000..f39af15
Binary files /dev/null and b/res/drawable-hdpi/dnstest.png differ
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
new file mode 100644
index 0000000..8074c4c
Binary files /dev/null and b/res/drawable-hdpi/icon.png differ
diff --git a/res/drawable-hdpi/partest.png b/res/drawable-hdpi/partest.png
new file mode 100644
index 0000000..c15f84d
Binary files /dev/null and b/res/drawable-hdpi/partest.png differ
diff --git a/res/drawable-ldpi/dnstest.png b/res/drawable-ldpi/dnstest.png
new file mode 100644
index 0000000..f39af15
Binary files /dev/null and b/res/drawable-ldpi/dnstest.png differ
diff --git a/res/drawable-ldpi/icon.png b/res/drawable-ldpi/icon.png
new file mode 100644
index 0000000..1095584
Binary files /dev/null and b/res/drawable-ldpi/icon.png differ
diff --git a/res/drawable-ldpi/partest.png b/res/drawable-ldpi/partest.png
new file mode 100644
index 0000000..c15f84d
Binary files /dev/null and b/res/drawable-ldpi/partest.png differ
diff --git a/res/drawable-mdpi/dnstest.png b/res/drawable-mdpi/dnstest.png
new file mode 100644
index 0000000..f39af15
Binary files /dev/null and b/res/drawable-mdpi/dnstest.png differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..a07c69f
Binary files /dev/null and b/res/drawable-mdpi/icon.png differ
diff --git a/res/drawable-mdpi/partest.png b/res/drawable-mdpi/partest.png
new file mode 100644
index 0000000..c15f84d
Binary files /dev/null and b/res/drawable-mdpi/partest.png differ
diff --git a/res/layout/event_list.xml b/res/layout/event_list.xml
new file mode 100644
index 0000000..9acb594
--- /dev/null
+++ b/res/layout/event_list.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/footer.xml b/res/layout/footer.xml
new file mode 100644
index 0000000..8be28ff
--- /dev/null
+++ b/res/layout/footer.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/header.xml b/res/layout/header.xml
new file mode 100644
index 0000000..95aaca1
--- /dev/null
+++ b/res/layout/header.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/main.xml b/res/layout/main.xml
new file mode 100644
index 0000000..80c5f28
--- /dev/null
+++ b/res/layout/main.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..aa64879
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,9 @@
+
+
+ Det Norske Studentersamfund
+ PROGRAM
+ BLI MED
+ Ingen nettilkobling. Du må være tilkoblet nettet for å se programmet.
+ Ingen nettilkobling. Programmet er altså ikke oppdatert.
+ Booke band, tappe øl eller lede politiske debatter? Du vil garantert finne noe av interesse hvis du har lyst til å bli aktiv i en av de mange foreningene som driver DNS. Her lærer vi alt du ikke hører om på forelesningene. Praktisk erfaring og utfordringer som kan være gull verdt når den voksne verden en gang banker på døren.\n\nHva vil du huske fra studietiden? Lesesalen? Pensum? Eksamensnerver? Det er nå du har sjansen til å skape minnene som varer hele livet. Venner, fester, gallamiddager og nach så lenge du orker.\n\n “Vi gir deg minnene fra studietiden du aldri vil glemme.”\n\nTa kontakt på blimed@studentersamfundet.no for mer informasjon!
+
diff --git a/src/com/studentersamfundet/app/DataHandler.java b/src/com/studentersamfundet/app/DataHandler.java
new file mode 100644
index 0000000..8f16441
--- /dev/null
+++ b/src/com/studentersamfundet/app/DataHandler.java
@@ -0,0 +1,29 @@
+package com.studentersamfundet.app;
+
+public class DataHandler {
+ Event events;
+
+ void insert(String id, String title, String description, String date, String location, String category) {
+ int intId = Integer.parseInt(id);
+ if (get(intId) != null)
+ return;
+
+ Event e = new Event(intId, title, description, date, location, category);
+
+ if (events == null)
+ events = e;
+ else {
+ Event tmp = events;
+ while (tmp.next != null)
+ tmp = tmp.next;
+ tmp.next = e;
+ }
+ }
+
+ Event get(int id) {
+ Event e = events;
+ while (e != null && e.id != id)
+ e = e.next;
+ return e;
+ }
+}
diff --git a/src/com/studentersamfundet/app/DnsActivity.java b/src/com/studentersamfundet/app/DnsActivity.java
new file mode 100644
index 0000000..002b66a
--- /dev/null
+++ b/src/com/studentersamfundet/app/DnsActivity.java
@@ -0,0 +1,103 @@
+package com.studentersamfundet.app;
+
+import org.w3c.dom.NodeList;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+public class DnsActivity extends Activity {
+ public static final String PREFS_NAME = "DnsPrefs";
+ public static final String feedURL = "http://folk.uio.no/larsjeng/test.xml";
+ public static final String localURL = "/data/com.studentersamfundet.app/files/dns_events";
+ public static FeedFetcher feed = new FeedFetcher();
+ public static XmlParser parser = new XmlParser();
+ public DataHandler dh;
+ Context context = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+
+ View tmp = this.findViewById(R.id.join_us_textview);
+ tmp.setVisibility(View.INVISIBLE);
+
+ context = getApplicationContext();
+ SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
+ boolean firstStart = prefs.getBoolean("firstStart", false);
+
+ // Is it the first time the app is started?
+ if (!firstStart) {
+ // Do we have intarwebs?
+ // YAY = Fetch the feed.
+ // NAY = Inform about no connection.
+ if (checkConnection()) {
+ NodeList itemNodes = feed.fetch(feedURL, this, true);
+ dh = parser.parse(itemNodes);
+ } else {
+ Toast toast = Toast.makeText(context, R.string.error_noconnection_firstart, Toast.LENGTH_LONG);
+ toast.show();
+ }
+ } else {
+ if (checkConnection()) {
+ NodeList itemNodes = feed.fetch(feedURL, this, true);
+ dh = parser.parse(itemNodes);
+ } else {
+ NodeList itemNodes = feed.fetch(localURL, this, false);
+ dh = parser.parse(itemNodes);
+
+ Toast toast = Toast.makeText(context, R.string.error_noconnection_noupdate, Toast.LENGTH_LONG);
+ toast.show();
+ }
+ }
+ }
+
+ public void clickHandler(View v) {
+ if (v.getId() == R.id.program_button) {
+ startActivity(new Intent(context, ProgramList.class));
+ } else if (v.getId() == R.id.bli_med_button) {
+ View j = this.findViewById(R.id.bli_med_button);
+ ImageView p = (ImageView)this.findViewById(R.id.paragraph);
+ View t = this.findViewById(R.id.join_us_textview);
+
+ j.setClickable(false);
+ p.setVisibility(View.INVISIBLE);
+ t.setVisibility(View.VISIBLE);
+
+ // FIX ON BACK PRESSED!
+ }
+ }
+
+ @Override
+ public void onBackPressed () {
+ View t = this.findViewById(R.id.join_us_textview);
+ if (t.getVisibility() == View.VISIBLE) {
+ View j = this.findViewById(R.id.bli_med_button);
+ ImageView p = (ImageView)this.findViewById(R.id.paragraph);
+ j.setClickable(true);
+ t.setVisibility(View.INVISIBLE);
+ p.setVisibility(View.VISIBLE);
+ } else {
+ finish();
+ }
+
+ }
+
+ /* Check for Internet connection. */
+ boolean checkConnection() {
+ ConnectivityManager conMan
+ = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo netInfo = conMan.getActiveNetworkInfo();
+ return netInfo != null;
+ }
+}
\ No newline at end of file
diff --git a/src/com/studentersamfundet/app/Event.java b/src/com/studentersamfundet/app/Event.java
new file mode 100644
index 0000000..3c68619
--- /dev/null
+++ b/src/com/studentersamfundet/app/Event.java
@@ -0,0 +1,20 @@
+package com.studentersamfundet.app;
+
+public class Event {
+ int id;
+ String title;
+ String description;
+ String date;
+ String location;
+ String category;
+ Event next;
+
+ Event(int id, String title, String description, String date, String location, String category) {
+ this.id = id;
+ this.title = title;
+ this.description = description;
+ this.date = date;
+ this.location = location;
+ this.category = category;
+ }
+}
diff --git a/src/com/studentersamfundet/app/FeedFetcher.java b/src/com/studentersamfundet/app/FeedFetcher.java
new file mode 100644
index 0000000..24fc453
--- /dev/null
+++ b/src/com/studentersamfundet/app/FeedFetcher.java
@@ -0,0 +1,109 @@
+package com.studentersamfundet.app;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import android.content.Context;
+
+public class FeedFetcher {
+ String curLastBuild = "";
+
+ private InputStream OpenHttpConnection(String URL) throws IOException {
+ InputStream in = null;
+ int response = -1;
+ URL url = new URL(URL);
+ URLConnection con = url.openConnection();
+
+ if (!(con instanceof HttpURLConnection))
+ throw new IOException("Not an HTTP connection!");
+
+ try {
+ HttpURLConnection httpCon = (HttpURLConnection) con;
+ httpCon.setAllowUserInteraction(false);
+ httpCon.setInstanceFollowRedirects(true);
+ httpCon.setRequestMethod("GET");
+ httpCon.connect();
+
+ response = httpCon.getResponseCode();
+
+ if (response == HttpURLConnection.HTTP_OK)
+ in = httpCon.getInputStream();
+ } catch (Exception e) {
+ throw new IOException("Error connecting.");
+ }
+
+ return in;
+ }
+
+ public NodeList fetch(String URL, Context c, boolean con) {
+ InputStream in = null;
+ NodeList itemNodes = null;
+
+ try {
+ if (con) {
+ in = OpenHttpConnection(URL);
+ saveFile(in, c);
+ in = OpenHttpConnection(URL);
+ } else
+ in = new FileInputStream(URL);
+ Document doc = null;
+ DocumentBuilderFactory dbf =
+ DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+
+ try {
+ db = dbf.newDocumentBuilder();
+ doc = db.parse(in);
+ } catch (ParserConfigurationException e) {
+ } catch (SAXException e) {}
+
+ doc.getDocumentElement().normalize();
+
+ // Retrieve all the - nodes.
+ itemNodes = doc.getElementsByTagName("item");
+ in.close();
+ } catch (IOException e) {}
+ return itemNodes;
+ }
+
+ void saveFile(InputStream in, Context c) {
+ InputStreamReader isr = new InputStreamReader(in);
+ int charRead;
+ int BUFFER_SIZE = 2000;
+ String FILENAME = "dns_events";
+ String str = "";
+ char[] inputBuffer = new char[BUFFER_SIZE];
+
+ try {
+ while ((charRead = isr.read(inputBuffer))>0) {
+ String readString = String.copyValueOf(inputBuffer, 0, charRead);
+ str += readString;
+ inputBuffer = new char[BUFFER_SIZE];
+ }
+ in.close();
+ } catch (IOException e) {}
+
+ try {
+ FileOutputStream fos = c.openFileOutput(FILENAME, Context.MODE_PRIVATE);
+ fos.write(str.getBytes());
+ fos.close();
+ } catch (FileNotFoundException e) {
+ } catch (IOException e){}
+
+ }
+}
diff --git a/src/com/studentersamfundet/app/ProgramList.java b/src/com/studentersamfundet/app/ProgramList.java
new file mode 100644
index 0000000..03c55a2
--- /dev/null
+++ b/src/com/studentersamfundet/app/ProgramList.java
@@ -0,0 +1,51 @@
+package com.studentersamfundet.app;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+
+public class ProgramList extends ListActivity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // setContentView(R.layout.event_list);
+
+ // View v = this.findViewById(R.id.program_button);
+ // v.setClickable(false);
+
+ View header = getLayoutInflater().inflate(R.layout.header, null);
+ View footer = getLayoutInflater().inflate(R.layout.footer, null);
+
+ ListView listView = getListView();
+ listView.addHeaderView(header);
+ listView.addFooterView(footer);
+
+ ListAdapter adapter = createAdapter();
+ setListAdapter(adapter);
+ }
+
+ protected ListAdapter createAdapter() {
+ String[] vals = populateList();
+ ListAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, vals);
+
+ return adapter;
+ }
+
+ public String[] populateList() {
+ String[] val = new String[10];
+ val[0] = "test!";
+ val[1] = "test2";
+ val[2] = "test3";
+ val[3] = "test3";
+ val[4] = "test3";
+ val[5] = "test3";
+ val[6] = "test3";
+ val[7] = "test3";
+ val[8] = "test3";
+ val[9] = "test3";
+ return val;
+ }
+}
diff --git a/src/com/studentersamfundet/app/XmlParser.java b/src/com/studentersamfundet/app/XmlParser.java
new file mode 100644
index 0000000..baf8e72
--- /dev/null
+++ b/src/com/studentersamfundet/app/XmlParser.java
@@ -0,0 +1,66 @@
+package com.studentersamfundet.app;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class XmlParser {
+ public static DataHandler dh;
+
+ public XmlParser() {
+ dh = new DataHandler();
+ }
+
+ DataHandler parse(NodeList itemNodes) {
+ String id = "";
+ String title = "";
+ String description = "";
+ String date = "";
+ String location = "";
+ String category = "";
+ // String pictureUrl = ""; Necessary?
+
+ for (int i = 0; i < itemNodes.getLength(); i++) {
+ Node itemNode = itemNodes.item(i);
+
+ if (itemNode.getNodeType() == Node.ELEMENT_NODE) {
+ // Convert the Node into an Element.
+ Element itemElement = (Element) itemNode;
+
+ // Get all elements under the
- element.
+ NodeList idNodes = (itemElement).getElementsByTagName("id");
+ NodeList titleNodes = (itemElement).getElementsByTagName("title");
+ NodeList descriptionNodes = (itemElement).getElementsByTagName("description");
+ NodeList dateNodes = (itemElement).getElementsByTagName("date");
+ NodeList locationNodes = (itemElement).getElementsByTagName("location");
+ NodeList categoryNodes = (itemElement).getElementsByTagName("category");
+
+ // Convert a Node into an Element.
+ Element idElement = (Element) idNodes.item(0);
+ Element titleElement = (Element) titleNodes.item(0);
+ Element descriptionElement = (Element) descriptionNodes.item(0);
+ Element dateElement = (Element) dateNodes.item(0);
+ Element locationElement = (Element) locationNodes.item(0);
+ Element categoryElement = (Element) categoryNodes.item(0);
+
+ // Get all the child nodes.
+ NodeList idTextNodes = ((Node) idElement).getChildNodes();
+ NodeList titleTextNodes = ((Node) titleElement).getChildNodes();
+ NodeList descriptionTextNodes = ((Node) descriptionElement).getChildNodes();
+ NodeList dateTextNodes = ((Node) dateElement).getChildNodes();
+ NodeList locationTextNodes = ((Node) locationElement).getChildNodes();
+ NodeList categoryTextNodes = ((Node) categoryElement).getChildNodes();
+
+ // Retrieve the text.
+ id = ((Node) idTextNodes.item(0)).getNodeValue();
+ title = ((Node) titleTextNodes.item(0)).getNodeValue();
+ description = ((Node) descriptionTextNodes.item(0)).getNodeValue();
+ date = ((Node) dateTextNodes.item(0)).getNodeValue();
+ location = ((Node) locationTextNodes.item(0)).getNodeValue();
+ category = ((Node) categoryTextNodes.item(0)).getNodeValue();
+ dh.insert(id, title, description, date, location, category);
+ }
+ }
+ return dh;
+ }
+}