mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-30 22:34:02 +01:00 
			
		
		
		
	Migrated filepicker module from Java to Kotlin
This commit is contained in:
		
							parent
							
								
									6c319362bb
								
							
						
					
					
						commit
						24181a8fb8
					
				
					 2 changed files with 25 additions and 21 deletions
				
			
		|  | @ -1,32 +1,36 @@ | ||||||
| package fr.free.nrw.commons.filepicker; | package fr.free.nrw.commons.filepicker | ||||||
| 
 | 
 | ||||||
| import android.database.Cursor; | import android.database.Cursor | ||||||
| import android.database.MatrixCursor; | import android.database.MatrixCursor | ||||||
| import android.net.Uri; | import android.net.Uri | ||||||
| import android.provider.OpenableColumns; | import android.provider.OpenableColumns | ||||||
| import androidx.core.content.FileProvider; | import androidx.core.content.FileProvider | ||||||
| import org.robolectric.annotation.Implementation; | import org.robolectric.annotation.Implementation | ||||||
| import org.robolectric.annotation.Implements; | import org.robolectric.annotation.Implements | ||||||
| 
 | 
 | ||||||
| @Implements(FileProvider.class) | @Implements(FileProvider::class) | ||||||
| public class ShadowFileProvider { | class ShadowFileProvider { | ||||||
| 
 | 
 | ||||||
|     @Implementation |     @Implementation | ||||||
|     public Cursor query(final Uri uri, final String[] projection, final String selection, |     fun query( | ||||||
|         final String[] selectionArgs, |         uri: Uri?, | ||||||
|         final String sortOrder) { |         projection: Array<String>?, | ||||||
|  |         selection: String?, | ||||||
|  |         selectionArgs: Array<String>?, | ||||||
|  |         sortOrder: String? | ||||||
|  |     ): Cursor? { | ||||||
| 
 | 
 | ||||||
|         if (uri == null) { |         if (uri == null) { | ||||||
|             return null; |             return null | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         final String[] columns = {OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}; |         val columns = arrayOf(OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE) | ||||||
|         final Object[] values = {"dummy", 500}; |         val values = arrayOf<Any>("dummy", 500) | ||||||
|         final MatrixCursor cursor = new MatrixCursor(columns, 1); |         val cursor = MatrixCursor(columns, 1) | ||||||
| 
 | 
 | ||||||
|         if (!uri.equals(Uri.EMPTY)) { |         if (uri != Uri.EMPTY) { | ||||||
|             cursor.addRow(values); |             cursor.addRow(values) | ||||||
|         } |         } | ||||||
|         return cursor; |         return cursor | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -62,7 +62,7 @@ class UploadPresenterTest { | ||||||
|         `when`(repository.buildContributions()).thenReturn(Observable.just(contribution)) |         `when`(repository.buildContributions()).thenReturn(Observable.just(contribution)) | ||||||
|         uploadableFiles.add(uploadableFile) |         uploadableFiles.add(uploadableFile) | ||||||
|         `when`(view.uploadableFiles).thenReturn(uploadableFiles) |         `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
	
	 Saifuddin
						Saifuddin