Skip to content

Commit 3ce63e6

Browse files
committed
Removed some redundant linear layouts.
Remove MesgEditText again. Remove hard coded /data path. Use File(File, "id");
1 parent a2abc59 commit 3ce63e6

File tree

10 files changed

+96
-170
lines changed

10 files changed

+96
-170
lines changed

FinchFramework/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<uses-sdk android:minSdkVersion="7" />
88

99
<uses-permission android:name="android.permission.INTERNET" />
10-
10+
1111
<application android:icon="@drawable/icon"
1212
android:label="@string/app_name"
1313
android:debuggable="true">
1414
<activity android:name=".FinchWelcome"
1515
android:label="@string/app_name">
1616
<intent-filter>
17-
<action android:name="android.intent.action.MAIN" />
18-
<category android:name="android.intent.category.LAUNCHER" />
17+
<action android:name="android.intent.action.MAIN"/>
18+
<category android:name="android.intent.category.LAUNCHER"/>
1919
</intent-filter>
2020
</activity>
2121
</application>

FinchFramework/project.properties

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
#
44
# This file must be checked in Version Control Systems.
55
#
6-
# To customize properties used by the Ant build system use,
6+
# To customize properties used by the Ant build system edit
77
# "ant.properties", and override values to adapt the script to your
88
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
912

10-
# Project target.
11-
target=android-14
1213
android.library=true
14+
# Project target.
15+
target=android-16

FinchFramework/res/values/strings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
33

44
<string name="app_name">FinchFramework</string>
5-
5+
66
<string name="connect">Connect a device</string>
77
<string name="discoverable">Make discoverable</string>
88

@@ -11,4 +11,4 @@
1111
<string name="bluetooth_tools">Bluetooth tools</string>
1212
<string name="animation_example">Animation</string>
1313

14-
</resources>
14+
</resources>

FinchFramework/src/com/finchframework/finch/FinchApplication.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,41 @@
77
/**
88
* Provides the framework's Application subclass. This illustrates what
99
* you may need to do in an Application subclass.
10-
*
10+
* <p/>
1111
* To get this class instantiated, you must refer to it in the
1212
* application tag of the manifest.
1313
*/
1414
public class FinchApplication extends Application {
15-
private final String TAG = this.getClass().getSimpleName();
16-
17-
@Override
18-
public void onCreate() {
19-
// First, call the parent class
20-
super.onCreate();
21-
22-
// This is a place to put code that must manage storage across
23-
// multiple activities, but it's better to keep most things in a
24-
// database, rather than in memory
25-
Log.i(TAG, "onCreate");
26-
}
27-
28-
@Override
29-
public void onTerminate() {
30-
Log.i(TAG, "onTerminate");
31-
32-
}
33-
34-
@Override
35-
public void onLowMemory() {
36-
// In-memory caches should be thrown overboard here
37-
Log.i(TAG, "onLowMemory");
38-
}
39-
40-
@Override
41-
public void onConfigurationChanged(Configuration newConfig) {
42-
Log.i(TAG, "onConifgurationChanged");
43-
if (Log.isLoggable(TAG, Log.VERBOSE)) {
44-
Log.v(TAG, newConfig.toString());
45-
}
46-
}
15+
private final String TAG = this.getClass().getSimpleName();
16+
17+
@Override
18+
public void onCreate() {
19+
// First, call the parent class
20+
super.onCreate();
21+
22+
// This is a place to put code that must manage storage across
23+
// multiple activities, but it's better to keep most things in a
24+
// database, rather than in memory
25+
Log.i(TAG, "onCreate");
26+
}
27+
28+
@Override
29+
public void onTerminate() {
30+
Log.i(TAG, "onTerminate");
31+
32+
}
33+
34+
@Override
35+
public void onLowMemory() {
36+
// In-memory caches should be thrown overboard here
37+
Log.i(TAG, "onLowMemory");
38+
}
39+
40+
@Override
41+
public void onConfigurationChanged(Configuration newConfig) {
42+
Log.i(TAG, "onConifgurationChanged");
43+
if (Log.isLoggable(TAG, Log.VERBOSE)) {
44+
Log.v(TAG, newConfig.toString());
45+
}
46+
}
4747
}

FinchFramework/src/com/finchframework/finch/rest/FileHandler.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@
1414
*/
1515
public class FileHandler implements ResponseHandler {
1616
private String mId;
17-
private String mCacheDir;
17+
private File mCacheDir;
1818

19-
public FileHandler(String cacheDir, String id) {
19+
public FileHandler(File cacheDir, String id) {
2020
mCacheDir = cacheDir;
2121
mId = id;
2222
}
2323

24-
public
25-
String getFileName(String ID) {
26-
return mCacheDir + "/" + ID;
24+
public File getFile(String ID) {
25+
return new File(mCacheDir, ID);
2726
}
2827

2928
public void handleResponse(HttpResponse response, Uri uri)
30-
throws IOException
31-
{
29+
throws IOException {
3230
InputStream urlStream = response.getEntity().getContent();
3331
FileOutputStream fout =
34-
new FileOutputStream(getFileName(mId));
32+
new FileOutputStream(getFile(mId));
3533
byte[] bytes = new byte[256];
36-
int r = 0;
34+
int r;
3735
do {
3836
r = urlStream.read(bytes);
3937
if (r >= 0) {

FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,31 @@
77
* The cache directory is set in the constructor to the file handler factory.
88
*/
99
public class FileHandlerFactory {
10-
private String mCacheDir;
10+
private File mCacheDir;
1111

12-
public FileHandlerFactory(String cacheDir) {
12+
public FileHandlerFactory(File cacheDir) {
1313
mCacheDir = cacheDir;
1414
init();
1515
}
1616

1717
private void init() {
18-
File cacheDir = new File(mCacheDir);
19-
if (!cacheDir.exists()) {
20-
cacheDir.mkdir();
18+
if (!mCacheDir.exists()) {
19+
mCacheDir.mkdir();
2120
}
2221
}
2322

2423
public FileHandler newFileHandler(String id) {
2524
return new FileHandler(mCacheDir, id);
2625
}
2726

28-
// not really used since ContentResolver uses _data field.
29-
public File getFile(String ID) {
30-
String cachePath = getFileName(ID);
31-
32-
File cacheFile = new File(cachePath);
33-
if (cacheFile.exists()) {
34-
return cacheFile;
35-
}
36-
return null;
37-
}
38-
3927
public void delete(String ID) {
40-
String cachePath = mCacheDir + "/" + ID;
41-
42-
File cacheFile = new File(cachePath);
28+
File cacheFile = new File(mCacheDir, ID);
4329
if (cacheFile.exists()) {
4430
cacheFile.delete();
4531
}
4632
}
4733

4834
public String getFileName(String ID) {
49-
return mCacheDir + "/" + ID;
35+
return new File(mCacheDir, ID).toString();
5036
}
5137
}

FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ public abstract class RESTfulContentProvider extends ContentProvider {
2424
private Map<String, UriRequestTask> mRequestsInProgress =
2525
new HashMap<String, UriRequestTask>();
2626

27-
public RESTfulContentProvider(FileHandlerFactory fileHandlerFactory) {
27+
public RESTfulContentProvider() {
28+
}
29+
30+
public void setFileHandlerFactory(FileHandlerFactory fileHandlerFactory) {
2831
mFileHandlerFactory = fileHandlerFactory;
2932
}
3033

31-
public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);
34+
public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);
3235

3336
private UriRequestTask getRequestTask(String queryText) {
3437
return mRequestsInProgress.get(queryText);
@@ -53,10 +56,10 @@ public void requestComplete(String mQueryText) {
5356
*
5457
* @param requestTag unique tag identifying this request.
5558
* @return The response handler created by a subclass used to parse the
56-
* request response.
59+
* request response.
5760
*/
5861
protected abstract ResponseHandler newResponseHandler(String requestTag);
59-
62+
6063
UriRequestTask newQueryTask(String requestTag, String url) {
6164
UriRequestTask requestTask;
6265

@@ -73,7 +76,6 @@ UriRequestTask newQueryTask(String requestTag, String url) {
7376
* Creates a new worker thread to carry out a RESTful network invocation.
7477
*
7578
* @param queryTag unique tag that identifies this request.
76-
*
7779
* @param queryUri the complete URI that should be access by this request.
7880
*/
7981
public void asyncQueryRequest(String queryTag, String queryUri) {

FinchFramework/src/com/finchframework/finch/rest/RawResponse.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,75 +29,101 @@ public RawResponse(Context c, int rawResource) {
2929
Log.d(Finch.LOG_TAG, "exception from raw input stream", e);
3030
}
3131
}
32+
3233
public StatusLine getStatusLine() {
3334
return null;
3435
}
36+
3537
public void setStatusLine(StatusLine statusLine) {
3638
}
39+
3740
public void setStatusLine(ProtocolVersion protocolVersion,
3841
int i) {
3942
}
43+
4044
public void setStatusLine(ProtocolVersion protocolVersion,
4145
int i, String s) {
4246
}
47+
4348
public void setStatusCode(int i)
44-
throws IllegalStateException
45-
{
49+
throws IllegalStateException {
4650
}
51+
4752
public void setReasonPhrase(String s)
4853
throws IllegalStateException {
4954
}
55+
5056
public HttpEntity getEntity() {
5157
return mDebugEntity;
5258
}
59+
5360
public void setEntity(HttpEntity httpEntity) {
5461
}
62+
5563
public Locale getLocale() {
5664
return null;
5765
}
66+
5867
public void setLocale(Locale locale) {
5968
}
69+
6070
public ProtocolVersion getProtocolVersion() {
6171
return null;
6272
}
73+
6374
public boolean containsHeader(String s) {
6475
return false;
6576
}
77+
6678
public Header[] getHeaders(String s) {
6779
return new Header[0];
6880
}
81+
6982
public Header getFirstHeader(String s) {
7083
return null;
7184
}
85+
7286
public Header getLastHeader(String s) {
7387
return null;
7488
}
89+
7590
public Header[] getAllHeaders() {
7691
return new Header[0];
7792
}
93+
7894
public void addHeader(Header header) {
7995
}
96+
8097
public void addHeader(String s, String s1) {
8198
}
99+
82100
public void setHeader(Header header) {
83101
}
102+
84103
public void setHeader(String s, String s1) {
85104
}
105+
86106
public void setHeaders(Header[] headers) {
87107
}
108+
88109
public void removeHeader(Header header) {
89110
}
111+
90112
public void removeHeaders(String s) {
91113
}
114+
92115
public HeaderIterator headerIterator() {
93116
return null;
94117
}
118+
95119
public HeaderIterator headerIterator(String s) {
96120
return null;
97121
}
122+
98123
public HttpParams getParams() {
99124
return null;
100125
}
126+
101127
public void setParams(HttpParams httpParams) {
102128
}
103129
};

FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,19 @@ public class UriRequestTask implements Runnable {
2424

2525
private RESTfulContentProvider mSiteProvider;
2626
private String mRequestTag;
27-
27+
2828
private int mRawResponse = -1;
2929
// private int mRawResponse = R.raw.map_src;
3030

3131
public UriRequestTask(HttpUriRequest request,
32-
ResponseHandler handler, Context appContext)
33-
{
32+
ResponseHandler handler, Context appContext) {
3433
this(null, null, request, handler, appContext);
3534
}
36-
35+
3736
public UriRequestTask(String requestTag,
3837
RESTfulContentProvider siteProvider,
3938
HttpUriRequest request,
40-
ResponseHandler handler, Context appContext)
41-
{
39+
ResponseHandler handler, Context appContext) {
4240
mRequestTag = requestTag;
4341
mSiteProvider = siteProvider;
4442
mRequest = request;

0 commit comments

Comments
 (0)