mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-31 23:03:54 +01:00
Merge 7df1c65654 into b9bb9bcf34
This commit is contained in:
commit
73d34ca827
3 changed files with 33 additions and 22 deletions
6
.idea/inspectionProfiles/Project_Default.xml
generated
6
.idea/inspectionProfiles/Project_Default.xml
generated
|
|
@ -1,8 +1,7 @@
|
||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="AndroidLintNewerVersionAvailable" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="AndroidLintNewerVersionAvailable" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="ClassWithOnlyPrivateConstructors" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="ClassWithOnlyPrivateConstructors" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="ConfusingElse" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="ConfusingElse" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="reportWhenNoStatementFollow" value="true" />
|
<option name="reportWhenNoStatementFollow" value="true" />
|
||||||
|
|
@ -10,7 +9,6 @@
|
||||||
<inspection_tool class="ControlFlowStatementWithoutBraces" enabled="true" level="ERROR" enabled_by_default="true" />
|
<inspection_tool class="ControlFlowStatementWithoutBraces" enabled="true" level="ERROR" enabled_by_default="true" />
|
||||||
<inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="DefaultNotLastCaseInSwitch" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="ExplicitThis" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
<inspection_tool class="ExplicitThis" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="FieldMayBeFinal" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="LocalCanBeFinal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="REPORT_VARIABLES" value="true" />
|
<option name="REPORT_VARIABLES" value="true" />
|
||||||
<option name="REPORT_PARAMETERS" value="true" />
|
<option name="REPORT_PARAMETERS" value="true" />
|
||||||
|
|
@ -25,7 +23,6 @@
|
||||||
<option name="ignoreInMatchingInstanceof" value="false" />
|
<option name="ignoreInMatchingInstanceof" value="false" />
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
<inspection_tool class="ProblematicWhitespace" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="ProblematicWhitespace" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="ProtectedMemberInFinalClass" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
<inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="RedundantFieldInitialization" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="RedundantImplements" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="ignoreSerializable" value="false" />
|
<option name="ignoreSerializable" value="false" />
|
||||||
|
|
@ -47,6 +44,5 @@
|
||||||
<inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="UnnecessaryQualifierForThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="UnnecessarySuperConstructor" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="UnnecessaryThis" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
<inspection_tool class="UnnecessaryToStringCall" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
||||||
|
|
@ -31,9 +31,11 @@ import java.io.File
|
||||||
*/
|
*/
|
||||||
class EditActivity : AppCompatActivity() {
|
class EditActivity : AppCompatActivity() {
|
||||||
private var imageUri = ""
|
private var imageUri = ""
|
||||||
|
private var imageRotation = 0
|
||||||
private lateinit var vm: EditViewModel
|
private lateinit var vm: EditViewModel
|
||||||
private val sourceExifAttributeList = mutableListOf<Pair<String, String?>>()
|
private val sourceExifAttributeList = mutableListOf<Pair<String, String?>>()
|
||||||
private lateinit var binding: ActivityEditBinding
|
private lateinit var binding: ActivityEditBinding
|
||||||
|
private var totalRotation = 0
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
@ -42,6 +44,8 @@ class EditActivity : AppCompatActivity() {
|
||||||
supportActionBar?.title = ""
|
supportActionBar?.title = ""
|
||||||
val intent = intent
|
val intent = intent
|
||||||
imageUri = intent.getStringExtra("image") ?: ""
|
imageUri = intent.getStringExtra("image") ?: ""
|
||||||
|
imageRotation = intent.getIntExtra("rotation",0)
|
||||||
|
totalRotation = imageRotation
|
||||||
vm = ViewModelProvider(this).get(EditViewModel::class.java)
|
vm = ViewModelProvider(this).get(EditViewModel::class.java)
|
||||||
val sourceExif = imageUri.toUri().path?.let { ExifInterface(it) }
|
val sourceExif = imageUri.toUri().path?.let { ExifInterface(it) }
|
||||||
val exifTags = arrayOf(
|
val exifTags = arrayOf(
|
||||||
|
|
@ -87,7 +91,7 @@ class EditActivity : AppCompatActivity() {
|
||||||
private fun init() {
|
private fun init() {
|
||||||
binding.iv.adjustViewBounds = true
|
binding.iv.adjustViewBounds = true
|
||||||
binding.iv.scaleType = ImageView.ScaleType.MATRIX
|
binding.iv.scaleType = ImageView.ScaleType.MATRIX
|
||||||
binding.iv.post(Runnable {
|
binding.iv.post {
|
||||||
val options = BitmapFactory.Options()
|
val options = BitmapFactory.Options()
|
||||||
options.inJustDecodeBounds = true
|
options.inJustDecodeBounds = true
|
||||||
BitmapFactory.decodeFile(imageUri, options)
|
BitmapFactory.decodeFile(imageUri, options)
|
||||||
|
|
@ -103,6 +107,8 @@ class EditActivity : AppCompatActivity() {
|
||||||
options.inJustDecodeBounds = false
|
options.inJustDecodeBounds = false
|
||||||
val scaledBitmap = BitmapFactory.decodeFile(imageUri, options)
|
val scaledBitmap = BitmapFactory.decodeFile(imageUri, options)
|
||||||
binding.iv.setImageBitmap(scaledBitmap)
|
binding.iv.setImageBitmap(scaledBitmap)
|
||||||
|
binding.iv.rotation = (imageRotation % 360).toFloat()
|
||||||
|
imageRotation = 0
|
||||||
// Update the ImageView with the scaled bitmap
|
// Update the ImageView with the scaled bitmap
|
||||||
val scale = binding.iv.measuredWidth.toFloat() / scaledBitmap.width.toFloat()
|
val scale = binding.iv.measuredWidth.toFloat() / scaledBitmap.width.toFloat()
|
||||||
binding.iv.layoutParams.height = (scale * scaledBitmap.height).toInt()
|
binding.iv.layoutParams.height = (scale * scaledBitmap.height).toInt()
|
||||||
|
|
@ -112,12 +118,13 @@ class EditActivity : AppCompatActivity() {
|
||||||
options.inJustDecodeBounds = false
|
options.inJustDecodeBounds = false
|
||||||
val bitmap = BitmapFactory.decodeFile(imageUri, options)
|
val bitmap = BitmapFactory.decodeFile(imageUri, options)
|
||||||
binding.iv.setImageBitmap(bitmap)
|
binding.iv.setImageBitmap(bitmap)
|
||||||
|
binding.iv.rotation = (imageRotation % 360).toFloat()
|
||||||
|
imageRotation = 0
|
||||||
val scale = binding.iv.measuredWidth.toFloat() / bitmapWidth.toFloat()
|
val scale = binding.iv.measuredWidth.toFloat() / bitmapWidth.toFloat()
|
||||||
binding.iv.layoutParams.height = (scale * bitmapHeight).toInt()
|
binding.iv.layoutParams.height = (scale * bitmapHeight).toInt()
|
||||||
binding.iv.imageMatrix = scaleMatrix(scale, scale)
|
binding.iv.imageMatrix = scaleMatrix(scale, scale)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
binding.rotateBtn.setOnClickListener {
|
binding.rotateBtn.setOnClickListener {
|
||||||
animateImageHeight()
|
animateImageHeight()
|
||||||
}
|
}
|
||||||
|
|
@ -126,12 +133,10 @@ class EditActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var imageRotation = 0
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates the height, rotation, and scale of an ImageView to provide a smooth
|
* Animates the height, rotation, and scale of an ImageView to provide a smooth
|
||||||
* transition effect when rotating an image by 90 degrees.
|
* transition effect when rotating an image by 90 degrees.
|
||||||
*
|
* @param shouldRotate A boolean indicating whether the image should rotate by 90 degrees.
|
||||||
* This function calculates the new height, rotation, and scale for the ImageView
|
* This function calculates the new height, rotation, and scale for the ImageView
|
||||||
* based on the current image rotation angle and animates the changes using a
|
* based on the current image rotation angle and animates the changes using a
|
||||||
* ValueAnimator. It also disables a rotate button during the animation to prevent
|
* ValueAnimator. It also disables a rotate button during the animation to prevent
|
||||||
|
|
@ -176,6 +181,8 @@ class EditActivity : AppCompatActivity() {
|
||||||
|
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
imageRotation = newRotation % 360
|
imageRotation = newRotation % 360
|
||||||
|
val t1 = totalRotation % 360
|
||||||
|
totalRotation = t1 + 90
|
||||||
binding.rotateBtn.setEnabled(true)
|
binding.rotateBtn.setEnabled(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,7 +240,7 @@ class EditActivity : AppCompatActivity() {
|
||||||
val file = filePath?.let { File(it) }
|
val file = filePath?.let { File(it) }
|
||||||
|
|
||||||
|
|
||||||
val rotatedImage = file?.let { vm.rotateImage(imageRotation, it) }
|
val rotatedImage = if(totalRotation == 360 || totalRotation == 0) file else file?.let { vm.rotateImage(totalRotation, it) }
|
||||||
if (rotatedImage == null) {
|
if (rotatedImage == null) {
|
||||||
Toast.makeText(this, "Failed to rotate to image", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, "Failed to rotate to image", Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
@ -244,6 +251,7 @@ class EditActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
val resultIntent = Intent()
|
val resultIntent = Intent()
|
||||||
resultIntent.putExtra("editedImageFilePath", rotatedImage?.toUri()?.path ?: "Error");
|
resultIntent.putExtra("editedImageFilePath", rotatedImage?.toUri()?.path ?: "Error");
|
||||||
|
resultIntent.putExtra("editedImageRotation",totalRotation)
|
||||||
setResult(RESULT_OK, resultIntent);
|
setResult(RESULT_OK, resultIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
private int indexOfFragment;
|
private int indexOfFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the rotation angle of the image in degrees.
|
||||||
|
*/
|
||||||
|
private int rotation = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A key for applicationKvStore. By this key we can retrieve the location of last UploadItem ex.
|
* A key for applicationKvStore. By this key we can retrieve the location of last UploadItem ex.
|
||||||
* 12.3433,54.78897 from applicationKvStore.
|
* 12.3433,54.78897 from applicationKvStore.
|
||||||
|
|
@ -183,18 +188,18 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
|
|
||||||
if(savedInstanceState!=null){
|
if(savedInstanceState!=null){
|
||||||
if(uploadMediaDetailAdapter.getItems().size()==0 && callback != null){
|
if(uploadMediaDetailAdapter.getItems().size()==0 && callback != null){
|
||||||
uploadMediaDetailAdapter.setItems(savedInstanceState.getParcelableArrayList(UPLOAD_MEDIA_DETAILS));
|
uploadMediaDetailAdapter.setItems(savedInstanceState.getParcelableArrayList(UPLOAD_MEDIA_DETAILS));
|
||||||
presenter.setUploadMediaDetails(uploadMediaDetailAdapter.getItems(),
|
presenter.setUploadMediaDetails(uploadMediaDetailAdapter.getItems(),
|
||||||
indexOfFragment);
|
indexOfFragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!presenter.getImageQuality(indexOfFragment, inAppPictureLocation, getActivity())) {
|
if(!presenter.getImageQuality(indexOfFragment, inAppPictureLocation, getActivity())) {
|
||||||
startActivityWithFlags(
|
startActivityWithFlags(
|
||||||
getActivity(), MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
getActivity(), MainActivity.class, Intent.FLAG_ACTIVITY_CLEAR_TOP,
|
||||||
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
@ -223,7 +228,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
|
|
||||||
// If the image EXIF data contains the location, show the map icon with a green tick
|
// If the image EXIF data contains the location, show the map icon with a green tick
|
||||||
if (inAppPictureLocation != null ||
|
if (inAppPictureLocation != null ||
|
||||||
(uploadableFile != null && uploadableFile.hasLocation())) {
|
(uploadableFile != null && uploadableFile.hasLocation())) {
|
||||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_available_20dp);
|
||||||
binding.locationImageView.setImageDrawable(mapTick);
|
binding.locationImageView.setImageDrawable(mapTick);
|
||||||
binding.locationTextView.setText(R.string.edit_location);
|
binding.locationTextView.setText(R.string.edit_location);
|
||||||
|
|
@ -600,6 +605,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
editableUploadItem = uploadItem;
|
editableUploadItem = uploadItem;
|
||||||
Intent intent = new Intent(getContext(), EditActivity.class);
|
Intent intent = new Intent(getContext(), EditActivity.class);
|
||||||
intent.putExtra("image", uploadableFile.getFilePath().toString());
|
intent.putExtra("image", uploadableFile.getFilePath().toString());
|
||||||
|
intent.putExtra("rotation",rotation);
|
||||||
startActivityForResult(intent, REQUEST_CODE_FOR_EDIT_ACTIVITY);
|
startActivityForResult(intent, REQUEST_CODE_FOR_EDIT_ACTIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -680,6 +686,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
||||||
}
|
}
|
||||||
if (requestCode == REQUEST_CODE_FOR_EDIT_ACTIVITY && resultCode == RESULT_OK) {
|
if (requestCode == REQUEST_CODE_FOR_EDIT_ACTIVITY && resultCode == RESULT_OK) {
|
||||||
String result = data.getStringExtra("editedImageFilePath");
|
String result = data.getStringExtra("editedImageFilePath");
|
||||||
|
rotation = data.getIntExtra("editedImageRotation",0);
|
||||||
|
|
||||||
if (Objects.equals(result, "Error")) {
|
if (Objects.equals(result, "Error")) {
|
||||||
Timber.e("Error in rotating image");
|
Timber.e("Error in rotating image");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue