mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 882715 - Implement history/last tabs buttons in VisitedPage (r=bnicholson)
This commit is contained in:
parent
832c9f541f
commit
53aa620280
@ -1431,6 +1431,13 @@ abstract public class BrowserApp extends GeckoApp
|
||||
return;
|
||||
}
|
||||
|
||||
// Hide any visible homepager subpages
|
||||
final FragmentManager fm = getSupportFragmentManager();
|
||||
final Fragment subPage = fm.findFragmentByTag(HomePager.SUBPAGE_TAG);
|
||||
if (subPage != null) {
|
||||
fm.beginTransaction().remove(subPage).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
// FIXME: do animation if animate is true
|
||||
mHomePager.hide();
|
||||
|
||||
|
@ -471,6 +471,7 @@ RES_LAYOUT = \
|
||||
res/layout/home_header_row.xml \
|
||||
res/layout/home_list_with_title.xml \
|
||||
res/layout/home_search_item_row.xml \
|
||||
res/layout/home_visited_page.xml \
|
||||
res/layout/web_app.xml \
|
||||
res/layout/launch_app_list.xml \
|
||||
res/layout/launch_app_listitem.xml \
|
||||
|
@ -46,6 +46,12 @@ class HomeFragment extends Fragment {
|
||||
// URL to Title replacement regex.
|
||||
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
|
||||
|
||||
protected void showSubPage(Fragment subPage) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.addToBackStack(null).replace(R.id.home_pager_container, subPage, HomePager.SUBPAGE_TAG)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
|
||||
if (!(menuInfo instanceof HomeContextMenuInfo)) {
|
||||
|
@ -22,6 +22,9 @@ import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class HomePager extends ViewPager {
|
||||
// Subpage fragment tag
|
||||
public static final String SUBPAGE_TAG = "home_pager_subpage";
|
||||
|
||||
private final Context mContext;
|
||||
private volatile boolean mLoaded;
|
||||
|
||||
|
@ -43,6 +43,12 @@ public class VisitedPage extends HomeFragment {
|
||||
// The view shown by the fragment.
|
||||
private ListView mList;
|
||||
|
||||
// Empty message view
|
||||
private View mEmptyMessage;
|
||||
|
||||
// Buttons container
|
||||
private View mButtonsContainer;
|
||||
|
||||
// Callbacks used for the search and favicon cursor loaders
|
||||
private CursorLoaderCallbacks mCursorLoaderCallbacks;
|
||||
|
||||
@ -74,16 +80,15 @@ public class VisitedPage extends HomeFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// All list views are styled to look the same with a global activity theme.
|
||||
// If the style of the list changes, inflate it from an XML.
|
||||
mList = new HomeListView(container.getContext());
|
||||
return mList;
|
||||
return inflater.inflate(R.layout.home_visited_page, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mList = (HomeListView) view.findViewById(R.id.visited_list);
|
||||
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@ -98,12 +103,33 @@ public class VisitedPage extends HomeFragment {
|
||||
});
|
||||
|
||||
registerForContextMenu(mList);
|
||||
|
||||
mEmptyMessage = view.findViewById(R.id.empty_message);
|
||||
mButtonsContainer = view.findViewById(R.id.buttons_container);
|
||||
|
||||
final View historyButton = view.findViewById(R.id.history_button);
|
||||
historyButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showHistoryPage();
|
||||
}
|
||||
});
|
||||
|
||||
final View tabsButton = view.findViewById(R.id.tabs_button);
|
||||
tabsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showTabsPage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
mList = null;
|
||||
mButtonsContainer = null;
|
||||
mEmptyMessage = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -121,6 +147,16 @@ public class VisitedPage extends HomeFragment {
|
||||
getLoaderManager().initLoader(FRECENCY_LOADER_ID, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
private void showHistoryPage() {
|
||||
final HistoryPage historyPage = HistoryPage.newInstance();
|
||||
showSubPage(historyPage);
|
||||
}
|
||||
|
||||
private void showTabsPage() {
|
||||
final LastTabsPage lastTabsPage = LastTabsPage.newInstance();
|
||||
showSubPage(lastTabsPage);
|
||||
}
|
||||
|
||||
private static class FrecencyCursorLoader extends SimpleCursorLoader {
|
||||
// Max number of search results
|
||||
private static final int SEARCH_LIMIT = 50;
|
||||
@ -172,6 +208,13 @@ public class VisitedPage extends HomeFragment {
|
||||
final int loaderId = loader.getId();
|
||||
switch(loaderId) {
|
||||
case FRECENCY_LOADER_ID:
|
||||
// Only set empty view once cursor is loaded to avoid
|
||||
// flashing the empty message before loading.
|
||||
mList.setEmptyView(mEmptyMessage);
|
||||
|
||||
final int buttonsVisibility = (c.getCount() == 0 ? View.GONE : View.VISIBLE);
|
||||
mButtonsContainer.setVisibility(buttonsVisibility);
|
||||
|
||||
mAdapter.swapCursor(c);
|
||||
|
||||
FaviconsLoader.restartFromCursor(getLoaderManager(), FAVICONS_LOADER_ID,
|
||||
|
@ -274,6 +274,7 @@ size. -->
|
||||
<!ENTITY abouthome_topsites_edit "Edit">
|
||||
<!ENTITY abouthome_topsites_pin "Pin Site">
|
||||
<!ENTITY abouthome_topsites_unpin "Unpin Site">
|
||||
<!ENTITY abouthome_visited_empty "Websites you visited go here">
|
||||
|
||||
<!-- Localization note (abouthome_about_sync3, abouthome_about_apps2): The
|
||||
chevron (ex: "»"; unicode= U+00BB) is used as an arrow to show that
|
||||
|
45
mobile/android/base/resources/layout/home_visited_page.xml
Normal file
45
mobile/android/base/resources/layout/home_visited_page.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView android:id="@+id/empty_message"
|
||||
style="@style/AboutHome.EmptyMessage"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:text="@string/abouthome_visited_empty"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.home.HomeListView
|
||||
android:id="@+id/visited_list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<LinearLayout android:id="@+id/buttons_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/background_light"
|
||||
android:visibility="gone">
|
||||
|
||||
<Button android:id="@+id/history_button"
|
||||
style="@style/AboutHome.PageButton"
|
||||
android:text="@string/history_title"/>
|
||||
|
||||
<View android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="#FFD1D5DA"/>
|
||||
|
||||
<Button android:id="@+id/tabs_button"
|
||||
style="@style/AboutHome.PageButton"
|
||||
android:text="@string/abouthome_last_tabs_title"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -502,6 +502,25 @@
|
||||
<item name="android:textColor">@color/abouthome_section_subtitle</item>
|
||||
</style>
|
||||
|
||||
<style name="AboutHome.EmptyMessage">
|
||||
<item name="android:textAppearance">@style/AboutHome.TextAppearance.PageTitle</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:focusable">false</item>
|
||||
<item name="android:paddingLeft">10dip</item>
|
||||
<item name="android:paddingRight">10dip</item>
|
||||
</style>
|
||||
|
||||
<style name="AboutHome.PageButton">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">40dip</item>
|
||||
<item name="android:textAppearance">@style/AboutHome.TextAppearance.PageTitle</item>
|
||||
<item name="android:background">@drawable/action_bar_button</item>
|
||||
<item name="android:focusable">true</item>
|
||||
<item name="android:gravity">center|left</item>
|
||||
<item name="android:paddingLeft">10dip</item>
|
||||
<item name="android:paddingRight">10dip</item>
|
||||
</style>
|
||||
|
||||
<style name="AboutHome.PageTitle">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">32dp</item>
|
||||
|
@ -249,6 +249,8 @@
|
||||
<string name="abouthome_topsites_pin">&abouthome_topsites_pin;</string>
|
||||
<string name="abouthome_topsites_unpin">&abouthome_topsites_unpin;</string>
|
||||
|
||||
<string name="abouthome_visited_empty">&abouthome_visited_empty;</string>
|
||||
|
||||
<string name="filepicker_title">&filepicker_title;</string>
|
||||
<string name="filepicker_audio_title">&filepicker_audio_title;</string>
|
||||
<string name="filepicker_image_title">&filepicker_image_title;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user