mirror of https://github.com/perkeep/perkeep.git
android: add Version menu option
Change-Id: I64aeacf18421edd51517c92ec8782b4bb62ca1b1
This commit is contained in:
parent
a8e3cfde54
commit
8128b51bb7
|
@ -1 +1,2 @@
|
|||
camput.arm
|
||||
camput-version.txt
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<string name="resume">Resume</string>
|
||||
<string name="stop">Stop</string>
|
||||
<string name="stop_die">Force-kill all</string>
|
||||
<string name="version">Version</string>
|
||||
<string name="uploading">Uploading…</string>
|
||||
<string name="digesting">Digesting….</string>
|
||||
<string name="settings_auto">Auto-Upload</string>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue