Commit c404b263 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Use the modern navigation popup style.

BUG=800033

Change-Id: I9e9b1904004b0f4e82806b53b0fa53e8abfea396
Reviewed-on: https://chromium-review.googlesource.com/1220551
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590503}
parent 438b4435
...@@ -229,7 +229,6 @@ public abstract class ChromeFeatureList { ...@@ -229,7 +229,6 @@ public abstract class ChromeFeatureList {
public static final String INTEREST_FEED_CONTENT_SUGGESTIONS = "InterestFeedContentSuggestions"; public static final String INTEREST_FEED_CONTENT_SUGGESTIONS = "InterestFeedContentSuggestions";
public static final String LANGUAGES_PREFERENCE = "LanguagesPreference"; public static final String LANGUAGES_PREFERENCE = "LanguagesPreference";
public static final String LONG_PRESS_BACK_FOR_HISTORY = "LongPressBackForHistory"; public static final String LONG_PRESS_BACK_FOR_HISTORY = "LongPressBackForHistory";
public static final String LONG_PRESS_BACK_NEW_DESIGN = "LongPressBackNewDesign";
public static final String SEARCH_ENGINE_PROMO_EXISTING_DEVICE = public static final String SEARCH_ENGINE_PROMO_EXISTING_DEVICE =
"SearchEnginePromo.ExistingDevice"; "SearchEnginePromo.ExistingDevice";
public static final String SEARCH_ENGINE_PROMO_NEW_DEVICE = "SearchEnginePromo.NewDevice"; public static final String SEARCH_ENGINE_PROMO_NEW_DEVICE = "SearchEnginePromo.NewDevice";
......
...@@ -6,13 +6,8 @@ package org.chromium.chrome.browser; ...@@ -6,13 +6,8 @@ package org.chromium.chrome.browser;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnAttachStateChangeListener; import android.view.View.OnAttachStateChangeListener;
...@@ -37,7 +32,6 @@ import org.chromium.chrome.browser.profiles.Profile; ...@@ -37,7 +32,6 @@ import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.content_public.browser.NavigationController; import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.NavigationEntry; import org.chromium.content_public.browser.NavigationEntry;
import org.chromium.content_public.browser.NavigationHistory; import org.chromium.content_public.browser.NavigationHistory;
import org.chromium.ui.base.LocalizationUtils;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -66,7 +60,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -66,7 +60,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
private final NavigationController mNavigationController; private final NavigationController mNavigationController;
private NavigationHistory mHistory; private NavigationHistory mHistory;
private final NavigationAdapter mAdapter; private final NavigationAdapter mAdapter;
private final ListItemFactory mListItemFactory;
private final @Type int mType; private final @Type int mType;
private final int mFaviconSize; private final int mFaviconSize;
...@@ -113,12 +106,7 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -113,12 +106,7 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
// prevent that. // prevent that.
if (anchorToBottom) setVerticalOffset(0); if (anchorToBottom) setVerticalOffset(0);
if (ChromeFeatureList.isInitialized() mAdapter = new NavigationAdapter();
&& ChromeFeatureList.isEnabled(ChromeFeatureList.LONG_PRESS_BACK_NEW_DESIGN)) {
mAdapter = new NewNavigationAdapter();
} else {
mAdapter = new NavigationAdapter();
}
if (anchorToBottom) mAdapter.reverseOrder(); if (anchorToBottom) mAdapter.reverseOrder();
setModal(true); setModal(true);
...@@ -128,7 +116,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -128,7 +116,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
setAdapter(mAdapter); setAdapter(mAdapter);
mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size); mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size);
mListItemFactory = new ListItemFactory(context);
} }
private String buildComputedAction(String action) { private String buildComputedAction(String action) {
...@@ -222,68 +209,8 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -222,68 +209,8 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
dismiss(); dismiss();
} }
private void updateBitmapForTextView(TextView view, Bitmap bitmap) {
Drawable faviconDrawable = null;
if (bitmap != null) {
faviconDrawable = new BitmapDrawable(mContext.getResources(), bitmap);
((BitmapDrawable) faviconDrawable).setGravity(Gravity.FILL);
} else {
faviconDrawable = new ColorDrawable(Color.TRANSPARENT);
}
faviconDrawable.setBounds(0, 0, mFaviconSize, mFaviconSize);
view.setCompoundDrawables(faviconDrawable, null, null, null);
}
private static class ListItemFactory {
private static final int LIST_ITEM_HEIGHT_DP = 48;
private static final int PADDING_DP = 8;
private static final int TEXT_SIZE_SP = 18;
private static final float FADE_LENGTH_DP = 25.0f;
private static final float FADE_STOP = 0.75f;
int mFadeEdgeLength;
int mFadePadding;
int mListItemHeight;
int mPadding;
boolean mIsLayoutDirectionRTL;
Context mContext;
public ListItemFactory(Context context) {
mContext = context;
computeFadeDimensions();
}
private void computeFadeDimensions() {
// Fade with linear gradient starting 25dp from right margin.
// Reaches 0% opacity at 75% length. (Simulated with extra padding)
float density = mContext.getResources().getDisplayMetrics().density;
float fadeLength = (FADE_LENGTH_DP * density);
mFadeEdgeLength = (int) (fadeLength * FADE_STOP);
mFadePadding = (int) (fadeLength * (1 - FADE_STOP));
mListItemHeight = (int) (density * LIST_ITEM_HEIGHT_DP);
mPadding = (int) (density * PADDING_DP);
mIsLayoutDirectionRTL = LocalizationUtils.isLayoutRtl();
}
public TextView createListItem() {
TextView view = new TextView(mContext);
view.setFadingEdgeLength(mFadeEdgeLength);
view.setHorizontalFadingEdgeEnabled(true);
view.setSingleLine();
view.setTextSize(TEXT_SIZE_SP);
view.setMinimumHeight(mListItemHeight);
view.setGravity(Gravity.CENTER_VERTICAL);
view.setCompoundDrawablePadding(mPadding);
if (!mIsLayoutDirectionRTL) {
view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
} else {
view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
}
return view;
}
}
private class NavigationAdapter extends BaseAdapter { private class NavigationAdapter extends BaseAdapter {
private Integer mTopPadding;
boolean mInReverseOrder; boolean mInReverseOrder;
public void reverseOrder() { public void reverseOrder() {
...@@ -306,25 +233,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -306,25 +233,6 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
return ((NavigationEntry) getItem(position)).getIndex(); return ((NavigationEntry) getItem(position)).getIndex();
} }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView view;
if (convertView instanceof TextView) {
view = (TextView) convertView;
} else {
view = mListItemFactory.createListItem();
}
NavigationEntry entry = (NavigationEntry) getItem(position);
setViewText(entry, view);
updateBitmapForTextView(view, entry.getFavicon());
return view;
}
}
private class NewNavigationAdapter extends NavigationAdapter {
private Integer mTopPadding;
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
EntryViewHolder viewHolder; EntryViewHolder viewHolder;
...@@ -357,6 +265,14 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -357,6 +265,14 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
return convertView; return convertView;
} }
private void setViewText(NavigationEntry entry, TextView view) {
String entryText = entry.getTitle();
if (TextUtils.isEmpty(entryText)) entryText = entry.getVirtualUrl();
if (TextUtils.isEmpty(entryText)) entryText = entry.getUrl();
view.setText(entryText);
}
} }
private static class EntryViewHolder { private static class EntryViewHolder {
...@@ -365,11 +281,5 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt ...@@ -365,11 +281,5 @@ public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt
TextView mTextView; TextView mTextView;
} }
private static void setViewText(NavigationEntry entry, TextView view) {
String entryText = entry.getTitle();
if (TextUtils.isEmpty(entryText)) entryText = entry.getVirtualUrl();
if (TextUtils.isEmpty(entryText)) entryText = entry.getUrl();
view.setText(entryText);
}
} }
...@@ -279,12 +279,7 @@ public class NavigationPopupTest { ...@@ -279,12 +279,7 @@ public class NavigationPopupTest {
ThreadUtils.runOnUiThreadBlocking(() -> { ThreadUtils.runOnUiThreadBlocking(() -> {
ListView list = popup.getListView(); ListView list = popup.getListView();
View view = list.getAdapter().getView(list.getAdapter().getCount() - 1, null, list); View view = list.getAdapter().getView(list.getAdapter().getCount() - 1, null, list);
TextView text = null; TextView text = (TextView) view.findViewById(R.id.entry_title);
if (view instanceof TextView) {
text = (TextView) view;
} else {
text = (TextView) view.findViewById(R.id.entry_title);
}
Assert.assertNotNull(text); Assert.assertNotNull(text);
Assert.assertEquals(text.getResources().getString(R.string.show_full_history), Assert.assertEquals(text.getResources().getString(R.string.show_full_history),
text.getText().toString()); text.getText().toString());
......
...@@ -4382,13 +4382,6 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -4382,13 +4382,6 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(chrome::android::kLongPressBackForHistory)}, FEATURE_VALUE_TYPE(chrome::android::kLongPressBackForHistory)},
#endif #endif
#if defined(OS_ANDROID)
{"long-press-back-new-design",
flag_descriptions::kLongPressBackNewDesignName,
flag_descriptions::kLongPressBackNewDesignDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kLongPressBackNewDesign)},
#endif
{"sync-standalone-transport", {"sync-standalone-transport",
flag_descriptions::kSyncStandaloneTransportName, flag_descriptions::kSyncStandaloneTransportName,
flag_descriptions::kSyncStandaloneTransportDescription, kOsAll, flag_descriptions::kSyncStandaloneTransportDescription, kOsAll,
......
...@@ -115,7 +115,6 @@ const base::Feature* kFeaturesExposedToJava[] = { ...@@ -115,7 +115,6 @@ const base::Feature* kFeaturesExposedToJava[] = {
&kInflateToolbarOnBackgroundThread, &kInflateToolbarOnBackgroundThread,
&kLanguagesPreference, &kLanguagesPreference,
&kLongPressBackForHistory, &kLongPressBackForHistory,
&kLongPressBackNewDesign,
&kModalPermissionDialogView, &kModalPermissionDialogView,
&kNewContactsPicker, &kNewContactsPicker,
&kNewPhotoPicker, &kNewPhotoPicker,
...@@ -326,9 +325,6 @@ const base::Feature kLanguagesPreference{"LanguagesPreference", ...@@ -326,9 +325,6 @@ const base::Feature kLanguagesPreference{"LanguagesPreference",
const base::Feature kLongPressBackForHistory{"LongPressBackForHistory", const base::Feature kLongPressBackForHistory{"LongPressBackForHistory",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kLongPressBackNewDesign{"LongPressBackNewDesign",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kModalPermissionDialogView{ const base::Feature kModalPermissionDialogView{
"ModalPermissionDialogView", base::FEATURE_DISABLED_BY_DEFAULT}; "ModalPermissionDialogView", base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -57,7 +57,6 @@ extern const base::Feature kImprovedA2HS; ...@@ -57,7 +57,6 @@ extern const base::Feature kImprovedA2HS;
extern const base::Feature kInflateToolbarOnBackgroundThread; extern const base::Feature kInflateToolbarOnBackgroundThread;
extern const base::Feature kLanguagesPreference; extern const base::Feature kLanguagesPreference;
extern const base::Feature kLongPressBackForHistory; extern const base::Feature kLongPressBackForHistory;
extern const base::Feature kLongPressBackNewDesign;
extern const base::Feature kModalPermissionDialogView; extern const base::Feature kModalPermissionDialogView;
extern const base::Feature kSearchEnginePromoExistingDevice; extern const base::Feature kSearchEnginePromoExistingDevice;
extern const base::Feature kSearchEnginePromoNewDevice; extern const base::Feature kSearchEnginePromoNewDevice;
......
...@@ -2503,11 +2503,6 @@ const char kLongPressBackForHistoryName[] = ...@@ -2503,11 +2503,6 @@ const char kLongPressBackForHistoryName[] =
const char kLongPressBackForHistoryDescription[] = const char kLongPressBackForHistoryDescription[] =
"Long press system back button to show navigation history if enabled"; "Long press system back button to show navigation history if enabled";
const char kLongPressBackNewDesignName[] = "Long Press Back New Design";
const char kLongPressBackNewDesignDescription[] =
"Long press system back button to show material design refreshed navigation"
" popup if enabled";
const char kLsdPermissionPromptName[] = const char kLsdPermissionPromptName[] =
"Location Settings Dialog Permission Prompt"; "Location Settings Dialog Permission Prompt";
const char kLsdPermissionPromptDescription[] = const char kLsdPermissionPromptDescription[] =
......
...@@ -1507,9 +1507,6 @@ extern const char kLanguagesPreferenceDescription[]; ...@@ -1507,9 +1507,6 @@ extern const char kLanguagesPreferenceDescription[];
extern const char kLongPressBackForHistoryName[]; extern const char kLongPressBackForHistoryName[];
extern const char kLongPressBackForHistoryDescription[]; extern const char kLongPressBackForHistoryDescription[];
extern const char kLongPressBackNewDesignName[];
extern const char kLongPressBackNewDesignDescription[];
extern const char kLsdPermissionPromptName[]; extern const char kLsdPermissionPromptName[];
extern const char kLsdPermissionPromptDescription[]; extern const char kLsdPermissionPromptDescription[];
......
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