mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Migrated filepicker from Java to Kotlin (#5997)
* Rename .java to .kt * Migrated filepicker module from Java to Kotlin * Rename .java to .kt * Migrated filepicker module from Java to Kotlin * fix: test cases
This commit is contained in:
parent
3777f18bf9
commit
f8d519e8eb
21 changed files with 970 additions and 929 deletions
|
|
@ -1,32 +0,0 @@
|
|||
package fr.free.nrw.commons.filepicker;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.OpenableColumns;
|
||||
import androidx.core.content.FileProvider;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(FileProvider.class)
|
||||
public class ShadowFileProvider {
|
||||
|
||||
@Implementation
|
||||
public Cursor query(final Uri uri, final String[] projection, final String selection,
|
||||
final String[] selectionArgs,
|
||||
final String sortOrder) {
|
||||
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String[] columns = {OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE};
|
||||
final Object[] values = {"dummy", 500};
|
||||
final MatrixCursor cursor = new MatrixCursor(columns, 1);
|
||||
|
||||
if (!uri.equals(Uri.EMPTY)) {
|
||||
cursor.addRow(values);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package fr.free.nrw.commons.filepicker
|
||||
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.net.Uri
|
||||
import android.provider.OpenableColumns
|
||||
import androidx.core.content.FileProvider
|
||||
import org.robolectric.annotation.Implementation
|
||||
import org.robolectric.annotation.Implements
|
||||
|
||||
@Implements(FileProvider::class)
|
||||
class ShadowFileProvider {
|
||||
|
||||
@Implementation
|
||||
fun query(
|
||||
uri: Uri?,
|
||||
projection: Array<String>?,
|
||||
selection: String?,
|
||||
selectionArgs: Array<String>?,
|
||||
sortOrder: String?
|
||||
): Cursor? {
|
||||
|
||||
if (uri == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
val columns = arrayOf(OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE)
|
||||
val values = arrayOf<Any>("dummy", 500)
|
||||
val cursor = MatrixCursor(columns, 1)
|
||||
|
||||
if (uri != Uri.EMPTY) {
|
||||
cursor.addRow(values)
|
||||
}
|
||||
return cursor
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ class UploadPresenterTest {
|
|||
`when`(repository.buildContributions()).thenReturn(Observable.just(contribution))
|
||||
uploadableFiles.add(uploadableFile)
|
||||
`when`(view.uploadableFiles).thenReturn(uploadableFiles)
|
||||
`when`(uploadableFile.filePath).thenReturn("data://test")
|
||||
`when`(uploadableFile.getFilePath()).thenReturn("data://test")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue