mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Bug 872762: Page title strip for the HomePager. [r=margaret]
This commit is contained in:
parent
863b18e46c
commit
a280726e90
@ -363,7 +363,7 @@ abstract public class BrowserApp extends GeckoApp
|
||||
}
|
||||
});
|
||||
|
||||
mHomePager = (HomePager) findViewById(R.id.abouthome_pager);
|
||||
mHomePager = (HomePager) findViewById(R.id.home_pager);
|
||||
|
||||
mBrowserToolbar = new BrowserToolbar(this);
|
||||
mBrowserToolbar.from(actionBar);
|
||||
|
@ -221,6 +221,7 @@ FENNEC_JAVA_FILES = \
|
||||
gfx/ViewTransform.java \
|
||||
gfx/VirtualLayer.java \
|
||||
home/HomePager.java \
|
||||
home/HomePagerTabStrip.java \
|
||||
widget/AboutHome.java \
|
||||
widget/AboutHomeView.java \
|
||||
widget/AboutHomeSection.java \
|
||||
|
@ -48,7 +48,7 @@ public class HomePager extends ViewPager {
|
||||
public void show(FragmentManager fm) {
|
||||
mLoaded = true;
|
||||
TabsAdapter adapter = new TabsAdapter(fm);
|
||||
adapter.addTab(Page.ABOUT_HOME, AboutHome.class, null);
|
||||
adapter.addTab(Page.ABOUT_HOME, AboutHome.class, null, "");
|
||||
setAdapter(adapter);
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
@ -101,11 +101,13 @@ public class HomePager extends ViewPager {
|
||||
private final Page page;
|
||||
private final Class<?> clss;
|
||||
private final Bundle args;
|
||||
private final String title;
|
||||
|
||||
TabInfo(Page page, Class<?> clss, Bundle args) {
|
||||
TabInfo(Page page, Class<?> clss, Bundle args, String title) {
|
||||
this.page = page;
|
||||
this.clss = clss;
|
||||
this.args = args;
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,8 +115,8 @@ public class HomePager extends ViewPager {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
public void addTab(Page page, Class<?> clss, Bundle args) {
|
||||
TabInfo info = new TabInfo(page, clss, args);
|
||||
public void addTab(Page page, Class<?> clss, Bundle args, String title) {
|
||||
TabInfo info = new TabInfo(page, clss, args, title);
|
||||
mTabs.add(info);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
@ -130,6 +132,12 @@ public class HomePager extends ViewPager {
|
||||
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
TabInfo info = mTabs.get(position);
|
||||
return info.title.toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
Fragment fragment = (Fragment) super.instantiateItem(container, position);
|
||||
|
35
mobile/android/base/home/HomePagerTabStrip.java
Normal file
35
mobile/android/base/home/HomePagerTabStrip.java
Normal file
@ -0,0 +1,35 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* 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/. */
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.v4.view.PagerTabStrip;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
/**
|
||||
* HomePagerTabStrip is a custom implementation of PagerTabStrip
|
||||
* that exposes XML attributes for the public methods.
|
||||
*/
|
||||
|
||||
public class HomePagerTabStrip extends PagerTabStrip {
|
||||
|
||||
public HomePagerTabStrip(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HomePagerTabStrip(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HomePagerTabStrip);
|
||||
int color = a.getColor(R.styleable.HomePagerTabStrip_tabIndicatorColor, 0x00);
|
||||
a.recycle();
|
||||
|
||||
setTabIndicatorColor(color);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
@ -28,11 +29,21 @@
|
||||
|
||||
<include layout="@layout/shared_ui_components"/>
|
||||
|
||||
<org.mozilla.gecko.home.HomePager android:id="@+id/abouthome_pager"
|
||||
<org.mozilla.gecko.home.HomePager android:id="@+id/home_pager"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/background_normal"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone">
|
||||
|
||||
<org.mozilla.gecko.home.HomePagerTabStrip android:layout_width="fill_parent"
|
||||
android:layout_height="32dip"
|
||||
android:layout_gravity="top"
|
||||
android:gravity="bottom"
|
||||
android:background="#FFECF0F3"
|
||||
gecko:tabIndicatorColor="@color/text_color_highlight"
|
||||
android:textAppearance="@style/TextAppearance.Widget.HomePagerTabStrip"/>
|
||||
|
||||
</org.mozilla.gecko.home.HomePager>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -164,5 +164,9 @@
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="HomePagerTabStrip">
|
||||
<attr name="tabIndicatorColor" format="color"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
|
@ -157,6 +157,10 @@
|
||||
<item name="android:textColor">@color/primary_text</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Widget.HomePagerTabStrip" parent="TextAppearance.Small">
|
||||
<item name="android:textColor">?android:attr/textColorHint</item>
|
||||
</style>
|
||||
|
||||
<!-- BrowserToolbar -->
|
||||
<style name="BrowserToolbar">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
|
Loading…
Reference in New Issue
Block a user