Commit aed78260 authored by Kyle Milka's avatar Kyle Milka Committed by Chromium LUCI CQ

[LongScreenshots] Create area selection dialog

Create base for area selection dialog. Currently just
display an empty dialog with the title and two bottom buttons
with logic/classes added to control the dialog.

Bug: 1153969
Change-Id: I489dc95d198037e57262938bf9f94fc6041dbbff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2630825Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Commit-Queue: Kyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846251}
parent 5aa62765
......@@ -816,6 +816,7 @@ chrome_java_resources = [
"java/res/layout/location_status.xml",
"java/res/layout/location_status_icon.xml",
"java/res/layout/location_status_incognito_badge.xml",
"java/res/layout/long_screenshots_area_selection_dialog.xml",
"java/res/layout/main.xml",
"java/res/layout/manage_space_activity.xml",
"java/res/layout/managed_by_menu_item.xml",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/long_screenshots_area_selection_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/footer"
android:gravity="center_vertical"
android:layout_alignParentBottom="true"
android:layout_height="56dp"
android:layout_width="match_parent">
<org.chromium.ui.widget.ChromeImageButton
android:id="@+id/close_button"
android:contentDescription="@string/close"
android:src="@drawable/btn_close"
android:layout_alignParentStart="true"
android:layout_height="@dimen/long_screenshots_button_size"
android:layout_marginStart="@dimen/long_screenshots_button_padding"
android:layout_width="@dimen/long_screenshots_button_size"
app:tint="@color/default_icon_color_tint_list"
style="@style/ToolbarButton" />
<TextView
android:id="@+id/qrcode_camera_error_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:text="@string/sharing_long_screenshot"
android:textAppearance="@style/TextAppearance.TextLarge.Primary" />
<org.chromium.ui.widget.ChromeImageButton
android:id="@+id/done_button"
android:contentDescription="@string/close"
android:src="@drawable/ic_checkmark_24dp"
android:layout_alignParentEnd="true"
android:layout_height="@dimen/long_screenshots_button_size"
android:layout_marginEnd="@dimen/long_screenshots_button_padding"
android:layout_width="@dimen/long_screenshots_button_size"
app:tint="@color/default_icon_color_tint_list"
style="@style/ToolbarButton" />
</RelativeLayout>
<View
android:id="@+id/divider"
android:background="@color/divider_line_bg_color"
android:layout_height="1dp"
android:layout_width="match_parent"/>
<FrameLayout
android:id="@+id/bitmap_container"
android:layout_width="match_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
......@@ -516,4 +516,9 @@
<dimen name="sharing_hub_preview_inner_icon_size">24dp</dimen>
<dimen name="sharing_hub_3p_icon_size">36dp</dimen>
<dimen name="sharing_hub_3p_icon_padding_top">20dp</dimen>
<!-- Long Screenshots dimensions -->
<dimen name="long_screenshots_button_size">24dp</dimen>
<dimen name="long_screenshots_button_padding">17dp</dimen>
</resources>
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.long_screenshots;
import android.view.View.OnClickListener;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModel.WritableObjectPropertyKey;
/**
* Data properties for the Long Screenshots area selection dialog.
*/
final class LongScreenshotsAreaSelectionDialogProperties {
// Callback handling clicks on the done (check) button.
public static final WritableObjectPropertyKey<OnClickListener> DONE_BUTTON_CALLBACK =
new WritableObjectPropertyKey<>();
// Callback handling clicks on the close (x) button.
public static final WritableObjectPropertyKey<OnClickListener> CLOSE_BUTTON_CALLBACK =
new WritableObjectPropertyKey<>();
private LongScreenshotsAreaSelectionDialogProperties() {}
static PropertyModel.Builder defaultModelBuilder() {
return new PropertyModel.Builder(DONE_BUTTON_CALLBACK, CLOSE_BUTTON_CALLBACK);
}
}
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.long_screenshots;
import android.view.View;
import android.widget.ImageButton;
import org.chromium.chrome.R;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
/**
* Class responsible for binding the model and the view.
*/
class LongScreenshotsAreaSelectionDialogViewBinder {
static void bind(PropertyModel model, View parent, PropertyKey propertyKey) {
if (LongScreenshotsAreaSelectionDialogProperties.CLOSE_BUTTON_CALLBACK.equals(
propertyKey)) {
ImageButton view = (ImageButton) parent.findViewById(R.id.close_button);
view.setOnClickListener(
model.get(LongScreenshotsAreaSelectionDialogProperties.CLOSE_BUTTON_CALLBACK));
} else if (LongScreenshotsAreaSelectionDialogProperties.DONE_BUTTON_CALLBACK.equals(
propertyKey)) {
ImageButton view = (ImageButton) parent.findViewById(R.id.done_button);
view.setOnClickListener(
model.get(LongScreenshotsAreaSelectionDialogProperties.DONE_BUTTON_CALLBACK));
}
}
}
......@@ -18,6 +18,8 @@ import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
*/
public class LongScreenshotsCoordinator extends ScreenshotCoordinator {
private LongScreenshotsTabService mLongScreenshotsTabService;
private Activity mActivity;
private LongScreenshotsMediator mMediator;
private static final String DIR_NAME = "long_screenshots_dir";
......@@ -35,6 +37,7 @@ public class LongScreenshotsCoordinator extends ScreenshotCoordinator {
BottomSheetController sheetController,
ImageEditorModuleProvider imageEditorModuleProvider) {
super(activity, tab, chromeOptionShareCallback, sheetController, imageEditorModuleProvider);
mActivity = activity;
PaintPreviewCompositorUtils.warmupCompositor();
}
......@@ -52,7 +55,8 @@ public class LongScreenshotsCoordinator extends ScreenshotCoordinator {
@Override
public void onResult(int status) {
mScreenshot = entry.getBitmap();
launchSharesheet();
mMediator = new LongScreenshotsMediator(mActivity, entryManager);
mMediator.showAreaSelectionDialog();
}
});
}
......
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.share.long_screenshots;
import static org.chromium.chrome.browser.share.long_screenshots.LongScreenshotsAreaSelectionDialogProperties.CLOSE_BUTTON_CALLBACK;
import static org.chromium.chrome.browser.share.long_screenshots.LongScreenshotsAreaSelectionDialogProperties.DONE_BUTTON_CALLBACK;
import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.widget.LinearLayout;
import org.chromium.chrome.R;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.modelutil.PropertyModelChangeProcessor;
/**
* LongScreenshotsMediator is responsible for retrieving the long screenshot Bitmaps
* via {@link LongScreenshotsEntryManager} and displaying them in the area selection
* dialog.
*/
public class LongScreenshotsMediator {
private Dialog mDialog;
private PropertyModel mModel;
private final Activity mActivity;
private final EntryManager mEntryManager;
public LongScreenshotsMediator(Activity activity, EntryManager entryManager) {
mActivity = activity;
mEntryManager = entryManager;
}
public void showAreaSelectionDialog() {
View view = mActivity.getLayoutInflater().inflate(
R.layout.long_screenshots_area_selection_dialog, null);
mModel = LongScreenshotsAreaSelectionDialogProperties.defaultModelBuilder()
.with(DONE_BUTTON_CALLBACK, this::areaSelectionDone)
.with(CLOSE_BUTTON_CALLBACK, this::areaSelectionClose)
.build();
PropertyModelChangeProcessor.create(
mModel, view, LongScreenshotsAreaSelectionDialogViewBinder::bind);
mDialog = new Dialog(mActivity, R.style.Theme_Chromium_Fullscreen);
mDialog.addContentView(view,
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
mDialog.show();
}
public void areaSelectionDone(View view) {
// TODO(1163193): Delete all bitmaps.
mDialog.cancel();
}
public void areaSelectionClose(View view) {
// TODO(1163193): Delete all bitmaps.
mDialog.cancel();
}
}
......@@ -11,9 +11,12 @@ share_java_sources = [
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/link_to_text/LinkToTextCoordinator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/BitmapGenerator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/EntryManager.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsAreaSelectionDialogProperties.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsAreaSelectionDialogViewBinder.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsCompositor.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsCoordinator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsEntry.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsMediator.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsTabService.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/long_screenshots/LongScreenshotsTabServiceFactory.java",
"//chrome/browser/share/android/java/src/org/chromium/chrome/browser/share/qrcode/QRCodeGenerationRequest.java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment