Skip to content

Commit 71061cb

Browse files
committed
- change connection IP(Server)
- modify CameraPreview.java : removing folder if compressed resource is success Signed-off-by: yoonsubKim <camera702@naver.com>
1 parent fcc0543 commit 71061cb

File tree

10 files changed

+141
-20
lines changed

10 files changed

+141
-20
lines changed

.classpath

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
4+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
5+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
6+
<classpathentry exported="true" kind="lib" path="lib/google-play-services.jar"/>
7+
<classpathentry kind="src" path="src"/>
8+
<classpathentry kind="src" path="gen"/>
9+
<classpathentry kind="output" path="bin/classes"/>
10+
</classpath>

.project

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CameraPreview2</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
4+
org.eclipse.jdt.core.compiler.source=1.6

res/layout/activity_image.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical" >
6+
<ImageView
7+
android:id="@+id/img_result"
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"/>
10+
11+
</LinearLayout>

src/com/androidhuman/example/CameraPreview2/Preview.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,13 @@ public void onShutter() {
191191
public void onPictureTaken(byte[] data, Camera camera) {
192192
Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length); //이미지객체생성
193193

194-
195194
if(picture!=null){
196-
197-
198-
199-
200-
File file=new File(SocketUtils.FOLDER_PATH);
195+
File file=new File(SocketUtils.TEMP_FOLDER_PATH);
201196
if(!file.isDirectory()){
202197
file.mkdir();
203198
}
204199

205-
file=new File(SocketUtils.FOLDER_PATH,System.currentTimeMillis()+".jpg");
206-
200+
file=new File(SocketUtils.TEMP_FOLDER_PATH,System.currentTimeMillis()+".jpg");
207201

208202
// 이미지를 찍는 각도(가로, 세로)에 맞추어 사진을 회전시켜 기본 방향으로 재조정한다.
209203
int rotation = mMyApp.getCurrentActivity().getWindowManager().getDefaultDisplay().getRotation();

src/com/androidhuman/example/Notification/GalleryActivity.java

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
import android.app.Activity;
44
import android.app.NotificationManager;
5-
import android.content.ActivityNotFoundException;
65
import android.content.Intent;
6+
import android.database.Cursor;
7+
import android.graphics.Bitmap;
8+
import android.graphics.BitmapFactory;
9+
import android.net.Uri;
710
import android.os.Bundle;
11+
import android.provider.MediaStore;
12+
import android.util.Log;
13+
import android.widget.ImageView;
14+
15+
import com.androidhuman.example.CameraPreview2.R;
816

917
public class GalleryActivity extends Activity {
1018

@@ -14,23 +22,60 @@ public class GalleryActivity extends Activity {
1422
@Override
1523
protected void onCreate(Bundle savedInstanceState) {
1624
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_image);
1726

27+
// Intent intent = new Intent();
28+
//
29+
// intent.setType("image/*");
30+
// intent.setAction(Intent.ACTION_GET_CONTENT);
31+
//// Log.i("yoon", "income gallery Class");
32+
// try{
33+
//
34+
// startActivityForResult(intent.createChooser(intent, "Complete"),PICK_FROM_GALLERY);
35+
// } catch (ActivityNotFoundException e){
36+
//
37+
// }
1838
Intent intent = new Intent();
19-
2039
intent.setType("image/*");
2140
intent.setAction(Intent.ACTION_GET_CONTENT);
22-
23-
try{
24-
25-
startActivityForResult(intent.createChooser(intent, "Complete"),PICK_FROM_GALLERY);
26-
} catch (ActivityNotFoundException e){
27-
28-
}
41+
startActivityForResult(intent, 2);
2942
// notification 매니저 생성
43+
Log.i("yoon","start img view");
3044
NotificationManager nm =
3145
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
3246

3347
// 등록된 notification 을 제거 한다.
3448
nm.cancel(1234);
3549
}
50+
@Override
51+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
52+
super.onActivityResult(requestCode, resultCode, data);
53+
if (requestCode == PICK_FROM_GALLERY && resultCode == Activity.RESULT_OK) {
54+
if (data == null) {
55+
//Display an error
56+
return;
57+
}
58+
59+
Uri selectedImage = data.getData();
60+
String[] filePathColumn = { MediaStore.Images.Media.DATA };
61+
62+
Cursor cursor = getContentResolver().query(selectedImage,
63+
filePathColumn, null, null, null);
64+
cursor.moveToFirst();
65+
66+
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
67+
String picturePath = cursor.getString(columnIndex);
68+
cursor.close();
69+
70+
Bitmap bitmap = BitmapFactory.decodeFile(picturePath);
71+
// image.setImageBitmap(bitmap);
72+
73+
if (bitmap != null) {
74+
ImageView rotate = (ImageView) findViewById(R.id.img_result);
75+
rotate.setImageBitmap(bitmap);
76+
77+
}
78+
//Now you can do whatever you want with your inpustream, save it as file, upload to a server, decode a bitmap...
79+
}
80+
}
3681
}

src/com/androidhuman/example/socket/Socket_data.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void run(){
5151
os = socket.getOutputStream();
5252

5353
fis = new FileInputStream(filePath);
54-
byte[] buf = new byte[1024*4];
54+
byte[] buf = new byte[1024*128];
5555
int data =0;
5656

5757
while(true){
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.androidhuman.example.utils;
2+
3+
import java.io.File;
4+
5+
public class CustomIO {
6+
/* * Right way to delete a non empty directory in Java */
7+
public static boolean deleteDirectory(File dir) {
8+
if (dir.isDirectory()) {
9+
File[] children = dir.listFiles();
10+
for (int i = 0; i < children.length; i++) {
11+
boolean success = deleteDirectory(children[i]);
12+
if (!success) {
13+
return false;
14+
}
15+
}
16+
}
17+
18+
// either file or an empty directory
19+
System.out.println("removing file or directory : " + dir.getName());
20+
return dir.delete();
21+
}
22+
}

src/com/androidhuman/example/utils/SocketUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class SocketUtils {
66

7-
static final public String SERVER_IP = "192.168.0.14";
7+
static final public String SERVER_IP = "113.198.39.114";
88
static final public int SERVER_PORT = 2020;
99
static final public int SERVER_PORT2 = 2021;
1010

@@ -19,6 +19,6 @@ public class SocketUtils {
1919
static final public int BLUETOOTH_CONNECTION = 1;
2020
static final public int BLUETOOTH_CONNECTION_CLOSE = 0;
2121

22-
static final public String FOLDER_PATH = Environment.getExternalStorageDirectory()+"/Pictures/pastels";
22+
static final public String TEMP_FOLDER_PATH = Environment.getExternalStorageDirectory()+"/Pictures/pastel-temp";
2323
static final public String IMAGE_FILEPATH= Environment.getExternalStorageDirectory()+"/Pictures/pastel/";
2424
}

0 commit comments

Comments
 (0)