mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
* Fix #5104: popup shown when tapping an already uploaded image in Media Details * Small Changes * JavaDoc Changes * Javadoc Changes * Coding Standards Changes
This commit is contained in:
parent
3e073583ea
commit
191186a474
2 changed files with 59 additions and 10 deletions
|
|
@ -11,6 +11,9 @@ import static fr.free.nrw.commons.description.EditDescriptionConstants.UPDATED_W
|
|||
import static fr.free.nrw.commons.description.EditDescriptionConstants.WIKITEXT;
|
||||
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION;
|
||||
import static fr.free.nrw.commons.utils.LangCodeUtils.getLocalizedResources;
|
||||
|
||||
import android.Manifest;
|
||||
import android.Manifest.permission;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
|
|
@ -81,6 +84,7 @@ import fr.free.nrw.commons.ui.widget.HtmlTextView;
|
|||
import fr.free.nrw.commons.upload.categories.UploadCategoriesFragment;
|
||||
import fr.free.nrw.commons.upload.depicts.DepictsFragment;
|
||||
import fr.free.nrw.commons.upload.UploadMediaDetail;
|
||||
import fr.free.nrw.commons.utils.PermissionUtils;
|
||||
import fr.free.nrw.commons.utils.ViewUtilWrapper;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
|
|
@ -356,11 +360,38 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
}
|
||||
|
||||
@OnClick(R.id.mediaDetailImageViewSpacer)
|
||||
public void launchZoomActivity(View view) {
|
||||
public void launchZoomActivity(final View view) {
|
||||
final boolean permission = PermissionUtils.
|
||||
hasPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
|
||||
|
||||
if (permission) {
|
||||
launchZoomActivityAfterPermissionCheck(view);
|
||||
}
|
||||
else {
|
||||
PermissionUtils.checkPermissionsAndPerformAction(getActivity(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
() -> {
|
||||
launchZoomActivityAfterPermissionCheck(view);
|
||||
},
|
||||
R.string.storage_permission_title,
|
||||
R.string.read_storage_permission_rationale
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* launch zoom acitivity after permission check
|
||||
* @param view as ImageView
|
||||
*/
|
||||
private void launchZoomActivityAfterPermissionCheck(final View view) {
|
||||
if (media.getImageUrl() != null) {
|
||||
Context ctx = view.getContext();
|
||||
final Context ctx = view.getContext();
|
||||
final Intent zoomableIntent = new Intent(ctx, ZoomableActivity.class);
|
||||
zoomableIntent.setData(Uri.parse(media.getImageUrl()));
|
||||
zoomableIntent.putExtra(
|
||||
ZoomableActivity.ZoomableActivityConstants.ORIGIN, "MediaDetails");
|
||||
ctx.startActivity(
|
||||
new Intent(ctx, ZoomableActivity.class).setData(Uri.parse(media.getImageUrl()))
|
||||
zoomableIntent
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,14 @@ class ZoomableActivity : BaseActivity() {
|
|||
handleResult(it)
|
||||
}
|
||||
|
||||
val origin = intent.getStringExtra(ZoomableActivityConstants.ORIGIN);
|
||||
|
||||
/**
|
||||
* If origin is "null" it means that ZoomableActivity was created by the custom picker
|
||||
* (rather than by MediaDetailsFragment) so we need to show the first time popup in
|
||||
* full screen mode if needed.
|
||||
*/
|
||||
if (origin == null) {
|
||||
if (prefs.getBoolean(CustomSelectorConstants.FULL_SCREEN_MODE_FIRST_LUNCH, true)) {
|
||||
// show welcome dialog on first launch
|
||||
showWelcomeDialog()
|
||||
|
|
@ -172,6 +180,7 @@ class ZoomableActivity : BaseActivity() {
|
|||
).apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Full Screen Mode Welcome Dialog.
|
||||
|
|
@ -650,4 +659,13 @@ class ZoomableActivity : BaseActivity() {
|
|||
scope.cancel()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
object ZoomableActivityConstants {
|
||||
/**
|
||||
* Key for Accessing Intent Data Named "Origin", The value indicates what fragment
|
||||
* ZoomableActivity was created by. It is null if ZoomableActivity was created by
|
||||
* the custom picker.
|
||||
*/
|
||||
const val ORIGIN = "Origin";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue