mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Copy onRequestPermissionsResult into NearbyMapFragment
This commit is contained in:
parent
8b473260f3
commit
745b3e1918
1 changed files with 37 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package fr.free.nrw.commons.nearby;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -47,6 +48,7 @@ import fr.free.nrw.commons.utils.UriDeserializer;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
|
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
|
||||||
|
|
||||||
public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
|
|
||||||
|
|
@ -411,11 +413,43 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller);
|
DirectUpload directUpload = new DirectUpload(place.getName(), place.getLongDescription(), this, controller);
|
||||||
directUpload.storeSharedPrefs();
|
directUpload.storeSharedPrefs();
|
||||||
directUpload.initiateGalleryUpload();
|
directUpload.initiateGalleryUpload();
|
||||||
|
|
||||||
//TODO: Handle onRequestPermissionsResult
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Handle onRequestPermissionsResult
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
Timber.d("onRequestPermissionsResult: req code = " + " perm = "
|
||||||
|
+ permissions + " grant =" + grantResults);
|
||||||
|
|
||||||
|
switch (requestCode) {
|
||||||
|
// 1 = Storage allowed when gallery selected
|
||||||
|
case 1: {
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
|
||||||
|
Timber.d("Call controller.startGalleryPick()");
|
||||||
|
controller.startGalleryPick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// 2 = Location allowed when 'nearby places' selected
|
||||||
|
case 2: {
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED) {
|
||||||
|
Timber.d("Location permission granted");
|
||||||
|
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||||
|
startActivity(nearbyIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: {
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Timber.d("Call controller.startCameraCapture()");
|
||||||
|
controller.startCameraCapture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue