Merge "Replace cancel button with a delete icon." into sc-dev
This commit is contained in:
@@ -38,20 +38,21 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/preview" />
|
app:layout_constraintBottom_toTopOf="@id/preview" />
|
||||||
|
|
||||||
<Button
|
<ImageButton
|
||||||
android:id="@+id/cancel"
|
android:id="@+id/delete"
|
||||||
style="@android:style/Widget.DeviceDefault.Button.Colored"
|
style="@android:style/Widget.Material.Button.Borderless"
|
||||||
android:layout_width="wrap_content"
|
android:tint="?android:textColorPrimary"
|
||||||
android:layout_height="40dp"
|
android:layout_width="48dp"
|
||||||
android:text="@android:string/cancel"
|
android:layout_height="48dp"
|
||||||
android:layout_marginStart="6dp"
|
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:background="@drawable/screenshot_button_background"
|
android:padding="12dp"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:src="@drawable/ic_screenshot_delete"
|
||||||
app:layout_constraintStart_toEndOf="@id/save"
|
android:scaleType="fitCenter"
|
||||||
|
android:contentDescription="@*android:string/delete"
|
||||||
|
android:tooltipText="@*android:string/delete"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/share"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/preview"
|
app:layout_constraintBottom_toTopOf="@id/preview" />
|
||||||
/>
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/share"
|
android:id="@+id/share"
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class LongScreenshotActivity extends Activity {
|
|||||||
private View mSave;
|
private View mSave;
|
||||||
private View mEdit;
|
private View mEdit;
|
||||||
private View mShare;
|
private View mShare;
|
||||||
|
private View mDelete;
|
||||||
private CropView mCropView;
|
private CropView mCropView;
|
||||||
private MagnifierView mMagnifierView;
|
private MagnifierView mMagnifierView;
|
||||||
private ScrollCaptureResponse mScrollCaptureResponse;
|
private ScrollCaptureResponse mScrollCaptureResponse;
|
||||||
@@ -120,18 +121,24 @@ public class LongScreenshotActivity extends Activity {
|
|||||||
mSave = requireViewById(R.id.save);
|
mSave = requireViewById(R.id.save);
|
||||||
mEdit = requireViewById(R.id.edit);
|
mEdit = requireViewById(R.id.edit);
|
||||||
mShare = requireViewById(R.id.share);
|
mShare = requireViewById(R.id.share);
|
||||||
|
mDelete = requireViewById(R.id.delete);
|
||||||
mCropView = requireViewById(R.id.crop_view);
|
mCropView = requireViewById(R.id.crop_view);
|
||||||
mMagnifierView = requireViewById(R.id.magnifier);
|
mMagnifierView = requireViewById(R.id.magnifier);
|
||||||
mCropView.setCropInteractionListener(mMagnifierView);
|
mCropView.setCropInteractionListener(mMagnifierView);
|
||||||
mTransitionView = requireViewById(R.id.transition);
|
mTransitionView = requireViewById(R.id.transition);
|
||||||
mEnterTransitionView = requireViewById(R.id.enter_transition);
|
mEnterTransitionView = requireViewById(R.id.enter_transition);
|
||||||
|
|
||||||
requireViewById(R.id.cancel).setOnClickListener(v -> finishAndRemoveTask());
|
|
||||||
|
|
||||||
mSave.setOnClickListener(this::onClicked);
|
mSave.setOnClickListener(this::onClicked);
|
||||||
mEdit.setOnClickListener(this::onClicked);
|
mEdit.setOnClickListener(this::onClicked);
|
||||||
mShare.setOnClickListener(this::onClicked);
|
mShare.setOnClickListener(this::onClicked);
|
||||||
|
|
||||||
|
// Only show the delete button if we have something to delete (should typically be the case)
|
||||||
|
if (getIntent().getData() != null) {
|
||||||
|
mDelete.setOnClickListener(this::onClicked);
|
||||||
|
} else {
|
||||||
|
mDelete.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
mPreview.addOnLayoutChangeListener(
|
mPreview.addOnLayoutChangeListener(
|
||||||
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
|
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) ->
|
||||||
updateImageDimensions());
|
updateImageDimensions());
|
||||||
@@ -321,6 +328,7 @@ public class LongScreenshotActivity extends Activity {
|
|||||||
mSave.setEnabled(enabled);
|
mSave.setEnabled(enabled);
|
||||||
mEdit.setEnabled(enabled);
|
mEdit.setEnabled(enabled);
|
||||||
mShare.setEnabled(enabled);
|
mShare.setEnabled(enabled);
|
||||||
|
mDelete.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doEdit(Uri uri) {
|
private void doEdit(Uri uri) {
|
||||||
@@ -375,6 +383,11 @@ public class LongScreenshotActivity extends Activity {
|
|||||||
} else if (id == R.id.share) {
|
} else if (id == R.id.share) {
|
||||||
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_SHARE);
|
mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_SHARE);
|
||||||
startExport(PendingAction.SHARE);
|
startExport(PendingAction.SHARE);
|
||||||
|
} else if (id == R.id.delete) {
|
||||||
|
mBackgroundExecutor.execute(() -> {
|
||||||
|
getContentResolver().delete(getIntent().getData(), null);
|
||||||
|
finishAndRemoveTask();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ public class ScreenshotController {
|
|||||||
|
|
||||||
private Animator mScreenshotAnimation;
|
private Animator mScreenshotAnimation;
|
||||||
private RequestCallback mCurrentRequestCallback;
|
private RequestCallback mCurrentRequestCallback;
|
||||||
|
private Uri mLatestUriSaved;
|
||||||
|
|
||||||
private final Handler mScreenshotHandler = new Handler(Looper.getMainLooper()) {
|
private final Handler mScreenshotHandler = new Handler(Looper.getMainLooper()) {
|
||||||
@Override
|
@Override
|
||||||
@@ -546,7 +547,6 @@ public class ScreenshotController {
|
|||||||
mAccessibilityManager.sendAccessibilityEvent(event);
|
mAccessibilityManager.sendAccessibilityEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mScreenshotView.isAttachedToWindow()) {
|
if (mScreenshotView.isAttachedToWindow()) {
|
||||||
// if we didn't already dismiss for another reason
|
// if we didn't already dismiss for another reason
|
||||||
if (!mScreenshotView.isDismissing()) {
|
if (!mScreenshotView.isDismissing()) {
|
||||||
@@ -563,6 +563,7 @@ public class ScreenshotController {
|
|||||||
.getWindowInsets().getDisplayCutout());
|
.getWindowInsets().getDisplayCutout());
|
||||||
|
|
||||||
mScreenBitmap = screenshot;
|
mScreenBitmap = screenshot;
|
||||||
|
mLatestUriSaved = null;
|
||||||
|
|
||||||
if (!isUserSetupComplete()) {
|
if (!isUserSetupComplete()) {
|
||||||
Log.w(TAG, "User setup not complete, displaying toast only");
|
Log.w(TAG, "User setup not complete, displaying toast only");
|
||||||
@@ -700,6 +701,7 @@ public class ScreenshotController {
|
|||||||
longScreenshot));
|
longScreenshot));
|
||||||
|
|
||||||
final Intent intent = new Intent(mContext, LongScreenshotActivity.class);
|
final Intent intent = new Intent(mContext, LongScreenshotActivity.class);
|
||||||
|
intent.setData(mLatestUriSaved);
|
||||||
intent.setFlags(
|
intent.setFlags(
|
||||||
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
|
||||||
@@ -889,6 +891,8 @@ public class ScreenshotController {
|
|||||||
|
|
||||||
resetTimeout();
|
resetTimeout();
|
||||||
|
|
||||||
|
mLatestUriSaved = imageData.uri;
|
||||||
|
|
||||||
if (imageData.uri != null) {
|
if (imageData.uri != null) {
|
||||||
mScreenshotHandler.post(() -> {
|
mScreenshotHandler.post(() -> {
|
||||||
if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) {
|
if (mScreenshotAnimation != null && mScreenshotAnimation.isRunning()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user