Skip to content

Commit

Permalink
Implement Sharing and Deleting
Browse files Browse the repository at this point in the history
This enables the user to either share or delete the modified pictures received
back from the server.
  • Loading branch information
victorssilva committed Jun 6, 2012
1 parent 5255d39 commit ab0afdc
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 11 deletions.
4 changes: 3 additions & 1 deletion simplecv-android-app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".DisplayResultsActivity"></activity>"
<activity
android:name=".DisplayResultsActivity" >
</activity>
</application>

</manifest>
Binary file modified simplecv-android-app/bin/resources.ap_
Binary file not shown.
Binary file modified simplecv-android-app/bin/simplecv-android.apk
Binary file not shown.
19 changes: 11 additions & 8 deletions simplecv-android-app/gen/com/simplecv/hellocamera/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int capturedimage=0x7f060005;
public static final int choose_picture_button=0x7f060002;
public static final int go_button=0x7f060004;
public static final int modifiedimage=0x7f060000;
public static final int take_picture_button=0x7f060001;
public static final int transformations_spinner=0x7f060003;
public static final int capturedimage=0x7f060006;
public static final int choose_picture_button=0x7f060003;
public static final int go_button=0x7f060005;
public static final int modifiedimage=0x7f060001;
public static final int share_button=0x7f060000;
public static final int take_picture_button=0x7f060002;
public static final int transformations_spinner=0x7f060004;
}
public static final class layout {
public static final int display=0x7f030000;
Expand All @@ -31,9 +32,11 @@ public static final class layout {
public static final class string {
public static final int app_name=0x7f040002;
public static final int choose_picture_button=0x7f040004;
public static final int go_button=0x7f040005;
public static final int delete_button=0x7f040006;
public static final int go_button=0x7f040007;
public static final int share_button=0x7f040005;
public static final int slogan=0x7f040001;
public static final int spinner_prompt=0x7f040006;
public static final int spinner_prompt=0x7f040008;
public static final int take_picture_button=0x7f040003;
public static final int title=0x7f040000;
}
Expand Down
22 changes: 22 additions & 0 deletions simplecv-android-app/res/layout/display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@
android:layout_gravity="center_horizontal"
android:textSize="15dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" >

<Button
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="deletePicture"
android:text="@string/delete_button" />

<Button
android:id="@+id/share_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="sharePicture"
android:text="@string/share_button" />
</LinearLayout>

<ImageView
android:id="@+id/modifiedimage"
android:layout_width="fill_parent"
Expand Down
2 changes: 2 additions & 0 deletions simplecv-android-app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<string name="app_name">SimpleCV</string>
<string name="take_picture_button">Take Picture</string>
<string name="choose_picture_button">Choose from Gallery</string>
<string name="share_button">Share!</string>
<string name="delete_button">Delete</string>
<string name="go_button">Go!</string>
<string name="spinner_prompt">Select a transformation...</string>
<string-array name="transformations_array">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.simplecv.hellocamera;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class DisplayResultsActivity extends Activity {
Expand All @@ -21,4 +24,18 @@ public void onCreate(Bundle savedInstanceState) {
modifiedImage = (ImageView) findViewById(R.id.modifiedimage);
modifiedImage.setImageURI(modifiedImageUri);
}

public void deletePicture(View view){
File picture = new File(modifiedImageUri.getPath());
if (picture.delete()) {
finish();
}
}

public void sharePicture(View view){
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/png"); //png?
sharingIntent.putExtra(Intent.EXTRA_STREAM, modifiedImageUri);
startActivity(Intent.createChooser(sharingIntent, "Share using"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,10 @@ public void modifyPicture(View view) {
String transformedImageURL = EntityUtils.toString(responseEntity);
try {
Bitmap transformedImageBitmap = BitmapFactory.decodeStream((InputStream)new URL(transformedImageURL).getContent());
//capturedImage.setImageBitmap(transformedImageBitmap);
Uri transformedImageUri = getUriFromBitmap(transformedImageBitmap);
Intent displayIntent = new Intent(getApplicationContext(), DisplayResultsActivity.class);
displayIntent.putExtra("uriAsString", transformedImageUri.toString());
startActivity(displayIntent);
//capturedImage.setImageURI(transformedImageUri);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down

0 comments on commit ab0afdc

Please sign in to comment.