Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nRike/GDG-Hackup-AndroidTitlan
Browse files Browse the repository at this point in the history
  • Loading branch information
vic committed Dec 13, 2012
2 parents 413dc74 + 86822a8 commit b80b9e8
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
6 changes: 6 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -4,6 +4,12 @@
android:versionCode="1"
android:versionName="1.0" >

<!-- Permisos para utilizar la camara -->
<uses-permission android:name="android.permission.CAMERA" />

<uses-feature android:name="android.hardware.camara" />
<uses-feature android:name="android.hardware.autofocus" />

<uses-sdk
android:minSdkVersion="4"
android:targetSdkVersion="17" />
Expand Down
2 changes: 1 addition & 1 deletion project.properties
Expand Up @@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-17
target=android-14
16 changes: 13 additions & 3 deletions res/layout/activity_home.xml
Expand Up @@ -4,11 +4,21 @@
android:layout_height="match_parent"
tools:context=".HomeActivity" >

<TextView
<Button
android:id="@+id/tomar_foto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
android:text="Foto" />

<ImageView
android:id="@+id/imagen_capturada"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tomar_foto"
android:layout_centerHorizontal="true"
android:layout_marginTop="130dp"
android:src="@drawable/ic_launcher" />

</RelativeLayout>
2 changes: 2 additions & 0 deletions server/.gitignore
@@ -1 +1,3 @@
node_modules/
uploads/
log.txt
5 changes: 3 additions & 2 deletions server/app.js
@@ -1,3 +1,4 @@
var fs = require("fs");
var express = require("express");
var app = express();

Expand All @@ -7,7 +8,7 @@ app.set('view engine', 'jade')

var saveReport = function(report){
// Saves the report
fs.appendFile('log.txt', report, function(err){
fs.appendFile('log.txt', JSON.stringify(report), function(err){
console.log(err);
});
return 0;
Expand All @@ -18,7 +19,7 @@ app.get('/', function(req, res){
})

// POST Datos
app.get('/newreport', function(req, res){
app.post('/newreport', function(req, res){
try {
var report = {
image: req.files.image,
Expand Down
7 changes: 5 additions & 2 deletions server/views/index.jade
@@ -1,6 +1,9 @@
html
body
h1 Hello
form(method='post',action='/newreport')
input(type='file')
form(method='post', action='/newreport', enctype="multipart/form-data")
input(name='image', type='file')
input(name='location', type='hidden')
input(name='time', type='hidden')
input(name='type', type='hidden')
input(type='submit') Subir
68 changes: 66 additions & 2 deletions src/mx/androidtitlan/GDGHackup/HomeActivity.java
@@ -1,22 +1,86 @@
package mx.androidtitlan.GDGHackup;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class HomeActivity extends Activity {

private Button button;
private final int flag = 1;
private ImageView imageView;
private Bitmap imagenCapturada;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

this.button = (Button) findViewById(R.id.tomar_foto);
imageView = (ImageView) findViewById(R.id.imagen_capturada);

button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View arg0) {
tomarFoto(flag);
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_home, menu);
return true;
}

private void tomarFoto(int flag) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, flag);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

AlertDialog dialog;

if (resultCode == RESULT_CANCELED) {

dialog = crearDialogo("FOTO", "Fallo al tomar la foto", "OK");

} else {
imagenCapturada = (Bitmap) data.getExtras().get("data");
dialog = crearDialogo("FOTO", "Éxito al tomar la foto", "OK");

}
dialog.show();
}

private AlertDialog crearDialogo(String title, String msg, String buttonText) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
AlertDialog msgDialog = dialogBuilder.create();
msgDialog.setTitle(title);
msgDialog.setMessage(msg);
msgDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int idx) {
dialog.dismiss();
imageView.setImageBitmap(imagenCapturada);

}
});

return msgDialog;
}

}

0 comments on commit b80b9e8

Please sign in to comment.