Skip to content
Browse files

Intial commit of code from presentation

  • Loading branch information...
0 parents commit f12f56126cb6ba2b3419cac9a6309280c11191ca @justingrammens committed Jun 27, 2009
7 .classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
9 .gitignore
@@ -0,0 +1,9 @@
+# Android noise
+bin/*
+
+# old skool
+.svn
+
+# osx noise
+.DS_Store
+
33 .project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>penguinsunbound</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
26 AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.localtone.penguinsunbound"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
+ <activity android:name=".PenguinsUnbound"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".Website" android:label="@string/hello">
+ </activity>
+
+ <activity android:name=".RssFeedList" android:label="@string/hello">
+ </activity>
+
+ </application>
+ <uses-sdk android:minSdkVersion="3" />
+</manifest>
8 README
@@ -0,0 +1,8 @@
+This is a sample tab based Android appliction that I created for a presentation at our local PenguinsUnbound group. http://www.penguinsunbound.org/Future_Meetings/20090627_-_Android
+
+To find out more about Android programming, would like a presentation of mobile development or are in need consulting services around mobile applications (iPhone, Android and Blackberry) please contact me at justin@localtone.com.
+
+Thanks,
+Justin Grammens
+Localtone Interactive
+justin@localtone.com
11 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-3
30 gen/com/localtone/penguinsunbound/R.java
@@ -0,0 +1,30 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.localtone.penguinsunbound;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int icon=0x7f020000;
+ }
+ public static final class id {
+ public static final int listview1=0x7f050001;
+ public static final int web_view=0x7f050002;
+ public static final int webview1=0x7f050000;
+ }
+ public static final class layout {
+ public static final int main=0x7f030000;
+ public static final int website=0x7f030001;
+ }
+ public static final class string {
+ public static final int app_name=0x7f040001;
+ public static final int hello=0x7f040000;
+ public static final int no_feeds=0x7f040002;
+ }
+}
BIN res/drawable/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 res/layout/main.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/tabhost"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <TabWidget
+ android:id="@android:id/tabs"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ <FrameLayout
+ android:id="@android:id/tabcontent"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <WebView
+ android:id="@+id/webview1"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ />
+ <ListView
+ android:id="@+id/listview1"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="#000"
+ />
+ <TextView android:id="@+id/android:empty"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="10px"
+ android:text="@string/no_feeds"/>
+ </FrameLayout>
+ </LinearLayout>
+</TabHost>
9 res/layout/website.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="horizontal" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <WebView android:id="@+id/web_view" android:layout_width="fill_parent"
+ android:layout_height="fill_parent" />
+
+</LinearLayout>
6 res/values/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, PenguinsUnbound!</string>
+ <string name="app_name">Penguins Unbound</string>
+ <string name ="no_feeds">Sorry, there are no items in the What&apos;s New RSS feed.</string>
+</resources>
40 src/com/localtone/penguinsunbound/PenguinsUnbound.java
@@ -0,0 +1,40 @@
+/**
+ * Created by Justin Grammens
+ * Copyright Localtone Interactive. All Rights Reserved.
+ */
+
+package com.localtone.penguinsunbound;
+
+import android.app.TabActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.widget.TabHost;
+
+public class PenguinsUnbound extends TabActivity {
+
+ TabHost mTabHost;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Intent websiteItent = new Intent(this, Website.class);
+ websiteItent.putExtra("link", "http://www.penguinsunbound.org/");
+
+ Intent RssFeedList = new Intent(this, RssFeedList.class);
+ RssFeed.loadFeedList();
+
+ mTabHost = getTabHost();
+
+ mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator(
+ "Website").setContent(websiteItent));
+
+ mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("RSS Feed")
+ .setContent(RssFeedList));
+
+ mTabHost.setCurrentTab(0);
+ }
+
+}
81 src/com/localtone/penguinsunbound/RssFeed.java
@@ -0,0 +1,81 @@
+/**
+ * Created by Justin Grammens
+ * Copyright Localtone Interactive. All Rights Reserved.
+ */
+
+package com.localtone.penguinsunbound;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class RssFeed {
+
+ public static List<RssFeed> feedItems = new ArrayList<RssFeed>();
+
+ private String title;
+ private String link;
+ private String pubDate;
+
+ public RssFeed(String title, String link, String pubDate) {
+ this.title = title;
+ this.link = link;
+ this.pubDate = pubDate;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public String getPubDate() {
+ return pubDate;
+ }
+
+
+ public static void loadFeedList() {
+
+ String url = "http://www.penguinsunbound.org/index.php?title=Special:Recentchanges&feed=rss";
+ try {
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder();
+
+ Document doc = builder.parse(new URL(url).openStream());
+
+ NodeList nodes = doc.getElementsByTagName("item");
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Element element = (Element) nodes.item(i);
+
+ NodeList titleNode = element.getElementsByTagName("title");
+ Element titleLine = (Element) titleNode.item(0);
+ String title = titleLine.getFirstChild().getNodeValue();
+
+ NodeList linkNode = element.getElementsByTagName("link");
+ Element linkLine = (Element) linkNode.item(0);
+ String link = linkLine.getFirstChild().getNodeValue();
+
+ NodeList pubNode = element.getElementsByTagName("pubDate");
+ Element pubLine = (Element) pubNode.item(0);
+ String pubDate = pubLine.getFirstChild().getNodeValue();
+
+ RssFeed rssFeed = new RssFeed(title, link, pubDate);
+ feedItems.add(rssFeed);
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+}
57 src/com/localtone/penguinsunbound/RssFeedList.java
@@ -0,0 +1,57 @@
+/**
+ * Created by Justin Grammens
+ * Copyright Localtone Interactive. All Rights Reserved.
+ */
+
+package com.localtone.penguinsunbound;
+
+import java.util.Iterator;
+import java.util.List;
+
+import android.app.ListActivity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class RssFeedList extends ListActivity implements OnClickListener {
+
+ private static List<RssFeed> feedItems = RssFeed.feedItems;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Iterator<RssFeed> fi = feedItems.iterator();
+
+ String[]dd = new String [feedItems.size()];
+
+ int i = 0;
+ while(fi.hasNext()) {
+ RssFeed rss = (RssFeed)fi.next();
+ dd[i] = rss.getTitle();
+ i++;
+ }
+
+ setListAdapter(new ArrayAdapter<String>(this,
+ android.R.layout.simple_list_item_1, dd));
+ getListView().setTextFilterEnabled(true);
+
+ }
+
+ protected void onListItemClick(ListView l, View v,
+ int position, long id) {
+ String url = feedItems.get(position).getLink();
+ Intent websiteItent = new Intent(this, Website.class);
+ websiteItent.putExtra("link", url);
+ startActivity(websiteItent);
+ }
+
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ }
+
+
+}
29 src/com/localtone/penguinsunbound/Website.java
@@ -0,0 +1,29 @@
+/**
+ * Created by Justin Grammens
+ * Copyright Localtone Interactive. All Rights Reserved.
+ */
+
+package com.localtone.penguinsunbound;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebView;
+
+public class Website extends Activity {
+
+ WebView webView;
+
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.website);
+
+ String link = this.getIntent().getStringExtra("link");
+
+ webView = (WebView) findViewById(R.id.web_view);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.loadUrl(link);
+
+ }
+
+}

0 comments on commit f12f561

Please sign in to comment.
Something went wrong with that request. Please try again.