Skip to content

Commit 1c416e4

Browse files
committed
2do msg
1 parent 3281f32 commit 1c416e4

File tree

10 files changed

+489
-27
lines changed

10 files changed

+489
-27
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@
149149
</activity>
150150
</application>
151151

152+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
152153
<uses-permission android:name="android.permission.INTERNET" />
153154
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
155+
<uses-permission android:name="android.permission.CAMERA" />
156+
<uses-feature android:name="android.hardware.camera"
157+
android:required="true"/>
158+
<uses-feature android:name="android.hardware.camera.autofocus" />
159+
160+
154161

155162
</manifest>

app/src/main/java/maas/com/mx/maas/db/sql.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ public void insertaBuzon(ArrayList<RegistroBuzon> buzonDesdeWs, String buzon)thr
218218
}*/
219219

220220
for(RegistroBuzon item: buzonDesdeWs){
221+
222+
item.COMENTARIO=item.COMENTARIO==null?"":item.COMENTARIO;
223+
if(item.ID_SOLICITUD==null)continue;
221224
db.execSQL("INSERT INTO BUZON_"+buzon+"(ID_SOLICITUD,COMENTARIO,ESTATUS,SOLICITUD_XML,FECHA_MODIFICACION) VALUES("
222225
+item.ID_SOLICITUD.toString() +",'"+item.COMENTARIO.toString()+"',"+item.ESTATUS.toString()+",'"+item.SOLICITUD_XML.toString() +"','"+item.FECHA_MODIFICACION.toString()+"')");
223226
}

app/src/main/java/maas/com/mx/maas/entidades/DataGridLayout.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ TableRow componentBTableRow(){
249249
for(int x=0; x<(headerFieldCount-2); x++){
250250
TextView textView = this.headerTextView(this.headers[x+2]);
251251
textView.setLayoutParams(params);
252-
252+
//ANCHOS
253253
switch(x+2){
254-
case 2:textView.setWidth(230);break;
255-
case 3:textView.setWidth(180);break;
256-
case 4:textView.setWidth(330);break;
254+
case 2:textView.setWidth(350);break;//NOMBRE
255+
case 3:textView.setWidth(180);break;//FECHA
256+
case 4:textView.setWidth(430);break;//COMENTARIO
257257
}
258258

259259
textView.setTextColor(Color.WHITE);
@@ -319,6 +319,8 @@ TableRow tableRowForTableC(Header sampleObject){
319319
Color.parseColor("#BDBDBD"), Color.parseColor("#A4A4A4"), Color.WHITE });textView.setText("");textView.setWidth(25);break;
320320
case Blue: gd =new GradientDrawable(GradientDrawable.Orientation.TL_BR, new int[] {
321321
Color.parseColor("#0174DF"), Color.parseColor("#2E9AFE"), Color.WHITE });textView.setText("");textView.setWidth(25);break;
322+
case Green: gd =new GradientDrawable(GradientDrawable.Orientation.TL_BR, new int[] {
323+
Color.parseColor("#7CFC00"), Color.parseColor("#458B00"), Color.WHITE });textView.setText("");textView.setWidth(25);break;
322324
}
323325
//textView.setPadding(2,20,2,20);//top/right/bottom/left
324326

@@ -367,7 +369,7 @@ public void onClick(View v) {
367369
}
368370

369371
private enum Colores {
370-
Red, Blue, Yellow, Gray;
372+
Red, Blue, Yellow, Gray, Green;
371373
}
372374

373375

@@ -437,11 +439,12 @@ void getTableRowHeaderCellWidth(){
437439
int tableAChildCount = ((TableRow)this.tableA.getChildAt(0)).getChildCount();
438440
int tableBChildCount = ((TableRow)this.tableB.getChildAt(0)).getChildCount();
439441

440-
this.headerCellsWidth[0]=100;
441-
this.headerCellsWidth[1]=120;
442-
this.headerCellsWidth[2]=230;
443-
this.headerCellsWidth[3]=180;
444-
this.headerCellsWidth[4]=330;
442+
//ANCHOS
443+
this.headerCellsWidth[0]=100;//COLOR
444+
this.headerCellsWidth[1]=120;//ID SOL
445+
this.headerCellsWidth[2]=350;//NOMBRE
446+
this.headerCellsWidth[3]=180;//FECHA
447+
this.headerCellsWidth[4]=430;//COMENTARIO
445448
/*for(int x=0; x<(tableAChildCount+tableBChildCount); x++){
446449
447450
if(x<2){

app/src/main/java/maas/com/mx/maas/entidades/RegistroBuzon.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
* Created by damserver on 17/04/2015.
55
*/
66
public class RegistroBuzon {
7+
8+
public RegistroBuzon(){
9+
this.COORDINADOR="";
10+
this.GERENTE="";
11+
this.PROMOTOR="";
12+
this.ID_SOLICITUD="";
13+
this.ESTATUS="";
14+
this.FECHA_ALTA="";
15+
this.SOLICITUD_XML="";
16+
this.VALIDADOR="";
17+
this.FECHA_MODIFICACION="";
18+
this.VALIDADO_POR="";
19+
this.NOMBRE_CLIENTE="";
20+
this.COMENTARIO="";
21+
22+
this.doc=new Documento();
23+
24+
}
25+
726
public String COORDINADOR;
827
public String GERENTE;
928
public String PROMOTOR;

app/src/main/java/maas/com/mx/maas/frmDocumentos.java

Lines changed: 221 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,32 @@
55
import android.content.Context;
66
import android.content.Intent;
77
import android.content.SharedPreferences;
8+
import android.graphics.Bitmap;
9+
import android.graphics.BitmapFactory;
10+
import android.net.Uri;
811
import android.os.Bundle;
12+
import android.os.Environment;
13+
import android.provider.MediaStore;
914
import android.view.Menu;
1015
import android.view.MenuItem;
1116
import android.view.View;
1217
import android.view.WindowManager;
1318
import android.view.inputmethod.InputMethodManager;
1419
import android.widget.Button;
1520
import android.widget.ImageButton;
21+
import android.widget.ImageView;
1622
import android.widget.TableRow;
1723
import android.widget.Toast;
1824

1925
import com.google.gson.Gson;
2026

27+
import java.io.File;
28+
import java.io.FileInputStream;
29+
import java.io.FileNotFoundException;
30+
import java.io.IOException;
31+
import java.text.SimpleDateFormat;
32+
import java.util.Date;
33+
2134
import maas.com.mx.maas.R;
2235
import maas.com.mx.maas.entidades.Solicitud;
2336
import maas.com.mx.maas.entidades.SolicitudType;
@@ -31,6 +44,14 @@ public class frmDocumentos extends Activity {
3144
String objSolicitud="";
3245
int countExtras=0;
3346

47+
private static final int CAMERA_REQUEST = 1888;
48+
private static File path;
49+
static String str_Camera_Photo_ImagePath = "";
50+
private static int Take_Photo = 2;
51+
static String imageName="";
52+
Bitmap myBitmap;
53+
String mCurrentPhotoPath;
54+
3455
@Override
3556
protected void onCreate(Bundle savedInstanceState) {
3657
super.onCreate(savedInstanceState);
@@ -208,10 +229,209 @@ private SolicitudType getLastVersion(SolicitudType objSol) {
208229

209230
public void clickPhoto(View view) {
210231

211-
Intent myIntent = new Intent(frmDocumentos.this, frmPhoto.class);
232+
/* Intent myIntent = new Intent(frmDocumentos.this, frmPhoto.class);
212233
myIntent.putExtra("idSolicitud",this.idSolicitud);
213234
myIntent.putExtra("objSolicitud",this.objSolicitud);
214235
236+
startActivity(myIntent);*/
237+
//String pathTaget=getApplicationContext().getFilesDir().getPath().toString();
238+
//imageName="TEC_" + System.currentTimeMillis() + ".jpg";
239+
240+
//Uri newImageUri = null;
241+
//path = new File(pathTaget);
242+
243+
/*if (!path.exists())
244+
path.mkdirs();
245+
246+
boolean setWritable = false;
247+
setWritable = path.setWritable(true, false);
248+
path.setReadable(true,false);
249+
path.setExecutable(true,false);
250+
251+
File file = new File(path, imageName);//ok
252+
newImageUri = Uri.fromFile(file);
253+
254+
file.setWritable(true, false);
255+
file.setReadable(true,false);
256+
file.setExecutable(true,false);
257+
258+
str_Camera_Photo_ImagePath = pathTaget + "/" + imageName;*/
259+
260+
File photoFile = null;
261+
try {
262+
photoFile = createImageFile();
263+
} catch (IOException ex) {
264+
// Error occurred while creating the File
265+
}
266+
267+
Intent takePictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
268+
//takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, newImageUri);
269+
if (photoFile != null) {
270+
imageName=photoFile.getName();
271+
mCurrentPhotoPath=photoFile.getAbsolutePath();
272+
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photoFile));
273+
startActivityForResult(takePictureIntent, Take_Photo);
274+
}
275+
276+
/* if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
277+
startActivityForResult(takePictureIntent, Take_Photo);
278+
}*/
279+
280+
}
281+
282+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
283+
284+
// super.onActivityResult(requestCode, resultCode, data);
285+
286+
if (requestCode == Take_Photo && resultCode == RESULT_OK) {
287+
288+
Button btnIdentificacion1 = (Button) findViewById(R.id.btnIdentificacion1);
289+
btnIdentificacion1.setText(imageName);
290+
btnIdentificacion1.setTag(mCurrentPhotoPath);
291+
292+
//Bundle extras = data.getExtras();
293+
//Bitmap imageBitmap = (Bitmap) extras.get("data");
294+
295+
//File myfile=new File( getApplicationContext().getFilesDir().getPath().toString(),imageName);
296+
//Bitmap myBitmap = BitmapFactory.decodeFile(myfile.getAbsolutePath());//imgFile.getAbsolutePath());
297+
//Bitmap faceView = ( new_decode(new File( getApplicationContext().getFilesDir().getPath().toString(),imageName)));
298+
//String h="";
299+
//btnIdentificacion1.setTag(imageName);
300+
/* String filePath = null;
301+
302+
filePath = str_Camera_Photo_ImagePath;
303+
304+
File imgFile = new File(str_Camera_Photo_ImagePath);
305+
306+
if(imgFile.exists()){
307+
308+
myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
309+
//ImageView imageView1 = (ImageView) findViewById(R.id.imageViewTest);
310+
// imageView1.setImageBitmap(myBitmap);
311+
312+
}*/
313+
314+
/*
315+
if (filePath != null) {
316+
Bitmap faceView = ( new_decode(new File(
317+
filePath))); // ========================> good lines
318+
imageView.setImageBitmap(faceView);
319+
320+
} else {
321+
bitmap = null;
322+
}*/
323+
}
324+
}
325+
326+
private File createImageFile() throws IOException {
327+
// Create an image file name
328+
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
329+
String imageFileName = "TEC_" + timeStamp;
330+
File storageDir = Environment.getExternalStoragePublicDirectory(
331+
Environment.DIRECTORY_PICTURES);
332+
File image = File.createTempFile(
333+
imageFileName, /* prefix */
334+
".jpg", /* suffix */
335+
storageDir /* directory */
336+
);
337+
338+
// Save a file: path for use with ACTION_VIEW intents
339+
mCurrentPhotoPath = "file:" + image.getAbsolutePath();
340+
return image;
341+
}
342+
343+
344+
public void clickBtnIdentificacion1(View view) {
345+
346+
Button btnIdentificacion1 = (Button) findViewById(R.id.btnIdentificacion1);
347+
String strImage=btnIdentificacion1.getText().toString();
348+
String strPath=btnIdentificacion1.getTag().toString();
349+
350+
Intent myIntent = new Intent(frmDocumentos.this, frmPhoto.class);
351+
myIntent.putExtra("imageName",strImage);
352+
myIntent.putExtra("strPath",strPath);
353+
215354
startActivity(myIntent);
355+
216356
}
357+
358+
public static Bitmap new_decode(File f) {
359+
360+
// decode image size
361+
362+
BitmapFactory.Options o = new BitmapFactory.Options();
363+
o.inJustDecodeBounds = true;
364+
o.inDither = false; // Disable Dithering mode
365+
366+
o.inPurgeable = true; // Tell to gc that whether it needs free memory,
367+
// the Bitmap can be cleared
368+
369+
o.inInputShareable = true; // Which kind of reference will be used to
370+
// recover the Bitmap data after being
371+
// clear, when it will be used in the future
372+
try {
373+
374+
375+
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
376+
} catch (FileNotFoundException e1) {
377+
// TODO Auto-generated catch block
378+
e1.printStackTrace();
379+
}
380+
381+
// Find the correct scale value. It should be the power of 2.
382+
final int REQUIRED_SIZE = 300;
383+
int width_tmp = o.outWidth, height_tmp = o.outHeight;
384+
int scale = 1;
385+
while (true) {
386+
if (width_tmp / 1.5 < REQUIRED_SIZE && height_tmp / 1.5 < REQUIRED_SIZE)
387+
break;
388+
width_tmp /= 1.5;
389+
height_tmp /= 1.5;
390+
scale *= 1.5;
391+
}
392+
393+
// decode with inSampleSize
394+
BitmapFactory.Options o2 = new BitmapFactory.Options();
395+
// o2.inSampleSize=scale;
396+
o.inDither = false; // Disable Dithering mode
397+
398+
o.inPurgeable = true; // Tell to gc that whether it needs free memory,
399+
// the Bitmap can be cleared
400+
401+
o.inInputShareable = true; // Which kind of reference will be used to
402+
// recover the Bitmap data after being
403+
// clear, when it will be used in the future
404+
// return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
405+
try {
406+
407+
// return BitmapFactory.decodeStream(new FileInputStream(f), null,
408+
// null);
409+
Bitmap bitmap= BitmapFactory.decodeStream(new FileInputStream(f), null, null);
410+
System.out.println(" IW " + width_tmp);
411+
System.out.println("IHH " + height_tmp);
412+
int iW = width_tmp;
413+
int iH = height_tmp;
414+
415+
return Bitmap.createScaledBitmap(bitmap, iW, iH, true);
416+
417+
} catch (OutOfMemoryError e) {
418+
// TODO: handle exception
419+
e.printStackTrace();
420+
// clearCache();
421+
422+
// System.out.println("bitmap creating success");
423+
System.gc();
424+
return null;
425+
// System.runFinalization();
426+
// Runtime.getRuntime().gc();
427+
// System.gc();
428+
// decodeFile(f);
429+
} catch (FileNotFoundException e) {
430+
// TODO Auto-generated catch block
431+
e.printStackTrace();
432+
return null;
433+
}
434+
435+
}
436+
217437
}

0 commit comments

Comments
 (0)