mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* Add XML map icons with a tick/question mark for the Upload Wizard The existing map icon may not be intuitive enough to indicate whether the location EXIF data will be included The two new XML map icons are intended to indicate the status of location sharing with the location data in the Upload Wizard * Label the map icon in the Upload Wizard if location is included If an image is capture with the in-app camera, the location in the image metadata by default If so, the map icon in the Upload Wizard should be labelled with a green tick during initialisation of its UploadMediaDetailFragment instance * Update the map icon in Upload Wizard if location is pin-pointed If the user selects images from the device storage to upload, the location EXIF data might originally not be included The map icon is labelled with a red question mark After pin-pointing the location manully, the map icon should be labelled with a green tick instead * Fix Upload Wizard map icon XML rendering failure SVG path is invalid, resulting in failure to render the icons Also imports are required for UploadMediaDetailFragment to use Drawable objects and R objects * Add hasLocation() to UploadableFile to indicate existence of EXIF When an image is chosen from the album to the Upload Wizard, its EXIF might contain location data. hasLocation() and fix of init() in UploadMediaDetailFragment ensures that the map icon is shown correctly * Fix init() NullPointerException in UploadMediaDetailFragment * Fix comment typo in UploadMediaDetailFragment Fix the comment about red and green labels for the map icon * Use SLF4J logging for try-catch clauses in UploadableFile class Instead of using printStackTrace(), error directed to logcat * Use Timber for logging in UploadableFile Clean up the catch clause in hasLocation() and getDataTimeFromExif()
This commit is contained in:
parent
64652b987d
commit
f7164d0b78
6 changed files with 90 additions and 13 deletions
|
|
@ -10,13 +10,11 @@ import android.os.Parcelable;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
import fr.free.nrw.commons.upload.FileUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import fr.free.nrw.commons.upload.FileUtils;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class UploadableFile implements Parcelable {
|
||||
public static final Creator<UploadableFile> CREATOR = new Creator<UploadableFile>() {
|
||||
|
|
@ -74,7 +72,6 @@ public class UploadableFile implements Parcelable {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* First try to get the file creation date from EXIF else fall back to CP
|
||||
* @param context
|
||||
|
|
@ -118,6 +115,24 @@ public class UploadableFile implements Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether the EXIF contains the location (both latitude and longitude).
|
||||
*
|
||||
* @return whether the location exists for the file's EXIF
|
||||
*/
|
||||
public boolean hasLocation() {
|
||||
try {
|
||||
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
|
||||
final String latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
|
||||
final String longitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
|
||||
return latitude != null && longitude != null;
|
||||
} catch (IOException | NumberFormatException | IndexOutOfBoundsException e) {
|
||||
Timber.tag("UploadableFile");
|
||||
Timber.d(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filePath creation date from uri from EXIF
|
||||
*
|
||||
|
|
@ -143,13 +158,9 @@ public class UploadableFile implements Parcelable {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException | NumberFormatException | IndexOutOfBoundsException e) {
|
||||
Timber.tag("UploadableFile");
|
||||
Timber.d(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
|
@ -47,6 +48,7 @@ import fr.free.nrw.commons.upload.UploadMediaDetailAdapter;
|
|||
import fr.free.nrw.commons.utils.DialogUtil;
|
||||
import fr.free.nrw.commons.utils.ImageUtils;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import fr.free.nrw.commons.R.drawable.*;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
|
@ -180,6 +182,18 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
btnPrevious.setAlpha(1.0f);
|
||||
}
|
||||
|
||||
// If the image EXIF data contains the location, show the map icon with a green tick
|
||||
if (inAppPictureLocation != null ||
|
||||
(uploadableFile != null && uploadableFile.hasLocation())) {
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_tick_white_24dp);
|
||||
ibMap.setImageDrawable(mapTick);
|
||||
} else {
|
||||
// Otherwise, show the map icon with a red question mark
|
||||
Drawable mapQuestionMark =
|
||||
getResources().getDrawable(R.drawable.ic_map_question_white_24dp);
|
||||
ibMap.setImageDrawable(mapQuestionMark);
|
||||
}
|
||||
|
||||
//If this is the last media, we have nothing to copy, lets not show the button
|
||||
if (callback.getIndexInViewFlipper(this) == callback.getTotalNumberOfSteps()-4) {
|
||||
btnCopyToSubsequentMedia.setVisibility(View.GONE);
|
||||
|
|
@ -188,7 +202,6 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
}
|
||||
|
||||
attachImageViewScaleChangeListener();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -540,6 +553,11 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
editableUploadItem.getGpsCoords().setDecimalCoords(latitude+"|"+longitude);
|
||||
editableUploadItem.getGpsCoords().setImageCoordsExists(true);
|
||||
editableUploadItem.getGpsCoords().setZoomLevel(zoom);
|
||||
|
||||
// Replace the map icon using the one with a green tick
|
||||
Drawable mapTick = getResources().getDrawable(R.drawable.ic_map_tick_white_24dp);
|
||||
ibMap.setImageDrawable(mapTick);
|
||||
|
||||
Toast.makeText(getContext(), "Location Updated", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
|
|
|||
12
app/src/main/res/drawable/ic_map_question_dark_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_map_question_dark_24dp.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/half_standard_height"
|
||||
android:height="@dimen/half_standard_height"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/button_background_dark"
|
||||
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||
<path
|
||||
android:fillColor="#FF0000"
|
||||
android:pathData="m16.544673,17.112357 q 0,-0.811828 0.149547,-1.388654 0.170911,-0.598188 0.555461,-1.132286 0.405915,-0.534097 1.08956,-1.110923 0.833191,-0.705008 1.281834,-1.175014 0.470006,-0.470006 0.66228,-0.918647 0.192275,-0.448643 0.192275,-1.08956 0,-1.0254662 -0.662281,-1.580927 -0.66228,-0.5554621 -1.922751,-0.5554621 -1.04683,0 -1.858659,0.2777304 -0.811828,0.256367 -1.559564,0.6195535 L 13.810094,7.562695 q 0.854556,-0.4486413 1.880023,-0.7477364 1.046831,-0.2990947 2.328665,-0.2990947 2.02957,0 3.140493,1.0041031 1.110922,1.0041034 1.110922,2.734578 0,0.961377 -0.320458,1.64502 -0.299094,0.662282 -0.87592,1.239107 -0.555461,0.555461 -1.324562,1.196378 -0.705008,0.598189 -1.089558,1.046832 -0.363186,0.448641 -0.49137,0.897283 -0.128183,0.427278 -0.128183,1.046831 v 0.363186 h -1.495473 z m -0.491369,3.717318 q 0,-0.790464 0.363186,-1.110923 0.38455,-0.320458 0.961375,-0.320458 0.534098,0 0.918648,0.320458 0.38455,0.320459 0.38455,1.110923 0,0.7691 -0.38455,1.110923 -0.38455,0.341822 -0.918648,0.341822 -0.576825,0 -0.961375,-0.341822 -0.363186,-0.341823 -0.363186,-1.110923z" />
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/ic_map_question_white_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_map_question_white_24dp.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/half_standard_height"
|
||||
android:height="@dimen/half_standard_height"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||
<path
|
||||
android:fillColor="#FF0000"
|
||||
android:pathData="m 16.544673,17.112357 q 0,-0.811828 0.149547,-1.388654 0.170911,-0.598188 0.555461,-1.132286 0.405915,-0.534097 1.08956,-1.110923 0.833191,-0.705008 1.281834,-1.175014 0.470006,-0.470006 0.66228,-0.918647 0.192275,-0.448643 0.192275,-1.08956 0,-1.0254662 -0.662281,-1.580927 -0.66228,-0.5554621 -1.922751,-0.5554621 -1.04683,0 -1.858659,0.2777304 -0.811828,0.256367 -1.559564,0.6195535 L 13.810094,7.562695 q 0.854556,-0.4486413 1.880023,-0.7477364 1.046831,-0.2990947 2.328665,-0.2990947 2.02957,0 3.140493,1.0041031 1.110922,1.0041034 1.110922,2.734578 0,0.961377 -0.320458,1.64502 -0.299094,0.662282 -0.87592,1.239107 -0.555461,0.555461 -1.324562,1.196378 -0.705008,0.598189 -1.089558,1.046832 -0.363186,0.448641 -0.49137,0.897283 -0.128183,0.427278 -0.128183,1.046831 v 0.363186 h -1.495473 z m -0.491369,3.717318 q 0,-0.790464 0.363186,-1.110923 0.38455,-0.320458 0.961375,-0.320458 0.534098,0 0.918648,0.320458 0.38455,0.320459 0.38455,1.110923 0,0.7691 -0.38455,1.110923 -0.38455,0.341822 -0.918648,0.341822 -0.576825,0 -0.961375,-0.341822 -0.363186,-0.341823 -0.363186,-1.110923 z" />
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/ic_map_tick_dark_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_map_tick_dark_24dp.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/half_standard_height"
|
||||
android:height="@dimen/half_standard_height"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="@color/button_background_dark"
|
||||
android:pathData="M20.5,3m-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||
<path
|
||||
android:fillColor="#00FF00"
|
||||
android:pathData="m 11.168943,16.76403 q 0.481743,0 0.728791,0.790553 0.494095,1.482287 0.704086,1.482287 0.160581,0 0.333515,-0.247048 3.471022,-5.558576 6.423244,-8.9925417 Q 20.124427,8.907908 21.792,8.907908 q 0.395277,0 0.531153,0.074114 0.135877,0.074114 0.135877,0.1852859 0,0.1729335 -0.407629,0.6793817 -4.768024,5.7315104 -8.844314,12.1053454 -0.284105,0.444686 -1.161125,0.444686 -0.889372,0 -1.049953,-0.07411 -0.419981,-0.185286 -0.988191,-1.889916 -0.6423249,-1.889916 -0.6423249,-2.37166 0,-0.5188 0.8646679,-1.000544 0.531153,-0.296457 0.938782,-0.296457 z"/>
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/ic_map_tick_white_24dp.xml
Normal file
12
app/src/main/res/drawable/ic_map_tick_white_24dp.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="@dimen/half_standard_height"
|
||||
android:height="@dimen/half_standard_height"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M20.5,3m-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
|
||||
<path
|
||||
android:fillColor="#00FF00"
|
||||
android:pathData="m 11.168943,16.76403 q 0.481743,0 0.728791,0.790553 0.494095,1.482287 0.704086,1.482287 0.160581,0 0.333515,-0.247048 3.471022,-5.558576 6.423244,-8.9925417 Q 20.124427,8.907908 21.792,8.907908 q 0.395277,0 0.531153,0.074114 0.135877,0.074114 0.135877,0.1852859 0,0.1729335 -0.407629,0.6793817 -4.768024,5.7315104 -8.844314,12.1053454 -0.284105,0.444686 -1.161125,0.444686 -0.889372,0 -1.049953,-0.07411 -0.419981,-0.185286 -0.988191,-1.889916 -0.6423249,-1.889916 -0.6423249,-2.37166 0,-0.5188 0.8646679,-1.000544 0.531153,-0.296457 0.938782,-0.296457 z"/>
|
||||
</vector>
|
||||
Loading…
Add table
Add a link
Reference in a new issue