mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Experiments
This commit is contained in:
parent
26d2669a74
commit
76a95fb474
22 changed files with 70 additions and 1 deletions
|
|
@ -55,6 +55,8 @@ dependencies {
|
|||
testImplementation "androidx.paging:paging-common-ktx:$PAGING_VERSION"
|
||||
implementation "androidx.paging:paging-rxjava2-ktx:$PAGING_VERSION"
|
||||
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha02"
|
||||
implementation "androidx.activity:activity:1.2.0"
|
||||
implementation "androidx.fragment:fragment:1.3.0"
|
||||
implementation "com.squareup.okhttp3:okhttp-ws:$OKHTTP_VERSION"
|
||||
|
||||
// Logging
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
|
||||
|
||||
<queries>
|
||||
<!-- Browser -->
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import static android.view.View.GONE;
|
|||
import static android.view.View.VISIBLE;
|
||||
import static fr.free.nrw.commons.di.NetworkingModule.NAMED_LANGUAGE_WIKI_PEDIA_WIKI_SITE;
|
||||
|
||||
import android.Manifest;
|
||||
import android.Manifest.permission;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -21,6 +24,7 @@ import android.widget.TextView;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
|
@ -28,6 +32,8 @@ import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver;
|
|||
import androidx.recyclerview.widget.RecyclerView.ItemAnimator;
|
||||
import androidx.recyclerview.widget.RecyclerView.OnItemTouchListener;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
|
@ -319,6 +325,24 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
rvContributionsList.smoothScrollToPosition(0);
|
||||
}
|
||||
|
||||
// Register the permissions callback, which handles the user's response to the
|
||||
// system permissions dialog. Save the return value, an instance of
|
||||
// ActivityResultLauncher, as an instance variable.
|
||||
private ActivityResultLauncher<String> requestPermissionLauncher =
|
||||
registerForActivityResult(new RequestPermission(), isGranted -> {
|
||||
if (isGranted) {
|
||||
// Permission is granted. Continue the action or workflow in your
|
||||
// app.
|
||||
} else {
|
||||
// Explain to the user that the feature is unavailable because the
|
||||
// feature requires a permission that the user has denied. At the
|
||||
// same time, respect the user's decision. Don't link to system
|
||||
// settings in an effort to convince the user to change their
|
||||
// decision.
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
private void animateFAB(final boolean isFabOpen) {
|
||||
this.isFabOpen = !isFabOpen;
|
||||
if (fabPlus.isShown()) {
|
||||
|
|
@ -338,6 +362,26 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl
|
|||
fabCamera.show();
|
||||
fabGallery.show();
|
||||
fabCustomGallery.show();
|
||||
|
||||
//int i = ContextCompat.checkSelfPermission(
|
||||
// getContext(), permission.ACCESS_MEDIA_LOCATION);
|
||||
//if (i !=
|
||||
// PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
/*if (shouldShowRequestPermissionRationale(...)) {
|
||||
// In an educational UI, explain to the user why your app requires this
|
||||
// permission for a specific feature to behave as expected, and what
|
||||
// features are disabled if it's declined. In this UI, include a
|
||||
// "cancel" or "no thanks" button that lets the user continue
|
||||
// using your app without granting the permission.
|
||||
showInContextUI(...);
|
||||
} else {*/
|
||||
// You can directly ask for the permission.
|
||||
// The registered ActivityResultCallback gets the result of this request.
|
||||
requestPermissionLauncher.launch(
|
||||
Manifest.permission.ACCESS_MEDIA_LOCATION);
|
||||
//}
|
||||
//}
|
||||
}
|
||||
this.isFabOpen = !isFabOpen;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.TextUtils;
|
||||
|
|
@ -19,6 +20,7 @@ import fr.free.nrw.commons.customselector.model.Image;
|
|||
import fr.free.nrw.commons.customselector.ui.selector.CustomSelectorActivity;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -270,11 +272,29 @@ public class FilePicker implements Constants {
|
|||
ClipData clipData = data.getClipData();
|
||||
if (clipData == null) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
InputStream stream = activity.getBaseContext().getContentResolver().openInputStream(uri);
|
||||
//if (stream == null) {
|
||||
//Log.w(TAG, "Got a null input stream for " + photoUri);
|
||||
//continue;
|
||||
//}
|
||||
ExifInterface exif = new ExifInterface(stream);
|
||||
double[] location = exif.getLatLong();
|
||||
|
||||
UploadableFile file = PickedFiles.pickedExistingPicture(activity, uri);
|
||||
files.add(file);
|
||||
} else {
|
||||
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||
Uri uri = clipData.getItemAt(i).getUri();
|
||||
|
||||
InputStream stream = activity.getBaseContext().getContentResolver().openInputStream(uri);
|
||||
//if (stream == null) {
|
||||
//Log.w(TAG, "Got a null input stream for " + photoUri);
|
||||
//continue;
|
||||
//}
|
||||
ExifInterface exif = new ExifInterface(stream);
|
||||
double[] location = exif.getLatLong();
|
||||
|
||||
UploadableFile file = PickedFiles.pickedExistingPicture(activity, uri);
|
||||
files.add(file);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,9 @@ public class UploadableFile implements Parcelable {
|
|||
*/
|
||||
private DateTimeWithSource getDateTimeFromExif() {
|
||||
try {
|
||||
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
|
||||
ExifInterface exif = new ExifInterface(file.getAbsolutePath() /* unfortunately at this point the file (/data/user/0/fr.free.nrw.commons/cache/CommonsContributions/15d5892c-d7c4-46f7-8645-020a7ab032ab.jpg) has 0,0 as EXIF lat/lon */);
|
||||
double[] location = exif.getLatLong();
|
||||
exif.getAltitude(-1);
|
||||
// TAG_DATETIME returns the last edited date, we need TAG_DATETIME_ORIGINAL for creation date
|
||||
// See issue https://github.com/commons-app/apps-android-commons/issues/1971
|
||||
String dateTimeSubString = exif.getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue