mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
back button functionality (#1517)
This commit is contained in:
parent
f6c18c6480
commit
ac2de1a1fe
1 changed files with 19 additions and 1 deletions
|
|
@ -25,6 +25,7 @@ import android.support.design.widget.Snackbar;
|
|||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
|
@ -137,6 +138,8 @@ public class ShareActivity
|
|||
private long ShortAnimationDuration;
|
||||
private boolean isFABOpen = false;
|
||||
private float startScaleFinal;
|
||||
private boolean isZoom = false;
|
||||
|
||||
|
||||
/**
|
||||
* Called when user taps the submit button.
|
||||
|
|
@ -505,6 +508,7 @@ public class ShareActivity
|
|||
if (CurrentAnimator != null) {
|
||||
CurrentAnimator.cancel();
|
||||
}
|
||||
isZoom = true;
|
||||
ViewUtil.hideKeyboard(ShareActivity.this.findViewById(R.id.titleEdit | R.id.descEdit));
|
||||
closeFABMenu();
|
||||
mainFab.setVisibility(View.GONE);
|
||||
|
|
@ -521,7 +525,6 @@ public class ShareActivity
|
|||
|
||||
// Load the high-resolution "zoomed-in" image.
|
||||
expandedImageView.setImageBitmap(scaledImage);
|
||||
|
||||
float startScale = zoomObj.adjustStartEndBounds(startBounds, finalBounds, globalOffset);
|
||||
|
||||
// Hide the thumbnail and show the zoomed-in view. When the animation
|
||||
|
|
@ -593,6 +596,7 @@ public class ShareActivity
|
|||
if (CurrentAnimator != null) {
|
||||
CurrentAnimator.cancel();
|
||||
}
|
||||
isZoom = false;
|
||||
zoomOutButton.setVisibility(View.GONE);
|
||||
mainFab.setVisibility(View.VISIBLE);
|
||||
|
||||
|
|
@ -603,6 +607,7 @@ public class ShareActivity
|
|||
.with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top))
|
||||
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal))
|
||||
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal));
|
||||
|
||||
set.setDuration(ShortAnimationDuration);
|
||||
set.setInterpolator(new DecelerateInterpolator());
|
||||
set.addListener(new AnimatorListenerAdapter() {
|
||||
|
|
@ -635,4 +640,17 @@ public class ShareActivity
|
|||
startActivity(mapIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
if(isZoom) {
|
||||
onZoomOutFabClicked();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode,event);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue