Skip to content

Commit

Permalink
- change connection IP(Server)
Browse files Browse the repository at this point in the history
- modify CameraPreview.java : removing folder if compressed resource is success

Signed-off-by: yoonsubKim <camera702@naver.com>
  • Loading branch information
rupert-kim committed Sep 22, 2015
1 parent fcc0543 commit 71061cb
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry exported="true" kind="lib" path="lib/google-play-services.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CameraPreview2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions res/layout/activity_image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/img_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>
10 changes: 2 additions & 8 deletions src/com/androidhuman/example/CameraPreview2/Preview.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
63 changes: 54 additions & 9 deletions src/com/androidhuman/example/Notification/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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...
}
}
}
2 changes: 1 addition & 1 deletion src/com/androidhuman/example/socket/Socket_data.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
22 changes: 22 additions & 0 deletions src/com/androidhuman/example/utils/CustomIO.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
4 changes: 2 additions & 2 deletions src/com/androidhuman/example/utils/SocketUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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/";
}

0 comments on commit 71061cb

Please sign in to comment.