Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new samples plus updated project properties for r14 tools

  • Loading branch information...
commit 401892eb35f1572c78d8c2fb9c5700694dd16d3d 1 parent 43ac63c
Mark Murphy authored
Showing with 2,378 additions and 20 deletions.
  1. +1 −1  CPU-Java/AIDLOverhead/Client/.classpath
  2. +1 −1  CPU-Java/AIDLOverhead/Client/{default.properties → project.properties}
  3. +1 −1  CPU-Java/AIDLOverhead/RemoteService/.classpath
  4. +1 −1  CPU-Java/AIDLOverhead/RemoteService/{default.properties → project.properties}
  5. +1 −1  CPU-Java/GoAsync/.classpath
  6. +1 −1  CPU-Java/GoAsync/{default.properties → project.properties}
  7. +1 −1  CPU-Java/PrefsPersist/.classpath
  8. +1 −1  CPU-Java/PrefsPersist/{default.properties → project.properties}
  9. +7 −0 MAT/LeakedThread/.classpath
  10. +33 −0 MAT/LeakedThread/.project
  11. +18 −0 MAT/LeakedThread/AndroidManifest.xml
  12. +40 −0 MAT/LeakedThread/proguard.cfg
  13. +1 −1  Traceview/default.properties → MAT/LeakedThread/project.properties
  14. BIN  MAT/LeakedThread/res/drawable-hdpi/icon.png
  15. BIN  MAT/LeakedThread/res/drawable-ldpi/icon.png
  16. BIN  MAT/LeakedThread/res/drawable-mdpi/icon.png
  17. +12 −0 MAT/LeakedThread/res/layout/main.xml
  18. +5 −0 MAT/LeakedThread/res/values/strings.xml
  19. +35 −0 MAT/LeakedThread/src/com/commonsware/android/tuning/mat/LeakedThreadActivity.java
  20. +7 −0 MAT/NonConfigWidget/.classpath
  21. +33 −0 MAT/NonConfigWidget/.project
  22. +18 −0 MAT/NonConfigWidget/AndroidManifest.xml
  23. +40 −0 MAT/NonConfigWidget/proguard.cfg
  24. +3 −3 NDK/WeakBench/default.properties → MAT/NonConfigWidget/project.properties
  25. BIN  MAT/NonConfigWidget/res/drawable-hdpi/icon.png
  26. BIN  MAT/NonConfigWidget/res/drawable-ldpi/icon.png
  27. BIN  MAT/NonConfigWidget/res/drawable-mdpi/icon.png
  28. +5 −0 MAT/NonConfigWidget/res/layout/main.xml
  29. +5 −0 MAT/NonConfigWidget/res/values/strings.xml
  30. +35 −0 MAT/NonConfigWidget/src/com/commonsware/android/tuning/mat/NonConfigWidgetActivity.java
  31. +7 −0 MAT/RandomAppOfCrap/.classpath
  32. +33 −0 MAT/RandomAppOfCrap/.project
  33. +22 −0 MAT/RandomAppOfCrap/AndroidManifest.xml
  34. +67 −0 MAT/RandomAppOfCrap/build.xml
  35. +36 −0 MAT/RandomAppOfCrap/proguard.cfg
  36. +12 −0 MAT/RandomAppOfCrap/project.properties
  37. BIN  MAT/RandomAppOfCrap/res/drawable/cw.png
  38. BIN  MAT/RandomAppOfCrap/res/drawable/eject.png
  39. BIN  MAT/RandomAppOfCrap/res/drawable/mail_generic.png
  40. +6 −0 MAT/RandomAppOfCrap/res/layout/main.xml
  41. +5 −0 MAT/RandomAppOfCrap/res/values/strings.xml
  42. +45 −0 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/Forecast.java
  43. +126 −0 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherBinder.java
  44. +172 −0 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherDemo.java
  45. +22 −0 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherListener.java
  46. +33 −0 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherService.java
  47. +7 −0 MAT/Spinners/.classpath
  48. +33 −0 MAT/Spinners/.project
  49. +24 −0 MAT/Spinners/AndroidManifest.xml
  50. +20 −0 MAT/Spinners/build.properties
  51. +67 −0 MAT/Spinners/build.xml
  52. +40 −0 MAT/Spinners/proguard.cfg
  53. +1 −1  TrafficMonitor/default.properties → MAT/Spinners/project.properties
  54. BIN  MAT/Spinners/res/drawable-mdpi/cw.png
  55. BIN  MAT/Spinners/res/drawable/cw.png
  56. +18 −0 MAT/Spinners/res/layout/main.xml
  57. +4 −0 MAT/Spinners/res/values/strings.xml
  58. +66 −0 MAT/Spinners/src/com/commonsware/android/contacts/spinners/ContactSpinners.java
  59. +37 −0 MAT/Spinners/src/com/commonsware/android/contacts/spinners/ContactsAdapterBridge.java
  60. +85 −0 MAT/Spinners/src/com/commonsware/android/contacts/spinners/NewContactsAdapterBridge.java
  61. +86 −0 MAT/Spinners/src/com/commonsware/android/contacts/spinners/OldContactsAdapterBridge.java
  62. +7 −0 MAT/Spinners/tests/.classpath
  63. +33 −0 MAT/Spinners/tests/.project
  64. +23 −0 MAT/Spinners/tests/AndroidManifest.xml
  65. +18 −0 MAT/Spinners/tests/build.properties
  66. +71 −0 MAT/Spinners/tests/build.xml
  67. +40 −0 MAT/Spinners/tests/proguard.cfg
  68. +11 −0 MAT/Spinners/tests/project.properties
  69. +2 −0  MAT/Spinners/tests/run
  70. +53 −0 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/ContactsDemoBaseTest.java
  71. +48 −0 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/ContactsDemoTest.java
  72. +27 −0 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/FullSuite.java
  73. +36 −0 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/HprofTestRunner.java
  74. +35 −0 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/SillyTest.java
  75. +7 −0 MAT/StaticWidget/.classpath
  76. +33 −0 MAT/StaticWidget/.project
  77. +18 −0 MAT/StaticWidget/AndroidManifest.xml
  78. +40 −0 MAT/StaticWidget/proguard.cfg
  79. +11 −0 MAT/StaticWidget/project.properties
  80. BIN  MAT/StaticWidget/res/drawable-hdpi/icon.png
  81. BIN  MAT/StaticWidget/res/drawable-ldpi/icon.png
  82. BIN  MAT/StaticWidget/res/drawable-mdpi/icon.png
  83. +8 −0 MAT/StaticWidget/res/layout/main.xml
  84. +5 −0 MAT/StaticWidget/res/values/strings.xml
  85. +32 −0 MAT/StaticWidget/src/com/commonsware/android/tuning/mat/StaticWidgetActivity.java
  86. +1 −1  NDK/LuaInterpreter/.classpath
  87. +1 −1  NDK/WeakBench/.classpath
  88. +4 −0 NDK/WeakBench/AndroidManifest.xml
  89. +7 −0 Power/Downloader/.classpath
  90. +33 −0 Power/Downloader/.project
  91. +24 −0 Power/Downloader/AndroidManifest.xml
  92. +17 −0 Power/Downloader/build.properties
  93. +67 −0 Power/Downloader/build.xml
  94. +40 −0 Power/Downloader/proguard.cfg
  95. +11 −0 Power/Downloader/project.properties
  96. BIN  Power/Downloader/res/drawable/cw.png
  97. BIN  Power/Downloader/res/drawable/eject.png
  98. BIN  Power/Downloader/res/drawable/ic_menu_add.png
  99. BIN  Power/Downloader/res/drawable/ic_menu_info_details.png
  100. BIN  Power/Downloader/res/drawable/ic_menu_refresh.png
  101. +9 −0 Power/Downloader/res/layout/main.xml
  102. +4 −0 Power/Downloader/res/values/strings.xml
  103. +44 −0 Power/Downloader/src/com/commonsware/android/tuning/downloader/ByteArrayResponseHandler.java
  104. +102 −0 Power/Downloader/src/com/commonsware/android/tuning/downloader/Downloader.java
  105. +61 −0 Power/Downloader/src/com/commonsware/android/tuning/downloader/DownloaderDemo.java
  106. +1 −1  Traceview/.classpath
  107. +11 −0 Traceview/project.properties
  108. +1 −1  TrafficMonitor/.classpath
  109. +3 −3 NDK/LuaInterpreter/default.properties → TrafficMonitor/project.properties
View
2  CPU-Java/AIDLOverhead/Client/.classpath
@@ -3,5 +3,5 @@
<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"/>
+ <classpathentry kind="output" path="bin/classes"/>
</classpath>
View
2  ...va/AIDLOverhead/Client/default.properties → ...va/AIDLOverhead/Client/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
2  CPU-Java/AIDLOverhead/RemoteService/.classpath
@@ -3,5 +3,5 @@
<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"/>
+ <classpathentry kind="output" path="bin/classes"/>
</classpath>
View
2  ...Overhead/RemoteService/default.properties → ...Overhead/RemoteService/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
2  CPU-Java/GoAsync/.classpath
@@ -3,5 +3,5 @@
<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"/>
+ <classpathentry kind="output" path="bin/classes"/>
</classpath>
View
2  CPU-Java/GoAsync/default.properties → CPU-Java/GoAsync/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
2  CPU-Java/PrefsPersist/.classpath
@@ -3,5 +3,5 @@
<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"/>
+ <classpathentry kind="output" path="bin/classes"/>
</classpath>
View
2  CPU-Java/PrefsPersist/default.properties → CPU-Java/PrefsPersist/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
7 MAT/LeakedThread/.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/classes"/>
+</classpath>
View
33 MAT/LeakedThread/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>LeakedThread</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>
View
18 MAT/LeakedThread/AndroidManifest.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.android.tuning.mat"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="7" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".LeakedThreadActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
View
40 MAT/LeakedThread/proguard.cfg
@@ -0,0 +1,40 @@
+-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 <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
View
2  Traceview/default.properties → MAT/LeakedThread/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
BIN  MAT/LeakedThread/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/LeakedThread/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/LeakedThread/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
12 MAT/LeakedThread/res/layout/main.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
View
5 MAT/LeakedThread/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, LeakedThreadActivity!</string>
+ <string name="app_name">LeakedThread</string>
+</resources>
View
35 MAT/LeakedThread/src/com/commonsware/android/tuning/mat/LeakedThreadActivity.java
@@ -0,0 +1,35 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _Tuning Android Applications_
+ http://commonsware.com/AndTuning
+*/
+
+package com.commonsware.android.tuning.mat;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.SystemClock;
+
+public class LeakedThreadActivity extends Activity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ new Thread() {
+ public void run() {
+ while(true) {
+ SystemClock.sleep(100);
+ }
+ }
+ }.start();
+ }
+}
View
7 MAT/NonConfigWidget/.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/classes"/>
+</classpath>
View
33 MAT/NonConfigWidget/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>NonConfigWidget</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>
View
18 MAT/NonConfigWidget/AndroidManifest.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.commonsware.android.tuning.mat"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="7" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".NonConfigWidgetActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
View
40 MAT/NonConfigWidget/proguard.cfg
@@ -0,0 +1,40 @@
+-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 <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
View
6 NDK/WeakBench/default.properties → MAT/NonConfigWidget/project.properties
@@ -1,10 +1,10 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
BIN  MAT/NonConfigWidget/res/drawable-hdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/NonConfigWidget/res/drawable-ldpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/NonConfigWidget/res/drawable-mdpi/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
5 MAT/NonConfigWidget/res/layout/main.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:text="Bet you can't click me!" android:enabled="true"
+ android:onClick="btnClick" android:id="@+id/non_config" />
View
5 MAT/NonConfigWidget/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, NonConfigWidgetActivity!</string>
+ <string name="app_name">NonConfigWidget</string>
+</resources>
View
35 MAT/NonConfigWidget/src/com/commonsware/android/tuning/mat/NonConfigWidgetActivity.java
@@ -0,0 +1,35 @@
+package com.commonsware.android.tuning.mat;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+public class NonConfigWidgetActivity extends Activity {
+ View button;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ button=findViewById(R.id.non_config);
+
+ View old=(View)getLastNonConfigurationInstance();
+
+ if (old!=null) {
+ button.setEnabled(old.isEnabled());
+
+Log.w("NCWA", String.valueOf(button.getContext()==this));
+ }
+ }
+
+ @Override
+ public Object onRetainNonConfigurationInstance() {
+ return(button);
+ }
+
+ public void btnClick(View v) {
+ button.setEnabled(false);
+ }
+}
View
7 MAT/RandomAppOfCrap/.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/classes"/>
+</classpath>
View
33 MAT/RandomAppOfCrap/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>RandomAppOfCrap</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>
View
22 MAT/RandomAppOfCrap/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="com.commonsware.android.weather"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <application android:icon="@drawable/cw"
+ android:label="@string/app_name">
+ <activity android:label="@string/app_name"
+ android:name=".WeatherDemo">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <service android:name=".WeatherService" />
+ </application>
+ <supports-screens android:anyDensity="true"
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true" />
+</manifest>
View
67 MAT/RandomAppOfCrap/build.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="WeatherAPI" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked in in Version
+ Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the default property values
+ used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ application.package
+ the name of your application package as defined in the manifest. Used by the
+ 'uninstall' rule.
+ source.dir
+ the name of the source directory. Default is 'src'.
+ out.dir
+ the name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should be updated
+ using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android' tool, as well
+ as ADT.
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+ <!-- Execute the Android Setup task that will setup some properties specific to the target,
+ and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/templates/android_rules.xml
+
+ To customize some build steps for your project:
+ - copy the content of the main node <project> from android_rules.xml
+ - paste it in this build.xml below the <setup /> task.
+ - disable the import by changing the setup task below to <setup import="false" />
+
+ This will ensure that the properties are setup correctly but that your customized
+ build steps are used.
+ -->
+ <setup />
+
+</project>
View
36 MAT/RandomAppOfCrap/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 <methods>;
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembernames class * {
+ public <init>(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 *;
+}
View
12 MAT/RandomAppOfCrap/project.properties
@@ -0,0 +1,12 @@
+# 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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=Google Inc.:Google APIs:8
+sdk-folder=/opt/android-sdk-linux_x86-1.1_r1
View
BIN  MAT/RandomAppOfCrap/res/drawable/cw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/RandomAppOfCrap/res/drawable/eject.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/RandomAppOfCrap/res/drawable/mail_generic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 MAT/RandomAppOfCrap/res/layout/main.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WebView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/webkit"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ />
View
5 MAT/RandomAppOfCrap/res/values/strings.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Weather Service</string>
+ <string name="url">http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?&amp;lat=%1$f&amp;lon=%2$f&amp;product=time-series&amp;begin=2004-01-01T00:00:00&amp;end=2011-12-03T00:00:00&amp;temp=temp&amp;icons=icons</string>
+</resources>
View
45 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/Forecast.java
@@ -0,0 +1,45 @@
+/***
+ Copyright (c) 2010-2011 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package com.commonsware.android.weather;
+
+class Forecast {
+ String time="";
+ Integer temp=null;
+ String iconUrl="";
+
+ String getTime() {
+ return(time);
+ }
+
+ void setTime(String time) {
+ this.time=time.substring(0,16).replace('T', ' ');
+ }
+
+ Integer getTemp() {
+ return(temp);
+ }
+
+ void setTemp(Integer temp) {
+ this.temp=temp;
+ }
+
+ String getIcon() {
+ return(iconUrl);
+ }
+
+ void setIcon(String iconUrl) {
+ this.iconUrl=iconUrl;
+ }
+}
View
126 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherBinder.java
@@ -0,0 +1,126 @@
+/***
+ Copyright (c) 2010-2011 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package com.commonsware.android.weather;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import android.location.Location;
+import android.os.AsyncTask;
+import android.os.Binder;
+
+public class WeatherBinder extends Binder {
+ private HttpClient client=null;
+ private String urlTemplate=null;
+ private WeatherListener listener;
+
+ WeatherBinder(String urlTemplate) {
+ this.urlTemplate=urlTemplate;
+ }
+
+ void getForecast(Location loc, WeatherListener listener) {
+ this.listener=listener;
+ client=new DefaultHttpClient();
+ new FetchForecastTask().execute(loc);
+ }
+
+ private ArrayList<Forecast> buildForecasts(String raw) throws Exception {
+ ArrayList<Forecast> forecasts=new ArrayList<Forecast>();
+ DocumentBuilder builder=DocumentBuilderFactory
+ .newInstance()
+ .newDocumentBuilder();
+ Document doc=builder.parse(new InputSource(new StringReader(raw)));
+ NodeList times=doc.getElementsByTagName("start-valid-time");
+
+ for (int i=0;i<times.getLength();i++) {
+ Element time=(Element)times.item(i);
+ Forecast forecast=new Forecast();
+
+ forecasts.add(forecast);
+ forecast.setTime(time.getFirstChild().getNodeValue());
+ }
+
+ NodeList temps=doc.getElementsByTagName("value");
+
+ for (int i=0;i<temps.getLength();i++) {
+ Element temp=(Element)temps.item(i);
+ Forecast forecast=forecasts.get(i);
+
+ forecast.setTemp(new Integer(temp.getFirstChild().getNodeValue()));
+ }
+
+ NodeList icons=doc.getElementsByTagName("icon-link");
+
+ for (int i=0;i<icons.getLength();i++) {
+ Element icon=(Element)icons.item(i);
+ Forecast forecast=forecasts.get(i);
+
+ forecast.setIcon(icon.getFirstChild().getNodeValue());
+ }
+
+ return(forecasts);
+ }
+
+ class FetchForecastTask extends AsyncTask<Location, Void, ArrayList<Forecast>> {
+ Exception e=null;
+
+ @Override
+ protected ArrayList<Forecast> doInBackground(Location... locs) {
+ ArrayList<Forecast> result=null;
+
+ try {
+ Location loc=locs[0];
+ String url=String.format(urlTemplate, loc.getLatitude(),
+ loc.getLongitude());
+ HttpGet getMethod=new HttpGet(url);
+ ResponseHandler<String> responseHandler=new BasicResponseHandler();
+ String responseBody=client.execute(getMethod, responseHandler);
+
+ result=buildForecasts(responseBody);
+ client.getConnectionManager().shutdown();
+ }
+ catch (Exception e) {
+ this.e=e;
+ }
+
+ return(result);
+ }
+
+ @Override
+ protected void onPostExecute(ArrayList<Forecast> forecast) {
+ if (listener!=null) {
+ if (forecast!=null) {
+ listener.updateForecast(forecast);
+ }
+
+ if (e!=null) {
+ listener.handleError(e);
+ }
+ }
+
+ // BUG: we are always holding onto the last listener
+ }
+ }
+}
View
172 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherDemo.java
@@ -0,0 +1,172 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+package com.commonsware.android.weather;
+
+import java.util.ArrayList;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.util.Log;
+import android.webkit.WebView;
+
+public class WeatherDemo extends Activity {
+ private WebView browser;
+ private LocationManager mgr=null;
+ private State state=null;
+ private boolean isConfigurationChanging=false;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ browser=(WebView)findViewById(R.id.webkit);
+ state=(State)getLastNonConfigurationInstance();
+
+ if (state==null) {
+ state=new State();
+
+ Intent i=new Intent(this, WeatherService.class);
+
+ getApplicationContext().bindService(i, state.svcConn,
+ BIND_AUTO_CREATE);
+ }
+ else if (state.lastForecast!=null) {
+ showForecast();
+ }
+
+ state.attach(this);
+
+ mgr=(LocationManager)getSystemService(LOCATION_SERVICE);
+ mgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3600000,
+ 1000, onLocationChange);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ // BUG: we should be removing location updates
+ // somewhere...
+
+ if (!isConfigurationChanging) {
+ getApplicationContext().unbindService(state.svcConn);
+ }
+ }
+
+ @Override
+ public Object onRetainNonConfigurationInstance() {
+ isConfigurationChanging=true;
+
+ return(state);
+ }
+
+ private void goBlooey(Throwable t) {
+ AlertDialog.Builder builder=new AlertDialog.Builder(this);
+
+ builder.setTitle("Exception!").setMessage(t.toString())
+ .setPositiveButton("OK", null).show();
+ }
+
+ static String generatePage(ArrayList<Forecast> forecasts) {
+ StringBuilder bufResult=new StringBuilder("<html><body><table>");
+
+ bufResult.append("<tr><th width=\"50%\">Time</th>"
+ +"<th>Temperature</th><th>Forecast</th></tr>");
+
+ for (Forecast forecast : forecasts) {
+ bufResult.append("<tr><td align=\"center\">");
+ bufResult.append(forecast.getTime());
+ bufResult.append("</td><td align=\"center\">");
+ bufResult.append(forecast.getTemp());
+ bufResult.append("</td><td><img src=\"");
+ bufResult.append(forecast.getIcon());
+ bufResult.append("\"></td></tr>");
+ }
+
+ bufResult.append("</table></body></html>");
+
+ return(bufResult.toString());
+ }
+
+ void showForecast() {
+ browser.loadDataWithBaseURL(null, state.lastForecast, "text/html",
+ "UTF-8", null);
+ }
+
+ LocationListener onLocationChange=new LocationListener() {
+ public void onLocationChanged(Location location) {
+ if (state.weather!=null) {
+ state.weather.getForecast(location, state);
+ }
+ else {
+ Log.w(getClass().getName(),
+ "Unable to fetch forecast -- no WeatherBinder");
+ }
+ }
+
+ public void onProviderDisabled(String provider) {
+ // required for interface, not used
+ }
+
+ public void onProviderEnabled(String provider) {
+ // required for interface, not used
+ }
+
+ public void onStatusChanged(String provider, int status,
+ Bundle extras) {
+ // required for interface, not used
+ }
+ };
+
+ // BUG: not using a static inner class for state
+
+ class State implements WeatherListener {
+ WeatherBinder weather=null;
+ WeatherDemo activity=null;
+ String lastForecast=null;
+
+ void attach(WeatherDemo activity) {
+ this.activity=activity;
+ }
+
+ public void updateForecast(ArrayList<Forecast> forecast) {
+ lastForecast=generatePage(forecast);
+ activity.showForecast();
+ }
+
+ public void handleError(Exception e) {
+ activity.goBlooey(e);
+ }
+
+ ServiceConnection svcConn=new ServiceConnection() {
+ public void onServiceConnected(ComponentName className,
+ IBinder rawBinder) {
+ state.weather=(WeatherBinder)rawBinder;
+ }
+
+ public void onServiceDisconnected(ComponentName className) {
+ state.weather=null;
+ }
+ };
+ }
+}
View
22 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherListener.java
@@ -0,0 +1,22 @@
+/***
+ Copyright (c) 2010-2011 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package com.commonsware.android.weather;
+
+import java.util.ArrayList;
+
+public interface WeatherListener {
+ void updateForecast(ArrayList<Forecast> forecast);
+ void handleError(Exception e);
+}
View
33 MAT/RandomAppOfCrap/src/com/commonsware/android/weather/WeatherService.java
@@ -0,0 +1,33 @@
+/***
+ Copyright (c) 2010-2011 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package com.commonsware.android.weather;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+public class WeatherService extends Service {
+ private WeatherBinder binder;
+
+ @Override
+ public void onCreate() {
+ binder=new WeatherBinder(getString(R.string.url));
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return(binder);
+ }
+}
View
7 MAT/Spinners/.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/classes"/>
+</classpath>
View
33 MAT/Spinners/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ContactSpinners</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>
View
24 MAT/Spinners/AndroidManifest.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest android:versionCode="1"
+ android:versionName="1.0"
+ package="com.commonsware.android.contacts.spinners"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <uses-permission android:name="android.permission.READ_CONTACTS" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-sdk android:minSdkVersion="3"
+ android:targetSdkVersion="6" />
+ <supports-screens android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="false" />
+ <application android:icon="@drawable/cw"
+ android:label="@string/app_name">
+ <activity android:label="@string/app_name"
+ android:name=".ContactSpinners">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
View
20 MAT/Spinners/build.properties
@@ -0,0 +1,20 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
+# The name of your application package as defined in the manifest.
+# Used by the 'uninstall' rule.
+application.package=com.commonsware.android.contacts.spinners
View
67 MAT/Spinners/build.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Spinners" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked in in Version
+ Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the default property values
+ used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ application.package
+ the name of your application package as defined in the manifest. Used by the
+ 'uninstall' rule.
+ source.dir
+ the name of the source directory. Default is 'src'.
+ out.dir
+ the name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should be updated
+ using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android' tool, as well
+ as ADT.
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+ <!-- Execute the Android Setup task that will setup some properties specific to the target,
+ and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/templates/android_rules.xml
+
+ To customize some build steps for your project:
+ - copy the content of the main node <project> from android_rules.xml
+ - paste it in this build.xml below the <setup /> task.
+ - disable the import by changing the setup task below to <setup import="false" />
+
+ This will ensure that the properties are setup correctly but that your customized
+ build steps are used.
+ -->
+ <setup />
+
+</project>
View
40 MAT/Spinners/proguard.cfg
@@ -0,0 +1,40 @@
+-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 <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
View
2  TrafficMonitor/default.properties → MAT/Spinners/project.properties
@@ -4,7 +4,7 @@
# 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
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
BIN  MAT/Spinners/res/drawable-mdpi/cw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  MAT/Spinners/res/drawable/cw.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
18 MAT/Spinners/res/layout/main.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+ <Spinner android:id="@+id/spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:drawSelectorOnTop="true"
+ />
+ <ListView
+ android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:drawSelectorOnTop="false"
+ />
+</LinearLayout>
View
4 MAT/Spinners/res/values/strings.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">ContactSpinners</string>
+</resources>
View
66 MAT/Spinners/src/com/commonsware/android/contacts/spinners/ContactSpinners.java
@@ -0,0 +1,66 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.app.ListActivity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+import android.widget.Spinner;
+
+public class ContactSpinners extends ListActivity
+ implements AdapterView.OnItemSelectedListener {
+ private static String[] options={"Contact Names",
+ "Contact Names & Numbers",
+ "Contact Names & Email Addresses"};
+ private ListAdapter[] listAdapters=new ListAdapter[3];
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ initListAdapters();
+
+ Spinner spin=(Spinner)findViewById(R.id.spinner);
+ spin.setOnItemSelectedListener(this);
+
+ ArrayAdapter<String> aa=new ArrayAdapter<String>(this,
+ android.R.layout.simple_spinner_item,
+ options);
+
+ aa.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
+ spin.setAdapter(aa);
+ }
+
+ public void onItemSelected(AdapterView<?> parent,
+ View v, int position, long id) {
+ setListAdapter(listAdapters[position]);
+ }
+
+ public void onNothingSelected(AdapterView<?> parent) {
+ // ignore
+ }
+
+ private void initListAdapters() {
+ listAdapters[0]=ContactsAdapterBridge.INSTANCE.buildNameAdapter(this);
+ listAdapters[1]=ContactsAdapterBridge.INSTANCE.buildPhonesAdapter(this);
+ listAdapters[2]=ContactsAdapterBridge.INSTANCE.buildEmailAdapter(this);
+ }
+
+}
View
37 MAT/Spinners/src/com/commonsware/android/contacts/spinners/ContactsAdapterBridge.java
@@ -0,0 +1,37 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.app.Activity;
+import android.os.Build;
+import android.widget.ListAdapter;
+
+abstract class ContactsAdapterBridge {
+ abstract ListAdapter buildNameAdapter(Activity a);
+ abstract ListAdapter buildPhonesAdapter(Activity a);
+ abstract ListAdapter buildEmailAdapter(Activity a);
+
+ public static final ContactsAdapterBridge INSTANCE=buildBridge();
+
+ private static ContactsAdapterBridge buildBridge() {
+ int sdk=new Integer(Build.VERSION.SDK).intValue();
+
+ if (sdk<5) {
+ return(new OldContactsAdapterBridge());
+ }
+
+ return(new NewContactsAdapterBridge());
+ }
+}
View
85 MAT/Spinners/src/com/commonsware/android/contacts/spinners/NewContactsAdapterBridge.java
@@ -0,0 +1,85 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.app.Activity;
+import android.database.Cursor;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.CommonDataKinds.Email;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.widget.ListAdapter;
+import android.widget.SimpleCursorAdapter;
+
+class NewContactsAdapterBridge extends ContactsAdapterBridge {
+ ListAdapter buildNameAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts._ID,
+ Contacts.DISPLAY_NAME,
+ };
+ Cursor c=a.managedQuery(Contacts.CONTENT_URI,
+ PROJECTION, null, null, null);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_1,
+ c,
+ new String[] {
+ Contacts.DISPLAY_NAME
+ },
+ new int[] {
+ android.R.id.text1
+ }));
+ }
+
+ ListAdapter buildPhonesAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts._ID,
+ Contacts.DISPLAY_NAME,
+ Phone.NUMBER
+ };
+ Cursor c=a.managedQuery(Phone.CONTENT_URI,
+ PROJECTION, null, null, null);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_2,
+ c,
+ new String[] {
+ Contacts.DISPLAY_NAME,
+ Phone.NUMBER
+ },
+ new int[] {
+ android.R.id.text1,
+ android.R.id.text2
+ }));
+ }
+
+ ListAdapter buildEmailAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts._ID,
+ Contacts.DISPLAY_NAME,
+ Email.DATA
+ };
+ Cursor c=a.managedQuery(Email.CONTENT_URI,
+ PROJECTION, null, null, null);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_2,
+ c,
+ new String[] {
+ Contacts.DISPLAY_NAME,
+ Email.DATA
+ },
+ new int[] {
+ android.R.id.text1,
+ android.R.id.text2
+ }));
+ }
+}
View
86 MAT/Spinners/src/com/commonsware/android/contacts/spinners/OldContactsAdapterBridge.java
@@ -0,0 +1,86 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.app.Activity;
+import android.database.Cursor;
+import android.provider.Contacts;
+import android.widget.ListAdapter;
+import android.widget.SimpleCursorAdapter;
+
+class OldContactsAdapterBridge extends ContactsAdapterBridge {
+ ListAdapter buildNameAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts.People._ID,
+ Contacts.PeopleColumns.NAME
+ };
+ Cursor c=a.managedQuery(Contacts.People.CONTENT_URI,
+ PROJECTION, null, null,
+ Contacts.People.DEFAULT_SORT_ORDER);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_1,
+ c,
+ new String[] {
+ Contacts.PeopleColumns.NAME
+ },
+ new int[] {
+ android.R.id.text1
+ }));
+ }
+
+ ListAdapter buildPhonesAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts.Phones._ID,
+ Contacts.Phones.NAME,
+ Contacts.Phones.NUMBER
+ };
+ Cursor c=a.managedQuery(Contacts.Phones.CONTENT_URI,
+ PROJECTION, null, null,
+ Contacts.Phones.DEFAULT_SORT_ORDER);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_2,
+ c,
+ new String[] {
+ Contacts.Phones.NAME,
+ Contacts.Phones.NUMBER
+ },
+ new int[] {
+ android.R.id.text1,
+ android.R.id.text2
+ }));
+ }
+
+ ListAdapter buildEmailAdapter(Activity a) {
+ String[] PROJECTION=new String[] { Contacts.ContactMethods._ID,
+ Contacts.ContactMethods.DATA,
+ Contacts.PeopleColumns.NAME
+ };
+ Cursor c=a.managedQuery(Contacts.ContactMethods.CONTENT_EMAIL_URI,
+ PROJECTION, null, null,
+ Contacts.ContactMethods.DEFAULT_SORT_ORDER);
+
+ return(new SimpleCursorAdapter( a,
+ android.R.layout.simple_list_item_2,
+ c,
+ new String[] {
+ Contacts.PeopleColumns.NAME,
+ Contacts.ContactMethods.DATA
+ },
+ new int[] {
+ android.R.id.text1,
+ android.R.id.text2
+ }));
+ }
+}
View
7 MAT/Spinners/tests/.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/classes"/>
+</classpath>
View
33 MAT/Spinners/tests/.project
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ContactsSpinnersTests</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>
View
23 MAT/Spinners/tests/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest android:versionCode="1"
+ android:versionName="1.0"
+ package="com.commonsware.android.contacts.spinners.tests"
+ xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+ <!--
+ This declares that this application uses the instrumentation test runner targeting
+ the package of com.commonsware.android.database. To run the tests use the command:
+ "adb shell am instrument -w com.commonsware.android.database.tests/android.test.InstrumentationTestRunner"
+ -->
+ <instrumentation android:label="Tests for ContactSpinners"
+ android:name="com.commonsware.android.contacts.spinners.HprofTestRunner"
+ android:targetPackage="com.commonsware.android.contacts.spinners" />
+
+</manifest>
View
18 MAT/Spinners/tests/build.properties
@@ -0,0 +1,18 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
+tested.project.dir=..
View
71 MAT/Spinners/tests/build.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ContactSpinnersTests" default="help">
+
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked in in Version
+ Control Systems. -->
+ <property file="local.properties" />
+
+ <!-- The build.properties file can be created by you and is never touched
+ by the 'android' tool. This is the place to change some of the default property values
+ used by the Ant rules.
+ Here are some properties you may want to change/update:
+
+ application.package
+ the name of your application package as defined in the manifest. Used by the
+ 'uninstall' rule.
+ source.dir
+ the name of the source directory. Default is 'src'.
+ out.dir
+ the name of the output directory. Default is 'bin'.
+
+ Properties related to the SDK location or the project target should be updated
+ using the 'android' tool with the 'update' action.
+
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems.
+
+ -->
+ <property file="build.properties" />
+
+ <!-- The default.properties file is created and updated by the 'android' tool, as well
+ as ADT.
+ This file is an integral part of the build system for your application and
+ should be checked in in Version Control Systems. -->
+ <property file="default.properties" />
+
+ <!-- Custom Android task to deal with the project target, and import the proper rules.
+ This requires ant 1.6.0 or above. -->
+ <path id="android.antlibs">
+ <pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
+ <pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
+ </path>
+
+ <taskdef name="setup"
+ classname="com.android.ant.SetupTask"
+ classpathref="android.antlibs" />
+
+ <!-- Execute the Android Setup task that will setup some properties specific to the target,
+ and import the build rules files.
+
+ The rules file is imported from
+ <SDK>/platforms/<target_platform>/templates/android_rules.xml
+
+ To customize some build steps for your project:
+ - copy the content of the main node <project> from android_rules.xml
+ - paste it in this build.xml below the <setup /> task.
+ - disable the import by changing the setup task below to <setup import="false" />
+
+ This will ensure that the properties are setup correctly but that your customized
+ build steps are used.
+ -->
+
+ <property name="test.runner"
+ value="com.commonsware.android.contacts.spinners.HprofTestRunner"/>
+
+ <setup />
+
+</project>
View
40 MAT/Spinners/tests/proguard.cfg
@@ -0,0 +1,40 @@
+-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 <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
View
11 MAT/Spinners/tests/project.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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-7
View
2  MAT/Spinners/tests/run
@@ -0,0 +1,2 @@
+#!/bin/bash
+adb shell am instrument -w com.commonsware.android.contacts.spinners.tests/android.test.InstrumentationTestRunner
View
53 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/ContactsDemoBaseTest.java
@@ -0,0 +1,53 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.test.AndroidTestCase;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+import android.widget.Spinner;
+
+public class ContactsDemoBaseTest extends AndroidTestCase {
+ private ListView list=null;
+ private Spinner spinner=null;
+ private ViewGroup root=null;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ LayoutInflater inflater=LayoutInflater.from(getContext());
+
+ root=(ViewGroup)inflater.inflate(R.layout.main, null);
+ root.measure(480, 320);
+ root.layout(0, 0, 480, 320);
+
+ list=(ListView)root.findViewById(android.R.id.list);
+ spinner=(Spinner)root.findViewById(R.id.spinner);
+ }
+
+ public void testExists() {
+ assertNotNull(list);
+ assertNotNull(spinner);
+ }
+
+ public void testRelativePosition() {
+ assertTrue(list.getTop()>=spinner.getBottom());
+ assertTrue(list.getLeft()==spinner.getLeft());
+ assertTrue(list.getRight()==spinner.getRight());
+ }
+}
View
48 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/ContactsDemoTest.java
@@ -0,0 +1,48 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.test.ActivityInstrumentationTestCase;
+import android.widget.ListView;
+import android.widget.Spinner;
+
+public class ContactsDemoTest
+ extends ActivityInstrumentationTestCase<ContactSpinners> {
+ private ListView list=null;
+ private Spinner spinner=null;
+
+ public ContactsDemoTest() {
+ super("com.commonsware.android.contacts.spinners",
+ ContactSpinners.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ ContactSpinners activity=getActivity();
+
+ list=(ListView)activity.findViewById(android.R.id.list);
+ spinner=(Spinner)activity.findViewById(R.id.spinner);
+ }
+
+ public void testSpinnerCount() {
+ assertTrue(spinner.getAdapter().getCount()==3);
+ }
+
+ public void testListDefaultCount() {
+ assertTrue(list.getAdapter().getCount()>0);
+ }
+}
View
27 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/FullSuite.java
@@ -0,0 +1,27 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import android.test.suitebuilder.TestSuiteBuilder;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class FullSuite extends TestSuite {
+ public static Test suite() {
+ return(new TestSuiteBuilder(FullSuite.class)
+ .includeAllPackagesUnderHere()
+ .build());
+ }
+}
View
36 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/HprofTestRunner.java
@@ -0,0 +1,36 @@
+/***
+ Copyright (c) 2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import java.io.File;
+import java.io.IOException;
+import android.os.Bundle;
+import android.os.Debug;
+import android.os.Environment;
+import android.test.InstrumentationTestRunner;
+
+public class HprofTestRunner extends InstrumentationTestRunner {
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ try {
+ Debug.dumpHprofData(new File(Environment.getExternalStorageDirectory(), "hprof.dmp").getAbsolutePath());
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ super.finish(resultCode, results);
+ }
+}
View
35 MAT/Spinners/tests/src/com/commonsware/android/contacts/spinners/SillyTest.java
@@ -0,0 +1,35 @@
+/***
+ Copyright (c) 2008-2011 CommonsWare, LLC
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License. You may obtain a copy
+ of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
+ by applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ OF ANY KIND, either express or implied. See the License for the specific
+ language governing permissions and limitations under the License.
+
+ From _The Busy Coder's Guide to Advanced Android Development_
+ http://commonsware.com/AdvAndroid
+*/
+
+package com.commonsware.android.contacts.spinners;
+
+import junit.framework.TestCase;
+
+public class SillyTest extends TestCase {
+ protected void setUp() throws Exception {
+ super.setUp();