Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52358a7d authored by Mark Harman's avatar Mark Harman
Browse files

Using AndroidX ExifInterface means we can now get rid of pre-Android 6, 7 codepaths.

parent 5bf3cb0a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -899,10 +899,10 @@ photos will still be as the camera (or other people) view the scene. This option
resultant photo, so the resultant photo matches the mirrored image you see on the screen.</p>

<p><b>Artist</b> - If text is entered in this setting, then the text will be stored in the image's Exif metadata as the
    "Artist" tag. Only supported for JPEG format. Not supported for RAW photos (DNG format). (Requires Android 7.)</p>
    "Artist" tag. Only supported for JPEG format. Not supported for RAW photos (DNG format).</p>

<p><b>Copyright</b> - If text is entered in this setting, then the text will be stored in the image's Exif metadata as the
    "Copyright" tag. Only supported for JPEG format. Not supported for RAW photos (DNG format). (Requires Android 7.)</p>
    "Copyright" tag. Only supported for JPEG format. Not supported for RAW photos (DNG format).</p>

<p><a name="stamp_photos"><b>Stamp photos</b></a> - Option to add a date and timestamp to the resultant photos. If "Store
location data" is enabled (see "Location settings" below), then the current location latitude
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ Version 1.48.2 (Work in progress)

FIXED   Manual focus and focus bracketing seekbars weren't being hidden when in immersive mode.
UPDATED Switched to AndroidX support library.
UPDATED Artist, Copyright exif tags option now supported for devices running Android 6 or earlier.
UPDATED Selecting remote device type for Bluetooth remote control no longer calls DeviceScanner
        activity directly; DeviceScanner activity no longer exported.

+99 −237

File changed.

Preview size limit exceeded, changes collapsed.

+2 −14
Original line number Diff line number Diff line
@@ -641,20 +641,8 @@ public class MyPreferenceFragment extends PreferenceFragment implements OnShared
            pg.removePreference(pref);
        }

        if( Build.VERSION.SDK_INT < Build.VERSION_CODES.N ) {
            // the required ExifInterface tags requires Android N or greater
            Preference pref = findPreference("preference_category_exif_tags");
            PreferenceGroup pg = (PreferenceGroup)this.findPreference("preference_screen_photo_settings");
            pg.removePreference(pref);

            pref = findPreference("preference_comment_ypr");
            pg = (PreferenceGroup)this.findPreference("preference_screen_location_settings");
            pg.removePreference(pref);
        }
        else {
        setSummary("preference_exif_artist");
        setSummary("preference_exif_copyright");
        }

        setSummary("preference_save_photo_prefix");
        setSummary("preference_save_video_prefix");
+12 −17
Original line number Diff line number Diff line
package net.sourceforge.opencamera.ui;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
@@ -44,7 +43,6 @@ import android.location.Location;
import androidx.exifinterface.media.ExifInterface;
import android.net.Uri;
import android.os.BatteryManager;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Log;
import android.util.Pair;
@@ -593,8 +591,7 @@ public class DrawPreview {
                }
                Uri uri = Uri.parse(ghost_selected_image_pref);
                try {
                    File file = main_activity.getStorageUtils().getFileFromDocumentUriSAF(uri, false);
                    ghost_selected_image_bitmap = loadBitmap(uri, file);
                    ghost_selected_image_bitmap = loadBitmap(uri);
                }
                catch(IOException e) {
                    Log.e(TAG, "failed to load ghost_selected_image uri: " + uri);
@@ -682,11 +679,10 @@ public class DrawPreview {
        }
    }

    /** Loads the bitmap from the uri. File is optional, and is used on pre-Android 7 devices to
     *  read the exif orientation.
    /** Loads the bitmap from the uri.
     *  The image will be downscaled if required to be comparable to the preview width.
     */
    private Bitmap loadBitmap(Uri uri, File file) throws IOException {
    private Bitmap loadBitmap(Uri uri) throws IOException {
        if( MyDebug.LOG )
            Log.d(TAG, "loadBitmap: " + uri);
        Bitmap bitmap;
@@ -755,18 +751,17 @@ public class DrawPreview {

        // now need to take exif orientation into account, as some devices or camera apps store the orientation in the exif tag,
        // which getBitmap() doesn't account for
        ExifInterface exif = null;
        if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ) {
            // better to use the Uri from Android 7, so this works when images are shared to Vibrance
            try( InputStream inputStream = main_activity.getContentResolver().openInputStream(uri) ) {
        ExifInterface exif;
        InputStream inputStream = null;
        try {
            inputStream = main_activity.getContentResolver().openInputStream(uri);
            exif = new ExifInterface(inputStream);
        }
        finally {
            if( inputStream != null )
                inputStream.close();
        }
        else {
            if( file != null ) {
                exif = new ExifInterface(file.getAbsolutePath());
            }
        }

        if( exif != null ) {
            int exif_orientation_s = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
            boolean needs_tf = false;