Skip to content

Commit 7ce3b7e

Browse files
committed
Revert a1b6973 until we find out why it uses OPEN_DOCUMENT by default on fresh install
1 parent 5073ca0 commit 7ce3b7e

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

app/src/main/java/fr/free/nrw/commons/contributions/ContributionController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ public void initiateCustomGalleryPickWithPermission(final Activity activity) {
171171
*/
172172
private void initiateGalleryUpload(final Activity activity, final boolean allowMultipleUploads) {
173173
setPickerConfiguration(activity, allowMultipleUploads);
174-
boolean openDocumentIntentPreferred = defaultKvStore.getBoolean("openDocumentPhotoPickerPref");
175-
FilePicker.openGallery(activity, 0, openDocumentIntentPreferred);
174+
boolean isGetContentPickerPreferred = defaultKvStore.getBoolean("getContentPhotoPickerPref");
175+
FilePicker.openGallery(activity, 0, isGetContentPickerPreferred);
176176
}
177177

178178
/**

app/src/main/java/fr/free/nrw/commons/filepicker/FilePicker.java

+12-13
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ private static Uri createCameraPictureFile(@NonNull Context context) throws IOEx
4747
}
4848

4949
private static Intent createGalleryIntent(@NonNull Context context, int type,
50-
boolean openDocumentIntentPreferred) {
50+
boolean isGetContentPickerPreferred) {
5151
// storing picked image type to shared preferences
5252
storeType(context, type);
53-
return plainGalleryPickerIntent(openDocumentIntentPreferred)
53+
return plainGalleryPickerIntent(isGetContentPickerPreferred)
5454
.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, configuration(context).allowsMultiplePickingInGallery());
5555
}
5656

@@ -106,8 +106,8 @@ private static int restoreType(@NonNull Context context) {
106106
*
107107
* @param type Custom type of your choice, which will be returned with the images
108108
*/
109-
public static void openGallery(Activity activity, int type, boolean openDocumentIntentPreferred) {
110-
Intent intent = createGalleryIntent(activity, type, openDocumentIntentPreferred);
109+
public static void openGallery(Activity activity, int type, boolean isGetContentPickerPreferred) {
110+
Intent intent = createGalleryIntent(activity, type, isGetContentPickerPreferred);
111111
activity.startActivityForResult(intent, RequestCodes.PICK_PICTURE_FROM_GALLERY);
112112
}
113113

@@ -201,8 +201,8 @@ private static boolean isPhoto(Intent data) {
201201
return data == null || (data.getData() == null && data.getClipData() == null);
202202
}
203203

204-
private static Intent plainGalleryPickerIntent(boolean openDocumentIntentPreferred) {
205-
/*
204+
private static Intent plainGalleryPickerIntent(boolean isGetContentPickerPreferred) {
205+
/**
206206
* Asking for ACCESS_MEDIA_LOCATION at runtime solved the location-loss issue
207207
* in the custom selector in Contributions fragment.
208208
* Detailed discussion: https://github.com/commons-app/apps-android-commons/issues/5015
@@ -217,24 +217,23 @@ private static Intent plainGalleryPickerIntent(boolean openDocumentIntentPreferr
217217
* Reported on the Google Issue Tracker: https://issuetracker.google.com/issues/243294058
218218
* Status: Won't fix (Intended behaviour)
219219
*
220-
* Switched intent from ACTION_GET_CONTENT to ACTION_OPEN_DOCUMENT (by default; can
221-
* be changed through the Setting page) as:
220+
* Switched intent from ACTION_GET_CONTENT to ACTION_OPEN_DOCUMENT
221+
* (based on user's preference) as:
222222
*
223223
* ACTION_GET_CONTENT opens the 'best application' for choosing that kind of data
224224
* The best application is the new Photo Picker that redacts the location tags
225225
*
226226
* ACTION_OPEN_DOCUMENT, however, displays the various DocumentsProvider instances
227227
* installed on the device, letting the user interactively navigate through them.
228228
*
229-
* So, this allows us to use the traditional file picker that does not redact location tags
230-
* from EXIF.
229+
* So, this allows us to use the traditional file picker that does not redact location tags from EXIF.
231230
*
232231
*/
233232
Intent intent;
234-
if (openDocumentIntentPreferred) {
235-
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
236-
} else {
233+
if (isGetContentPickerPreferred) {
237234
intent = new Intent(Intent.ACTION_GET_CONTENT);
235+
} else {
236+
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
238237
}
239238
intent.setType("image/*");
240239
return intent;

app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ public boolean onPreferenceClick(Preference preference) {
171171
return true;
172172
});
173173

174-
Preference documentBasedPickerPreference = findPreference("openDocumentPhotoPickerPref");
175-
documentBasedPickerPreference.setOnPreferenceChangeListener(
174+
Preference getContentPickerPreference = findPreference("getContentPhotoPickerPref");
175+
getContentPickerPreference.setOnPreferenceChangeListener(
176176
(preference, newValue) -> {
177-
boolean isGetContentPickerTurnedOn = !(boolean) newValue;
177+
boolean isGetContentPickerTurnedOn = (boolean) newValue;
178178
if (isGetContentPickerTurnedOn) {
179179
showLocationLossWarning();
180180
}

app/src/main/res/values/strings.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ Upload your first media by tapping on the add button.</string>
451451
<string name="in_app_camera_location_unavailable">The app would not record location along with in-shots as the GPS is turned off</string>
452452
<string name="open_document_photo_picker_title">Use document based photo picker</string>
453453
<string name="open_document_photo_picker_explanation">The new Android photo picker risks losing location information. Enable if you seem to be using it.</string>
454-
<string name="location_loss_warning">Turning this off could trigger the new Android photo picker. It risks losing location information.\n\nTap on \'Read more\' for more information.</string>
454+
<string name="get_content_photo_picker_title">Use GET_CONTENT photo picker</string>
455+
<string name="get_content_photo_picker_explanation">Disable if your pictures get uploaded without location</string>
456+
<string name="location_loss_warning">Please make sure that this new Android picker does not strip location from your pictures.</string>
455457

456458
<string name="nearby_campaign_dismiss_message">You won\'t see the campaigns anymore. However, you can re-enable this notification in Settings if you wish.</string>
457459
<string name="this_function_needs_network_connection">This function requires network connection, please check your connection settings.</string>

app/src/main/res/xml/preferences.xml

+5-7
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
android:title="Uploads">
5858

5959
<SwitchPreference
60-
6160
android:defaultValue="true"
6261
android:key="useExternalStorage"
6362
app:singleLineTitle="false"
@@ -69,12 +68,6 @@
6968
android:title="@string/in_app_camera_location_permission_title"
7069
android:summary="@string/in_app_camera_location_switch_pref_summary"/>
7170

72-
<SwitchPreference
73-
android:defaultValue="true"
74-
android:key="openDocumentPhotoPickerPref"
75-
android:summary="@string/open_document_photo_picker_explanation"
76-
android:title="@string/open_document_photo_picker_title"/>
77-
7871
<SwitchPreference
7972
android:key="useAuthorName"
8073
app:singleLineTitle="false"
@@ -88,6 +81,11 @@
8881
app:useSimpleSummaryProvider="true"
8982
android:title="@string/preference_author_name" />
9083

84+
<SwitchPreference
85+
android:defaultValue="false"
86+
android:key="getContentPhotoPickerPref"
87+
android:summary="@string/get_content_photo_picker_explanation"
88+
android:title="@string/get_content_photo_picker_title"/>
9189
</PreferenceCategory>
9290

9391
<PreferenceCategory

0 commit comments

Comments
 (0)