Commit 47e56fd0 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Remove some //chrome dependencies from Contacts Picker

This is in preparation for componentization of the contacts picker.

Bug: 1016938
Change-Id: Iba35bbd752087f17c5636fb10706f029a2522da7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321563
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarFinnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799135}
parent d7868e48
...@@ -109,7 +109,7 @@ public class ContactView extends SelectableItemView<ContactDetails> { ...@@ -109,7 +109,7 @@ public class ContactView extends SelectableItemView<ContactDetails> {
@Override @Override
public boolean onLongClick(View view) { public boolean onLongClick(View view) {
mManager = mCategoryView.getActivity().getModalDialogManager(); mManager = mCategoryView.getModalDialogManager();
ModalDialogProperties.Controller controller = new ModalDialogProperties.Controller() { ModalDialogProperties.Controller controller = new ModalDialogProperties.Controller() {
@Override @Override
public void onClick(PropertyModel model, int buttonType) { public void onClick(PropertyModel model, int buttonType) {
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
package org.chromium.chrome.browser.contacts_picker; package org.chromium.chrome.browser.contacts_picker;
import android.content.Context;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.ui.ContactsPickerListener; import org.chromium.ui.ContactsPickerListener;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.vr.VrModeProvider;
/** /**
* UI for the contacts picker that shows on the Android platform as a result of * UI for the contacts picker that shows on the Android platform as a result of
...@@ -23,7 +23,7 @@ public class ContactsPickerDialog ...@@ -23,7 +23,7 @@ public class ContactsPickerDialog
/** /**
* The ContactsPickerDialog constructor. * The ContactsPickerDialog constructor.
* @param context The context to use. * @param windowAndroid The window associated with the main Activity.
* @param listener The listener object that gets notified when an action is taken. * @param listener The listener object that gets notified when an action is taken.
* @param allowMultiple Whether the contacts picker should allow multiple items to be selected. * @param allowMultiple Whether the contacts picker should allow multiple items to be selected.
* @param includeNames Whether the contacts data returned should include names. * @param includeNames Whether the contacts data returned should include names.
...@@ -34,14 +34,16 @@ public class ContactsPickerDialog ...@@ -34,14 +34,16 @@ public class ContactsPickerDialog
* @param formattedOrigin The origin the data will be shared with, formatted for display with * @param formattedOrigin The origin the data will be shared with, formatted for display with
* the scheme omitted. * the scheme omitted.
*/ */
public ContactsPickerDialog(Context context, ContactsPickerListener listener, public ContactsPickerDialog(WindowAndroid windowAndroid, ContactsPickerListener listener,
boolean allowMultiple, boolean includeNames, boolean includeEmails, boolean includeTel, boolean allowMultiple, boolean includeNames, boolean includeEmails, boolean includeTel,
boolean includeAddresses, boolean includeIcons, String formattedOrigin) { boolean includeAddresses, boolean includeIcons, String formattedOrigin,
super(context, R.style.Theme_Chromium_Fullscreen); VrModeProvider vrModeProvider) {
super(windowAndroid.getContext().get(), R.style.Theme_Chromium_Fullscreen);
// Initialize the main content view. // Initialize the main content view.
mCategoryView = new PickerCategoryView(context, allowMultiple, includeNames, includeEmails, mCategoryView = new PickerCategoryView(windowAndroid, allowMultiple, includeNames,
includeTel, includeAddresses, includeIcons, formattedOrigin, this); includeEmails, includeTel, includeAddresses, includeIcons, formattedOrigin, this,
vrModeProvider);
mCategoryView.initialize(this, listener); mCategoryView.initialize(this, listener);
setView(mCategoryView); setView(mCategoryView);
} }
......
...@@ -21,8 +21,6 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -21,8 +21,6 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.task.AsyncTask; import org.chromium.base.task.AsyncTask;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.vr.VrModeProviderImpl;
import org.chromium.components.browser_ui.util.BitmapCache; import org.chromium.components.browser_ui.util.BitmapCache;
import org.chromium.components.browser_ui.util.ConversionUtils; import org.chromium.components.browser_ui.util.ConversionUtils;
import org.chromium.components.browser_ui.util.GlobalDiscardableReferencePool; import org.chromium.components.browser_ui.util.GlobalDiscardableReferencePool;
...@@ -33,6 +31,9 @@ import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelega ...@@ -33,6 +31,9 @@ import org.chromium.components.browser_ui.widget.selectable_list.SelectionDelega
import org.chromium.content.browser.contacts.ContactsPickerPropertiesRequested; import org.chromium.content.browser.contacts.ContactsPickerPropertiesRequested;
import org.chromium.ui.ContactsPickerListener; import org.chromium.ui.ContactsPickerListener;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.ui.vr.VrModeProvider;
import org.chromium.ui.widget.OptimizedFrameLayout; import org.chromium.ui.widget.OptimizedFrameLayout;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -67,8 +68,8 @@ public class PickerCategoryView extends OptimizedFrameLayout ...@@ -67,8 +68,8 @@ public class PickerCategoryView extends OptimizedFrameLayout
// The view containing the RecyclerView and the toolbar, etc. // The view containing the RecyclerView and the toolbar, etc.
private SelectableListLayout<ContactDetails> mSelectableListLayout; private SelectableListLayout<ContactDetails> mSelectableListLayout;
// Our activity. // The window for the main Activity.
private ChromeActivity mActivity; private WindowAndroid mWindowAndroid;
// The callback to notify the listener of decisions reached in the picker. // The callback to notify the listener of decisions reached in the picker.
private ContactsPickerListener mListener; private ContactsPickerListener mListener;
...@@ -129,13 +130,14 @@ public class PickerCategoryView extends OptimizedFrameLayout ...@@ -129,13 +130,14 @@ public class PickerCategoryView extends OptimizedFrameLayout
* selected. * selected.
*/ */
@SuppressWarnings("unchecked") // mSelectableListLayout @SuppressWarnings("unchecked") // mSelectableListLayout
public PickerCategoryView(Context context, boolean multiSelectionAllowed, public PickerCategoryView(WindowAndroid windowAndroid, boolean multiSelectionAllowed,
boolean shouldIncludeNames, boolean shouldIncludeEmails, boolean shouldIncludeTel, boolean shouldIncludeNames, boolean shouldIncludeEmails, boolean shouldIncludeTel,
boolean shouldIncludeAddresses, boolean shouldIncludeIcons, String formattedOrigin, boolean shouldIncludeAddresses, boolean shouldIncludeIcons, String formattedOrigin,
ContactsPickerToolbar.ContactsToolbarDelegate delegate) { ContactsPickerToolbar.ContactsToolbarDelegate delegate, VrModeProvider vrModeProvider) {
super(context, null); super(windowAndroid.getContext().get(), null);
mActivity = (ChromeActivity) context; mWindowAndroid = windowAndroid;
Context context = windowAndroid.getContext().get();
mMultiSelectionAllowed = multiSelectionAllowed; mMultiSelectionAllowed = multiSelectionAllowed;
includeNames = shouldIncludeNames; includeNames = shouldIncludeNames;
includeEmails = shouldIncludeEmails; includeEmails = shouldIncludeEmails;
...@@ -166,7 +168,7 @@ public class PickerCategoryView extends OptimizedFrameLayout ...@@ -166,7 +168,7 @@ public class PickerCategoryView extends OptimizedFrameLayout
: R.string.contacts_picker_select_contact; : R.string.contacts_picker_select_contact;
mToolbar = (ContactsPickerToolbar) mSelectableListLayout.initializeToolbar( mToolbar = (ContactsPickerToolbar) mSelectableListLayout.initializeToolbar(
R.layout.contacts_picker_toolbar, mSelectionDelegate, titleId, 0, 0, null, false, R.layout.contacts_picker_toolbar, mSelectionDelegate, titleId, 0, 0, null, false,
false, new VrModeProviderImpl()); false, vrModeProvider);
mToolbar.setNavigationOnClickListener(this); mToolbar.setNavigationOnClickListener(this);
mToolbar.initializeSearchView(this, R.string.contacts_picker_search, 0); mToolbar.initializeSearchView(this, R.string.contacts_picker_search, 0);
mToolbar.setDelegate(delegate); mToolbar.setDelegate(delegate);
...@@ -323,8 +325,8 @@ public class PickerCategoryView extends OptimizedFrameLayout ...@@ -323,8 +325,8 @@ public class PickerCategoryView extends OptimizedFrameLayout
return mBitmapCache; return mBitmapCache;
} }
ChromeActivity getActivity() { ModalDialogManager getModalDialogManager() {
return mActivity; return mWindowAndroid.getModalDialogManager();
} }
void setTopView(TopView topView) { void setTopView(TopView topView) {
...@@ -350,7 +352,8 @@ public class PickerCategoryView extends OptimizedFrameLayout ...@@ -350,7 +352,8 @@ public class PickerCategoryView extends OptimizedFrameLayout
if (includeIcons && PickerAdapter.includesIcons()) { if (includeIcons && PickerAdapter.includesIcons()) {
// Fetch missing icons and compress them first. // Fetch missing icons and compress them first.
new CompressContactIconsWorkerTask( new CompressContactIconsWorkerTask(
mActivity.getContentResolver(), mBitmapCache, selectedContacts, this) mWindowAndroid.getContext().get().getContentResolver(), mBitmapCache,
selectedContacts, this)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return; return;
} }
......
...@@ -29,6 +29,7 @@ import org.chromium.base.task.TaskTraits; ...@@ -29,6 +29,7 @@ import org.chromium.base.task.TaskTraits;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.AfterStartupTaskUtils; import org.chromium.chrome.browser.AfterStartupTaskUtils;
import org.chromium.chrome.browser.AppHooks; import org.chromium.chrome.browser.AppHooks;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeActivitySessionTracker; import org.chromium.chrome.browser.ChromeActivitySessionTracker;
import org.chromium.chrome.browser.ChromeApplication; import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.chrome.browser.ChromeBackupAgent; import org.chromium.chrome.browser.ChromeBackupAgent;
...@@ -74,6 +75,7 @@ import org.chromium.chrome.browser.share.clipboard.ClipboardImageFileProvider; ...@@ -74,6 +75,7 @@ import org.chromium.chrome.browser.share.clipboard.ClipboardImageFileProvider;
import org.chromium.chrome.browser.sharing.shared_clipboard.SharedClipboardShareActivity; import org.chromium.chrome.browser.sharing.shared_clipboard.SharedClipboardShareActivity;
import org.chromium.chrome.browser.signin.SigninHelper; import org.chromium.chrome.browser.signin.SigninHelper;
import org.chromium.chrome.browser.sync.SyncController; import org.chromium.chrome.browser.sync.SyncController;
import org.chromium.chrome.browser.vr.VrModeProviderImpl;
import org.chromium.chrome.browser.webapps.WebApkVersionManager; import org.chromium.chrome.browser.webapps.WebApkVersionManager;
import org.chromium.chrome.browser.webapps.WebappRegistry; import org.chromium.chrome.browser.webapps.WebappRegistry;
import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory; import org.chromium.components.background_task_scheduler.BackgroundTaskSchedulerFactory;
...@@ -244,8 +246,11 @@ public class ProcessInitializationHandler { ...@@ -244,8 +246,11 @@ public class ProcessInitializationHandler {
boolean allowMultiple, boolean includeNames, boolean includeEmails, boolean allowMultiple, boolean includeNames, boolean includeEmails,
boolean includeTel, boolean includeAddresses, boolean includeIcons, boolean includeTel, boolean includeAddresses, boolean includeIcons,
String formattedOrigin) { String formattedOrigin) {
mDialog = new ContactsPickerDialog(context, listener, allowMultiple, includeNames, // TODO(crbug.com/1117536): remove this cast.
includeEmails, includeTel, includeAddresses, includeIcons, formattedOrigin); ChromeActivity activity = (ChromeActivity) context;
mDialog = new ContactsPickerDialog(activity.getWindowAndroid(), listener,
allowMultiple, includeNames, includeEmails, includeTel, includeAddresses,
includeIcons, formattedOrigin, new VrModeProviderImpl());
mDialog.getWindow().getAttributes().windowAnimations = mDialog.getWindow().getAttributes().windowAnimations =
R.style.PickerDialogAnimation; R.style.PickerDialogAnimation;
mDialog.show(); mDialog.show();
......
...@@ -43,6 +43,8 @@ import org.chromium.content_public.browser.test.util.TestTouchUtils; ...@@ -43,6 +43,8 @@ import org.chromium.content_public.browser.test.util.TestTouchUtils;
import org.chromium.payments.mojom.PaymentAddress; import org.chromium.payments.mojom.PaymentAddress;
import org.chromium.ui.ContactsPickerListener; import org.chromium.ui.ContactsPickerListener;
import org.chromium.ui.test.util.DisableAnimationsTestRule; import org.chromium.ui.test.util.DisableAnimationsTestRule;
import org.chromium.ui.vr.VrModeObserver;
import org.chromium.ui.vr.VrModeProvider;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -167,9 +169,19 @@ public class ContactsPickerDialogTest ...@@ -167,9 +169,19 @@ public class ContactsPickerDialogTest
@Override @Override
public ContactsPickerDialog call() { public ContactsPickerDialog call() {
final ContactsPickerDialog dialog = new ContactsPickerDialog( final ContactsPickerDialog dialog = new ContactsPickerDialog(
mActivityTestRule.getActivity(), ContactsPickerDialogTest.this, mActivityTestRule.getActivity().getWindowAndroid(),
multiselect, includeNames, includeEmails, includeTel, ContactsPickerDialogTest.this, multiselect, includeNames,
includeAddresses, includeIcons, "example.com"); includeEmails, includeTel, includeAddresses, includeIcons,
"example.com", new VrModeProvider() {
@Override
public boolean isInVr() {
return false;
}
@Override
public void registerVrModeObserver(VrModeObserver observer) {}
@Override
public void unregisterVrModeObserver(VrModeObserver observer) {}
});
dialog.show(); dialog.show();
return dialog; return dialog;
} }
......
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