mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-03 08:13:55 +01:00
Convert FileMetadataUtils to kotlin
This commit is contained in:
parent
36f457b1ae
commit
7ff3e5f62c
2 changed files with 61 additions and 59 deletions
|
|
@ -1,59 +0,0 @@
|
||||||
package fr.free.nrw.commons.upload;
|
|
||||||
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_ARTIST;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_BODY_SERIAL_NUMBER;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_CAMERA_OWNER_NAME;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_COPYRIGHT;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_ALTITUDE;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_ALTITUDE_REF;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_LATITUDE;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_LATITUDE_REF;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_LONGITUDE;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_GPS_LONGITUDE_REF;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_LENS_MAKE;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_LENS_MODEL;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_LENS_SERIAL_NUMBER;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_LENS_SPECIFICATION;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_MAKE;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_MODEL;
|
|
||||||
import static androidx.exifinterface.media.ExifInterface.TAG_SOFTWARE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Support utils for EXIF metadata handling
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FileMetadataUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes EXIF label from sharedPreferences as input and returns relevant EXIF tags
|
|
||||||
*
|
|
||||||
* @param pref EXIF sharedPreference label
|
|
||||||
* @return EXIF tags
|
|
||||||
*/
|
|
||||||
public static String[] getTagsFromPref(String pref) {
|
|
||||||
Timber.d("Retuning tags for pref:%s", pref);
|
|
||||||
switch (pref) {
|
|
||||||
case "Author":
|
|
||||||
return new String[]{TAG_ARTIST, TAG_CAMERA_OWNER_NAME};
|
|
||||||
case "Copyright":
|
|
||||||
return new String[]{TAG_COPYRIGHT};
|
|
||||||
case "Location":
|
|
||||||
return new String[]{TAG_GPS_LATITUDE, TAG_GPS_LATITUDE_REF,
|
|
||||||
TAG_GPS_LONGITUDE, TAG_GPS_LONGITUDE_REF,
|
|
||||||
TAG_GPS_ALTITUDE, TAG_GPS_ALTITUDE_REF};
|
|
||||||
case "Camera Model":
|
|
||||||
return new String[]{TAG_MAKE, TAG_MODEL};
|
|
||||||
case "Lens Model":
|
|
||||||
return new String[]{TAG_LENS_MAKE, TAG_LENS_MODEL, TAG_LENS_SPECIFICATION};
|
|
||||||
case "Serial Numbers":
|
|
||||||
return new String[]{TAG_BODY_SERIAL_NUMBER, TAG_LENS_SERIAL_NUMBER};
|
|
||||||
case "Software":
|
|
||||||
return new String[]{TAG_SOFTWARE};
|
|
||||||
default:
|
|
||||||
return new String[]{};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package fr.free.nrw.commons.upload
|
||||||
|
|
||||||
|
import androidx.exifinterface.media.ExifInterface
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support utils for EXIF metadata handling
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
object FileMetadataUtils {
|
||||||
|
/**
|
||||||
|
* Takes EXIF label from sharedPreferences as input and returns relevant EXIF tags
|
||||||
|
*
|
||||||
|
* @param pref EXIF sharedPreference label
|
||||||
|
* @return EXIF tags
|
||||||
|
*/
|
||||||
|
fun getTagsFromPref(pref: String): Array<String> {
|
||||||
|
Timber.d("Retuning tags for pref:%s", pref)
|
||||||
|
return when (pref) {
|
||||||
|
"Author" -> arrayOf(
|
||||||
|
ExifInterface.TAG_ARTIST,
|
||||||
|
ExifInterface.TAG_CAMERA_OWNER_NAME
|
||||||
|
)
|
||||||
|
|
||||||
|
"Copyright" -> arrayOf(
|
||||||
|
ExifInterface.TAG_COPYRIGHT
|
||||||
|
)
|
||||||
|
|
||||||
|
"Location" -> arrayOf(
|
||||||
|
ExifInterface.TAG_GPS_LATITUDE,
|
||||||
|
ExifInterface.TAG_GPS_LATITUDE_REF,
|
||||||
|
ExifInterface.TAG_GPS_LONGITUDE,
|
||||||
|
ExifInterface.TAG_GPS_LONGITUDE_REF,
|
||||||
|
ExifInterface.TAG_GPS_ALTITUDE,
|
||||||
|
ExifInterface.TAG_GPS_ALTITUDE_REF
|
||||||
|
)
|
||||||
|
|
||||||
|
"Camera Model" -> arrayOf(
|
||||||
|
ExifInterface.TAG_MAKE,
|
||||||
|
ExifInterface.TAG_MODEL
|
||||||
|
)
|
||||||
|
|
||||||
|
"Lens Model" -> arrayOf(
|
||||||
|
ExifInterface.TAG_LENS_MAKE,
|
||||||
|
ExifInterface.TAG_LENS_MODEL,
|
||||||
|
ExifInterface.TAG_LENS_SPECIFICATION
|
||||||
|
)
|
||||||
|
|
||||||
|
"Serial Numbers" -> arrayOf(
|
||||||
|
ExifInterface.TAG_BODY_SERIAL_NUMBER,
|
||||||
|
ExifInterface.TAG_LENS_SERIAL_NUMBER
|
||||||
|
)
|
||||||
|
|
||||||
|
"Software" -> arrayOf(
|
||||||
|
ExifInterface.TAG_SOFTWARE
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> arrayOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue