mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 14:15:30 +00:00
Bug 1185002 - Use TabMenuStrip in firstrun. r=sebastian
--HG-- extra : commitid : HRT22juvpD7 extra : rebase_source : 38b322a7ecbf6727082f47c7d8c1f493b43fa91e
This commit is contained in:
parent
d855b4df41
commit
8c8e94258e
@ -11,7 +11,8 @@ import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.nineoldandroids.animation.Animator;
|
||||
import com.nineoldandroids.animation.AnimatorSet;
|
||||
import com.nineoldandroids.animation.ObjectAnimator;
|
||||
@ -21,6 +22,8 @@ import org.mozilla.gecko.RestrictedProfiles;
|
||||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.TelemetryContract;
|
||||
import org.mozilla.gecko.animation.TransitionsTracker;
|
||||
import org.mozilla.gecko.home.HomePager.Decor;
|
||||
import org.mozilla.gecko.home.TabMenuStrip;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -28,6 +31,8 @@ public class FirstrunPager extends ViewPager {
|
||||
|
||||
private Context context;
|
||||
protected FirstrunPanel.PagerNavigation pagerNavigation;
|
||||
private Decor mDecor;
|
||||
private View mTabStrip;
|
||||
|
||||
public FirstrunPager(Context context) {
|
||||
this(context, null);
|
||||
@ -38,6 +43,24 @@ public class FirstrunPager extends ViewPager {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
||||
if (child instanceof Decor) {
|
||||
((ViewPager.LayoutParams) params).isDecor = true;
|
||||
mDecor = (Decor) child;
|
||||
mTabStrip = child;
|
||||
|
||||
mDecor.setOnTitleClickListener(new TabMenuStrip.OnTitleClickListener() {
|
||||
@Override
|
||||
public void onTitleClicked(int index) {
|
||||
setCurrentItem(index, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
super.addView(child, index, params);
|
||||
}
|
||||
|
||||
public void load(Context appContext, FragmentManager fm, final FirstrunPane.OnFinishListener onFinishListener) {
|
||||
final List<FirstrunPagerConfig.FirstrunPanelConfig> panels;
|
||||
|
||||
@ -66,10 +89,13 @@ public class FirstrunPager extends ViewPager {
|
||||
};
|
||||
addOnPageChangeListener(new OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int i, float v, int i1) {}
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
mDecor.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int i) {
|
||||
mDecor.onPageSelected(i);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.PANEL, "onboarding." + i);
|
||||
}
|
||||
|
||||
@ -111,6 +137,9 @@ public class FirstrunPager extends ViewPager {
|
||||
super(fm);
|
||||
this.panels = panels;
|
||||
this.fragments = new Fragment[panels.size()];
|
||||
for (FirstrunPagerConfig.FirstrunPanelConfig panel : panels) {
|
||||
mDecor.onAddPagerView(context.getString(panel.getTitleRes()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,6 +160,7 @@ public class FirstrunPager extends ViewPager {
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int i) {
|
||||
// Unused now that we use TabMenuStrip.
|
||||
return context.getString(panels.get(i).getTitleRes()).toUpperCase();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
public class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private final Context mContext;
|
||||
private final ArrayList<PanelInfo> mPanelInfos;
|
||||
@ -29,8 +29,8 @@ class HomeAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private OnAddPanelListener mAddPanelListener;
|
||||
|
||||
interface OnAddPanelListener {
|
||||
public void onAddPanel(String title);
|
||||
public interface OnAddPanelListener {
|
||||
void onAddPanel(String title);
|
||||
}
|
||||
|
||||
public HomeAdapter(Context context, FragmentManager fm) {
|
||||
|
@ -114,19 +114,15 @@ public class HomePager extends ViewPager {
|
||||
public void onPanelSelected(String panelId);
|
||||
}
|
||||
|
||||
interface OnTitleClickListener {
|
||||
public void onTitleClicked(int index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Special type of child views that could be added as pager decorations by default.
|
||||
*/
|
||||
interface Decor {
|
||||
public void onAddPagerView(String title);
|
||||
public void removeAllPagerViews();
|
||||
public void onPageSelected(int position);
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels);
|
||||
public void setOnTitleClickListener(OnTitleClickListener onTitleClickListener);
|
||||
public interface Decor {
|
||||
void onAddPagerView(String title);
|
||||
void removeAllPagerViews();
|
||||
void onPageSelected(int position);
|
||||
void onPageScrolled(int position, float positionOffset, int positionOffsetPixels);
|
||||
void setOnTitleClickListener(TabMenuStrip.OnTitleClickListener onTitleClickListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +181,7 @@ public class HomePager extends ViewPager {
|
||||
mDecor = (Decor) child;
|
||||
mTabStrip = child;
|
||||
|
||||
mDecor.setOnTitleClickListener(new OnTitleClickListener() {
|
||||
mDecor.setOnTitleClickListener(new TabMenuStrip.OnTitleClickListener() {
|
||||
@Override
|
||||
public void onTitleClicked(int index) {
|
||||
setCurrentItem(index, true);
|
||||
|
@ -41,6 +41,10 @@ public class TabMenuStrip extends HorizontalScrollView
|
||||
private final Paint shadowPaint;
|
||||
private final int shadowSize;
|
||||
|
||||
public interface OnTitleClickListener {
|
||||
void onTitleClicked(int index);
|
||||
}
|
||||
|
||||
public TabMenuStrip(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@ -117,7 +121,7 @@ public class TabMenuStrip extends HorizontalScrollView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnTitleClickListener(HomePager.OnTitleClickListener onTitleClickListener) {
|
||||
public void setOnTitleClickListener(OnTitleClickListener onTitleClickListener) {
|
||||
layout.setOnTitleClickListener(onTitleClickListener);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import android.widget.TextView;
|
||||
class TabMenuStripLayout extends LinearLayout
|
||||
implements View.OnFocusChangeListener {
|
||||
|
||||
private HomePager.OnTitleClickListener onTitleClickListener;
|
||||
private TabMenuStrip.OnTitleClickListener onTitleClickListener;
|
||||
private Drawable strip;
|
||||
private TextView selectedView;
|
||||
|
||||
@ -209,7 +209,7 @@ class TabMenuStripLayout extends LinearLayout
|
||||
}
|
||||
}
|
||||
|
||||
void setOnTitleClickListener(HomePager.OnTitleClickListener onTitleClickListener) {
|
||||
void setOnTitleClickListener(TabMenuStrip.OnTitleClickListener onTitleClickListener) {
|
||||
this.onTitleClickListener = onTitleClickListener;
|
||||
}
|
||||
|
||||
|
@ -16,13 +16,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/firstrun_pager_background">
|
||||
|
||||
<org.mozilla.gecko.home.HomePagerTabStrip android:id="@+id/firstrun_tab_strip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="top"
|
||||
android:gravity="center_vertical"
|
||||
android:background="@color/firstrun_tabstrip"
|
||||
gecko:tabIndicatorColor="@color/fennec_ui_orange"
|
||||
android:textColor="@color/android:white"/>
|
||||
<org.mozilla.gecko.home.TabMenuStrip android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/tabs_strip_height"
|
||||
android:background="@color/firstrun_tabstrip"
|
||||
android:visibility="visible"
|
||||
android:layout_gravity="top"
|
||||
gecko:strip="@drawable/home_tab_menu_strip"/>
|
||||
|
||||
</org.mozilla.gecko.firstrun.FirstrunPager>
|
||||
</org.mozilla.gecko.firstrun.FirstrunPane>
|
||||
|
@ -4,8 +4,9 @@
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:minWidth="@dimen/tabs_strip_button_width"
|
||||
android:background="@drawable/tabs_strip_indicator"
|
||||
android:paddingLeft="@dimen/tabs_strip_button_padding"
|
||||
|
Loading…
Reference in New Issue
Block a user