Commit d82ad3a9 authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[ProfileCard] Fix build errors and remove unused inheritance

Add the component to build file and fix the importing and
depending errors that occurred.

Remove the inheritance of the TextBubble since we are no
longer using a pop-up dialog as a profile card container.

Bug: 1051208, 1051537
Change-Id: I23b71bc4f2f5d2fd9e8034cd0d35a1e4da2c6d75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047460
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740826}
parent a7b799ef
...@@ -259,6 +259,7 @@ android_library("chrome_java") { ...@@ -259,6 +259,7 @@ android_library("chrome_java") {
"//chrome/browser/image_fetcher:java", "//chrome/browser/image_fetcher:java",
"//chrome/browser/notifications/chime/android:java", "//chrome/browser/notifications/chime/android:java",
"//chrome/browser/preferences:java", "//chrome/browser/preferences:java",
"//chrome/browser/profile_card/android:java",
"//chrome/browser/settings:java", "//chrome/browser/settings:java",
"//chrome/browser/share/android:java_resources", "//chrome/browser/share/android:java_resources",
"//chrome/browser/thumbnail:java", "//chrome/browser/thumbnail:java",
...@@ -496,6 +497,7 @@ java_group("chrome_all_java") { ...@@ -496,6 +497,7 @@ java_group("chrome_all_java") {
"//chrome/android/features/media_router:java", "//chrome/android/features/media_router:java",
"//chrome/android/features/test_dummy/internal:base_module_java", "//chrome/android/features/test_dummy/internal:base_module_java",
"//chrome/android/modules/extra_icu/provider:java", "//chrome/android/modules/extra_icu/provider:java",
"//chrome/browser/profile_card/android/internal:java",
"//chrome/browser/touch_to_fill/android/internal:java", "//chrome/browser/touch_to_fill/android/internal:java",
"//chrome/browser/ui/android/appmenu/internal:java", "//chrome/browser/ui/android/appmenu/internal:java",
] ]
......
...@@ -5,6 +5,8 @@ include_rules = [ ...@@ -5,6 +5,8 @@ include_rules = [
"+chrome/browser/flags/android", "+chrome/browser/flags/android",
"+chrome/browser/share/android", "+chrome/browser/share/android",
"+chrome/browser/thumbnail/generator/android/java", "+chrome/browser/thumbnail/generator/android/java",
"+chrome/browser/profile_card/android",
"-chrome/browser/profile_card/android/internal",
"+chrome/browser/ui/android/appmenu", "+chrome/browser/ui/android/appmenu",
"-chrome/browser/ui/android/appmenu/internal", "-chrome/browser/ui/android/appmenu/internal",
"+chrome/browser/ui/messages/android/java", "+chrome/browser/ui/messages/android/java",
......
...@@ -6,11 +6,4 @@ import("//build/config/android/rules.gni") ...@@ -6,11 +6,4 @@ import("//build/config/android/rules.gni")
android_library("java") { android_library("java") {
sources = [ "java/src/org/chromium/chrome/browser/profile_card/ProfileCardCoordinator.java" ] sources = [ "java/src/org/chromium/chrome/browser/profile_card/ProfileCardCoordinator.java" ]
deps = [ "//chrome/lib/lifecycle/public/android:java" ]
}
android_resources("java_resources") {
custom_package = "org.chromium.chrome.browser.profile_card"
resource_dirs = [ "java/res" ]
deps = [ "//ui/android:ui_java_resources" ]
} }
...@@ -16,15 +16,14 @@ android_library("java") { ...@@ -16,15 +16,14 @@ android_library("java") {
deps = [ deps = [
":java_resources", ":java_resources",
"//base:base_java", "//base:base_java",
"//chrome/android:chrome_java",
"//chrome/browser/profile_card/android:java",
"//components/browser_ui/widget/android:java",
"//ui/android:ui_full_java",
] ]
} }
android_resources("java_resources") { android_resources("java_resources") {
custom_package = "org.chromium.chrome.browser.profile_card.internal" custom_package = "org.chromium.chrome.browser.profile_card.internal"
resource_dirs = [ "java/res" ] resource_dirs = [ "java/res" ]
visibility = [ ":*" ]
# Include resource dependencies needed by :java so that resources may
# all be accessed through the same custom_package.
deps = [ "//chrome/browser/profile_card:java_resources" ]
} }
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <org.chromium.chrome.browser.profile_card.ProfileCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/profile_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
...@@ -12,13 +14,11 @@ ...@@ -12,13 +14,11 @@
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"/>
android:textAppearance="@style/TextAppearance.TextMediumThick.Primary.Inverse" />
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"/>
android:textAppearance="@style/TextAppearance.TextMediumThick.Primary.Inverse" />
</LinearLayout> </org.chromium.chrome.browser.profile_card.ProfileCardView>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.profile_card.internal; package org.chromium.chrome.browser.profile_card;
import android.view.View; import android.view.View;
...@@ -21,18 +21,17 @@ import org.chromium.ui.widget.ViewRectProvider; ...@@ -21,18 +21,17 @@ import org.chromium.ui.widget.ViewRectProvider;
public class ProfileCardCoordinatorImpl implements ProfileCardCoordinator { public class ProfileCardCoordinatorImpl implements ProfileCardCoordinator {
private static final String TAG = "ShowError"; private static final String TAG = "ShowError";
private final PropertyModel mModel; private PropertyModel mModel;
private final ProfileCardView mView; private ProfileCardView mView;
private final ProfileCardMediator mMediator; private ProfileCardMediator mMediator;
private final PropertyModelChangeProcessor mModelChangeProcessor; private PropertyModelChangeProcessor mModelChangeProcessor;
private final JSONObject mProfileCardData; private JSONObject mProfileCardData;
@Override @Override
public void update(View anchorView, JSONObject profileCardData) { public void update(View anchorView, JSONObject profileCardData) {
if (mProfileCardData == profileCardData) return; if (mProfileCardData == profileCardData) return;
ViewRectProvider rectProvider = new ViewRectProvider(anchorView); ViewRectProvider rectProvider = new ViewRectProvider(anchorView);
mView = new ProfileCardView(anchorView.getContext(), anchorView, /*stringId=*/"", mView = new ProfileCardView(anchorView.getContext());
/*accessibilityStringId=*/"", rectProvider);
mProfileCardData = profileCardData; mProfileCardData = profileCardData;
mModel = new PropertyModel(ProfileCardProperties.ALL_KEYS); mModel = new PropertyModel(ProfileCardProperties.ALL_KEYS);
mModelChangeProcessor = mModelChangeProcessor =
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.profile_card.internal; package org.chromium.chrome.browser.profile_card;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.DESCRIPTION; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.DESCRIPTION;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.IS_DIALOG_VISIBLE; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.IS_DIALOG_VISIBLE;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.TITLE; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.TITLE;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.profile_card.internal; package org.chromium.chrome.browser.profile_card;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
......
...@@ -2,53 +2,37 @@ ...@@ -2,53 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.profile_card.internal; package org.chromium.chrome.browser.profile_card;
import android.content.Context; import android.content.Context;
import android.text.method.ScrollingMovementMethod; import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.chrome.browser.ui.widget.textbubble.TextBubble; import org.chromium.chrome.browser.profile_card.internal.R;
import org.chromium.ui.widget.RectProvider;
/** /**
* UI component that handles showing a text bubble with a preceding image. * UI component that handles showing a text bubble with a preceding image.
*/ */
public class ProfileCardView extends TextBubble { public class ProfileCardView extends LinearLayout {
private View mMainContentView; private View mMainContentView;
private TextView mTitleTextView; private TextView mTitleTextView;
private TextView mDescriptionTextView; private TextView mDescriptionTextView;
private ImageButton mFollowBtn;
private LinearLayout mNetworkContainer;
/** public ProfileCardView(Context context) {
* Constructs a {@link ProfileCardView} instance. super(context);
* @param context Context to draw resources from.
* @param rootView The {@link View} to use for size calculations and for display.
* @param stringId The id of the string resource for the text that should be shown.
* @param accessibilityStringId The id of the string resource of the accessibility text.
* @param anchorRectProvider The {@link RectProvider} used to anchor the text bubble.
*/
public ProfileCardView(Context context, View rootView, String stringId,
String accessibilityStringId, RectProvider anchorRectProvider) {
super(context, rootView, stringId, accessibilityStringId, /*showArrow=*/true,
anchorRectProvider);
setColor(context.getResources().getColor(org.chromium.chrome.R.color.material_grey_100));
setCardDismissListener();
} }
@Override @Override
protected View createContentView() { protected void onFinishInflate() {
super.onFinishInflate();
mMainContentView = mMainContentView =
LayoutInflater.from(mContext).inflate(R.layout.profile_card, /*root=*/null); LayoutInflater.from(getContext()).inflate(R.layout.profile_card, /*root=*/null);
mTitleTextView = mMainContentView.findViewById(R.id.title); mTitleTextView = mMainContentView.findViewById(R.id.title);
mDescriptionTextView = mMainContentView.findViewById(R.id.description); mDescriptionTextView = mMainContentView.findViewById(R.id.description);
mDescriptionTextView.setMovementMethod(new ScrollingMovementMethod()); mDescriptionTextView.setMovementMethod(new ScrollingMovementMethod());
return mMainContentView;
} }
void setTitle(String title) { void setTitle(String title) {
...@@ -67,19 +51,9 @@ public class ProfileCardView extends TextBubble { ...@@ -67,19 +51,9 @@ public class ProfileCardView extends TextBubble {
void setVisibility(boolean visible) { void setVisibility(boolean visible) {
if (visible) { if (visible) {
setOutsideTouchable(true); mMainContentView.setVisibility(View.VISIBLE);
show();
} else { } else {
dismiss(); mMainContentView.setVisibility(View.GONE);
} }
} }
void setCardDismissListener() {
addOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss() {
setVisibility(false);
}
});
}
} }
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.profile_card.internal; package org.chromium.chrome.browser.profile_card;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.DESCRIPTION; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.DESCRIPTION;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.IS_DIALOG_VISIBLE; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.IS_DIALOG_VISIBLE;
import static org.chromium.chrome.features.profile_card.ProfileCardProperties.TITLE; import static org.chromium.chrome.browser.profile_card.ProfileCardProperties.TITLE;
import org.chromium.ui.modelutil.PropertyKey; import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
......
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