Multiple Image Crop Android - android

I am making an application that allows the user to upload multiple images from the gallery. The user selects the photos and they are displayed in a list view and the user clicks an upload button. It was working fine until i discovered some images were changing orientation on the list view and on upload.
I asked around about the issue and someone told me that i had to allow for cropping before upload. Should i make the user crop every selected image from gallery or how should i go about it?
if (requestCode == SELECT_MULTIPLE_PHOTOS) {
String imagesArray = data.getStringExtra(EXTRA_SELECTED_PHOTOS);//get Intent data
//Convert string array into List by splitting by ',' and substring after '[' and before ']'
List<String> selectedImages =
Arrays.asList(imagesArray.substring(1, imagesArray.length() - 1)
.split(", "));
Log.d(TAG, "Selected images is " + selectedImages.size());
mPhotosPathList = new ArrayList<String>(selectedImages);
Log.d(TAG, "Selected images path is " + mPhotosPathList.size());
}

Get the image orientation. If it is not in the correct orientation, the get the correct orientation, Try this link

Related

how to select each image uniquely in android using appium

Hi i am new on automating mobile apps, some help would be appreciated.
i want to select some images from gallery through app, however all the images are having same class name and i can select only one image, while trying to select other image it just deselects first image and select that image again.
driver.findElement(By.xpath("//android.widget.TextView[#text='pictures']")).click(); //image selection // select folder
if(Product.equalsIgnoreCase("Photobooks"))
{
// number of images to be selected is equal to
for(int i=0;i<40;i++){
Thread.sleep(5000);
driver.findElement(By.className("android.widget.ImageView")).click();
}
This code goes clicks on one folder containing images and tries to selelct 40 images from the gallery to design book.
The problem is that you keep finding the same element.
What you need to do is to get the list of ALL the images, and then click on every image from that list:
List<WebElement> imageList = driver.findElements(By.className("android.widget.ImageView")).click();
if(Product.equalsIgnoreCase("Photobooks"))
{
// number of images to be selected is equal to
for(int i=0;i<40;i++){
imageList.get(i).click();
Thread.sleep(5000);
}
}

How do we know if an ImageView is updated in Android?

I have a form, where I have a imageview and other two text fields. This imageview will be updated with the pic a user chooses(either from gallery or by taking a pic). I will be saving this image in internal storage and other two text fields and saved image path in SQLite DB.
User has option of not choosing any image. In that case I should not save any image, coz I simply be wasting storage. For that how do I distinguish when a user chooses or not to upload any image?
int NEW_PIC=1;
int NO_CHANGE=0;
initialise
img_camera.setTag(AppConfig.NO_CHANGE);
when Changed set
img_camera.setTag(AppConfig.NEW_PIC_ADDED);
if ((int) iv_userImage.getTag() == NEW_PIC_ADDED) {
//New Image Added
}
else{
//Not New
}

Gravatar are not showing up in android app

Here is my code to display profile picture using gravatar.
ParseUser user = mUsers.get(position);
String email = user.getEmail().toLowerCase();
if (email.equals("")) {
holder.userImageView.setImageResource(R.drawable.avatar_empty);
} else {
String hash = MD5Util.md5Hex(email);
String gravatarUrl = "http://www.gravatar.com/avatar/" + hash + "?s=204&d=404";
Picasso.with(mContext).load(gravatarUrl)
.placeholder(R.drawable.avatar_empty)
.into(holder.userImageView);
}
But it is not showing even my profile picture and loads empty drawable.
You used a bunch of fake emails to populate your friend list, if so, gravatar won't be able to find images for those fake emails. So gravatar will return a 404, and your code will use the default "avatar_empty" image in the drawable folder.
A quick way to test to see if gravatar is working is to change the &d=404 to &d=monsterid and create a friend with a fake email "SDFSDSF#DSFSsdfsFSFSssf.com"
That friend will have an gravatar cartoon image.
Also you can try put http://www.gravatar.com/avatar/edb1260aa6f7f77688deee83e0a088f7?s=204&d=monsterid in your gravatarUrl. It will show picture.
Hope this helps someone , this is the code i used.
get library from:- https://github.com/tkeunebr/gravatar-android (you will get the .jar,, add it to lib)
Code for loading gravatar:
String gravatarUrl = Gravatar.init().with(user.email).size(100).build();
Picasso.with(mContext)
.load(gravatarUrl)
.into((ImageView) convertView.findViewById(R.id.user_avatar));
And if you want to set a default image in case of there is no gravatar set for the email(to override the default gravatar) then use:
String gravatarUrl = Gravatar.init().with(user.email).defaultImage(defaultImageUrl).size(100).build();
Hope this helps someone.

Storing contact photos with a possibility to retrieve original image in future

According to the official documentation which contains information about contact's photo handling (Android 4.0):
Large photos
Android now supports high resolution photos for contacts. Now, when
you push a photo into a contact record, the system processes it into
both a 96x96 thumbnail (as it has previously) and a 256x256 "display
photo" that's stored in a new file-based photo store (the exact
dimensions that the system chooses may vary in the future). You can
add a large photo to a contact by putting a large photo in the usual
PHOTO column of a data row, which the system will then process into
the appropriate thumbnail and display photo records.
So, I would like to know if I store a photo with the size of 400x400 px, is there any possibility to retrieve this photo with it's original size, or I have to be glad only having a photo with decreased size?
Try this example:
public void writeDisplayPhoto(long rawContactId, byte[] photo) {
Uri rawContactPhotoUri = Uri.withAppendedPath(
ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
RawContacts.DisplayPhoto.CONTENT_DIRECTORY
);
try {
AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
rawContactPhotoUri,
"rw"
);
OutputStream os = fd.createOutputStream();
os.write(photo);
os.close();
fd.close();
} catch (IOException e) {
// Handle error cases.
}
}
Using file descriptors you can read/write contact photo. Also I think you need store thumbnail of your photo to contact
For more info see ContactsContract.RawContacts.DisplayPhoto class
Simple solution:
Login to your gmail account from any PC, then search for "contacts"
From within contacts page: enter the contact name you want to search for
Click on the contact that you want & select "save image..."
Note: I don't know if there is a higher quality version inside the phone but I'm still working on it.

Posted Image size is changing while using facebook graph api

I posted message and image to facebook wall using graph api.Here is the code I used
if(i==1){
String res= UrltoValue.getValuefromUrl("https://graph.facebook.com/"+Login.facebookid+"/feed?access_token="+accesstoken+"&method="+"post"+"&message="+strFullMessage.replaceAll(" ", "%20")+"&source="+imageUrl);
Log.e("post response",res);
if(res.contains("id")){
Toast.makeText(getApplicationContext(), "successfully posted", Toast.LENGTH_SHORT).show();
}
Both the message and image are posted successfully,but the image size is taking as thumbnail.I used both "source" and "picture" parameters,but the result is same.
I am getting these images from my local database.
I checked the image size of that Url,it is 240*320 size,but it is displaying in small size in my facebook.
Posting to the wall using graph api will always result in the image size chosen by facebook.
https://developers.facebook.com/docs/reference/api/post/
This is to maintain uniformity in the feed. You can post as big an image as you want but it will be resized while being displayed in the feed. The user can view a bigger version when he clicks on it though.
Image sizes can be set while querying them from facebook. See:
https://developers.facebook.com/docs/reference/api/using-pictures/

Categories

Resources