Adds diagnostic logging for LongScreenshotActivity
This adds logging of dimensions and positions of
crop handles after a long screenshot capture.
Switches to OneShotPreDrawListener where appropriate
to improve readability.
Bug: 232633995
Test: logging only change; manually, take long screenshot
crop, save, observe result, verify results match
Change-Id: I699f8d69b78e89a7a5364fda84bc4d6316b77d31
This commit is contained in:
@@ -117,18 +117,22 @@ public class CropView extends View {
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
Log.d(TAG, "onSaveInstanceState");
|
||||
Parcelable superState = super.onSaveInstanceState();
|
||||
|
||||
SavedState ss = new SavedState(superState);
|
||||
ss.mCrop = mCrop;
|
||||
Log.d(TAG, "saving mCrop=" + mCrop);
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
Log.d(TAG, "onRestoreInstanceState");
|
||||
SavedState ss = (SavedState) state;
|
||||
super.onRestoreInstanceState(ss.getSuperState());
|
||||
|
||||
Log.d(TAG, "restoring mCrop=" + ss.mCrop + " (was " + mCrop + ")");
|
||||
mCrop = ss.mCrop;
|
||||
}
|
||||
|
||||
@@ -242,6 +246,7 @@ public class CropView extends View {
|
||||
* Set the given boundary to the given value without animation.
|
||||
*/
|
||||
public void setBoundaryPosition(CropBoundary boundary, float position) {
|
||||
Log.i(TAG, "setBoundaryPosition: " + boundary + ", position=" + position);
|
||||
position = (float) getAllowedValues(boundary).clamp(position);
|
||||
switch (boundary) {
|
||||
case TOP:
|
||||
@@ -260,6 +265,7 @@ public class CropView extends View {
|
||||
Log.w(TAG, "No boundary selected");
|
||||
break;
|
||||
}
|
||||
Log.i(TAG, "Updated mCrop: " + mCrop);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
@@ -350,26 +356,31 @@ public class CropView extends View {
|
||||
mCropInteractionListener = listener;
|
||||
}
|
||||
|
||||
private Range getAllowedValues(CropBoundary boundary) {
|
||||
private Range<Float> getAllowedValues(CropBoundary boundary) {
|
||||
float upper = 0f;
|
||||
float lower = 1f;
|
||||
switch (boundary) {
|
||||
case TOP:
|
||||
return new Range<>(0f,
|
||||
mCrop.bottom - pixelDistanceToFraction(mCropTouchMargin,
|
||||
CropBoundary.BOTTOM));
|
||||
lower = 0f;
|
||||
upper = mCrop.bottom - pixelDistanceToFraction(mCropTouchMargin,
|
||||
CropBoundary.BOTTOM);
|
||||
break;
|
||||
case BOTTOM:
|
||||
return new Range<>(
|
||||
mCrop.top + pixelDistanceToFraction(mCropTouchMargin,
|
||||
CropBoundary.TOP), 1f);
|
||||
lower = mCrop.top + pixelDistanceToFraction(mCropTouchMargin, CropBoundary.TOP);
|
||||
upper = 1;
|
||||
break;
|
||||
case LEFT:
|
||||
return new Range<>(0f,
|
||||
mCrop.right - pixelDistanceToFraction(mCropTouchMargin,
|
||||
CropBoundary.RIGHT));
|
||||
lower = 0f;
|
||||
upper = mCrop.right - pixelDistanceToFraction(mCropTouchMargin, CropBoundary.RIGHT);
|
||||
break;
|
||||
case RIGHT:
|
||||
return new Range<>(
|
||||
mCrop.left + pixelDistanceToFraction(mCropTouchMargin,
|
||||
CropBoundary.LEFT), 1f);
|
||||
lower = mCrop.left + pixelDistanceToFraction(mCropTouchMargin, CropBoundary.LEFT);
|
||||
upper = 1;
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
Log.i(TAG, "getAllowedValues: " + boundary + ", "
|
||||
+ "result=[lower=" + lower + ", upper=" + upper + "]");
|
||||
return new Range<>(lower, upper);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,17 +36,18 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ScrollCaptureResponse;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.android.internal.app.ChooserActivity;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.internal.view.OneShotPreDrawListener;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.flags.FeatureFlags;
|
||||
import com.android.systemui.screenshot.CropView.CropBoundary;
|
||||
import com.android.systemui.screenshot.ScrollCaptureController.LongScreenshot;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
|
||||
@@ -215,6 +216,7 @@ public class LongScreenshotActivity extends Activity {
|
||||
mPreview.setImageDrawable(drawable);
|
||||
mMagnifierView.setDrawable(mLongScreenshot.getDrawable(),
|
||||
mLongScreenshot.getWidth(), mLongScreenshot.getHeight());
|
||||
Log.i(TAG, "Completed: " + longScreenshot);
|
||||
// Original boundaries go from the image tile set's y=0 to y=pageSize, so
|
||||
// we animate to that as a starting crop position.
|
||||
float topFraction = Math.max(0,
|
||||
@@ -223,31 +225,26 @@ public class LongScreenshotActivity extends Activity {
|
||||
1 - (mLongScreenshot.getBottom() - mLongScreenshot.getPageHeight())
|
||||
/ (float) mLongScreenshot.getHeight());
|
||||
|
||||
Log.i(TAG, "topFraction: " + topFraction);
|
||||
Log.i(TAG, "bottomFraction: " + bottomFraction);
|
||||
|
||||
mEnterTransitionView.setImageDrawable(drawable);
|
||||
mEnterTransitionView.getViewTreeObserver().addOnPreDrawListener(
|
||||
new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
mEnterTransitionView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
updateImageDimensions();
|
||||
mEnterTransitionView.post(() -> {
|
||||
Rect dest = new Rect();
|
||||
mEnterTransitionView.getBoundsOnScreen(dest);
|
||||
mLongScreenshotHolder.takeTransitionDestinationCallback()
|
||||
.setTransitionDestination(dest, () -> {
|
||||
mPreview.animate().alpha(1f);
|
||||
mCropView.setBoundaryPosition(
|
||||
CropView.CropBoundary.TOP, topFraction);
|
||||
mCropView.setBoundaryPosition(
|
||||
CropView.CropBoundary.BOTTOM, bottomFraction);
|
||||
mCropView.animateEntrance();
|
||||
mCropView.setVisibility(View.VISIBLE);
|
||||
setButtonsEnabled(true);
|
||||
});
|
||||
OneShotPreDrawListener.add(mEnterTransitionView, () -> {
|
||||
updateImageDimensions();
|
||||
mEnterTransitionView.post(() -> {
|
||||
Rect dest = new Rect();
|
||||
mEnterTransitionView.getBoundsOnScreen(dest);
|
||||
mLongScreenshotHolder.takeTransitionDestinationCallback()
|
||||
.setTransitionDestination(dest, () -> {
|
||||
mPreview.animate().alpha(1f);
|
||||
mCropView.setBoundaryPosition(CropBoundary.TOP, topFraction);
|
||||
mCropView.setBoundaryPosition(CropBoundary.BOTTOM, bottomFraction);
|
||||
mCropView.animateEntrance();
|
||||
mCropView.setVisibility(View.VISIBLE);
|
||||
setButtonsEnabled(true);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Immediately export to temp image file for saved state
|
||||
mCacheSaveFuture = mImageExporter.exportToRawFile(mBackgroundExecutor,
|
||||
|
||||
@@ -130,8 +130,14 @@ public class ScrollCaptureController {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LongScreenshot{w=" + mImageTileSet.getWidth()
|
||||
+ ", h=" + mImageTileSet.getHeight() + "}";
|
||||
return "LongScreenshot{"
|
||||
+ "l=" + mImageTileSet.getLeft() + ", "
|
||||
+ "t=" + mImageTileSet.getTop() + ", "
|
||||
+ "r=" + mImageTileSet.getRight() + ", "
|
||||
+ "b=" + mImageTileSet.getBottom() + ", "
|
||||
+ "w=" + mImageTileSet.getWidth() + ", "
|
||||
+ "h=" + mImageTileSet.getHeight()
|
||||
+ "}";
|
||||
}
|
||||
|
||||
public Drawable getDrawable() {
|
||||
|
||||
Reference in New Issue
Block a user