Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e1a56d6 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Revised assets for progress bars and indeterminate progress spinners."

parents 58c492f2 6af97e1c
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -2297,6 +2297,17 @@
 visibility="public"
>
</field>
<field name="animationResolution"
 type="int"
 transient="false"
 volatile="false"
 value="16843563"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="antialias"
 type="int"
 transient="false"
@@ -5135,6 +5146,17 @@
 visibility="public"
>
</field>
<field name="indeterminateProgressStyle"
 type="int"
 transient="false"
 volatile="false"
 value="16843561"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="indicatorLeft"
 type="int"
 transient="false"
@@ -7159,6 +7181,17 @@
 visibility="public"
>
</field>
<field name="progressBarPadding"
 type="int"
 transient="false"
 volatile="false"
 value="16843562"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="progressBarStyle"
 type="int"
 transient="false"
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import java.text.NumberFormat;
 */
public class ProgressDialog extends AlertDialog {
    
    /** Creates a ProgressDialog with a ciruclar, spinning progress
    /** Creates a ProgressDialog with a circular, spinning progress
     * bar. This is the default.
     */
    public static final int STYLE_SPINNER = 0;
+15 −3
Original line number Diff line number Diff line
@@ -154,6 +154,8 @@ public class ProgressBar extends View {

    private boolean mInDrawing;

    private int mAnimationResolution;

    /**
     * Create a new progress bar with range 0...100 and initial progress of 0.
     * @param context the application environment
@@ -167,12 +169,19 @@ public class ProgressBar extends View {
    }

    public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
        this(context, attrs, defStyle, 0);
    }

    /**
     * @hide
     */
    public ProgressBar(Context context, AttributeSet attrs, int defStyle, int styleRes) {
        super(context, attrs, defStyle);
        mUiThreadId = Thread.currentThread().getId();
        initProgressBar();

        TypedArray a =
            context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, 0);
            context.obtainStyledAttributes(attrs, R.styleable.ProgressBar, defStyle, styleRes);
        
        mNoInvalidate = true;
        
@@ -222,6 +231,9 @@ public class ProgressBar extends View {
        setIndeterminate(mOnlyIndeterminate || a.getBoolean(
                R.styleable.ProgressBar_indeterminate, mIndeterminate));

        mAnimationResolution = a.getInteger(R.styleable.ProgressBar_animationResolution,
                ANIMATION_RESOLUTION);

        a.recycle();
    }

@@ -852,9 +864,9 @@ public class ProgressBar extends View {
                } finally {
                    mInDrawing = false;
                }
                if (SystemClock.uptimeMillis() - mLastDrawTime >= ANIMATION_RESOLUTION) {
                if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) {
                    mLastDrawTime = SystemClock.uptimeMillis();
                    postInvalidateDelayed(ANIMATION_RESOLUTION);
                    postInvalidateDelayed(mAnimationResolution);
                }
            }
            d.draw(canvas);
+53 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.app.ActionBar.NavigationCallback;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.TypedArray;
@@ -45,6 +44,7 @@ import android.widget.AdapterView;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
@@ -94,9 +94,15 @@ public class ActionBarView extends ViewGroup {
    private HorizontalScrollView mTabScrollView;
    private LinearLayout mTabLayout;
    private View mCustomNavView;
    private ProgressBar mProgressView;
    private ProgressBar mIndeterminateProgressView;

    private int mProgressBarPadding;
    
    private int mTitleStyleRes;
    private int mSubtitleStyleRes;
    private int mProgressStyle;
    private int mIndeterminateProgressStyle;

    private boolean mShowMenu;
    private boolean mUserTitle;
@@ -185,6 +191,11 @@ public class ActionBarView extends ViewGroup {
        
        mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
        mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
        mProgressStyle = a.getResourceId(R.styleable.ActionBar_progressBarStyle, 0);
        mIndeterminateProgressStyle = a.getResourceId(
                R.styleable.ActionBar_indeterminateProgressStyle, 0);

        mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.ActionBar_progressBarPadding, 0);

        setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, DISPLAY_DEFAULT));

@@ -216,6 +227,20 @@ public class ActionBarView extends ViewGroup {
        mHomeLayout.setFocusable(true);
    }

    public void initProgress() {
        mProgressView = new ProgressBar(mContext, null, 0, mProgressStyle);
        mProgressView.setId(R.id.progress_horizontal);
        mProgressView.setMax(10000);
        addView(mProgressView);
    }

    public void initIndeterminateProgress() {
        mIndeterminateProgressView = new ProgressBar(mContext, null, 0,
                mIndeterminateProgressStyle);
        mIndeterminateProgressView.setId(R.id.progress_circular);
        addView(mIndeterminateProgressView);
    }

    @Override
    public ActionMode startActionModeForChild(View child, ActionMode.Callback callback) {
        // No starting an action mode for an action bar child! (Where would it go?)
@@ -665,6 +690,13 @@ public class ActionBarView extends ViewGroup {
            break;
        }

        if (mIndeterminateProgressView != null &&
                mIndeterminateProgressView.getVisibility() != GONE) {
            availableWidth = measureChildView(mIndeterminateProgressView, availableWidth,
                    childSpecHeight, 0);
            rightOfCenter -= mIndeterminateProgressView.getMeasuredWidth();
        }

        if ((mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomNavView != null) {
            final LayoutParams lp = generateLayoutParams(mCustomNavView.getLayoutParams());
            final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
@@ -726,6 +758,12 @@ public class ActionBarView extends ViewGroup {
        if (mContextView != null) {
            mContextView.setHeight(getMeasuredHeight());
        }

        if (mProgressView != null && mProgressView.getVisibility() != GONE) {
            mProgressView.measure(MeasureSpec.makeMeasureSpec(
                    contentWidth - mProgressBarPadding * 2, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST));
        }
    }

    private int measureChildView(View child, int availableWidth, int childSpecHeight, int spacing) {
@@ -764,6 +802,7 @@ public class ActionBarView extends ViewGroup {
            if (mTabScrollView != null) {
                x += positionChild(mTabScrollView, x, y, contentHeight);
            }
            break;
        }

        int menuLeft = r - l - getPaddingRight();
@@ -772,6 +811,12 @@ public class ActionBarView extends ViewGroup {
            menuLeft -= mMenuView.getMeasuredWidth();
        }

        if (mIndeterminateProgressView != null &&
                mIndeterminateProgressView.getVisibility() != GONE) {
            positionChildInverse(mIndeterminateProgressView, menuLeft, y, contentHeight);
            menuLeft -= mIndeterminateProgressView.getMeasuredWidth();
        }

        if (mCustomNavView != null && (mDisplayOptions & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) {
            LayoutParams lp = mCustomNavView.getLayoutParams();
            final ActionBar.LayoutParams ablp = lp instanceof ActionBar.LayoutParams ?
@@ -830,6 +875,13 @@ public class ActionBarView extends ViewGroup {
            }
            x += positionChild(mCustomNavView, xpos, ypos, contentHeight);
        }

        if (mProgressView != null) {
            mProgressView.bringToFront();
            final int halfProgressHeight = mProgressView.getMeasuredHeight() / 2;
            mProgressView.layout(mProgressBarPadding, -halfProgressHeight,
                    mProgressBarPadding + mProgressView.getMeasuredWidth(), halfProgressHeight);
        }
    }

    private int positionChild(View child, int x, int y, int contentHeight) {
+151 B (313 B)
Loading image diff...
Loading