Skip to content

Commit

Permalink
Added functionality to send image from phone gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
SubZer0811 committed Feb 7, 2021
1 parent 4c55be8 commit efac35b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
8 changes: 7 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="true"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand All @@ -20,7 +22,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity
android:name="com.example.streamera.SendImage"
android:name="com.example.streamera.CaptureImage"
android:screenOrientation="landscape"
android:parentActivityName="com.example.streamera.MainActivity" />
<activity
Expand All @@ -36,6 +38,10 @@
android:name="com.example.streamera.VideoStream"
android:parentActivityName="com.example.streamera.MainActivity"
android:screenOrientation="landscape" />
<activity
android:name="com.example.streamera.SendImage"
android:parentActivityName="com.example.streamera.MainActivity"
android:screenOrientation="landscape" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.io.DataOutputStream;
import java.net.Socket;

public class SendImage extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2 {
public class CaptureImage extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2 {

private boolean isFrontCam = false;
private Mat mRgba;
Expand Down
25 changes: 23 additions & 2 deletions app/src/main/java/com/example/streamera/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,21 @@ public void onClick(View v) {
}
});

Button img_send_button = (Button) findViewById(R.id.ImageSend);
img_send_button.setOnClickListener(new View.OnClickListener() {
Button capture_img_button = (Button) findViewById(R.id.ImageSend);
capture_img_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openImageActivity();
}
});

Button send_img_button = (Button) findViewById(R.id.SendImage);
send_img_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openSendImageActivity();
}
});
}

public void openVideoActivity(){
Expand All @@ -83,6 +91,19 @@ public void openImageActivity(){
EditText port_ = (EditText) findViewById(R.id.Port);
Integer port = Integer.parseInt(port_.getText().toString());

Intent intent = new Intent(this, CaptureImage.class);
intent.putExtra(SERVER, server);
intent.putExtra(PORT, port);
startActivity(intent);
}

public void openSendImageActivity(){
EditText server_ = (EditText) findViewById(R.id.IPAddr);
String server = server_.getText().toString();

EditText port_ = (EditText) findViewById(R.id.Port);
Integer port = Integer.parseInt(port_.getText().toString());

Intent intent = new Intent(this, SendImage.class);
intent.putExtra(SERVER, server);
intent.putExtra(PORT, port);
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
android:text="Stream Video"
android:textSize="10sp" />

<Button
android:id="@+id/SendImage"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="327dp"
android:layout_marginEnd="314dp"
android:layout_marginBottom="110dp"
android:text="Send image"
android:textSize="10sp" />

<Button
android:id="@+id/ImageSend"
android:layout_width="88dp"
Expand All @@ -29,7 +42,7 @@
android:layout_marginStart="504dp"
android:layout_marginEnd="138dp"
android:layout_marginBottom="111dp"
android:text="Send Image"
android:text="Capture Image"
android:textSize="10sp" />

<EditText
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_send_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".SendImage">
tools:context=".CaptureImage">

<org.opencv.android.JavaCameraView
android:id="@+id/camView"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#Mon Jan 04 07:04:22 IST 2021
#Sun Feb 07 07:43:57 IST 2021

0 comments on commit efac35b

Please sign in to comment.