rotate avatars
This commit is contained in:
		
							parent
							
								
									6045bcc2eb
								
							
						
					
					
						commit
						f888b167c6
					
				| 
						 | 
					@ -201,17 +201,20 @@ public class FileBackend {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private int getRotation(Uri image) {
 | 
						private int getRotation(Uri image) {
 | 
				
			||||||
		if ("content".equals(image.getScheme())) {
 | 
							if ("content".equals(image.getScheme())) {
 | 
				
			||||||
			Cursor cursor = context
 | 
								try {
 | 
				
			||||||
					.getContentResolver()
 | 
									Cursor cursor = context
 | 
				
			||||||
					.query(image,
 | 
											.getContentResolver()
 | 
				
			||||||
							new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
 | 
											.query(image,
 | 
				
			||||||
							null, null, null);
 | 
													new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
 | 
				
			||||||
 | 
													null, null, null);
 | 
				
			||||||
			if (cursor.getCount() != 1) {
 | 
									if (cursor.getCount() != 1) {
 | 
				
			||||||
 | 
										return -1;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									cursor.moveToFirst();
 | 
				
			||||||
 | 
									return cursor.getInt(0);
 | 
				
			||||||
 | 
								} catch (IllegalArgumentException e) {
 | 
				
			||||||
				return -1;
 | 
									return -1;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			cursor.moveToFirst();
 | 
					 | 
				
			||||||
			return cursor.getInt(0);
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			ExifInterface exif;
 | 
								ExifInterface exif;
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
| 
						 | 
					@ -376,6 +379,10 @@ public class FileBackend {
 | 
				
			||||||
			if (input == null) {
 | 
								if (input == null) {
 | 
				
			||||||
				return null;
 | 
									return null;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
 | 
									int rotation = getRotation(image);
 | 
				
			||||||
 | 
									if (rotation > 0) {
 | 
				
			||||||
 | 
										input = rotate(input, rotation);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				return cropCenterSquare(input, size);
 | 
									return cropCenterSquare(input, size);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} catch (FileNotFoundException e) {
 | 
							} catch (FileNotFoundException e) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue