diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9e0ab6c --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..29d7cb5 --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + CameraPreview2 + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b080d2d --- /dev/null +++ b/.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 diff --git a/res/layout/activity_image.xml b/res/layout/activity_image.xml new file mode 100644 index 0000000..172418c --- /dev/null +++ b/res/layout/activity_image.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/src/com/androidhuman/example/CameraPreview2/Preview.java b/src/com/androidhuman/example/CameraPreview2/Preview.java index 3e1b3c9..40e176b 100644 --- a/src/com/androidhuman/example/CameraPreview2/Preview.java +++ b/src/com/androidhuman/example/CameraPreview2/Preview.java @@ -191,19 +191,13 @@ public void onShutter() { public void onPictureTaken(byte[] data, Camera camera) { Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length); //이미지객체생성 - if(picture!=null){ - - - - - File file=new File(SocketUtils.FOLDER_PATH); + File file=new File(SocketUtils.TEMP_FOLDER_PATH); if(!file.isDirectory()){ file.mkdir(); } - file=new File(SocketUtils.FOLDER_PATH,System.currentTimeMillis()+".jpg"); - + file=new File(SocketUtils.TEMP_FOLDER_PATH,System.currentTimeMillis()+".jpg"); // 이미지를 찍는 각도(가로, 세로)에 맞추어 사진을 회전시켜 기본 방향으로 재조정한다. int rotation = mMyApp.getCurrentActivity().getWindowManager().getDefaultDisplay().getRotation(); diff --git a/src/com/androidhuman/example/Notification/GalleryActivity.java b/src/com/androidhuman/example/Notification/GalleryActivity.java index fb89e7b..33fb419 100644 --- a/src/com/androidhuman/example/Notification/GalleryActivity.java +++ b/src/com/androidhuman/example/Notification/GalleryActivity.java @@ -2,9 +2,17 @@ import android.app.Activity; import android.app.NotificationManager; -import android.content.ActivityNotFoundException; import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; import android.os.Bundle; +import android.provider.MediaStore; +import android.util.Log; +import android.widget.ImageView; + +import com.androidhuman.example.CameraPreview2.R; public class GalleryActivity extends Activity { @@ -14,23 +22,60 @@ public class GalleryActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_image); +// Intent intent = new Intent(); +// +// intent.setType("image/*"); +// intent.setAction(Intent.ACTION_GET_CONTENT); +//// Log.i("yoon", "income gallery Class"); +// try{ +// +// startActivityForResult(intent.createChooser(intent, "Complete"),PICK_FROM_GALLERY); +// } catch (ActivityNotFoundException e){ +// +// } Intent intent = new Intent(); - intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); - - try{ - - startActivityForResult(intent.createChooser(intent, "Complete"),PICK_FROM_GALLERY); - } catch (ActivityNotFoundException e){ - - } + startActivityForResult(intent, 2); // notification 매니저 생성 + Log.i("yoon","start img view"); NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); // 등록된 notification 을 제거 한다. nm.cancel(1234); } + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == PICK_FROM_GALLERY && resultCode == Activity.RESULT_OK) { + if (data == null) { + //Display an error + return; + } + + Uri selectedImage = data.getData(); + String[] filePathColumn = { MediaStore.Images.Media.DATA }; + + Cursor cursor = getContentResolver().query(selectedImage, + filePathColumn, null, null, null); + cursor.moveToFirst(); + + int columnIndex = cursor.getColumnIndex(filePathColumn[0]); + String picturePath = cursor.getString(columnIndex); + cursor.close(); + + Bitmap bitmap = BitmapFactory.decodeFile(picturePath); +// image.setImageBitmap(bitmap); + + if (bitmap != null) { + ImageView rotate = (ImageView) findViewById(R.id.img_result); + rotate.setImageBitmap(bitmap); + + } + //Now you can do whatever you want with your inpustream, save it as file, upload to a server, decode a bitmap... + } + } } diff --git a/src/com/androidhuman/example/socket/Socket_data.java b/src/com/androidhuman/example/socket/Socket_data.java index 238cbf3..38f04c0 100644 --- a/src/com/androidhuman/example/socket/Socket_data.java +++ b/src/com/androidhuman/example/socket/Socket_data.java @@ -51,7 +51,7 @@ public void run(){ os = socket.getOutputStream(); fis = new FileInputStream(filePath); - byte[] buf = new byte[1024*4]; + byte[] buf = new byte[1024*128]; int data =0; while(true){ diff --git a/src/com/androidhuman/example/utils/CustomIO.java b/src/com/androidhuman/example/utils/CustomIO.java new file mode 100644 index 0000000..8ce988d --- /dev/null +++ b/src/com/androidhuman/example/utils/CustomIO.java @@ -0,0 +1,22 @@ +package com.androidhuman.example.utils; + +import java.io.File; + +public class CustomIO { + /* * Right way to delete a non empty directory in Java */ + public static boolean deleteDirectory(File dir) { + if (dir.isDirectory()) { + File[] children = dir.listFiles(); + for (int i = 0; i < children.length; i++) { + boolean success = deleteDirectory(children[i]); + if (!success) { + return false; + } + } + } + + // either file or an empty directory + System.out.println("removing file or directory : " + dir.getName()); + return dir.delete(); + } +} diff --git a/src/com/androidhuman/example/utils/SocketUtils.java b/src/com/androidhuman/example/utils/SocketUtils.java index fffdd26..512daa8 100644 --- a/src/com/androidhuman/example/utils/SocketUtils.java +++ b/src/com/androidhuman/example/utils/SocketUtils.java @@ -4,7 +4,7 @@ public class SocketUtils { - static final public String SERVER_IP = "192.168.0.14"; + static final public String SERVER_IP = "113.198.39.114"; static final public int SERVER_PORT = 2020; static final public int SERVER_PORT2 = 2021; @@ -19,6 +19,6 @@ public class SocketUtils { static final public int BLUETOOTH_CONNECTION = 1; static final public int BLUETOOTH_CONNECTION_CLOSE = 0; - static final public String FOLDER_PATH = Environment.getExternalStorageDirectory()+"/Pictures/pastels"; + static final public String TEMP_FOLDER_PATH = Environment.getExternalStorageDirectory()+"/Pictures/pastel-temp"; static final public String IMAGE_FILEPATH= Environment.getExternalStorageDirectory()+"/Pictures/pastel/"; }