зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1390356) for android build bustage in testActivityStreamContextMenu.java a=backout
Backed out changeset 864d9c092eaf (bug 1390356) Backed out changeset e4d9551839b6 (bug 1390356) Backed out changeset 72a0d4fe9278 (bug 1390356) MozReview-Commit-ID: CI51AdMUIYn --HG-- rename : mobile/android/app/src/main/res/layout/activity_stream_overridable_page_icon_layout.xml => mobile/android/app/src/main/res/layout/activity_stream_page_icon_layout.xml rename : mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java => mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamPageIconLayout.java extra : rebase_source : 44f628789a1c1c64bac0019655ba31564f37b168
This commit is contained in:
Родитель
842a3e50aa
Коммит
0d6630af13
|
@ -17,7 +17,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.mozilla.gecko.activitystream.homepanel.stream.StreamOverridablePageIconLayout
|
||||
<org.mozilla.gecko.activitystream.homepanel.stream.StreamPageIconLayout
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
|
|
|
@ -14,19 +14,20 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:padding="10dp">
|
||||
|
||||
<org.mozilla.gecko.activitystream.homepanel.stream.StreamOverridablePageIconLayout
|
||||
android:id="@+id/page_icon_layout"
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
android:layout_gravity="center"
|
||||
tools:background="@drawable/favicon_globe"/>
|
||||
<org.mozilla.gecko.widget.FaviconView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/favicon_bg"
|
||||
android:layout_height="@dimen/favicon_bg"
|
||||
android:layout_gravity="center"
|
||||
gecko:enableRoundCorners="false"
|
||||
tools:background="@drawable/favicon_globe"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/url"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toEndOf="@id/page_icon_layout"
|
||||
android:layout_toRightOf="@id/page_icon_layout"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:paddingLeft="@dimen/activity_stream_base_margin"
|
||||
android:paddingStart="@dimen/activity_stream_base_margin"
|
||||
android:textColor="@color/activity_stream_subtitle"
|
||||
|
@ -38,8 +39,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/url"
|
||||
android:layout_toEndOf="@id/page_icon_layout"
|
||||
android:layout_toRightOf="@id/page_icon_layout"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_toRightOf="@id/icon"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
android:paddingLeft="@dimen/activity_stream_base_margin"
|
||||
|
|
|
@ -307,15 +307,11 @@ public abstract class ActivityStreamContextMenu
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param shouldOverrideIconWithImageProvider true if the favicon should be replaced with an image provider,
|
||||
* if applicable, false otherwise.
|
||||
*/
|
||||
|
||||
@RobocopTarget
|
||||
public static ActivityStreamContextMenu show(Context context,
|
||||
View anchor, ActivityStreamTelemetry.Extras.Builder telemetryExtraBuilder,
|
||||
final MenuMode menuMode, final Item item,
|
||||
final boolean shouldOverrideIconWithImageProvider,
|
||||
HomePager.OnUrlOpenListener onUrlOpenListener,
|
||||
HomePager.OnUrlOpenInBackgroundListener onUrlOpenInBackgroundListener,
|
||||
final int tilesWidth, final int tilesHeight) {
|
||||
|
@ -324,7 +320,7 @@ public abstract class ActivityStreamContextMenu
|
|||
if (!HardwareUtils.isTablet()) {
|
||||
menu = new BottomSheetContextMenu(context,
|
||||
telemetryExtraBuilder, menuMode,
|
||||
item, shouldOverrideIconWithImageProvider, onUrlOpenListener, onUrlOpenInBackgroundListener,
|
||||
item, onUrlOpenListener, onUrlOpenInBackgroundListener,
|
||||
tilesWidth, tilesHeight);
|
||||
} else {
|
||||
menu = new PopupContextMenu(context,
|
||||
|
|
|
@ -6,6 +6,8 @@ package org.mozilla.gecko.activitystream.homepanel.menu;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.BottomSheetBehavior;
|
||||
import android.support.design.widget.BottomSheetDialog;
|
||||
import android.support.design.widget.NavigationView;
|
||||
|
@ -18,10 +20,13 @@ import android.widget.TextView;
|
|||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.activitystream.ActivityStreamTelemetry;
|
||||
import org.mozilla.gecko.activitystream.homepanel.model.Item;
|
||||
import org.mozilla.gecko.activitystream.homepanel.stream.StreamOverridablePageIconLayout;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
import org.mozilla.gecko.icons.IconCallback;
|
||||
import org.mozilla.gecko.icons.IconResponse;
|
||||
import org.mozilla.gecko.icons.Icons;
|
||||
import org.mozilla.gecko.util.StringUtils;
|
||||
import org.mozilla.gecko.util.URIUtils;
|
||||
import org.mozilla.gecko.widget.FaviconView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URI;
|
||||
|
@ -42,7 +47,6 @@ import java.net.URISyntaxException;
|
|||
final ActivityStreamTelemetry.Extras.Builder telemetryExtraBuilder,
|
||||
final MenuMode mode,
|
||||
final Item item,
|
||||
final boolean shouldOverrideIconWithImageProvider,
|
||||
HomePager.OnUrlOpenListener onUrlOpenListener,
|
||||
HomePager.OnUrlOpenInBackgroundListener onUrlOpenInBackgroundListener,
|
||||
final int tilesWidth, final int tilesHeight) {
|
||||
|
@ -81,16 +85,22 @@ import java.net.URISyntaxException;
|
|||
}
|
||||
|
||||
// Copy layouted parameters from the Highlights / TopSites items to ensure consistency
|
||||
final StreamOverridablePageIconLayout pageIconLayout =
|
||||
(StreamOverridablePageIconLayout) content.findViewById(R.id.page_icon_layout);
|
||||
final ViewGroup.LayoutParams layoutParams = pageIconLayout.getLayoutParams();
|
||||
final FaviconView faviconView = (FaviconView) content.findViewById(R.id.icon);
|
||||
ViewGroup.LayoutParams layoutParams = faviconView.getLayoutParams();
|
||||
layoutParams.width = tilesWidth;
|
||||
layoutParams.height = tilesHeight;
|
||||
pageIconLayout.setLayoutParams(layoutParams);
|
||||
faviconView.setLayoutParams(layoutParams);
|
||||
|
||||
// We're matching the specific icon behavior for highlights and top sites.
|
||||
final String overrideIconURL = !shouldOverrideIconWithImageProvider ? null : item.getImageUrl();
|
||||
pageIconLayout.updateIcon(item.getUrl(), overrideIconURL);
|
||||
Icons.with(context)
|
||||
.pageUrl(item.getUrl())
|
||||
.skipNetwork()
|
||||
.build()
|
||||
.execute(new IconCallback() {
|
||||
@Override
|
||||
public void onIconResponse(IconResponse response) {
|
||||
faviconView.updateImage(response);
|
||||
}
|
||||
});
|
||||
|
||||
navigationView = (NavigationView) content.findViewById(R.id.menu);
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.mozilla.gecko.activitystream.homepanel.model;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
@ -130,7 +129,6 @@ public class Highlight implements Item {
|
|||
* - {@link #getFastImageURLForComparison()}
|
||||
* - {@link #hasFastImageURL()}
|
||||
*/
|
||||
@NonNull
|
||||
public Metadata getMetadataSlow() {
|
||||
if (metadata == null) {
|
||||
metadata = new Metadata(metadataJSON);
|
||||
|
@ -138,21 +136,6 @@ public class Highlight implements Item {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image URL associated with this Highlight.
|
||||
*
|
||||
* This implementation may be slow: see {@link #getMetadataSlow()}.
|
||||
*
|
||||
* @return the image URL, or the empty String if there is none.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
final Metadata metadata = getMetadataSlow();
|
||||
final String imageUrl = metadata.getImageUrl();
|
||||
return imageUrl != null ? imageUrl : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image url in the highlight's metadata. This value does not provide valid image url but is
|
||||
* consistent across invocations and can be used to compare against other Highlight's fast image urls.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.mozilla.gecko.activitystream.homepanel.model;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -11,16 +10,6 @@ public interface Item {
|
|||
|
||||
String getUrl();
|
||||
|
||||
/**
|
||||
* Returns the image URL associated with this stream item.
|
||||
*
|
||||
* Some implementations may be slow due to lazy loading: see {@link Highlight#getImageUrl()}.
|
||||
*
|
||||
* @return the image URL, or the empty String when there is none.
|
||||
*/
|
||||
@NonNull
|
||||
String getImageUrl();
|
||||
|
||||
/**
|
||||
* @return True if the item is bookmarked, false otherwise. Might return 'null' if the bookmark
|
||||
* state is unknown and the database needs to be asked whether the URL is bookmarked.
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
package org.mozilla.gecko.activitystream.homepanel.model;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
|
@ -75,11 +74,8 @@ public class TopSite implements Item {
|
|||
return isPinned;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
final String imageUrl = metadata.getImageUrl();
|
||||
return imageUrl != null ? imageUrl : "";
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.mozilla.gecko.util.DrawableUtil;
|
|||
import org.mozilla.gecko.util.TouchTargetUtil;
|
||||
import org.mozilla.gecko.util.URIUtils;
|
||||
import org.mozilla.gecko.util.ViewUtil;
|
||||
import org.mozilla.gecko.widget.FaviconView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URI;
|
||||
|
@ -40,7 +41,7 @@ public class HighlightItem extends StreamItem {
|
|||
private Highlight highlight;
|
||||
private int position;
|
||||
|
||||
private final StreamOverridablePageIconLayout pageIconLayout;
|
||||
private final StreamPageIconLayout pageIconLayout;
|
||||
private final TextView pageTitleView;
|
||||
private final TextView pageSourceView;
|
||||
private final TextView pageDomainView;
|
||||
|
@ -56,7 +57,7 @@ public class HighlightItem extends StreamItem {
|
|||
tilesMargin = itemView.getResources().getDimensionPixelSize(R.dimen.activity_stream_base_margin);
|
||||
|
||||
pageTitleView = (TextView) itemView.findViewById(R.id.card_history_label);
|
||||
pageIconLayout = (StreamOverridablePageIconLayout) itemView.findViewById(R.id.icon);
|
||||
pageIconLayout = (StreamPageIconLayout) itemView.findViewById(R.id.icon);
|
||||
pageSourceView = (TextView) itemView.findViewById(R.id.card_history_source);
|
||||
pageDomainView = (TextView) itemView.findViewById(R.id.page);
|
||||
pageSourceIconView = (ImageView) itemView.findViewById(R.id.source_icon);
|
||||
|
@ -81,7 +82,6 @@ public class HighlightItem extends StreamItem {
|
|||
extras,
|
||||
ActivityStreamContextMenu.MenuMode.HIGHLIGHT,
|
||||
highlight,
|
||||
/* shouldOverrideWithImageProvider */ true, // we use image providers in pageIconLayout.
|
||||
onUrlOpenListener, onUrlOpenInBackgroundListener,
|
||||
pageIconLayout.getWidth(), pageIconLayout.getHeight());
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class HighlightItem extends StreamItem {
|
|||
|
||||
updateUiForSource(highlight.getSource());
|
||||
updatePageDomain();
|
||||
pageIconLayout.updateIcon(highlight.getUrl(), highlight.getImageUrl());
|
||||
pageIconLayout.updateIcon(highlight.getUrl(), highlight.getMetadataSlow().getImageUrl());
|
||||
}
|
||||
|
||||
private void updateUiForSource(Utils.HighlightSource source) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.mozilla.gecko.widget.FaviconView;
|
|||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* A layout that represents page icons in Activity Stream, which can be overridden with a custom URL.
|
||||
* A layout that represents page icons in Activity Stream.
|
||||
*
|
||||
* Under the hood, it switches between multiple icon views because favicons (in FaviconView)
|
||||
* are handled differently from other types of page images.
|
||||
|
@ -34,7 +34,7 @@ import java.util.concurrent.Future;
|
|||
* composable switcher layout abstracts the switching state from the FaviconView and keeps it simple, but will
|
||||
* use slightly more resources.
|
||||
*/
|
||||
public class StreamOverridablePageIconLayout extends FrameLayout implements IconCallback {
|
||||
public class StreamPageIconLayout extends FrameLayout implements IconCallback {
|
||||
|
||||
private enum UIMode {
|
||||
FAVICON_IMAGE, NONFAVICON_IMAGE
|
||||
|
@ -45,9 +45,9 @@ public class StreamOverridablePageIconLayout extends FrameLayout implements Icon
|
|||
|
||||
private @Nullable Future<IconResponse> ongoingFaviconLoad;
|
||||
|
||||
public StreamOverridablePageIconLayout(final Context context, final AttributeSet attrs) {
|
||||
public StreamPageIconLayout(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater.from(context).inflate(R.layout.activity_stream_overridable_page_icon_layout, this, true);
|
||||
LayoutInflater.from(context).inflate(R.layout.activity_stream_page_icon_layout, this, true);
|
||||
initViews();
|
||||
}
|
||||
|
|
@ -71,7 +71,6 @@ import java.util.concurrent.Future;
|
|||
extras,
|
||||
ActivityStreamContextMenu.MenuMode.TOPSITE,
|
||||
topSite,
|
||||
/* shouldOverrideWithImageProvider */ false, // we only use favicons for top sites.
|
||||
onUrlOpenListener, onUrlOpenInBackgroundListener,
|
||||
faviconView.getWidth(), faviconView.getHeight());
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
|
|||
'activitystream/homepanel/stream/HighlightItem.java',
|
||||
'activitystream/homepanel/stream/HighlightsTitle.java',
|
||||
'activitystream/homepanel/stream/StreamItem.java',
|
||||
'activitystream/homepanel/stream/StreamOverridablePageIconLayout.java',
|
||||
'activitystream/homepanel/stream/StreamPageIconLayout.java',
|
||||
'activitystream/homepanel/stream/TopPanel.java',
|
||||
'activitystream/homepanel/stream/WelcomePanel.java',
|
||||
'activitystream/homepanel/StreamItemAnimator.java',
|
||||
|
|
Загрузка…
Ссылка в новой задаче