Started building the third gen interaction.

parent 25a16c30
......@@ -26,14 +26,6 @@ import java.io.IOException;
*/
public class EarCaptureActivity extends Activity {
Button getImage;
Button returnToCommCare;
File location;
public static final int KEY_REQUEST_IMAGE = 1;
public static final int KEY_SIFT_ACTIVITY_LOADER = 2;
/*
* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
......@@ -42,132 +34,7 @@ public class EarCaptureActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_callout);
/*
returnToCommCare = (Button)this.findViewById(R.id.button_commcare);
returnToCommCare.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent("org.commcare.dalvik.action.CommCareSession");
String sssd = "";
sssd +=
"COMMAND_ID" + " " + "root" + " "
+
"CASE_ID" + " " + "case_id" + " " + "99de08b8-7235-41ba-9dbe-d1e5d70575cf" + " " +
"COMMAND_ID" + " " + "m1-f1";
i.putExtra("ccodk_session_request", sssd);
EarCaptureActivity.this.startActivity(i);
}
});
// Load data from Commcare
Cursor c = this.managedQuery(Uri.parse("content://org.commcare.dalvik.case/casedb/case"), null, null, null, null);
for (int i=0;i<c.getColumnCount();++i) {
System.out.print(c.getColumnName(i) + "|");
}
System.out.println();
while (c.moveToNext()) {
for (int i=0;i<c.getColumnCount();++i) {
System.out.print(c.getString(i) + "|");
}
System.out.println();
}
*/
getImage = (Button)this.findViewById(R.id.take_picture);
getImage.setOnClickListener(new OnClickListener() {
private Toast loginInCommCareToast = null;
public void onClick(View v) {
if (!EarDataLoaderCommcare.checkConnection(EarCaptureActivity.this)) {
if (loginInCommCareToast == null || loginInCommCareToast.getView().getWindowVisibility() != View.VISIBLE) {
loginInCommCareToast = Toast.makeText(EarCaptureActivity.this,
"Please login in CommCare application to proceed.",
Toast.LENGTH_LONG);
loginInCommCareToast.show();
}
return;
}
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
try {
location = ImageUtils.createTempImageFile();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return;
}
// if this gets modified, the onActivityResult in
// FormEntyActivity will also need to be updated.
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(location));
try {
startActivityForResult(i, KEY_REQUEST_IMAGE);
} catch (ActivityNotFoundException e) {
Toast.makeText(EarCaptureActivity.this, "No Camera", Toast.LENGTH_SHORT).show();
}
}
});
if(this.getLastNonConfigurationInstance() != null) {
location = ((EarCaptureActivity)this.getLastNonConfigurationInstance()).location;
}
if(savedInstanceState != null) {
location = new File(savedInstanceState.getString("location"));
}
}
/* (non-Javadoc)
* @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == KEY_REQUEST_IMAGE) {
//Go grab the image and set it's location
if(location == null || !location.exists()) {
location = null;
} else {
String path = location.getAbsolutePath();
EarIdentifier identifier = new EarIdentifier(null);
Intent intent = new Intent("com.auriclon.activity_sift");
intent.putExtra("image_path", path);
startActivityForResult(intent, KEY_SIFT_ACTIVITY_LOADER);
}
} else if (requestCode == KEY_SIFT_ACTIVITY_LOADER) {
startActivity(data);
}
}
/* (non-Javadoc)
* @see android.app.Activity#onResume()
*/
@Override
protected void onResume() {
super.onResume();
}
/* (non-Javadoc)
* @see android.app.Activity#onSaveInstanceState(android.os.Bundle)
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (location != null) {
outState.putString("location", location.toString());
}
}
/* (non-Javadoc)
* @see android.app.Activity#onRetainNonConfigurationInstance()
*/
@Override
public Object onRetainNonConfigurationInstance() {
return this;
setContentView(R.layout.open_commcare_layout);
}
}
......@@ -49,25 +49,18 @@ public class SelectFollowupActivity extends Activity {
topNListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent("org.commcare.dalvik.action.CommCareSession");
String sssd = "";
sssd +=
"COMMAND_ID" + " " + "m1" + " "
+
"CASE_ID" + " " + "case_id" + " " + earIdList.getTop().get(position).person.getCaseId() + " " /* + // "99de08b8-7235-41ba-9dbe-d1e5d70575cf" + " " +
"COMMAND_ID" + " " + "m1-f0" */;
intent.putExtra("ccodk_session_request", sssd);
SelectFollowupActivity.this.startActivityForResult(intent, COMMCARE_FOLLOW_UP);
Intent intent = new Intent();
intent.putExtra("case_id", earIdList.getTop().get(position).person.getCaseId());
SelectFollowupActivity.this.setResult(Activity.RESULT_OK, intent);
finish();
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent("org.commcare.dalvik.action.CommCareSession");
String sssd = "COMMAND_ID" + " " + "root" + " " + "COMMAND_ID" + " " + "m0-f0";
i.putExtra("ccodk_session_request", sssd);
SelectFollowupActivity.this.startActivityForResult(i, COMMCARE_REGISTER);
SelectFollowupActivity.this.setResult(Activity.RESULT_OK, new Intent());
finish();
}
});
}
......
package com.aluxoft.earrecognition.intents;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
import com.aluxoft.earrecognition.EarIdentifier;
import com.aluxoft.earrecognition.activities.SelectFollowupActivity;
import com.aluxoft.earrecognition.utils.ImageUtils;
import com.crashlytics.android.Crashlytics;
import java.io.File;
import java.io.IOException;
import io.fabric.sdk.android.Fabric;
/**
* Created by dkor on 11/13/15.
*/
public class IntentSearchFeatures extends Activity{
private File location;
public static final int KEY_REQUEST_IMAGE = 1;
public static final int KEY_SIFT_ACTIVITY_LOADER = 2;
public static final int KEY_TOP_X = 3;
@Override
protected void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
Fabric.with(this, new Crashlytics());
this.takePhoto();
// Mostrar la camara
/*
Intent returningIntent = new Intent(getIntent());
returningIntent.putExtra(
"ear_search_result",
"Juan");
this.setResult(Activity.RESULT_OK, returningIntent);
finish();
*/
}
public boolean takePhoto() {
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
try {
location = ImageUtils.createTempImageFile();
} catch (IOException e1) {
e1.printStackTrace();
return false;
}
// if this gets modified, the onActivityResult in
// FormEntyActivity will also need to be updated.
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(location));
try {
startActivityForResult(i, KEY_REQUEST_IMAGE);
} catch (ActivityNotFoundException e) {
return false;
}
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == KEY_REQUEST_IMAGE) {
//Go grab the image and set it's location
if(location == null || !location.exists()) {
location = null;
} else {
String path = location.getAbsolutePath();
EarIdentifier identifier = new EarIdentifier(null);
Intent intent = new Intent("com.auriclon.activity_sift");
intent.putExtra("image_path", path);
startActivityForResult(intent, KEY_SIFT_ACTIVITY_LOADER);
}
} else if (requestCode == KEY_SIFT_ACTIVITY_LOADER) {
startActivityForResult(data, KEY_TOP_X);
} else if (requestCode == KEY_TOP_X) {
String case_id = data.getStringExtra("case_id");
if (case_id == null) {
case_id = "";
}
Intent returningIntent = new Intent(getIntent());
returningIntent.putExtra(
"ear_search_result",
case_id);
this.setResult(Activity.RESULT_OK, returningIntent);
finish();
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (location != null) {
outState.putString("location", location.toString());
}
}
}
......@@ -52,6 +52,8 @@ public class EarDataLoaderCommcare extends EarDataLoader {
gender = caseCursor.getString(caseCursor.getColumnIndex("value"));
} else */if (datumId.equals("features")) {
features = caseCursor.getString(caseCursor.getColumnIndex("value"));
} else if (datumId.equals("case_id_internal")) { // ToDo: Remplazarlo con una mejor forma
caseId = caseCursor.getString(caseCursor.getColumnIndex("value"));
}
}
if (/*gender == null || */features == null) {
......
......@@ -10,79 +10,6 @@
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:id="@+id/MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capture First ear"
android:id="@+id/button"
android:layout_marginTop="47dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capture Second ear"
android:id="@+id/button2"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/imageView"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Capture ear to identify"
android:id="@+id/toidentify"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/imageView2"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_below="@+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/button"
android:layout_alignEnd="@+id/button"
android:maxHeight="150dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:layout_below="@+id/button2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2"
android:maxHeight="150dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
android:layout_below="@+id/toidentify"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2"
android:maxHeight="150dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Identify"
android:id="@+id/button3"
android:layout_below="@+id/imageView3"
android:layout_alignParentLeft="true" />
</RelativeLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="266dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Open Commcare to start"
android:id="@+id/textView2" />
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment