diff --git a/clients/android/assets/.gitignore b/clients/android/assets/.gitignore
index 83c65f6c4..bf9f3bec4 100644
--- a/clients/android/assets/.gitignore
+++ b/clients/android/assets/.gitignore
@@ -1 +1,2 @@
camput.arm
+camput-version.txt
diff --git a/clients/android/assets/Makefile b/clients/android/assets/Makefile
index c3ef5352b..609b23feb 100644
--- a/clients/android/assets/Makefile
+++ b/clients/android/assets/Makefile
@@ -1,5 +1,6 @@
all:
GOROOT=$(HOME)/armgo GOOS=linux GOARCH=arm CGO_ENABLED=0 $(HOME)/armgo/bin/go build -o camput.arm --ldflags="-X camlistore.org/pkg/buildinfo.GitInfo "`../../../misc/gitversion` camlistore.org/cmd/camput
+ ../../../misc/gitversion > camput-version.txt
/bin/echo -n "package org.camlistore; public final class ChildProcessConfig { // " > ../gen/org/camlistore/ChildProcessConfig.java
openssl sha1 camput.arm >> ../gen/org/camlistore/ChildProcessConfig.java
/bin/echo "}" >> ../gen/org/camlistore/ChildProcessConfig.java
diff --git a/clients/android/res/values/strings.xml b/clients/android/res/values/strings.xml
index fced4868c..50e28cfb1 100644
--- a/clients/android/res/values/strings.xml
+++ b/clients/android/res/values/strings.xml
@@ -13,6 +13,7 @@
Resume
Stop
Force-kill all
+ Version
Uploading…
Digesting….
Auto-Upload
diff --git a/clients/android/src/org/camlistore/CamliActivity.java b/clients/android/src/org/camlistore/CamliActivity.java
index 2db020635..d310c1eb0 100644
--- a/clients/android/src/org/camlistore/CamliActivity.java
+++ b/clients/android/src/org/camlistore/CamliActivity.java
@@ -34,6 +34,7 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
+import android.widget.Toast;
public class CamliActivity extends Activity {
private static final String TAG = "CamliActivity";
@@ -41,6 +42,7 @@ public class CamliActivity extends Activity {
private static final int MENU_STOP = 2;
private static final int MENU_STOP_DIE = 3;
private static final int MENU_UPLOAD_ALL = 4;
+ private static final int MENU_VERSION = 5;
private IUploadService mServiceStub = null;
private IStatusCallback mCallback = null;
@@ -218,6 +220,7 @@ public class CamliActivity extends Activity {
MenuItem settings = menu.add(Menu.NONE, MENU_SETTINGS, 0, R.string.settings);
settings.setIcon(android.R.drawable.ic_menu_preferences);
+ menu.add(Menu.NONE, MENU_VERSION, 0, R.string.version);
return true;
}
@@ -238,6 +241,9 @@ public class CamliActivity extends Activity {
case MENU_SETTINGS:
SettingsActivity.show(this);
break;
+ case MENU_VERSION:
+ Toast.makeText(this, "camput version: " + ((UploadApplication) getApplication()).getCamputVersion(), Toast.LENGTH_LONG).show();
+ break;
case MENU_UPLOAD_ALL:
Intent uploadAll = new Intent(UploadService.INTENT_UPLOAD_ALL);
uploadAll.setClass(this, UploadService.class);
diff --git a/clients/android/src/org/camlistore/UploadApplication.java b/clients/android/src/org/camlistore/UploadApplication.java
index fb763b884..14733ff63 100644
--- a/clients/android/src/org/camlistore/UploadApplication.java
+++ b/clients/android/src/org/camlistore/UploadApplication.java
@@ -16,17 +16,18 @@ limitations under the License.
package org.camlistore;
-import android.app.Application;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.util.Config;
-import android.util.Log;
-
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.lang.reflect.Method;
+import android.app.Application;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.util.Log;
+
public class UploadApplication extends Application {
private final static String TAG = "UploadApplication";
private final static boolean STRICT_MODE = true;
@@ -55,10 +56,10 @@ public class UploadApplication extends Application {
FileOutputStream fos = getBaseContext().openFileOutput("camput.bin.writing", MODE_PRIVATE);
byte[] buf = new byte[8192];
int offset;
- while ((offset = is.read(buf))>0) {
+ while ((offset = is.read(buf)) > 0) {
fos.write(buf, 0, offset);
}
- is.close();
+ is.close();
fos.flush();
fos.close();
@@ -75,6 +76,7 @@ public class UploadApplication extends Application {
}
}
+ @Override
public void onCreate() {
super.onCreate();
@@ -105,4 +107,22 @@ public class UploadApplication extends Application {
} catch (java.lang.reflect.InvocationTargetException e) {
}
}
+
+ public String getCamputVersion() {
+ InputStream is = null;
+ try {
+ is = getAssets().open("camput-version.txt");
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ return br.readLine();
+ } catch (IOException e) {
+ return e.toString();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
}
diff --git a/clients/android/src/org/camlistore/UploadService.java b/clients/android/src/org/camlistore/UploadService.java
index 2b9538eee..cb3ab6e5f 100644
--- a/clients/android/src/org/camlistore/UploadService.java
+++ b/clients/android/src/org/camlistore/UploadService.java
@@ -463,8 +463,14 @@ public class UploadService extends Service {
}
public String pathOfURI(Uri uri) {
+ if (uri == null) {
+ return null;
+ }
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(uri, proj, null, null, null);
+ if (cursor == null) {
+ return null;
+ }
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(proj[0]);