Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

DNS and button fix

  • Loading branch information...
commit 4f77a325fabde1a8048d7598cf91e44cc63417de 1 parent 17e558b
@apage43 apage43 authored
View
3  AndroidManifest.xml
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.couchdb.android"
- android:versionCode="1"
- android:versionName="1.0">
+ android:versionName="1.0" android:versionCode="3">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CouchDB"
android:label="@string/app_name">
View
2  res/layout/install.xml
@@ -2,6 +2,6 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:focusableInTouchMode="true" android:layout_gravity="center_vertical|center_horizontal" android:orientation="vertical" android:layout_width="wrap_content">
-<TextView android:layout_height="wrap_content" android:text="CouchDB Not Installed" android:layout_width="wrap_content"></TextView><Button android:layout_height="wrap_content" android:gravity="center" android:id="@+id/InstallButton" android:text="Install CouchDB" android:layout_width="fill_parent"></Button>
+<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="CouchDB Binaries Update Required"></TextView><Button android:layout_height="wrap_content" android:gravity="center" android:id="@+id/InstallButton" android:layout_width="fill_parent" android:text="Update CouchDB"></Button>
</LinearLayout>
View
38 src/org/couchdb/android/CouchDB.java
@@ -1,6 +1,11 @@
package org.couchdb.android;
+import java.util.List;
+
import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityManager.RunningServiceInfo;
+import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -9,7 +14,36 @@
public class CouchDB extends Activity {
public final static String TAG = "CouchDB";
+ Button startButton;
+ Button stopButton;
+
+ @Override
+ public void onResume()
+ {
+ super.onResume();
+ if(startButton == null) return;
+ ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
+
+ List<ActivityManager.RunningServiceInfo> serviceList = activityManager.getRunningServices(Integer.MAX_VALUE);
+
+ if (!(serviceList.size() > 0)) {
+ return;
+ }
+
+ for (int i = 0; i < serviceList.size(); i++) {
+ RunningServiceInfo serviceInfo = serviceList.get(i);
+ ComponentName serviceName = serviceInfo.service;
+ if (serviceName.getClassName().equals("org.couchdb.android.CouchService")) {
+ startButton.setEnabled(false);
+ stopButton.setEnabled(true);
+ return;
+ }
+ }
+ startButton.setEnabled(true);
+ stopButton.setEnabled(false);
+ }
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -18,8 +52,8 @@ public void onCreate(Bundle savedInstanceState) {
boolean installed = CouchInstaller.checkInstalled();
if(!installed)
startActivity(new Intent(this, CouchInstallActivity.class));
- final Button startButton = (Button) findViewById(R.id.StartButton);
- final Button stopButton = (Button) findViewById(R.id.StopButton);
+ startButton = (Button) findViewById(R.id.StartButton);
+ stopButton = (Button) findViewById(R.id.StopButton);
startButton.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
View
7 src/org/couchdb/android/CouchInstaller.java
@@ -96,6 +96,7 @@ public static boolean checkInstalled() {
// TODO: Different CPU arch support.
packages.add("couch-erlang-dev"); // CouchDB, Erlang, CouchJS
+ packages.add("dns-fix"); //Add inet config to fallback on erlang resolver
if (android.os.Build.VERSION.SDK_INT == 7)
packages.add("couch-icu-driver-eclair");
else if (android.os.Build.VERSION.SDK_INT == 8)
@@ -109,8 +110,10 @@ else if (android.os.Build.VERSION.SDK_INT == 8)
}
public static void doInstall(Handler handler) throws IOException {
- for (String pkg : packageSet())
- installPackage(pkg, handler);
+ for(String pkg : packageSet()) {
+ if(!(new File(dataPath + "/" + pkg + ".installedfiles")).exists())
+ installPackage(pkg, handler);
+ }
Message done = Message.obtain();
done.arg2 = 1;
View
2  src/org/couchdb/android/CouchService.java
@@ -94,7 +94,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
public void onDestroy() {
try {
Runtime.getRuntime().exec("/system/bin/kill " + couch.pid);
- Runtime.getRuntime().exec("/system/bin/killall beam"); //This is safe since couch can only kill couch.
+ Runtime.getRuntime().exec("/system/bin/killall -9 beam"); //This is safe since couch can only kill couch.
} catch (IOException e) {
//Failed to kill couch?
}
Please sign in to comment.
Something went wrong with that request. Please try again.