forked from getodk/collect
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from tiritea/master
Update to ODK Collect v2024.2.4 release
- Loading branch information
Showing
862 changed files
with
21,592 additions
and
9,128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
root = true | ||
|
||
[*.{kt,kts}] | ||
ktlint_standard_no-blank-lines-in-chained-method-calls = disabled | ||
ktlint_standard_trailing-comma-on-call-site = disabled | ||
ktlint_standard_trailing-comma-on-declaration-site = disabled | ||
ktlint_standard_function-signature = disabled | ||
ktlint_standard_no-empty-first-line-in-class-body = disabled | ||
ktlint_standard_argument-list-wrapping = disabled | ||
ktlint_standard_parameter-list-wrapping = disabled | ||
ktlint_standard_multiline-expression-wrapping = disabled | ||
ktlint_standard_max-line-length = disabled | ||
ktlint_standard_string-template-indent = disabled | ||
ktlint_standard_annotation = disabled | ||
ktlint_standard_value-parameter-comment = disabled | ||
ktlint_standard_property-naming = disabled | ||
ktlint_standard_value-argument-comment = disabled | ||
ktlint_standard_blank-line-before-declaration = disabled | ||
ktlint_standard_no-consecutive-comments = disabled | ||
ktlint_standard_enum-wrapping = disabled | ||
ktlint_standard_statement-wrapping = disabled | ||
ktlint_standard_try-catch-finally-spacing = disabled | ||
ktlint_standard_wrapping = disabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
androidshared/src/main/java/org/odk/collect/androidshared/network/ConnectivityProvider.kt
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
androidshared/src/main/java/org/odk/collect/androidshared/network/NetworkStateProvider.kt
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
androidshared/src/main/java/org/odk/collect/androidshared/system/UriExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.odk.collect.androidshared.system | ||
|
||
import android.content.ContentResolver | ||
import android.content.Context | ||
import android.net.Uri | ||
import android.provider.OpenableColumns | ||
import android.webkit.MimeTypeMap | ||
import androidx.core.net.toFile | ||
import java.io.File | ||
import java.io.FileOutputStream | ||
|
||
fun Uri.copyToFile(context: Context, dest: File) { | ||
try { | ||
context.contentResolver.openInputStream(this)?.use { inputStream -> | ||
FileOutputStream(dest).use { outputStream -> | ||
inputStream.copyTo(outputStream) | ||
} | ||
} | ||
} catch (e: Exception) { | ||
// ignore | ||
} | ||
} | ||
|
||
fun Uri.getFileExtension(context: Context): String? { | ||
var extension = getFileName(context)?.substringAfterLast(".", "") | ||
|
||
if (extension.isNullOrEmpty()) { | ||
val mimeType = context.contentResolver.getType(this) | ||
|
||
extension = if (scheme == ContentResolver.SCHEME_CONTENT) { | ||
MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType) | ||
} else { | ||
MimeTypeMap.getFileExtensionFromUrl(toString()) | ||
} | ||
|
||
if (extension.isNullOrEmpty()) { | ||
extension = mimeType?.substringAfterLast("/", "") | ||
} | ||
} | ||
|
||
return if (extension.isNullOrEmpty()) { | ||
null | ||
} else { | ||
".$extension" | ||
} | ||
} | ||
|
||
fun Uri.getFileName(context: Context): String? { | ||
var fileName: String? = null | ||
|
||
try { | ||
when (scheme) { | ||
ContentResolver.SCHEME_FILE -> fileName = toFile().name | ||
ContentResolver.SCHEME_CONTENT -> { | ||
val cursor = context.contentResolver.query(this, null, null, null, null) | ||
cursor?.use { | ||
if (it.moveToFirst()) { | ||
val fileNameColumnIndex = it.getColumnIndex(OpenableColumns.DISPLAY_NAME) | ||
if (fileNameColumnIndex != -1) { | ||
fileName = it.getString(fileNameColumnIndex) | ||
} | ||
} | ||
} | ||
} | ||
ContentResolver.SCHEME_ANDROID_RESOURCE -> { | ||
// for uris like [android.resource://com.example.app/1234567890] | ||
val resourceId = lastPathSegment?.toIntOrNull() | ||
if (resourceId != null) { | ||
fileName = context.resources.getResourceName(resourceId) | ||
} else { | ||
// for uris like [android.resource://com.example.app/raw/sample] | ||
val packageName = authority | ||
if (pathSegments.size >= 2) { | ||
val resourceType = pathSegments[0] | ||
val resourceEntryName = pathSegments[1] | ||
val resId = context.resources.getIdentifier(resourceEntryName, resourceType, packageName) | ||
if (resId != 0) { | ||
fileName = context.resources.getResourceName(resId) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (fileName == null) { | ||
fileName = path?.substringAfterLast("/") | ||
} | ||
} catch (e: Exception) { | ||
// ignore | ||
} | ||
|
||
return fileName | ||
} |
Oops, something went wrong.