Commit a6317a09 authored by Tanya Gupta's avatar Tanya Gupta Committed by Commit Bot

[SendTabToSelf] Added framework for device picker for STTS.

The device picker is the second step of the share experience that allows
users to choose which device to send the tab to.

This CL only contains the outline for the device picker.
Future CLs will add functionality, add polish, and wire
it to the share sheet.

Bug: 949223
Change-Id: I7ae8e3659c957acd0e33de33c4402562f577e91b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1623601Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarJeffrey Cohen <jeffreycohen@chromium.org>
Commit-Queue: Tanya Gupta <tgupta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663923}
parent cfc43234
...@@ -1359,6 +1359,8 @@ chrome_java_sources = [ ...@@ -1359,6 +1359,8 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java", "java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java",
"java/src/org/chromium/chrome/browser/searchwidget/SearchBoxDataProvider.java", "java/src/org/chromium/chrome/browser/searchwidget/SearchBoxDataProvider.java",
"java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java", "java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/DevicePickerBottomSheetAdapter.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/DevicePickerBottomSheetContent.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationManager.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationSharedPrefManager.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/NotificationSharedPrefManager.java",
"java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfAndroidBridge.java", "java/src/org/chromium/chrome/browser/send_tab_to_self/SendTabToSelfAndroidBridge.java",
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 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. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="56dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<org.chromium.ui.widget.ChromeImageView
android:id="@+id/device_icon"
android:layout_width="30dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:layout_gravity="start"
android:gravity="center_vertical"/>
<TextView
android:id="@+id/device_name"
android:layout_width="100dp"
android:layout_height="0dp"
android:layout_weight="0.75"
android:gravity="center_vertical"
android:paddingStart="30dp"
android:paddingEnd="2dp"
android:maxLines="2"
android:ellipsize="end"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 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. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="56dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingStart="19dp"
android:paddingEnd="24dp">
<ListView
android:id="@+id/device_picker_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 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. -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@android:color/white">
<TextView
android:id="@+id/device_picker_toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingStart="30dp"
android:paddingEnd="10dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:ellipsize="end"/>
</LinearLayout>
\ No newline at end of file
// Copyright 2019 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.send_tab_to_self;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R;
import org.chromium.ui.widget.ChromeImageView;
/**
* Adapter to populate the Target Device Picker sheet.
*/
public class DevicePickerBottomSheetAdapter extends BaseAdapter {
private final LayoutInflater mInflator;
private final Context mContext;
public DevicePickerBottomSheetAdapter() {
mContext = ContextUtils.getApplicationContext();
mInflator = LayoutInflater.from(mContext);
}
@Override
public int getCount() {
return 0;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView =
mInflator.inflate(R.layout.send_tab_to_self_device_picker_item, parent, false);
ChromeImageView deviceIcon = convertView.findViewById(R.id.device_icon);
/// TODO(crbug.com/949223): Populate with the right icon here.
// deviceIcon.setImageDrawable(
// AppCompatResources.getDrawable(mContext, R.drawable.ic_check_googblue_24dp));
deviceIcon.setVisibility(View.VISIBLE);
// TODO(crbug.com/949223): Populate the device name here.
// TextView deviceName = convertView.findViewById(R.id.device_name);
// deviceName.setText(getItem(position));
// TODO(crbug.com/949223): Add logic to handle click action
}
return convertView;
}
}
// Copyright 2019 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.send_tab_to_self;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetContent;
/**
* Bottom sheet content to display a list of devices a user can send a tab to after they have
* chosen to share it with themselves through the SendTabToSelfFeature.
*/
public class DevicePickerBottomSheetContent implements BottomSheetContent, OnItemClickListener {
Context mContext;
ChromeActivity mActivity;
ViewGroup mToolbarView;
ViewGroup mContentView;
DevicePickerBottomSheetAdapter mAdapter;
public DevicePickerBottomSheetContent(Context context, ChromeActivity activity) {
mContext = context;
mActivity = activity;
mAdapter = new DevicePickerBottomSheetAdapter();
createToolbarView();
}
private void createToolbarView() {
mToolbarView = (ViewGroup) LayoutInflater.from(mContext).inflate(
R.layout.send_tab_to_self_device_picker_toolbar, null);
TextView toolbarText = mToolbarView.findViewById(R.id.device_picker_toolbar);
toolbarText.setText(R.string.send_tab_to_self_sheet_toolbar);
}
private void createContentView() {
mContentView = (ViewGroup) LayoutInflater.from(mContext).inflate(
R.layout.send_tab_to_self_device_picker_list, null);
ListView listView = mContentView.findViewById(R.id.device_picker_list);
// Set the padding so that the toolbar is aligned with the list.
// TODO(tgupta): Figure out whether this can be incorporated directly in the definition of
// the list view rather than set programatically.
// listView.setPadding(0, convertDpToPx(80), 0, 0);
listView.setAdapter(mAdapter);
listView.setOnItemClickListener(this);
}
@Override
public View getContentView() {
return mContentView;
}
private int convertDpToPx(int inDp) {
float scale = mContext.getResources().getDisplayMetrics().density;
return (int) (inDp * scale + 0.5f);
}
@Override
public View getToolbarView() {
return mToolbarView;
}
@Override
public int getVerticalScrollOffset() {
return 0;
}
@Override
public void destroy() {}
@Override
public int getPriority() {
return BottomSheet.ContentPriority.HIGH;
}
@Override
public boolean swipeToDismissEnabled() {
// This ensures that the bottom sheet reappears after the first time. Otherwise, the
// second time that a user initiates a share, the bottom sheet does not re-appear.
return true;
}
@Override
public boolean isPeekStateEnabled() {
// Return false to ensure that the entire bottom sheet is shown.
return false;
}
@Override
public int getSheetContentDescriptionStringId() {
return R.string.send_tab_to_self_content_description;
}
@Override
public int getSheetHalfHeightAccessibilityStringId() {
return R.string.send_tab_to_self_sheet_half_height;
}
@Override
public int getSheetFullHeightAccessibilityStringId() {
return R.string.send_tab_to_self_sheet_full_height;
}
@Override
public int getSheetClosedAccessibilityStringId() {
return R.string.send_tab_to_self_sheet_closed;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO(crbug.com/949223): Add logic to support tapping on a device.
}
}
...@@ -3951,6 +3951,21 @@ The site does NOT gain access to the camera. The camera images are only visible ...@@ -3951,6 +3951,21 @@ The site does NOT gain access to the camera. The camera images are only visible
<message name="IDS_SEND_TAB_TO_SELF_INFOBAR_MESSAGE_URL" desc="Clickable text displayed as part of a URL in the inforbar displayed when a user receives a shared tab from another device."> <message name="IDS_SEND_TAB_TO_SELF_INFOBAR_MESSAGE_URL" desc="Clickable text displayed as part of a URL in the inforbar displayed when a user receives a shared tab from another device.">
Open Open
</message> </message>
<message name="IDS_SEND_TAB_TO_SELF_CONTENT_DESCRIPTION" desc="Content description for the target device picker.">
Device picker to share a tab with.
</message>
<message name="IDS_SEND_TAB_TO_SELF_SHEET_HALF_HEIGHT" desc="Accessibility string read when the target device picker sheet is opened at half height. The sheet will occupy the bottom half the screen.">
Device picker to share a tab with is opened at half height.
</message>
<message name="IDS_SEND_TAB_TO_SELF_SHEET_FULL_HEIGHT" desc="Accessibility string read when the target device picker sheet is opened at full height. The sheet will occupy the entire screen.">
Device picker to share a tab with is opened at full height.
</message>
<message name="IDS_SEND_TAB_TO_SELF_SHEET_CLOSED" desc="Accessibility string read when the target device picker sheet is closed.">
Device picker to share a tab with is closed.
</message>
<message name="IDS_SEND_TAB_TO_SELF_SHEET_TOOLBAR" desc="Header for device picker sheet where users can pick a device to send a tab to.">
Send to
</message>
<!-- Chrome Duet --> <!-- Chrome Duet -->
<message name="IDS_IPH_DUET_TITLE" desc="This string appears in an overlay that explains a new UI to users. 'Search' refers to searching the web, and 'explore' refers to Chrome's suggested content."> <message name="IDS_IPH_DUET_TITLE" desc="This string appears in an overlay that explains a new UI to users. 'Search' refers to searching the web, and 'explore' refers to Chrome's suggested content.">
......
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