├── .gitignore
├── contrib
├── GreenDroid
└── GreenDroid-GoogleAPIs
├── res
├── drawable-mdpi
│ ├── icon.png
│ ├── rss.png
│ ├── icon_ad.png
│ ├── twitter.png
│ ├── youtube.png
│ ├── facebook.png
│ ├── foursquare.png
│ ├── icon_home.png
│ ├── icon_logo.png
│ ├── dashboard_button_default.png
│ └── dashboard_button_focused.png
├── values
│ ├── theme.xml
│ ├── dimen.xml
│ ├── style.xml
│ └── strings.xml
├── color
│ └── map_pin.xml
├── layout
│ ├── ad_layout.xml
│ ├── about.xml
│ ├── riders_view.xml
│ ├── mapscreen.xml
│ └── dashboard.xml
├── xml
│ ├── settings.xml
│ ├── news_items.xml
│ ├── partners_items.xml
│ ├── events_items.xml
│ └── schedule_items.xml
└── drawable
│ └── dashboard_button.xml
├── libs
└── GoogleAdMobAdsSdk-4.1.0.jar
├── src
└── com
│ └── fssle
│ └── adpad
│ ├── AdPadApplication.java
│ ├── ScheduleActivity.java
│ ├── PartnersActivity.java
│ ├── EventsActivity.java
│ ├── NewsActivity.java
│ ├── BrowserActivity.java
│ ├── ShareActivity.java
│ ├── SocialActivity.java
│ ├── MyLog.java
│ ├── SettingsActivity.java
│ ├── AdsUtils.java
│ ├── AdvertisingAdapter.java
│ ├── RidersActivity.java
│ ├── MapScreenActivity.java
│ ├── AdPadActivity.java
│ └── DashboardLayout.java
├── local.properties
├── default.properties
├── proguard.cfg
├── AndroidManifest.xml
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | gen/
3 | key/
--------------------------------------------------------------------------------
/contrib/GreenDroid:
--------------------------------------------------------------------------------
1 | /Users/dli/code/android/GreenDroid/GreenDroid
--------------------------------------------------------------------------------
/contrib/GreenDroid-GoogleAPIs:
--------------------------------------------------------------------------------
1 | /Users/dli/code/android/GreenDroid/GreenDroid-GoogleAPIs
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/rss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/rss.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon_ad.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/icon_ad.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/twitter.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/youtube.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/youtube.png
--------------------------------------------------------------------------------
/libs/GoogleAdMobAdsSdk-4.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/libs/GoogleAdMobAdsSdk-4.1.0.jar
--------------------------------------------------------------------------------
/res/drawable-mdpi/facebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/facebook.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/foursquare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/foursquare.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon_home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/icon_home.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/icon_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/icon_logo.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/dashboard_button_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/dashboard_button_default.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/dashboard_button_focused.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ad-pad/master/res/drawable-mdpi/dashboard_button_focused.png
--------------------------------------------------------------------------------
/res/values/theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
--------------------------------------------------------------------------------
/res/values/dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 50dp
4 | 5dp
5 |
6 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/AdPadApplication.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import greendroid.app.GDApplication;
6 |
7 | public class AdPadApplication extends GDApplication {
8 |
9 | @Override
10 | public Class> getHomeActivityClass() {
11 | return AdPadActivity.class;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/res/color/map_pin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked in Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 |
7 | # location of the SDK. This is only used by Ant
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Users/dli/tools/android-sdk/android-sdk-mac_x86
11 |
--------------------------------------------------------------------------------
/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=Google Inc.:Google APIs:4
12 | android.library.reference.1=./contrib/GreenDroid-GoogleAPIs
--------------------------------------------------------------------------------
/res/layout/ad_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
--------------------------------------------------------------------------------
/res/xml/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
10 |
--------------------------------------------------------------------------------
/res/drawable/dashboard_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
9 |
11 |
14 |
--------------------------------------------------------------------------------
/res/values/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/ScheduleActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.os.Bundle;
4 |
5 | import greendroid.app.GDListActivity;
6 | import greendroid.widget.ItemAdapter;
7 |
8 | public class ScheduleActivity extends GDListActivity
9 | {
10 | /** Called when the activity is first created. */
11 | @Override
12 | public void onCreate(Bundle savedInstanceState)
13 | {
14 | super.onCreate(savedInstanceState);
15 | // setContentView(R.layout.main);
16 |
17 | ItemAdapter adapter;
18 | try {
19 | adapter = ItemAdapter.createFromXml(this, R.xml.schedule_items);
20 | setListAdapter(adapter);
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/PartnersActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.os.Bundle;
4 |
5 | import greendroid.app.GDListActivity;
6 | import greendroid.widget.ItemAdapter;
7 |
8 | public class PartnersActivity extends GDListActivity
9 | {
10 | /** Called when the activity is first created. */
11 | @Override
12 | public void onCreate(Bundle savedInstanceState)
13 | {
14 | super.onCreate(savedInstanceState);
15 | // setContentView(R.layout.main);
16 |
17 | ItemAdapter adapter;
18 | try {
19 | adapter = ItemAdapter.createFromXml(this, R.xml.partners_items);
20 | setListAdapter(adapter);
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/res/layout/about.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
12 |
13 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/EventsActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.os.Bundle;
4 |
5 | import greendroid.app.GDListActivity;
6 | // import greendroid.app.GDExpandableListActivity;
7 | import greendroid.widget.ItemAdapter;
8 |
9 | public class EventsActivity extends GDListActivity
10 | {
11 | /** Called when the activity is first created. */
12 | @Override
13 | public void onCreate(Bundle savedInstanceState)
14 | {
15 | super.onCreate(savedInstanceState);
16 | // setContentView(R.layout.main);
17 |
18 | ItemAdapter adapter;
19 | try {
20 | adapter = ItemAdapter.createFromXml(this, R.xml.events_items);
21 | setListAdapter(adapter);
22 | } catch (Exception e) {
23 | e.printStackTrace();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/NewsActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.os.Bundle;
4 |
5 | import greendroid.app.GDListActivity;
6 | import greendroid.widget.ItemAdapter;
7 |
8 | public class NewsActivity extends GDListActivity
9 | {
10 | /** Called when the activity is first created. */
11 | @Override
12 | public void onCreate(Bundle savedInstanceState)
13 | {
14 | super.onCreate(savedInstanceState);
15 | // setContentView(R.layout.main);
16 | // setActionBarContentView(R.layout.main);
17 |
18 | ItemAdapter adapter;
19 | try {
20 | adapter = ItemAdapter.createFromXml(this, R.xml.news_items);
21 | setListAdapter(adapter);
22 | AdvertisingAdapter ad = new AdvertisingAdapter(this, adapter);
23 | } catch (Exception e) {
24 | e.printStackTrace();
25 | }
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/res/layout/riders_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/res/xml/news_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
12 |
15 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/res/layout/mapscreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
17 |
18 |
23 |
28 |
29 |
30 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/BrowserActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.text.TextUtils;
6 | import android.webkit.WebView;
7 | import android.webkit.WebViewClient;
8 |
9 | // import greendroid.app.GDActivity;
10 |
11 | public class BrowserActivity extends Activity {
12 |
13 | public static final String URL = "com.fssle.adpad.URL";
14 | private WebView browser;
15 |
16 | @Override
17 | public void onCreate(Bundle icicle) {
18 | super.onCreate(icicle);
19 |
20 | browser=new WebView(this);
21 | setContentView(browser);
22 | browser.getSettings().setJavaScriptEnabled(true);
23 | browser.setWebViewClient(new WebViewClient() {
24 | @Override
25 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
26 | {
27 | // Handle the error
28 | }
29 |
30 | @Override
31 | public boolean shouldOverrideUrlLoading(WebView view, String url)
32 | {
33 | view.loadUrl(url);
34 | return true;
35 | }
36 | });
37 | browser.loadUrl(getIntent().getStringExtra(URL));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembernames class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembernames class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers enum * {
30 | public static **[] values();
31 | public static ** valueOf(java.lang.String);
32 | }
33 |
34 | -keep class * implements android.os.Parcelable {
35 | public static final android.os.Parcelable$Creator *;
36 | }
37 |
--------------------------------------------------------------------------------
/res/xml/partners_items.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
14 |
19 |
24 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | AdPad
4 |
5 | News
6 | Map Screen
7 | Events
8 | Schedule
9 | Riders
10 | Partners
11 | Photos/videos
12 | Social
13 |
14 | Share
15 | Uploads
16 |
17 | Feed
18 | Facebook
19 | Twitter
20 | Youtube
21 | Foursquare
22 |
23 | Credits
24 | Show Ads
25 | Show/Hide Ads informations.
26 | About
27 | More informations.
28 | Version %1$s (r%2$s)
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/ShareActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.TabHost;
8 |
9 | import greendroid.app.GDTabActivity;
10 |
11 | public class ShareActivity extends GDTabActivity{
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | // setContentView (R.layout.web_view);
17 | // setActionBarContentView(R.layout.web_view);
18 | Intent i=new Intent(this, BrowserActivity.class);
19 |
20 | TabHost host=getTabHost();
21 |
22 | final String shareText = getString(R.string.share_label);
23 | // i.putExtra(BrowserActivity.URL, "http://www.flickr.com/photos/tags/blue/");
24 | i.putExtra(BrowserActivity.URL, "http://www.google.com.hk/imgcat?hl=zh-CN&catid=564&sa=h");
25 | // addTab(shareText, shareText, i);
26 | host.addTab(host.newTabSpec(shareText).setIndicator(shareText).setContent(i));
27 |
28 | final String uploadsText = getString(R.string.uploads_label);
29 | // i.putExtra(BrowserActivity.URL, "http://www.android.com");
30 | i.putExtra(BrowserActivity.URL, "http://www.google.com.hk/imgcat?hl=zh-CN&catid=603&sa=h");
31 | // addTab(uploadsText, uploadsText, i);
32 | host.addTab(host.newTabSpec(uploadsText).setIndicator(uploadsText).setContent(i));
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/res/xml/events_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
12 |
15 |
18 |
21 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/res/xml/schedule_items.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
12 |
15 |
18 |
21 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/SocialActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.TabHost;
8 |
9 | import greendroid.app.GDTabActivity;
10 |
11 | public class SocialActivity extends GDTabActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 |
17 | Intent i=new Intent(this, BrowserActivity.class);
18 |
19 | TabHost host=getTabHost();
20 |
21 | final String feedText = getString(R.string.feed_label);
22 | i.putExtra(BrowserActivity.URL, "http://www.google.com");
23 | // addTab(feedText, feedText, i);
24 | host.addTab(host.newTabSpec(feedText).setIndicator(feedText).setContent(i));
25 |
26 |
27 | final String facebookText = getString(R.string.facebook_label);
28 | i.putExtra(BrowserActivity.URL, "http://www.facebook.com");
29 | // addTab(facebookText, facebookText, i);
30 | host.addTab(host.newTabSpec(facebookText).setIndicator(facebookText).setContent(i));
31 |
32 | final String twitterText = getString(R.string.twitter_label);
33 | i.putExtra(BrowserActivity.URL, "http://www.twitter.com");
34 | // addTab(twitterText, twitterText, i);
35 | host.addTab(host.newTabSpec(twitterText).setIndicator(twitterText).setContent(i));
36 |
37 | final String youtubeText = getString(R.string.youtube_label);
38 | i.putExtra(BrowserActivity.URL, "http://www.youtube.com");
39 | // addTab(youtubeText, youtubeText, i);
40 | host.addTab(host.newTabSpec(youtubeText).setIndicator(youtubeText).setContent(i));
41 |
42 | final String foursquareText = getString(R.string.foursquare_label);
43 | i.putExtra(BrowserActivity.URL, "http://www.foursquare.com");
44 | // addTab(foursquareText, foursquareText, i);
45 | host.addTab(host.newTabSpec(foursquareText).setIndicator(foursquareText).setContent(i));
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/MyLog.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.util.Log;
4 |
5 | public class MyLog {
6 |
7 | public static final String MAIN_TAG = "MonTransit";
8 |
9 | private static boolean DEBUG = false;
10 | public static final boolean SHOW_LOCATION = false;
11 |
12 | public static boolean isLoggable(int level) {
13 | return DEBUG || Log.isLoggable(MAIN_TAG, level);
14 | }
15 |
16 | public static void v(String tag, String msg) {
17 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.VERBOSE)) {
18 | Log.v(MAIN_TAG, String.format("%s>%s", tag, msg));
19 | }
20 | }
21 |
22 | public static void v(String tag, String msg, Object... args) {
23 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.VERBOSE)) {
24 | Log.v(MAIN_TAG, String.format("%s>%s", tag, String.format(msg, args)));
25 | }
26 | }
27 |
28 | public static void d(String tag, String msg) {
29 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.DEBUG)) {
30 | Log.d(MAIN_TAG, String.format("%s>%s", tag, msg));
31 | }
32 | }
33 |
34 | public static void d(String tag, String msg, Object... args) {
35 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.DEBUG)) {
36 | Log.d(MAIN_TAG, String.format("%s>%s", tag, String.format(msg, args)));
37 | }
38 | }
39 |
40 | public static void i(String tag, String msg) {
41 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.INFO)) {
42 | Log.i(MAIN_TAG, String.format("%s>%s", tag, msg));
43 | }
44 | }
45 |
46 | public static void i(String tag, String msg, Object... args) {
47 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.INFO)) {
48 | Log.i(MAIN_TAG, String.format("%s>%s", tag, String.format(msg, args)));
49 | }
50 | }
51 |
52 | public static void w(String tag, String msg, Object... args) {
53 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.WARN)) {
54 | Log.w(MAIN_TAG, String.format("%s>%s", tag, String.format(msg, args)));
55 | }
56 | }
57 |
58 | public static void w(String tag, Throwable t, String msg, Object... args) {
59 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.WARN)) {
60 | Log.w(MAIN_TAG, String.format("%s>%s", tag, String.format(msg, args)), t);
61 | }
62 | }
63 |
64 | public static void e(String tag, Throwable t, String msg) {
65 | if (DEBUG || Log.isLoggable(MAIN_TAG, Log.ERROR)) {
66 | Log.e(MAIN_TAG, String.format("%s>%s", tag, msg), t);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/res/layout/dashboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
22 |
23 |
27 |
28 |
32 |
33 |
37 |
38 |
42 |
43 |
47 |
48 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | pre
2 | ====
3 |
4 | brew install android
5 |
6 | android create project --package com.fssle.adpad \
7 | --activity .AdPadActivity \
8 | --target "Google Inc.:Google APIs:4" \
9 | --path AdPad
10 |
11 | build
12 | ====
13 |
14 | android update project -t "Google Inc.:Google APIs:4" --path `pwd`
15 | ant clean
16 | ant install
17 |
18 | emulator
19 | ====
20 |
21 | android create avd -t "Google Inc.:Google APIs:4" -n android-api-r4
22 | emulator @android-api-r4 &
23 |
24 | adb
25 | ====
26 |
27 | adb logcat -c
28 | adb logcat -v time *
29 |
30 | adb uninstall com.fssle.adpad
31 | adb install bin/AdPad-release.apk
32 |
33 | key
34 | ====
35 | keytool -delete -alias mykeystore
36 | keytool -list -v | more
37 | keytool -genkey -keyalg RSA -alias mykeystore -dname "CN=lite, OU=dev, O=FssLe, L=NJ, S=JS, C=CN" -keystore "my.keystore"
38 | keytool -list -alias mykeystore -keystore "my.keystore"
39 |
40 | jarsigner -verbose -keystore mykeystore my_application.apk mykeystore
41 | jarsigner -verify my_signed.apk
42 |
43 | map
44 | ====
45 | 025aHjnrl521frBloxRW7_Iwcrc_nixLiMj_Ktw
46 |
47 | ads
48 | ====
49 | a14deccf77dab80
50 |
51 | ui
52 | ====
53 | Hierarchyviewer
54 |
55 | Catagories
56 | ----
57 |
58 | * News
59 | * Map Screen
60 | * Events
61 | * Schedule
62 | * Riders
63 | * Partners
64 | * Photos/videos
65 | * Social feed
66 |
67 | News
68 | ----
69 |
70 | * Advertisement
71 | * Event news feed
72 |
73 | Map Screen
74 | ----
75 |
76 | * Advertisement
77 | * City
78 | * Advertisement
79 | * Event
80 | * Advertisement
81 |
82 | Events
83 | ----
84 | * Advertisement
85 | * Event 6
86 | * Details
87 | * Event 7
88 | * Details
89 | * Event 8
90 | * Details
91 | * Ticket giveaways
92 | * Details
93 | * Road Tours
94 | * Details
95 |
96 | Schedule
97 | ----
98 |
99 | * Advertisement
100 | * Day 1
101 | * Day 2
102 | * Day 3
103 | * Day 4
104 | * Brackets
105 |
106 | Riders
107 | ----
108 |
109 | * Advertisement
110 | * Pic and basic bio for each
111 |
112 | Partners
113 | ----
114 |
115 | * Advertisement
116 | * Pick and basic web link/phone number for each
117 |
118 | Photos/videos
119 | ----
120 |
121 | * Advertisement
122 | * Share
123 | * Current uploads (event coordinator posted)
124 |
125 | Social
126 | ----
127 |
128 | * Advertisement
129 | * RSS/facebook/Twitter/youtube/foursquare links
130 | * Check in Four square
131 | * Feed from your website
132 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/SettingsActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.view.View;
4 | import android.app.AlertDialog;
5 | import android.widget.TextView;
6 | import android.content.pm.PackageInfo;
7 | import android.content.pm.PackageManager;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.SharedPreferences;
11 | import android.net.Uri;
12 | import android.os.Bundle;
13 | import android.preference.CheckBoxPreference;
14 | import android.preference.Preference;
15 | import android.preference.Preference.OnPreferenceClickListener;
16 | import android.preference.PreferenceActivity;
17 | import android.preference.PreferenceScreen;
18 | import android.preference.PreferenceManager;
19 |
20 | public class SettingsActivity extends PreferenceActivity
21 | {
22 | public static final String PREFS_ADS = "pAds";
23 | public static final boolean PREFS_ADS_DEFAULT = true;
24 | public static final String PKG = "com.fssle.adpad";
25 |
26 | private CheckBoxPreference adsCheckBox;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | addPreferencesFromResource(R.xml.settings);
32 |
33 | // ads dialog
34 | this.adsCheckBox = (CheckBoxPreference) findPreference(PREFS_ADS);
35 | this.adsCheckBox.setChecked(AdsUtils.isShowingAds(this));
36 | this.adsCheckBox.setOnPreferenceClickListener(new OnPreferenceClickListener() {
37 | @Override
38 | public boolean onPreferenceClick(Preference preference) {
39 | SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(SettingsActivity.this);
40 | boolean isNowChecked = settings.getBoolean(PREFS_ADS, PREFS_ADS_DEFAULT);
41 | if (!isNowChecked) {
42 | return true;
43 | } else {
44 | AdsUtils.setShowingAds(isNowChecked);
45 | return false;
46 | }
47 | }
48 | });
49 |
50 | // about dialog
51 | ((PreferenceScreen) findPreference("pAbout")).setOnPreferenceClickListener(new OnPreferenceClickListener() {
52 | @Override
53 | public boolean onPreferenceClick(Preference preference) {
54 | SettingsActivity.this.showAboutDialog();
55 | return false;
56 | }
57 | });
58 | }
59 |
60 | public void showAboutDialog() {
61 | String versionName = "";
62 | String versionCode = "";
63 | try {
64 | PackageInfo packageInfo = this.getPackageManager().getPackageInfo(PKG, 0);
65 | versionName = packageInfo.versionName;
66 | versionCode = String.valueOf(packageInfo.versionCode);
67 | } catch (Exception e) {
68 | }
69 | View view = this.getLayoutInflater().inflate(R.layout.about, null, false);
70 | // set the version
71 | TextView versionTv = (TextView) view.findViewById(R.id.version);
72 | versionTv.setText(this.getString(R.string.about_version, versionName, versionCode));
73 |
74 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
75 | builder.setTitle(this.getString(R.string.app_name));
76 | builder.setIcon(android.R.drawable.ic_dialog_info);
77 | builder.setView(view);
78 | builder.setPositiveButton(this.getString(android.R.string.ok), null);
79 | builder.setCancelable(true);
80 |
81 | builder.create();
82 | builder.show();
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/AdsUtils.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import java.util.Arrays;
4 | import java.util.HashSet;
5 | import java.util.Set;
6 |
7 | import android.app.Activity;
8 | import android.content.Context;
9 | import android.content.pm.PackageInfo;
10 | import android.content.pm.PackageManager;
11 | import android.view.View;
12 | import android.content.SharedPreferences;
13 | import android.preference.PreferenceManager;
14 |
15 | import com.google.ads.Ad;
16 | import com.google.ads.AdListener;
17 | import com.google.ads.AdRequest;
18 | import com.google.ads.AdRequest.ErrorCode;
19 | import com.google.ads.AdView;
20 |
21 | public class AdsUtils {
22 |
23 | private static final String TAG = AdsUtils.class.getSimpleName();
24 | private static boolean DEBUG = false;
25 | private static Boolean showingAds = null;
26 | public static final boolean AD_ENABLED = true;
27 | public static final String PREFS_ADS = "pAds";
28 | public static final boolean PREFS_ADS_DEFAULT = true;
29 |
30 | public static void setupAd(Activity activity) {
31 | MyLog.v(TAG, "setupAd()");
32 |
33 | View adLayout = activity.findViewById(R.id.ad_layout);
34 | if (AD_ENABLED && isShowingAds(activity)) {
35 | // show ads
36 | if (adLayout != null) {
37 | adLayout.setVisibility(View.VISIBLE);
38 | AdView adView = (AdView) adLayout.findViewById(R.id.ads);
39 | if (adView != null) {
40 | adView.setVisibility(View.VISIBLE);
41 | AdRequest adRequest = new AdRequest();
42 | if (DEBUG) {
43 | adRequest.setTesting(true);
44 | adView.setAdListener(new AdListener() {
45 | @Override
46 | public void onDismissScreen(Ad ad) {
47 | MyLog.v(TAG, "onDismissScreen()");
48 | }
49 |
50 | @Override
51 | public void onFailedToReceiveAd(Ad ad, ErrorCode errorCode) {
52 | MyLog.v(TAG, "onFailedToReceiveAd()");
53 | MyLog.w(TAG, "Failed to received ad! Error code: '%s'.", errorCode);
54 | }
55 |
56 | @Override
57 | public void onLeaveApplication(Ad ad) {
58 | MyLog.v(TAG, "onLeaveApplication()");
59 | }
60 |
61 | @Override
62 | public void onPresentScreen(Ad ad) {
63 | MyLog.v(TAG, "onPresentScreen()");
64 | }
65 |
66 | @Override
67 | public void onReceiveAd(Ad ad) {
68 | MyLog.v(TAG, "onReceiveAd()");
69 | }
70 | });
71 | }
72 | adView.loadAd(adRequest);
73 | }
74 | }
75 | } else {
76 | // hide ads
77 | if (adLayout != null) {
78 | adLayout.setVisibility(View.GONE);
79 | AdView adView = (AdView) adLayout.findViewById(R.id.ads);
80 | if (adView != null) {
81 | adView.setVisibility(View.GONE);
82 | }
83 | }
84 | }
85 | }
86 |
87 | public static void destroyAd(Activity activity) {
88 | if (AD_ENABLED && isShowingAds(activity)) {
89 | View adLayout = activity.findViewById(R.id.ad_layout);
90 | if (adLayout != null) {
91 | AdView adView = (AdView) adLayout.findViewById(R.id.ads);
92 | if (adView != null) {
93 | adView.stopLoading();
94 | }
95 | }
96 | }
97 | }
98 |
99 | public static boolean isShowingAds(Context context) {
100 | MyLog.v(TAG, "isShowingAds()");
101 | if (AdsUtils.showingAds == null) {
102 | SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
103 | AdsUtils.showingAds = settings.getBoolean(PREFS_ADS, PREFS_ADS_DEFAULT);
104 | }
105 | return AD_ENABLED ? AdsUtils.showingAds : AD_ENABLED;
106 | }
107 |
108 | public static void setShowingAds(Boolean showingAds) {
109 | AdsUtils.showingAds = showingAds;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/AdvertisingAdapter.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.app.Activity;
4 | import android.database.DataSetObserver;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.AbsListView;
8 | import android.widget.BaseAdapter;
9 |
10 | import com.google.ads.AdRequest;
11 | import com.google.ads.AdSize;
12 | import com.google.ads.AdView;
13 |
14 | /**
15 | * List adapter decorator that inserts adverts into the list.
16 | * @author Daniel Dyer
17 | */
18 | public class AdvertisingAdapter extends BaseAdapter
19 | {
20 | private static final String ADMOB_PUBLISHER_ID = "YOUR_ADMOB_ID_HERE";
21 |
22 | private final Activity activity;
23 | private final BaseAdapter delegate;
24 |
25 | public AdvertisingAdapter(Activity activity, BaseAdapter delegate)
26 | {
27 | this.activity = activity;
28 | this.delegate = delegate;
29 | delegate.registerDataSetObserver(new DataSetObserver()
30 | {
31 | @Override
32 | public void onChanged()
33 | {
34 | notifyDataSetChanged();
35 | }
36 |
37 | @Override
38 | public void onInvalidated()
39 | {
40 | notifyDataSetInvalidated();
41 | }
42 | });
43 | }
44 |
45 | public int getCount()
46 | {
47 | return delegate.getCount() + 1;
48 | }
49 |
50 | public Object getItem(int i)
51 | {
52 | return delegate.getItem(i - 1);
53 | }
54 |
55 | public long getItemId(int i)
56 | {
57 | return delegate.getItemId(i - 1);
58 | }
59 |
60 | public View getView(int position, View convertView, ViewGroup parent)
61 | {
62 | if (position == 0)
63 | {
64 | if (convertView instanceof AdView)
65 | {
66 | return convertView;
67 | }
68 | else
69 | {
70 | AdView adView = new AdView(activity, AdSize.BANNER, ADMOB_PUBLISHER_ID);
71 | // Disable focus for sub-views of the AdView to avoid problems with
72 | // trackpad navigation of the list.
73 | for (int i = 0; i < adView.getChildCount(); i++)
74 | {
75 | adView.getChildAt(i).setFocusable(false);
76 | }
77 | adView.setFocusable(false);
78 | // Default layout params have to be converted to ListView compatible
79 | // params otherwise there will be a ClassCastException.
80 | float density = activity.getResources().getDisplayMetrics().density;
81 | int height = Math.round(AdSize.BANNER.getHeight() * density);
82 | AbsListView.LayoutParams params
83 | = new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT,
84 | height);
85 | adView.setLayoutParams(params);
86 | adView.loadAd(new AdRequest());
87 | return adView;
88 | }
89 | }
90 | else
91 | {
92 | return delegate.getView(position - 1, convertView, parent);
93 | }
94 | }
95 |
96 | @Override
97 | public int getViewTypeCount()
98 | {
99 | return delegate.getViewTypeCount() + 1;
100 | }
101 |
102 | @Override
103 | public int getItemViewType(int position)
104 | {
105 | return position == 0 ? delegate.getViewTypeCount()
106 | : delegate.getItemViewType(position - 1);
107 | }
108 |
109 | @Override
110 | public boolean areAllItemsEnabled()
111 | {
112 | return false;
113 | }
114 |
115 | @Override
116 | public boolean isEnabled(int position)
117 | {
118 | return position != 0 && delegate.isEnabled(position - 1);
119 | }
120 | }
--------------------------------------------------------------------------------
/src/com/fssle/adpad/RidersActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.content.Context;
6 | import android.graphics.Bitmap;
7 | import android.graphics.Bitmap.Config;
8 | import android.graphics.Canvas;
9 | import android.graphics.Color;
10 | import android.graphics.Paint;
11 | import android.graphics.Paint.Style;
12 | import android.graphics.Path;
13 | import android.view.LayoutInflater;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.AbsListView;
17 | import android.widget.AbsListView.OnScrollListener;
18 | import android.widget.BaseAdapter;
19 | import android.widget.ImageView.ScaleType;
20 | import android.widget.TextView;
21 |
22 | import greendroid.app.GDListActivity;
23 | import greendroid.widget.AsyncImageView;
24 |
25 | public class RidersActivity extends GDListActivity implements OnScrollListener {
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 |
31 | setListAdapter(new MyAdapter(this));
32 | getListView().setOnScrollListener(this);
33 | }
34 |
35 | private static class MyAdapter extends BaseAdapter {
36 |
37 | private static final String BASE_URL_PREFIX = "http://www.cyrilmottier.com/files/greendroid/images/image";
38 | private static final String BASE_URL_SUFFIX = ".png";
39 | private static final StringBuilder BUILDER = new StringBuilder();
40 |
41 | static class ViewHolder {
42 | public AsyncImageView imageView;
43 | public TextView textView;
44 | public StringBuilder textBuilder = new StringBuilder();
45 | }
46 |
47 | private LayoutInflater mInflater;
48 |
49 | public MyAdapter(Context context) {
50 | mInflater = LayoutInflater.from(context);
51 | }
52 |
53 | public int getCount() {
54 | return 20;
55 | }
56 |
57 | public Object getItem(int position) {
58 | return null;
59 | }
60 |
61 | public long getItemId(int position) {
62 | return position;
63 | }
64 |
65 | public View getView(int position, View convertView, ViewGroup parent) {
66 |
67 | ViewHolder holder;
68 |
69 | if (convertView == null) {
70 | convertView = mInflater.inflate(R.layout.riders_view, parent, false);
71 | holder = new ViewHolder();
72 | holder.imageView = (AsyncImageView) convertView.findViewById(R.id.async_image);
73 | holder.textView = (TextView) convertView.findViewById(R.id.text);
74 | convertView.setTag(holder);
75 | } else {
76 | holder = (ViewHolder) convertView.getTag();
77 | }
78 |
79 | BUILDER.setLength(0);
80 | BUILDER.append(BASE_URL_PREFIX);
81 | BUILDER.append(position);
82 | BUILDER.append(BASE_URL_SUFFIX);
83 | holder.imageView.setUrl(BUILDER.toString());
84 |
85 | final StringBuilder textBuilder = holder.textBuilder;
86 | textBuilder.setLength(0);
87 | textBuilder.append("Photo");
88 | textBuilder.append(position);
89 | holder.textView.setText(textBuilder);
90 |
91 | return convertView;
92 | }
93 | }
94 |
95 | public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
96 | }
97 |
98 | public void onScrollStateChanged(AbsListView listView, int scrollState) {
99 | if (getListView() == listView) {
100 | searchAsyncImageViews(listView, scrollState == OnScrollListener.SCROLL_STATE_FLING);
101 | }
102 | }
103 |
104 | private void searchAsyncImageViews(ViewGroup viewGroup, boolean pause) {
105 | final int childCount = viewGroup.getChildCount();
106 | for (int i = 0; i < childCount; i++) {
107 | AsyncImageView image = (AsyncImageView) viewGroup.getChildAt(i).findViewById(R.id.async_image);
108 | if (image != null) {
109 | image.setPaused(pause);
110 | }
111 | }
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/MapScreenActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.ListView;
6 | import android.widget.AdapterView;
7 | import android.content.res.ColorStateList;
8 | import android.content.res.Resources;
9 | import android.content.res.XmlResourceParser;
10 | import android.graphics.drawable.Drawable;
11 |
12 |
13 | import java.util.ArrayList;
14 |
15 | import com.google.ads.*;
16 | import com.google.android.maps.MapActivity;
17 | import com.google.android.maps.MapView;
18 | import com.google.android.maps.GeoPoint;
19 | import com.google.android.maps.ItemizedOverlay;
20 | import com.google.android.maps.OverlayItem;
21 |
22 | import greendroid.app.GDMapActivity;
23 | import greendroid.graphics.drawable.DrawableStateSet;
24 | import greendroid.graphics.drawable.MapPinDrawable;
25 | import greendroid.widget.ItemAdapter;
26 |
27 | // import greendroid.app.GDActivity;
28 | // import greendroid.widget.ItemAdapter;
29 |
30 | public class MapScreenActivity extends GDMapActivity
31 | {
32 | private static final OverlayItem[] items = {
33 | new OverlayItem(new GeoPoint(40714400, -74006000), "New York City", null),
34 | new OverlayItem(new GeoPoint(39952300, -75163800), "Philadelphia", null),
35 | new OverlayItem(new GeoPoint(38895100, -77036400), "Washington", null),
36 | new OverlayItem(new GeoPoint(41374800, -83651300), "Bowling Green", null),
37 | new OverlayItem(new GeoPoint(42331400, -83045800), "Detroit", null)
38 | };
39 |
40 | private AdView adView;
41 | private ListView listView;
42 | private MapView mapView;
43 |
44 | /** Called when the activity is first created. */
45 | @Override
46 | public void onCreate(Bundle savedInstanceState)
47 | {
48 | super.onCreate(savedInstanceState);
49 |
50 | // setContentView(R.layout.mapscreen);
51 | setActionBarContentView(R.layout.mapscreen);
52 |
53 | adView = (AdView)this.findViewById(R.id.ad_view);
54 | adView.loadAd(new AdRequest());
55 |
56 | listView = (ListView) findViewById(R.id.list_view);
57 | mapView = (MapView) findViewById(R.id.map_view);
58 |
59 | try {
60 | ItemAdapter adapter;
61 | adapter = ItemAdapter.createFromXml(this, R.xml.events_items);
62 | listView.setAdapter(adapter);
63 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
64 |
65 | public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
66 | MyLog.v("changdoc", "Cliecked?");
67 | }
68 | });
69 |
70 | mapView.setBuiltInZoomControls(true);
71 | final Resources r = getResources();
72 |
73 | XmlResourceParser xpp = getResources().getXml(R.color.map_pin);
74 | ColorStateList csl = ColorStateList.createFromXml(r, xpp);
75 | BasicItemizedOverlay itemizedOverlay = new BasicItemizedOverlay(new MapPinDrawable(r, csl, csl));
76 |
77 | for (int j = 0; j < items.length; j++) {
78 | itemizedOverlay.addOverlay(items[j]);
79 | }
80 |
81 | mapView.getOverlays().add(itemizedOverlay);
82 | } catch (Exception e) {
83 | e.printStackTrace();
84 | }
85 |
86 |
87 | }
88 |
89 | @Override
90 | protected boolean isRouteDisplayed() {
91 | return false;
92 | }
93 |
94 | private class BasicItemizedOverlay extends ItemizedOverlay {
95 |
96 | private ArrayList mOverlays = new ArrayList();
97 |
98 | public BasicItemizedOverlay(Drawable defaultMarker) {
99 | super(boundCenterBottom(defaultMarker));
100 | }
101 |
102 | public void addOverlay(OverlayItem overlay) {
103 | mOverlays.add(overlay);
104 | populate();
105 | }
106 |
107 | @Override
108 | protected OverlayItem createItem(int i) {
109 | return mOverlays.get(i);
110 | }
111 |
112 | @Override
113 | public int size() {
114 | return mOverlays.size();
115 | }
116 |
117 | @Override
118 | protected boolean onTap(int index) {
119 | return true;
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/AdPadActivity.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.view.View.OnClickListener;
7 | // import android.widget.ListView;
8 |
9 | import greendroid.app.GDActivity;
10 | import greendroid.widget.ActionBar;
11 | import greendroid.widget.ActionBarItem.Type;
12 | import greendroid.widget.ActionBar.OnActionBarListener;
13 | // import greendroid.widget.ItemAdapter;
14 | // import greendroid.widget.item.TextItem;
15 |
16 | public class AdPadActivity extends GDActivity
17 | {
18 | /** Called when the activity is first created. */
19 | @Override
20 | public void onCreate(Bundle savedInstanceState)
21 | {
22 | super.onCreate(savedInstanceState);
23 |
24 | setActionBarContentView(R.layout.dashboard);
25 | getActionBar().addItem(Type.Settings);
26 | getActionBar().setTitle(getString(R.string.app_name));
27 | getActionBar().setOnActionBarListener(mActionBarListener);
28 |
29 | //attach event handler to dash buttons
30 | DashboardClickListener dBClickListener = new DashboardClickListener();
31 | findViewById(R.id.dashboard_button_news).setOnClickListener(dBClickListener);
32 | findViewById(R.id.dashboard_button_map).setOnClickListener(dBClickListener);
33 | findViewById(R.id.dashboard_button_events).setOnClickListener(dBClickListener);
34 | findViewById(R.id.dashboard_button_schedule).setOnClickListener(dBClickListener);
35 | findViewById(R.id.dashboard_button_riders).setOnClickListener(dBClickListener);
36 | findViewById(R.id.dashboard_button_partners).setOnClickListener(dBClickListener);
37 | findViewById(R.id.dashboard_button_share).setOnClickListener(dBClickListener);
38 | findViewById(R.id.dashboard_button_social).setOnClickListener(dBClickListener);
39 | //
40 | // AdManager.setTestDevices( new String[] {
41 | // AdManager.TEST_EMULATOR, // Android emulator
42 | // "", // My HTC Hero Test Phone (IMEI number)
43 | // } );
44 | }
45 |
46 | // private TextItem createTextItem(int stringId, Class> klass) {
47 | // final TextItem textItem = new TextItem(getString(stringId));
48 | // textItem.setTag(klass);
49 | // return textItem;
50 | // }
51 | //
52 | // @Override
53 | // protected void onListItemClick(ListView l, View v, int position, long id) {
54 | // final TextItem textItem = (TextItem) l.getAdapter().getItem(position);
55 | // Intent intent = new Intent(AdPadActivity.this, (Class>) textItem.getTag());
56 | // startActivity(intent);
57 | // }
58 | private OnActionBarListener mActionBarListener = new OnActionBarListener() {
59 | public void onActionBarItemClicked(int position) {
60 | Intent i = null;
61 | switch(position) {
62 | case 0:
63 | i = new Intent(AdPadActivity.this, SettingsActivity.class);
64 | startActivity(i);
65 | break;
66 | default:
67 | break;
68 | }
69 | }
70 | };
71 |
72 | private class DashboardClickListener implements OnClickListener {
73 | @Override
74 | public void onClick(View v) {
75 | Intent i = null;
76 | switch (v.getId()) {
77 | case R.id.dashboard_button_news:
78 | i = new Intent(AdPadActivity.this, NewsActivity.class);
79 | break;
80 | case R.id.dashboard_button_map:
81 | i = new Intent(AdPadActivity.this, MapScreenActivity.class);
82 | break;
83 | case R.id.dashboard_button_events:
84 | i = new Intent(AdPadActivity.this, EventsActivity.class);
85 | break;
86 | case R.id.dashboard_button_schedule:
87 | i = new Intent(AdPadActivity.this, ScheduleActivity.class);
88 | break;
89 | case R.id.dashboard_button_riders:
90 | i = new Intent(AdPadActivity.this, RidersActivity.class);
91 | break;
92 | case R.id.dashboard_button_partners:
93 | i = new Intent(AdPadActivity.this, PartnersActivity.class);
94 | break;
95 | case R.id.dashboard_button_share:
96 | i = new Intent(AdPadActivity.this, ShareActivity.class);
97 | break;
98 | case R.id.dashboard_button_social:
99 | i = new Intent(AdPadActivity.this, SocialActivity.class);
100 | break;
101 | default:
102 | break;
103 | }
104 | if(i != null) {
105 | startActivity(i);
106 | }
107 | }
108 | }
109 |
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/src/com/fssle/adpad/DashboardLayout.java:
--------------------------------------------------------------------------------
1 | package com.fssle.adpad;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | public class DashboardLayout extends ViewGroup {
9 |
10 | private static final int UNEVEN_GRID_PENALTY_MULTIPLIER = 10;
11 |
12 | private int mMaxChildWidth = 0;
13 | private int mMaxChildHeight = 0;
14 |
15 | public DashboardLayout(Context context) {
16 | super(context, null);
17 | }
18 |
19 | public DashboardLayout(Context context, AttributeSet attrs) {
20 | super(context, attrs, 0);
21 | }
22 |
23 | public DashboardLayout(Context context, AttributeSet attrs, int defStyle) {
24 | super(context, attrs, defStyle);
25 | }
26 |
27 | @Override
28 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
29 | mMaxChildWidth = 0;
30 | mMaxChildHeight = 0;
31 |
32 | final int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
33 | MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
34 | final int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
35 | MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST);
36 |
37 | final int count = getChildCount();
38 | for (int i = 0; i < count; i++) {
39 | final View child = getChildAt(i);
40 | if (child.getVisibility() == GONE) {
41 | continue;
42 | }
43 |
44 | child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
45 |
46 | mMaxChildWidth = Math.max(mMaxChildWidth, child.getMeasuredWidth());
47 | mMaxChildHeight = Math.max(mMaxChildHeight, child.getMeasuredHeight());
48 | }
49 |
50 | setMeasuredDimension(
51 | resolveSize(mMaxChildWidth, widthMeasureSpec),
52 | resolveSize(mMaxChildHeight, heightMeasureSpec));
53 | }
54 |
55 | @Override
56 | protected void onLayout(boolean changed, int l, int t, int r, int b) {
57 | int width = r - l;
58 | int height = b - t;
59 |
60 | final int count = getChildCount();
61 |
62 | // Calculate the number of visible children.
63 | int visibleCount = 0;
64 | for (int i = 0; i < count; i++) {
65 | final View child = getChildAt(i);
66 | if (child.getVisibility() == GONE) {
67 | continue;
68 | }
69 | ++visibleCount;
70 | }
71 |
72 | if (visibleCount == 0) {
73 | return;
74 | }
75 |
76 | // Calculate what number of rows and columns will optimize for even horizontal and
77 | // vertical whitespace between items. Start with a 1 x N grid, then try 2 x N, and so on.
78 | int bestSpaceDifference = Integer.MAX_VALUE;
79 | int spaceDifference;
80 |
81 | // Horizontal and vertical space between items
82 | int hSpace = 0;
83 | int vSpace = 0;
84 |
85 | int cols = 1;
86 | int rows;
87 |
88 | while (true) {
89 | rows = (visibleCount - 1) / cols + 1;
90 |
91 | hSpace = ((width - mMaxChildWidth * cols) / (cols + 1));
92 | vSpace = ((height - mMaxChildHeight * rows) / (rows + 1));
93 |
94 | spaceDifference = Math.abs(vSpace - hSpace);
95 | if (rows * cols != visibleCount) {
96 | spaceDifference *= UNEVEN_GRID_PENALTY_MULTIPLIER;
97 | }
98 |
99 | if (spaceDifference < bestSpaceDifference) {
100 | // Found a better whitespace squareness/ratio
101 | bestSpaceDifference = spaceDifference;
102 |
103 | // If we found a better whitespace squareness and there's only 1 row, this is
104 | // the best we can do.
105 | if (rows == 1) {
106 | break;
107 | }
108 | } else {
109 | // This is a worse whitespace ratio, use the previous value of cols and exit.
110 | --cols;
111 | rows = (visibleCount - 1) / cols + 1;
112 | hSpace = ((width - mMaxChildWidth * cols) / (cols + 1));
113 | vSpace = ((height - mMaxChildHeight * rows) / (rows + 1));
114 | break;
115 | }
116 |
117 | ++cols;
118 | }
119 |
120 | // Lay out children based on calculated best-fit number of rows and cols.
121 |
122 | // If we chose a layout that has negative horizontal or vertical space, force it to zero.
123 | hSpace = Math.max(0, hSpace);
124 | vSpace = Math.max(0, vSpace);
125 |
126 | // Re-use width/height variables to be child width/height.
127 | width = (width - hSpace * (cols + 1)) / cols;
128 | height = (height - vSpace * (rows + 1)) / rows;
129 |
130 | int left, top;
131 | int col, row;
132 | int visibleIndex = 0;
133 | for (int i = 0; i < count; i++) {
134 | final View child = getChildAt(i);
135 | if (child.getVisibility() == GONE) {
136 | continue;
137 | }
138 |
139 | row = visibleIndex / cols;
140 | col = visibleIndex % cols;
141 |
142 | left = hSpace * (col + 1) + width * col;
143 | top = vSpace * (row + 1) + height * row;
144 |
145 | child.layout(left, top,
146 | (hSpace == 0 && col == cols - 1) ? r : (left + width),
147 | (vSpace == 0 && row == rows - 1) ? b : (top + height));
148 | ++visibleIndex;
149 | }
150 | }
151 | }
--------------------------------------------------------------------------------