Loading core/java/com/tmobile/widget/ProgressBarOverlayLayout.java +66 −62 Original line number Diff line number Diff line package com.tmobile.widget; import com.android.internal.R; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import com.android.internal.R; public class ProgressBarOverlayLayout extends RelativeLayout { private Context mContext; public class ProgressBarOverlayLayout extends FrameLayout { private ProgressBar mProgressBar; private final int mProgressBarType; private static final int PROGRESS_TYPE_INDICATOR = 0; private static final int PROGRESS_TYPE_BAR = 1; Loading @@ -28,51 +29,54 @@ public class ProgressBarOverlayLayout extends RelativeLayout { public ProgressBarOverlayLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressOverlayLayout, defStyle, 0); final int progressType = a.getInt(R.styleable.ProgressOverlayLayout_progressType, PROGRESS_TYPE_INDICATOR); createProgressBar(progressType); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressOverlayLayout, defStyle, 0); final int progressType = a.getInt(R.styleable.ProgressOverlayLayout_progressType, PROGRESS_TYPE_INDICATOR); mProgressBarType = progressType; a.recycle(); init(context); } private void createProgressBar(int progressType) { switch(progressType) { private void init(Context context) { int layout; switch(mProgressBarType) { case PROGRESS_TYPE_INDICATOR: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressindicator_overlay, this, false); layout = R.layout.tmobile_progressindicator_overlay; break; case PROGRESS_TYPE_BAR: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressbar_overlay, this, false); layout = R.layout.tmobile_progressbar_overlay; break; case PROGRESS_TYPE_BAR_BOTTOM: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressbar_bottom_overlay, this, false); layout = R.layout.tmobile_progressbar_bottom_overlay; break; } default: throw new IllegalArgumentException("Unknown progressType " + mProgressBarType); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { boolean isFixedWidthSpec = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; boolean isFixedHeightSpec = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY; if (isFixedWidthSpec && isFixedHeightSpec) { addView(mProgressBar); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } else { // RelativeLayout cannot layout out progress bar overlay correctly until it knows its children's dimensions. super.onMeasure(widthMeasureSpec, heightMeasureSpec); addView(mProgressBar); widthMeasureSpec = isFixedWidthSpec ? widthMeasureSpec : MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY); heightMeasureSpec = isFixedHeightSpec ? heightMeasureSpec : MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); LayoutInflater.from(context).inflate(layout, this); mProgressBar = (ProgressBar)getChildAt(0); } public int getProgressBarType() { return mProgressBarType; } public ProgressBar getProgressBar() { return mProgressBar; } @Override public void addView(View child, int index, ViewGroup.LayoutParams params) { /* Make sure the ProgressBar is last. This is necessary because drawing * on FrameLayout occurs in order of addition. */ if (mProgressBar != null && (index == -1 || index == getChildCount())) { super.addView(child, getChildCount() - 1, params); } else { super.addView(child, index, params); } } } core/res/res/layout/tmobile_progressbar_bottom_overlay.xml +7 −9 Original line number Diff line number Diff line Loading @@ -2,10 +2,8 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbarOverlay" android:layout_gravity="bottom|right" android:layout_width="158dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginRight="5dp" android:layout_marginBottom="5dp" /> core/res/res/layout/tmobile_progressbar_overlay.xml +6 −8 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbarOverlay" android:layout_gravity="right|center_vertical" android:layout_width="158dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="5dp" /> core/res/res/layout/tmobile_progressindicator_overlay.xml +6 −8 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyle" android:id="@+id/progressbarOverlay" android:layout_gravity="right|center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="5dp" /> Loading
core/java/com/tmobile/widget/ProgressBarOverlayLayout.java +66 −62 Original line number Diff line number Diff line package com.tmobile.widget; import com.android.internal.R; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.RelativeLayout; import com.android.internal.R; public class ProgressBarOverlayLayout extends RelativeLayout { private Context mContext; public class ProgressBarOverlayLayout extends FrameLayout { private ProgressBar mProgressBar; private final int mProgressBarType; private static final int PROGRESS_TYPE_INDICATOR = 0; private static final int PROGRESS_TYPE_BAR = 1; Loading @@ -28,51 +29,54 @@ public class ProgressBarOverlayLayout extends RelativeLayout { public ProgressBarOverlayLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mContext = context; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressOverlayLayout, defStyle, 0); final int progressType = a.getInt(R.styleable.ProgressOverlayLayout_progressType, PROGRESS_TYPE_INDICATOR); createProgressBar(progressType); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressOverlayLayout, defStyle, 0); final int progressType = a.getInt(R.styleable.ProgressOverlayLayout_progressType, PROGRESS_TYPE_INDICATOR); mProgressBarType = progressType; a.recycle(); init(context); } private void createProgressBar(int progressType) { switch(progressType) { private void init(Context context) { int layout; switch(mProgressBarType) { case PROGRESS_TYPE_INDICATOR: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressindicator_overlay, this, false); layout = R.layout.tmobile_progressindicator_overlay; break; case PROGRESS_TYPE_BAR: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressbar_overlay, this, false); layout = R.layout.tmobile_progressbar_overlay; break; case PROGRESS_TYPE_BAR_BOTTOM: mProgressBar = (ProgressBar) LayoutInflater.from(mContext).inflate( R.layout.tmobile_progressbar_bottom_overlay, this, false); layout = R.layout.tmobile_progressbar_bottom_overlay; break; } default: throw new IllegalArgumentException("Unknown progressType " + mProgressBarType); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { boolean isFixedWidthSpec = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY; boolean isFixedHeightSpec = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY; if (isFixedWidthSpec && isFixedHeightSpec) { addView(mProgressBar); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } else { // RelativeLayout cannot layout out progress bar overlay correctly until it knows its children's dimensions. super.onMeasure(widthMeasureSpec, heightMeasureSpec); addView(mProgressBar); widthMeasureSpec = isFixedWidthSpec ? widthMeasureSpec : MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY); heightMeasureSpec = isFixedHeightSpec ? heightMeasureSpec : MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY); super.onMeasure(widthMeasureSpec, heightMeasureSpec); LayoutInflater.from(context).inflate(layout, this); mProgressBar = (ProgressBar)getChildAt(0); } public int getProgressBarType() { return mProgressBarType; } public ProgressBar getProgressBar() { return mProgressBar; } @Override public void addView(View child, int index, ViewGroup.LayoutParams params) { /* Make sure the ProgressBar is last. This is necessary because drawing * on FrameLayout occurs in order of addition. */ if (mProgressBar != null && (index == -1 || index == getChildCount())) { super.addView(child, getChildCount() - 1, params); } else { super.addView(child, index, params); } } }
core/res/res/layout/tmobile_progressbar_bottom_overlay.xml +7 −9 Original line number Diff line number Diff line Loading @@ -2,10 +2,8 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbarOverlay" android:layout_gravity="bottom|right" android:layout_width="158dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginRight="5dp" android:layout_marginBottom="5dp" />
core/res/res/layout/tmobile_progressbar_overlay.xml +6 −8 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyleHorizontal" android:id="@+id/progressbarOverlay" android:layout_gravity="right|center_vertical" android:layout_width="158dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="5dp" />
core/res/res/layout/tmobile_progressindicator_overlay.xml +6 −8 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ <ProgressBar xmlns:android="http://schemas.android.com/apk/res/android" style="?android:attr/progressBarStyle" android:id="@+id/progressbarOverlay" android:layout_gravity="right|center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="5dp" />