mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +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.graphics.drawable.VectorDrawableCompat;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
|
@ -137,6 +138,8 @@ public class ShareActivity
|
||||||
private long ShortAnimationDuration;
|
private long ShortAnimationDuration;
|
||||||
private boolean isFABOpen = false;
|
private boolean isFABOpen = false;
|
||||||
private float startScaleFinal;
|
private float startScaleFinal;
|
||||||
|
private boolean isZoom = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when user taps the submit button.
|
* Called when user taps the submit button.
|
||||||
|
|
@ -505,6 +508,7 @@ public class ShareActivity
|
||||||
if (CurrentAnimator != null) {
|
if (CurrentAnimator != null) {
|
||||||
CurrentAnimator.cancel();
|
CurrentAnimator.cancel();
|
||||||
}
|
}
|
||||||
|
isZoom = true;
|
||||||
ViewUtil.hideKeyboard(ShareActivity.this.findViewById(R.id.titleEdit | R.id.descEdit));
|
ViewUtil.hideKeyboard(ShareActivity.this.findViewById(R.id.titleEdit | R.id.descEdit));
|
||||||
closeFABMenu();
|
closeFABMenu();
|
||||||
mainFab.setVisibility(View.GONE);
|
mainFab.setVisibility(View.GONE);
|
||||||
|
|
@ -521,7 +525,6 @@ public class ShareActivity
|
||||||
|
|
||||||
// Load the high-resolution "zoomed-in" image.
|
// Load the high-resolution "zoomed-in" image.
|
||||||
expandedImageView.setImageBitmap(scaledImage);
|
expandedImageView.setImageBitmap(scaledImage);
|
||||||
|
|
||||||
float startScale = zoomObj.adjustStartEndBounds(startBounds, finalBounds, globalOffset);
|
float startScale = zoomObj.adjustStartEndBounds(startBounds, finalBounds, globalOffset);
|
||||||
|
|
||||||
// Hide the thumbnail and show the zoomed-in view. When the animation
|
// Hide the thumbnail and show the zoomed-in view. When the animation
|
||||||
|
|
@ -593,6 +596,7 @@ public class ShareActivity
|
||||||
if (CurrentAnimator != null) {
|
if (CurrentAnimator != null) {
|
||||||
CurrentAnimator.cancel();
|
CurrentAnimator.cancel();
|
||||||
}
|
}
|
||||||
|
isZoom = false;
|
||||||
zoomOutButton.setVisibility(View.GONE);
|
zoomOutButton.setVisibility(View.GONE);
|
||||||
mainFab.setVisibility(View.VISIBLE);
|
mainFab.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
|
@ -603,6 +607,7 @@ public class ShareActivity
|
||||||
.with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top))
|
.with(ObjectAnimator.ofFloat(expandedImageView, View.Y, startBounds.top))
|
||||||
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal))
|
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScaleFinal))
|
||||||
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal));
|
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScaleFinal));
|
||||||
|
|
||||||
set.setDuration(ShortAnimationDuration);
|
set.setDuration(ShortAnimationDuration);
|
||||||
set.setInterpolator(new DecelerateInterpolator());
|
set.setInterpolator(new DecelerateInterpolator());
|
||||||
set.addListener(new AnimatorListenerAdapter() {
|
set.addListener(new AnimatorListenerAdapter() {
|
||||||
|
|
@ -635,4 +640,17 @@ public class ShareActivity
|
||||||
startActivity(mapIntent);
|
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