Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c42a358
minor bug fixing and use media processor for edit photos
OS-ruimoreiramendes Mar 5, 2026
5ebc465
update methods doc
OS-ruimoreiramendes Mar 5, 2026
d1cb5c9
update file names to prefix ION
OS-ruimoreiramendes Mar 6, 2026
d7f3511
uncoment code on OSCAMRController
OS-ruimoreiramendes Mar 6, 2026
7d3fa9c
added unit tests working with OSCAMRController
OS-ruimoreiramendes Mar 9, 2026
c6a08b2
remove openCropActivity from CameraManager and GalleryManager
OS-ruimoreiramendes Mar 10, 2026
2ff6754
chore: Update mockito dependencies
OS-pedrogustavobilro Mar 10, 2026
316db7d
chore: point CaptureVideoTests to CameraManager
OS-pedrogustavobilro Mar 11, 2026
64b5140
chore: point PlayVideoTests to VideoManager
OS-pedrogustavobilro Mar 11, 2026
47c2025
chore: point ChooseFromGalleryTests to GalleryManager
OS-pedrogustavobilro Mar 11, 2026
ae9de79
chore: point ChoosePictureTests to GalleryManager
OS-pedrogustavobilro Mar 11, 2026
804ac92
chore: point TakePictureTests to CameraManager
OS-pedrogustavobilro Mar 11, 2026
572236d
chore: point EditPictureTests to EditManager
OS-pedrogustavobilro Mar 11, 2026
3680d49
ci: Comment sonar integration
OS-pedrogustavobilro Mar 11, 2026
492cfe9
chore: Rename test
OS-pedrogustavobilro Mar 11, 2026
b05eef5
refactor: Remove OSCAMRController.kt
OS-pedrogustavobilro Mar 11, 2026
5ec6375
move savePictureInGallery duplicated code into IONMediaProcessor and …
OS-ruimoreiramendes Mar 11, 2026
3093bf0
Merge branch 'feat/RMET-4099/edit-media-processor' into feat/RMET-409…
OS-ruimoreiramendes Mar 11, 2026
ea0ca30
added limit to chooseFromGallery
OS-ruimoreiramendes Mar 13, 2026
a486326
chore: fix unit tests
OS-pedrogustavobilro Mar 13, 2026
1cfb4de
address pr comments
OS-ruimoreiramendes Mar 16, 2026
35f560f
change file names to IONCAMR...
OS-ruimoreiramendes Mar 16, 2026
a056e3f
remove Companion and update LOG_TAG values
OS-ruimoreiramendes Mar 16, 2026
a9c7f7b
delete comment
OS-ruimoreiramendes Mar 16, 2026
a85b52b
revert changes on getVideoDuration func
OS-ruimoreiramendes Mar 16, 2026
ffba3d6
remove default null value for save param in IONCAMRMediaResult
OS-ruimoreiramendes Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ jobs:
- name: Code Coverage
run: bundle exec fastlane coverage

- name: Setup sonarqube
uses: warchant/setup-sonar-scanner@v8

- name: Send to Sonarcloud
run: bundle exec fastlane sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# Commenting Sonarqube steps for now, until we are able to configure Sonarqube in Ionic repos
#- name: Setup sonarqube
# uses: warchant/setup-sonar-scanner@v8

#- name: Send to Sonarcloud
# run: bundle exec fastlane sonarqube
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ android {
"outputs/code-coverage/connected/*coverage.ec"
]))
}

testOptions {
unitTests.returnDefaultValues = true
}
}

repositories {
Expand Down Expand Up @@ -88,7 +92,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:4.0.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.4.0'
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
}

This file was deleted.

6 changes: 3 additions & 3 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<application android:requestLegacyExternalStorage="true">
<activity
android:name="io.ionic.libs.ioncameralib.view.IONLoadingActivity"
android:name="io.ionic.libs.ioncameralib.view.IONCAMRLoadingActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="io.ionic.libs.ioncameralib.view.ImageEditorActivity"
android:name="io.ionic.libs.ioncameralib.view.IONCAMRImageEditorActivity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:enableOnBackInvokedCallback="true"
tools:targetApi="33" />
<activity
android:name="io.ionic.libs.ioncameralib.view.IONOpenPhotoPickerActivity"
android:name="io.ionic.libs.ioncameralib.view.IONCAMROpenPhotoPickerActivity"
android:exported="false"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<!-- Trigger Google Play services to install the backported photo picker module. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import android.media.ExifInterface
import android.net.Uri
import java.io.IOException

class OSCAMRExifHelper : OSCAMRExifHelperInterface {
class IONCAMRExifHelper : IONCAMRExifHelperInterface {

private var aperture: String? = null
private var datetime: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.ionic.libs.ioncameralib.helper
import android.media.ExifInterface
import android.net.Uri

interface OSCAMRExifHelperInterface {
interface IONCAMRExifHelperInterface {

fun createInFile(filePath: String?)
fun createOutFile(filePath: String?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import java.nio.file.Files
import java.nio.file.attribute.BasicFileAttributes
import java.util.*

class OSCAMRFileHelper: OSCAMRFileHelperInterface {
class IONCAMRFileHelper: IONCAMRFileHelperInterface {

companion object {
private const val LOG_TAG = "OSCAMRFileHelper"
private const val LOG_TAG = "IONCAMRFileHelper"
private const val EXTERNAL_STORAGE = "com.android.externalstorage.documents"
private const val DOWNLOADS_DOCUMENTS = "com.android.providers.downloads.documents"
private const val PROVIDERS_MEDIA = "com.android.providers.media.documents"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.net.Uri
import java.io.File
import java.io.InputStream

interface OSCAMRFileHelperInterface {
interface IONCAMRFileHelperInterface {
fun getRealPath(uri: Uri?, context: Context?): String?
fun getRealPath(uriString: String, context: Context): String?
fun getUriFromString(uriString: String): Uri
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.ionic.libs.ioncameralib.helper

class OSCAMRGalleryHelper(val picturesDirectory: String?, val galleryFileName: String?) {
class IONCAMRGalleryHelper(val picturesDirectory: String?, val galleryFileName: String?) {

var galleryPath = this.picturesDirectory + "/" + this.galleryFileName

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import android.graphics.Matrix
import android.net.Uri
import android.util.Base64
import androidx.core.graphics.scale
import io.ionic.libs.ioncameralib.model.IONError
import io.ionic.libs.ioncameralib.model.IONCAMRError
import java.io.*

class OSCAMRImageHelper: OSCAMRImageHelperInterface {
class IONCAMRImageHelper: IONCAMRImageHelperInterface {

companion object {
private const val JPEG = 0
Expand Down Expand Up @@ -50,9 +50,9 @@ class OSCAMRImageHelper: OSCAMRImageHelperInterface {
return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
}

override fun compressImage(activity: Activity?, uri: Uri?, bitmap: Bitmap?, compressFormat: CompressFormat, mQuality: Int, onError : (IONError) -> Unit){
override fun compressImage(activity: Activity?, uri: Uri?, bitmap: Bitmap?, compressFormat: CompressFormat, mQuality: Int, onError : (IONCAMRError) -> Unit){
if(bitmap == null || uri == null || activity == null){
onError(IONError.PROCESS_IMAGE_ERROR)
onError(IONCAMRError.PROCESS_IMAGE_ERROR)
return
}
val os: OutputStream? =
Expand All @@ -68,7 +68,7 @@ class OSCAMRImageHelper: OSCAMRImageHelperInterface {
*
* @param bitmap
*/
override fun processPicture(bitmap: Bitmap?, encodingType: Int, mQuality: Int, onSuccess : (String) -> Unit, onError : (IONError) -> Unit) {
override fun processPicture(bitmap: Bitmap?, encodingType: Int, mQuality: Int, onSuccess : (String) -> Unit, onError : (IONCAMRError) -> Unit) {
val jpegData = ByteArrayOutputStream()
val compressFormat: CompressFormat =
if (encodingType == JPEG) CompressFormat.JPEG else CompressFormat.PNG
Expand All @@ -80,7 +80,7 @@ class OSCAMRImageHelper: OSCAMRImageHelperInterface {
onSuccess(jsOut)
}
} catch (e: Exception) {
onError(IONError.PROCESS_IMAGE_ERROR)
onError(IONCAMRError.PROCESS_IMAGE_ERROR)
}
}

Expand All @@ -92,7 +92,7 @@ class OSCAMRImageHelper: OSCAMRImageHelperInterface {
return BitmapFactory.decodeFile(resultImagePath)
}

override fun bitmapToBase64(result: Bitmap?, resolution: Int, quality: Int, onSuccess : (String) -> Unit, onError : (IONError) -> Unit) {
override fun bitmapToBase64(result: Bitmap?, resolution: Int, quality: Int, onSuccess : (String) -> Unit, onError : (IONCAMRError) -> Unit) {
val byteArrayOutputStream = ByteArrayOutputStream()
result?.let {
val resizedImage = this.downsizeBitmapIfNeeded(it, resolution)
Expand All @@ -104,7 +104,7 @@ class OSCAMRImageHelper: OSCAMRImageHelperInterface {
}
}

onError(IONError.EDIT_IMAGE_ERROR)
onError(IONCAMRError.EDIT_IMAGE_ERROR)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Matrix
import android.net.Uri
import io.ionic.libs.ioncameralib.model.IONError
import io.ionic.libs.ioncameralib.model.IONCAMRError
import java.io.File
import java.io.InputStream

interface OSCAMRImageHelperInterface {
interface IONCAMRImageHelperInterface {
fun getBitmapForInputStream(fileStream: InputStream?): Bitmap?
fun downsizeBitmapIfNeeded(bitmap: Bitmap, resolution: Int): Bitmap
fun compressBitmap(bitmap: Bitmap, quality: Int): Bitmap
fun compressImage(activity: Activity?, uri: Uri?, bitmap: Bitmap?, compressFormat: Bitmap.CompressFormat, mQuality: Int, onError : (IONError) -> Unit)
fun processPicture(bitmap: Bitmap?, encodingType: Int, mQuality: Int, onSuccess : (String) -> Unit, onError : (IONError) -> Unit)
fun compressImage(activity: Activity?, uri: Uri?, bitmap: Bitmap?, compressFormat: Bitmap.CompressFormat, mQuality: Int, onError : (IONCAMRError) -> Unit)
fun processPicture(bitmap: Bitmap?, encodingType: Int, mQuality: Int, onSuccess : (String) -> Unit, onError : (IONCAMRError) -> Unit)
fun decodeStream(fileStream: InputStream?, options: BitmapFactory.Options): Bitmap?
fun decodeFile(resultImagePath: String?): Bitmap?
fun bitmapToBase64(result: Bitmap?, resolution: Int, quality: Int, onSuccess : (String) -> Unit, onError : (IONError) -> Unit)
fun bitmapToBase64(result: Bitmap?, resolution: Int, quality: Int, onSuccess : (String) -> Unit, onError : (IONCAMRError) -> Unit)
fun base64toBitmap(imageByteArray: ByteArray): Bitmap?
fun writeBitmapToFile(imageBitmap: Bitmap?, inputFile: File?)
fun getScaledBitmap(unscaledBitmap: Bitmap?, scaledWidth: Int, scaledHeight: Int): Bitmap?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.ByteArrayOutputStream

class OSCAMRMediaHelper : OSCAMRMediaHelperInterface {
class IONCAMRMediaHelper : IONCAMRMediaHelperInterface {

companion object {
private const val CAMERA = 1
private const val LOG_TAG = "OSCAMRMediaHelper"
private const val LOG_TAG = "IONCAMRMediaHelper"
const val REQUEST_VIDEO_CAPTURE = 1
const val REQUEST_VIDEO_CAPTURE_SAVE_TO_GALLERY = 2
}
Expand Down Expand Up @@ -111,7 +111,7 @@ class OSCAMRMediaHelper : OSCAMRMediaHelperInterface {
return intent.resolveActivity(packageManager) != null
}

/*override fun openDeviceVideo(
override fun openDeviceVideo(
activity: Activity?,
intent: Intent,
videoFileUri: Uri?,
Expand All @@ -122,7 +122,7 @@ class OSCAMRMediaHelper : OSCAMRMediaHelperInterface {
intent,
if (!saveToGallery) REQUEST_VIDEO_CAPTURE else REQUEST_VIDEO_CAPTURE_SAVE_TO_GALLERY
)
}*/
}

override fun createDeviceVideoIntent(activity: Activity?, intent: Intent, videoFileUri: Uri?, saveToGallery: Boolean, ): Intent? {
val safeActivity = activity ?: return null
Expand Down Expand Up @@ -154,13 +154,14 @@ class OSCAMRMediaHelper : OSCAMRMediaHelperInterface {
return null
}

override fun getVideoDuration(activity: Activity, uri: Uri): Long {
override fun getVideoDuration(activity: Activity, uri: Uri): Int {
val mediaPlayer = MediaPlayer.create(activity, uri)
val duration = mediaPlayer?.duration?.toLong() ?: 0L
val duration = mediaPlayer?.duration ?: 0
mediaPlayer?.release()
return duration
}


override fun getVideoResolution(activity: Activity?, uri: Uri): Pair<Int, Int> {
val metaRetriever = MediaMetadataRetriever()
metaRetriever.setDataSource(activity, uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.content.Intent
import android.database.Cursor
import android.net.Uri

interface OSCAMRMediaHelperInterface {
interface IONCAMRMediaHelperInterface {
fun openDeviceCamera(activity: Activity?, imageUri: Uri?, returnType: Int)
fun createCameraIntent(activity: Activity?, imageUri: Uri?): Intent?
fun getCursor(activity: Activity?, contentStore: Uri): Cursor?
Expand All @@ -14,10 +14,11 @@ interface OSCAMRMediaHelperInterface {
fun getStringNumber(cursor: Cursor?, int: Int?): String?
fun equalsDifference(currentNumOfImages: Int, numPics: Int?, diff: Int): Boolean
fun existsActivity(activity: Activity?, intent: Intent): Boolean
fun openDeviceVideo(activity: Activity?, intent: Intent, videoFileUri: Uri?, saveToGallery: Boolean)
fun createDeviceVideoIntent(activity: Activity?, intent: Intent, videoFileUri: Uri?, saveToGallery: Boolean): Intent?
fun getVideoPathFromUri(activity: Activity, uri: Uri): String?
suspend fun getThumbnailBase64String(activity: Activity, videoUri: Uri, targetDimension: Int): String?
fun getVideoDuration(activity: Activity, uri: Uri): Long
fun getVideoDuration(activity: Activity, uri: Uri): Int
fun getVideoResolution(activity: Activity?, uri: Uri): Pair<Int, Int>
fun getImageResolution(imagePath: String): Pair<Int, Int>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.graphics.Bitmap
import android.graphics.Matrix
import android.graphics.Rect

class OSCAMRImageEditorController : OSCAMRImageEditorControllerInterface {
class IONCAMRImageEditorController : IONCAMRImageEditorControllerInterface {

override suspend fun rotateLeft(image: Bitmap): Bitmap {
val rotationMatrix = Matrix().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.ionic.libs.ioncameralib.imageeditor
import android.graphics.Bitmap
import android.graphics.Rect

interface OSCAMRImageEditorControllerInterface {
interface IONCAMRImageEditorControllerInterface {
suspend fun rotateLeft(image: Bitmap): Bitmap
suspend fun crop(image: Bitmap, rect: Rect) : Bitmap
suspend fun flip(image: Bitmap): Bitmap
Expand Down
Loading
Loading