diff --git a/.gitignore b/.gitignore index 710f3f0..720f2a7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ .classpath .project .settings +.metadata bin gen lint.xml -/.metadata diff --git a/AIDLDemo/project.properties b/AIDLDemo/project.properties index 730e911..8da376a 100644 --- a/AIDLDemo/project.properties +++ b/AIDLDemo/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/AndroidUIDemo/project.properties b/AndroidUIDemo/project.properties index 730e911..8da376a 100644 --- a/AndroidUIDemo/project.properties +++ b/AndroidUIDemo/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/AndroidViewDemo/project.properties b/AndroidViewDemo/project.properties index 730e911..8da376a 100644 --- a/AndroidViewDemo/project.properties +++ b/AndroidViewDemo/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/AsyncTaskDemo/project.properties b/AsyncTaskDemo/project.properties index 730e911..8da376a 100644 --- a/AsyncTaskDemo/project.properties +++ b/AsyncTaskDemo/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/ClientDemo/project.properties b/ClientDemo/project.properties index 730e911..8da376a 100644 --- a/ClientDemo/project.properties +++ b/ClientDemo/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/ContactViewer/project.properties b/ContactViewer/project.properties index 5a70945..8da376a 100644 --- a/ContactViewer/project.properties +++ b/ContactViewer/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-7 +target=android-15 diff --git a/FinchChat/AndroidManifest.xml b/FinchChat/AndroidManifest.xml index b740592..f9a2fe7 100644 --- a/FinchChat/AndroidManifest.xml +++ b/FinchChat/AndroidManifest.xml @@ -1,28 +1,35 @@ - - + package="com.finchframework.finch" + android:versionCode="1" + android:versionName="1.0" > + + + + - - + + + - + - + + \ No newline at end of file diff --git a/FinchChat/project.properties b/FinchChat/project.properties index 395d7de..b0439b1 100644 --- a/FinchChat/project.properties +++ b/FinchChat/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-14 +target=android-15 android.library=false diff --git a/FinchFramework/AndroidManifest.xml b/FinchFramework/AndroidManifest.xml index 18f0127..bc8df89 100644 --- a/FinchFramework/AndroidManifest.xml +++ b/FinchFramework/AndroidManifest.xml @@ -7,15 +7,15 @@ - + - - + + diff --git a/FinchFramework/project.properties b/FinchFramework/project.properties index d525577..5fa344c 100644 --- a/FinchFramework/project.properties +++ b/FinchFramework/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-14 +target=android-15 android.library=true diff --git a/FinchFramework/res/values/strings.xml b/FinchFramework/res/values/strings.xml index 8d3bbaf..851c82e 100644 --- a/FinchFramework/res/values/strings.xml +++ b/FinchFramework/res/values/strings.xml @@ -2,7 +2,7 @@ FinchFramework - + Connect a device Make discoverable @@ -11,4 +11,4 @@ Bluetooth tools Animation - \ No newline at end of file + diff --git a/FinchFramework/src/com/finchframework/finch/FinchApplication.java b/FinchFramework/src/com/finchframework/finch/FinchApplication.java index 26797ab..affad19 100644 --- a/FinchFramework/src/com/finchframework/finch/FinchApplication.java +++ b/FinchFramework/src/com/finchframework/finch/FinchApplication.java @@ -7,41 +7,41 @@ /** * Provides the framework's Application subclass. This illustrates what * you may need to do in an Application subclass. - * + *

* To get this class instantiated, you must refer to it in the * application tag of the manifest. */ public class FinchApplication extends Application { - private final String TAG = this.getClass().getSimpleName(); - - @Override - public void onCreate() { - // First, call the parent class - super.onCreate(); - - // This is a place to put code that must manage storage across - // multiple activities, but it's better to keep most things in a - // database, rather than in memory - Log.i(TAG, "onCreate"); - } - - @Override - public void onTerminate() { - Log.i(TAG, "onTerminate"); - - } - - @Override - public void onLowMemory() { - // In-memory caches should be thrown overboard here - Log.i(TAG, "onLowMemory"); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - Log.i(TAG, "onConifgurationChanged"); - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.v(TAG, newConfig.toString()); - } - } + private final String TAG = this.getClass().getSimpleName(); + + @Override + public void onCreate() { + // First, call the parent class + super.onCreate(); + + // This is a place to put code that must manage storage across + // multiple activities, but it's better to keep most things in a + // database, rather than in memory + Log.i(TAG, "onCreate"); + } + + @Override + public void onTerminate() { + Log.i(TAG, "onTerminate"); + + } + + @Override + public void onLowMemory() { + // In-memory caches should be thrown overboard here + Log.i(TAG, "onLowMemory"); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + Log.i(TAG, "onConifgurationChanged"); + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, newConfig.toString()); + } + } } diff --git a/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java b/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java index 33f25c7..e6dbcdc 100644 --- a/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java +++ b/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java @@ -14,26 +14,24 @@ */ public class FileHandler implements ResponseHandler { private String mId; - private String mCacheDir; + private File mCacheDir; - public FileHandler(String cacheDir, String id) { + public FileHandler(File cacheDir, String id) { mCacheDir = cacheDir; mId = id; } - public - String getFileName(String ID) { - return mCacheDir + "/" + ID; + public File getFile(String ID) { + return new File(mCacheDir, ID); } public void handleResponse(HttpResponse response, Uri uri) - throws IOException - { + throws IOException { InputStream urlStream = response.getEntity().getContent(); FileOutputStream fout = - new FileOutputStream(getFileName(mId)); + new FileOutputStream(getFile(mId)); byte[] bytes = new byte[256]; - int r = 0; + int r; do { r = urlStream.read(bytes); if (r >= 0) { diff --git a/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java b/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java index 2efb3f5..1f172b8 100644 --- a/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java +++ b/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java @@ -7,17 +7,16 @@ * The cache directory is set in the constructor to the file handler factory. */ public class FileHandlerFactory { - private String mCacheDir; + private File mCacheDir; - public FileHandlerFactory(String cacheDir) { + public FileHandlerFactory(File cacheDir) { mCacheDir = cacheDir; init(); } private void init() { - File cacheDir = new File(mCacheDir); - if (!cacheDir.exists()) { - cacheDir.mkdir(); + if (!mCacheDir.exists()) { + mCacheDir.mkdir(); } } @@ -25,27 +24,14 @@ public FileHandler newFileHandler(String id) { return new FileHandler(mCacheDir, id); } - // not really used since ContentResolver uses _data field. - public File getFile(String ID) { - String cachePath = getFileName(ID); - - File cacheFile = new File(cachePath); - if (cacheFile.exists()) { - return cacheFile; - } - return null; - } - public void delete(String ID) { - String cachePath = mCacheDir + "/" + ID; - - File cacheFile = new File(cachePath); + File cacheFile = new File(mCacheDir, ID); if (cacheFile.exists()) { cacheFile.delete(); } } public String getFileName(String ID) { - return mCacheDir + "/" + ID; + return new File(mCacheDir, ID).toString(); } } diff --git a/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java b/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java index 9b67077..9b7d917 100644 --- a/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java +++ b/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java @@ -24,11 +24,14 @@ public abstract class RESTfulContentProvider extends ContentProvider { private Map mRequestsInProgress = new HashMap(); - public RESTfulContentProvider(FileHandlerFactory fileHandlerFactory) { + public RESTfulContentProvider() { + } + + public void setFileHandlerFactory(FileHandlerFactory fileHandlerFactory) { mFileHandlerFactory = fileHandlerFactory; } - public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db); + public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db); private UriRequestTask getRequestTask(String queryText) { return mRequestsInProgress.get(queryText); @@ -53,10 +56,10 @@ public void requestComplete(String mQueryText) { * * @param requestTag unique tag identifying this request. * @return The response handler created by a subclass used to parse the - * request response. + * request response. */ protected abstract ResponseHandler newResponseHandler(String requestTag); - + UriRequestTask newQueryTask(String requestTag, String url) { UriRequestTask requestTask; @@ -73,7 +76,6 @@ UriRequestTask newQueryTask(String requestTag, String url) { * Creates a new worker thread to carry out a RESTful network invocation. * * @param queryTag unique tag that identifies this request. - * * @param queryUri the complete URI that should be access by this request. */ public void asyncQueryRequest(String queryTag, String queryUri) { diff --git a/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java b/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java index ea6b404..f7e3c1c 100644 --- a/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java +++ b/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java @@ -29,75 +29,101 @@ public RawResponse(Context c, int rawResource) { Log.d(Finch.LOG_TAG, "exception from raw input stream", e); } } + public StatusLine getStatusLine() { return null; } + public void setStatusLine(StatusLine statusLine) { } + public void setStatusLine(ProtocolVersion protocolVersion, int i) { } + public void setStatusLine(ProtocolVersion protocolVersion, int i, String s) { } + public void setStatusCode(int i) - throws IllegalStateException - { + throws IllegalStateException { } + public void setReasonPhrase(String s) throws IllegalStateException { } + public HttpEntity getEntity() { return mDebugEntity; } + public void setEntity(HttpEntity httpEntity) { } + public Locale getLocale() { return null; } + public void setLocale(Locale locale) { } + public ProtocolVersion getProtocolVersion() { return null; } + public boolean containsHeader(String s) { return false; } + public Header[] getHeaders(String s) { return new Header[0]; } + public Header getFirstHeader(String s) { return null; } + public Header getLastHeader(String s) { return null; } + public Header[] getAllHeaders() { return new Header[0]; } + public void addHeader(Header header) { } + public void addHeader(String s, String s1) { } + public void setHeader(Header header) { } + public void setHeader(String s, String s1) { } + public void setHeaders(Header[] headers) { } + public void removeHeader(Header header) { } + public void removeHeaders(String s) { } + public HeaderIterator headerIterator() { return null; } + public HeaderIterator headerIterator(String s) { return null; } + public HttpParams getParams() { return null; } + public void setParams(HttpParams httpParams) { } }; diff --git a/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java b/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java index 50865e3..79432f2 100644 --- a/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java +++ b/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java @@ -24,21 +24,19 @@ public class UriRequestTask implements Runnable { private RESTfulContentProvider mSiteProvider; private String mRequestTag; - + private int mRawResponse = -1; // private int mRawResponse = R.raw.map_src; public UriRequestTask(HttpUriRequest request, - ResponseHandler handler, Context appContext) - { + ResponseHandler handler, Context appContext) { this(null, null, request, handler, appContext); } - + public UriRequestTask(String requestTag, RESTfulContentProvider siteProvider, HttpUriRequest request, - ResponseHandler handler, Context appContext) - { + ResponseHandler handler, Context appContext) { mRequestTag = requestTag; mSiteProvider = siteProvider; mRequest = request; diff --git a/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java b/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java deleted file mode 100644 index 9bbd2d5..0000000 --- a/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.finchframework.finch.views; - -import android.content.Context; -import android.graphics.Rect; -import android.text.Editable; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.widget.EditText; - -/** - * A text field that can display a default message until a user types in their - * own text. - */ -public class MesgEditText extends EditText { - private String mMesgText; - - public MesgEditText(Context context) { - super(context); - } - - public MesgEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public MesgEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public void setMesgText(String messageText) { - mMesgText = messageText; - setText(messageText); - } - - @Override - public Editable getText() { - CharSequence current = super.getText(); - if ((current != null) && mMesgText.equals(current)) { - current = ""; - } - return Editable.Factory.getInstance().newEditable(current); - } - - @Override - protected void onFocusChanged(boolean focused, int direction, - Rect previouslyFocusedRect) - { - super.onFocusChanged(focused, direction, previouslyFocusedRect); - userOverride(); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent keyEvent) { -// if (keyCode == KeyEvent.KEYCODE_ENTER) { - userOverride(); -// } - return super.onKeyDown(keyCode, keyEvent); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - boolean superResponse = super.onTouchEvent(event); - String actualText = super.getText().toString(); - if (mMesgText.equals(actualText)) { - super.setText(""); - } - return superResponse; - } - - private void userOverride() { - String actualText = super.getText().toString(); - if (!hasFocus() && actualText.equals("")) { - setText(mMesgText); - } - if (hasFocus() && actualText.equals(mMesgText)) { - setText(""); - } - } - - public boolean searchEmpty() { - CharSequence actualText = super.getText(); - - return ((actualText == null) || - mMesgText.equals(actualText.toString()) || - "".equals(actualText.toString())); - } -} diff --git a/FinchLifecycle/project.properties b/FinchLifecycle/project.properties index 730e911..8da376a 100644 --- a/FinchLifecycle/project.properties +++ b/FinchLifecycle/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-14 +target=android-15 diff --git a/FinchLifecycleBackport/project.properties b/FinchLifecycleBackport/project.properties index 83afe56..67cc219 100644 --- a/FinchLifecycleBackport/project.properties +++ b/FinchLifecycleBackport/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-7 +target=android-15 android.library.reference.1=../FinchFramework diff --git a/FinchVideo/AndroidManifest.xml b/FinchVideo/AndroidManifest.xml index 32ae55e..9a3ab35 100644 --- a/FinchVideo/AndroidManifest.xml +++ b/FinchVideo/AndroidManifest.xml @@ -1,32 +1,42 @@ - - - - + package="com.oreilly.demo.android.pa.finchvideo" + android:versionCode="1" + android:versionName="1.0" > + + + + + + + + + + + - + + - - - + + \ No newline at end of file diff --git a/FinchVideo/README.txt b/FinchVideo/README.txt index 9cab5e5..9b21279 100644 --- a/FinchVideo/README.txt +++ b/FinchVideo/README.txt @@ -1,15 +1,20 @@ +The simplest way to set up this project is to use the project and classpath +files in the tools/ide/eclipse folders. To do this: +1) copy project and classpath files for the FinchFramework project into the + project root as .project and .classpath, respectively. +2) import the FinchFramework project into your eclipse workspace + (be sure to use "Import Existing Project into Workspace", not "Import + Existing Android Code into Workspace"!) +3) repeat steps 1 and 2 for the FinchVideo project -Probably the simplest way to set up this project is to use the project and -classpath files in the tools/ide/eclipse folders. The more complete description -is that need to set up the Finch Framework project -($root/finch/framework/FinchFramework). You need to be sure that the directory -lib-src is on the build path. You will also need to set up FinchWelcome as a library: -1) import FinchWelcome into your workspace -2) for FinchWelcome, check Properties > Android and verify that it is - a library project (bottom half of the dialog) -3) in the project, use Android > Properties to add that project - to this one, as a library +A more complete description is that you need to set up the FinchFramework +project as an Android library: +1) Set up this project. It will have compile errors. +2) import the FinchFramework into your workspace +3) verify that the FinchFramework project is a library project: + check Properties > Android and look in the bottom half of the dialog +4) Use Android > Properties > Add... in the lower pane, to add the + FinchFramework project to this one, as a library -Using the normal eclipse project dependency mechanism will not work. - +Using the normal eclipse project dependency mechanism will not work! diff --git a/FinchVideo/project.properties b/FinchVideo/project.properties index 817681e..67cc219 100644 --- a/FinchVideo/project.properties +++ b/FinchVideo/project.properties @@ -8,5 +8,5 @@ # project structure. # Project target. -target=android-14 +target=android-15 android.library.reference.1=../FinchFramework diff --git a/FinchVideo/res/layout/simple_video_activity.xml b/FinchVideo/res/layout/simple_video_activity.xml index b82c882..a614877 100644 --- a/FinchVideo/res/layout/simple_video_activity.xml +++ b/FinchVideo/res/layout/simple_video_activity.xml @@ -7,85 +7,53 @@ android:id="@+id/video_layout" android:orientation="vertical" > - + - - - - - - - - - - - - -