Search in sources :

Example 1 with ProgressBar

use of android.widget.ProgressBar in project philm by chrisbanes.

the class ListFragment method onCreateView.

/**
     * Provide default implementation to return a simple list view.  Subclasses
     * can override to replace with their own layout.  If doing so, the
     * returned view hierarchy <em>must</em> have a ListView whose id
     * is {@link android.R.id#list android.R.id.list} and can optionally
     * have a sibling view id {@link android.R.id#empty android.R.id.empty}
     * that is to be shown when the list is empty.
     *
     * <p>If you are overriding this method with your own custom content,
     * consider including the standard layout {@link android.R.layout#list_content}
     * in your layout file, so that you continue to retain all of the standard
     * behavior of ListFragment.  In particular, this is currently the only
     * way to have the built-in indeterminant progress state be shown.
     */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout contentRoot = new FrameLayout(context);
    // ------------------------------------------------------------------
    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    progress.setId(INTERNAL_PROGRESS_ID);
    progress.setVisibility(View.GONE);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER;
    contentRoot.addView(progress, lp);
    // ------------------------------------------------------------------
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    FontTextView tv = new FontTextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    tv.setFont(FontTextView.FONT_ROBOTO_CONDENSED);
    final int p = getResources().getDimensionPixelSize(R.dimen.spacing_major);
    tv.setPadding(p, p, p, p);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    E lv = createListView(context, inflater);
    lv.setId(android.R.id.list);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    contentRoot.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    // ------------------------------------------------------------------
    ProgressBar secondaryProgress = new SmoothProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    secondaryProgress.setId(INTERNAL_SECONDARY_PROGRESS_ID);
    secondaryProgress.setVisibility(View.GONE);
    secondaryProgress.setIndeterminate(true);
    contentRoot.addView(secondaryProgress, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
    View root;
    if (getParentFragment() == null) {
        final LinearLayout toolbarRoot = new LinearLayout(context);
        toolbarRoot.setOrientation(LinearLayout.VERTICAL);
        // Finally, add the Toolbar
        inflater.inflate(R.layout.include_toolbar, toolbarRoot, true);
        toolbarRoot.addView(contentRoot, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
        root = toolbarRoot;
    } else {
        root = contentRoot;
    }
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    return root;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) FontTextView(app.philm.in.view.FontTextView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) FrameLayout(android.widget.FrameLayout) FontTextView(app.philm.in.view.FontTextView) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) ProgressBar(android.widget.ProgressBar) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) LinearLayout(android.widget.LinearLayout)

Example 2 with ProgressBar

use of android.widget.ProgressBar in project android_frameworks_base by ParanoidAndroid.

the class ActionBarView method initProgress.

public void initProgress() {
    mProgressView = new ProgressBar(mContext, null, 0, mProgressStyle);
    mProgressView.setId(R.id.progress_horizontal);
    mProgressView.setMax(10000);
    mProgressView.setVisibility(GONE);
    addView(mProgressView);
}
Also used : ProgressBar(android.widget.ProgressBar)

Example 3 with ProgressBar

use of android.widget.ProgressBar in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindow method updateProgressBars.

/**
     * Updates the progress bars that are shown in the title bar.
     *
     * @param value Can be one of {@link Window#PROGRESS_VISIBILITY_ON},
     *            {@link Window#PROGRESS_VISIBILITY_OFF},
     *            {@link Window#PROGRESS_INDETERMINATE_ON},
     *            {@link Window#PROGRESS_INDETERMINATE_OFF}, or a value
     *            starting at {@link Window#PROGRESS_START} through
     *            {@link Window#PROGRESS_END} for setting the default
     *            progress (if {@link Window#PROGRESS_END} is given,
     *            the progress bar widgets in the title will be hidden after an
     *            animation), a value between
     *            {@link Window#PROGRESS_SECONDARY_START} -
     *            {@link Window#PROGRESS_SECONDARY_END} for the
     *            secondary progress (if
     *            {@link Window#PROGRESS_SECONDARY_END} is given, the
     *            progress bar widgets will still be shown with the secondary
     *            progress bar will be completely filled in.)
     */
private void updateProgressBars(int value) {
    ProgressBar circularProgressBar = getCircularProgressBar(true);
    ProgressBar horizontalProgressBar = getHorizontalProgressBar(true);
    final int features = getLocalFeatures();
    if (value == PROGRESS_VISIBILITY_ON) {
        if ((features & (1 << FEATURE_PROGRESS)) != 0) {
            int level = horizontalProgressBar.getProgress();
            int visibility = (horizontalProgressBar.isIndeterminate() || level < 10000) ? View.VISIBLE : View.INVISIBLE;
            horizontalProgressBar.setVisibility(visibility);
        }
        if ((features & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) {
            circularProgressBar.setVisibility(View.VISIBLE);
        }
    } else if (value == PROGRESS_VISIBILITY_OFF) {
        if ((features & (1 << FEATURE_PROGRESS)) != 0) {
            horizontalProgressBar.setVisibility(View.GONE);
        }
        if ((features & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) {
            circularProgressBar.setVisibility(View.GONE);
        }
    } else if (value == PROGRESS_INDETERMINATE_ON) {
        horizontalProgressBar.setIndeterminate(true);
    } else if (value == PROGRESS_INDETERMINATE_OFF) {
        horizontalProgressBar.setIndeterminate(false);
    } else if (PROGRESS_START <= value && value <= PROGRESS_END) {
        // We want to set the progress value before testing for visibility
        // so that when the progress bar becomes visible again, it has the
        // correct level.
        horizontalProgressBar.setProgress(value - PROGRESS_START);
        if (value < PROGRESS_END) {
            showProgressBars(horizontalProgressBar, circularProgressBar);
        } else {
            hideProgressBars(horizontalProgressBar, circularProgressBar);
        }
    } else if (PROGRESS_SECONDARY_START <= value && value <= PROGRESS_SECONDARY_END) {
        horizontalProgressBar.setSecondaryProgress(value - PROGRESS_SECONDARY_START);
        showProgressBars(horizontalProgressBar, circularProgressBar);
    }
}
Also used : ProgressBar(android.widget.ProgressBar)

Example 4 with ProgressBar

use of android.widget.ProgressBar in project android_frameworks_base by ParanoidAndroid.

the class PhoneWindow method generateLayout.

protected ViewGroup generateLayout(DecorView decor) {
    // Apply data from current theme.
    TypedArray a = getWindowStyle();
    if (false) {
        System.out.println("From style:");
        String s = "Attrs:";
        for (int i = 0; i < com.android.internal.R.styleable.Window.length; i++) {
            s = s + " " + Integer.toHexString(com.android.internal.R.styleable.Window[i]) + "=" + a.getString(i);
        }
        System.out.println(s);
    }
    mIsFloating = a.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating, false);
    int flagsToUpdate = (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR) & (~getForcedWindowFlags());
    if (mIsFloating) {
        setLayout(WRAP_CONTENT, WRAP_CONTENT);
        setFlags(0, flagsToUpdate);
    } else {
        setFlags(FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR, flagsToUpdate);
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowNoTitle, false)) {
        requestFeature(FEATURE_NO_TITLE);
    } else if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(FEATURE_ACTION_BAR);
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionBarOverlay, false)) {
        requestFeature(FEATURE_ACTION_BAR_OVERLAY);
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowActionModeOverlay, false)) {
        requestFeature(FEATURE_ACTION_MODE_OVERLAY);
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowFullscreen, false)) {
        setFlags(FLAG_FULLSCREEN, FLAG_FULLSCREEN & (~getForcedWindowFlags()));
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowOverscan, false)) {
        setFlags(FLAG_LAYOUT_IN_OVERSCAN, FLAG_LAYOUT_IN_OVERSCAN & (~getForcedWindowFlags()));
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowShowWallpaper, false)) {
        setFlags(FLAG_SHOW_WALLPAPER, FLAG_SHOW_WALLPAPER & (~getForcedWindowFlags()));
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_windowEnableSplitTouch, getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB)) {
        setFlags(FLAG_SPLIT_TOUCH, FLAG_SPLIT_TOUCH & (~getForcedWindowFlags()));
    }
    a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMajor, mMinWidthMajor);
    a.getValue(com.android.internal.R.styleable.Window_windowMinWidthMinor, mMinWidthMinor);
    if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedWidthMajor)) {
        if (mFixedWidthMajor == null)
            mFixedWidthMajor = new TypedValue();
        a.getValue(com.android.internal.R.styleable.Window_windowFixedWidthMajor, mFixedWidthMajor);
    }
    if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedWidthMinor)) {
        if (mFixedWidthMinor == null)
            mFixedWidthMinor = new TypedValue();
        a.getValue(com.android.internal.R.styleable.Window_windowFixedWidthMinor, mFixedWidthMinor);
    }
    if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedHeightMajor)) {
        if (mFixedHeightMajor == null)
            mFixedHeightMajor = new TypedValue();
        a.getValue(com.android.internal.R.styleable.Window_windowFixedHeightMajor, mFixedHeightMajor);
    }
    if (a.hasValue(com.android.internal.R.styleable.Window_windowFixedHeightMinor)) {
        if (mFixedHeightMinor == null)
            mFixedHeightMinor = new TypedValue();
        a.getValue(com.android.internal.R.styleable.Window_windowFixedHeightMinor, mFixedHeightMinor);
    }
    final Context context = getContext();
    final int targetSdk = context.getApplicationInfo().targetSdkVersion;
    final boolean targetPreHoneycomb = targetSdk < android.os.Build.VERSION_CODES.HONEYCOMB;
    final boolean targetPreIcs = targetSdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
    final boolean targetHcNeedsOptions = context.getResources().getBoolean(com.android.internal.R.bool.target_honeycomb_needs_options_menu);
    final boolean noActionBar = !hasFeature(FEATURE_ACTION_BAR) || hasFeature(FEATURE_NO_TITLE);
    if (targetPreHoneycomb || (targetPreIcs && targetHcNeedsOptions && noActionBar)) {
        addFlags(WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY);
    } else {
        clearFlags(WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY);
    }
    if (mAlwaysReadCloseOnTouchAttr || getContext().getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        if (a.getBoolean(com.android.internal.R.styleable.Window_windowCloseOnTouchOutside, false)) {
            setCloseOnTouchOutsideIfNotSet(true);
        }
    }
    WindowManager.LayoutParams params = getAttributes();
    if (!hasSoftInputMode()) {
        params.softInputMode = a.getInt(com.android.internal.R.styleable.Window_windowSoftInputMode, params.softInputMode);
    }
    if (a.getBoolean(com.android.internal.R.styleable.Window_backgroundDimEnabled, mIsFloating)) {
        /* All dialogs should have the window dimmed */
        if ((getForcedWindowFlags() & WindowManager.LayoutParams.FLAG_DIM_BEHIND) == 0) {
            params.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
        }
        if (!haveDimAmount()) {
            params.dimAmount = a.getFloat(android.R.styleable.Window_backgroundDimAmount, 0.5f);
        }
    }
    if (params.windowAnimations == 0) {
        params.windowAnimations = a.getResourceId(com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
    }
    // the values are inherited from our container.
    if (getContainer() == null) {
        if (mBackgroundDrawable == null) {
            if (mBackgroundResource == 0) {
                mBackgroundResource = a.getResourceId(com.android.internal.R.styleable.Window_windowBackground, 0);
            }
            if (mFrameResource == 0) {
                mFrameResource = a.getResourceId(com.android.internal.R.styleable.Window_windowFrame, 0);
            }
            if (false) {
                System.out.println("Background: " + Integer.toHexString(mBackgroundResource) + " Frame: " + Integer.toHexString(mFrameResource));
            }
        }
        mTextColor = a.getColor(com.android.internal.R.styleable.Window_textColor, 0xFF000000);
    }
    // Inflate the window decor.
    int layoutResource;
    int features = getLocalFeatures();
    // System.out.println("Features: 0x" + Integer.toHexString(features));
    if ((features & ((1 << FEATURE_LEFT_ICON) | (1 << FEATURE_RIGHT_ICON))) != 0) {
        if (mIsFloating) {
            TypedValue res = new TypedValue();
            getContext().getTheme().resolveAttribute(com.android.internal.R.attr.dialogTitleIconsDecorLayout, res, true);
            layoutResource = res.resourceId;
        } else {
            layoutResource = com.android.internal.R.layout.screen_title_icons;
        }
        // XXX Remove this once action bar supports these features.
        removeFeature(FEATURE_ACTION_BAR);
    // System.out.println("Title Icons!");
    } else if ((features & ((1 << FEATURE_PROGRESS) | (1 << FEATURE_INDETERMINATE_PROGRESS))) != 0 && (features & (1 << FEATURE_ACTION_BAR)) == 0) {
        // Special case for a window with only a progress bar (and title).
        // XXX Need to have a no-title version of embedded windows.
        layoutResource = com.android.internal.R.layout.screen_progress;
    // System.out.println("Progress!");
    } else if ((features & (1 << FEATURE_CUSTOM_TITLE)) != 0) {
        // If the window is floating, we need a dialog layout
        if (mIsFloating) {
            TypedValue res = new TypedValue();
            getContext().getTheme().resolveAttribute(com.android.internal.R.attr.dialogCustomTitleDecorLayout, res, true);
            layoutResource = res.resourceId;
        } else {
            layoutResource = com.android.internal.R.layout.screen_custom_title;
        }
        // XXX Remove this once action bar supports these features.
        removeFeature(FEATURE_ACTION_BAR);
    } else if ((features & (1 << FEATURE_NO_TITLE)) == 0) {
        // If the window is floating, we need a dialog layout
        if (mIsFloating) {
            TypedValue res = new TypedValue();
            getContext().getTheme().resolveAttribute(com.android.internal.R.attr.dialogTitleDecorLayout, res, true);
            layoutResource = res.resourceId;
        } else if ((features & (1 << FEATURE_ACTION_BAR)) != 0) {
            layoutResource = com.android.internal.R.layout.screen_action_bar;
        } else {
            layoutResource = com.android.internal.R.layout.screen_title;
        }
    // System.out.println("Title!");
    } else if ((features & (1 << FEATURE_ACTION_MODE_OVERLAY)) != 0) {
        layoutResource = com.android.internal.R.layout.screen_simple_overlay_action_mode;
    } else {
        // Embedded, so no decoration is needed.
        layoutResource = com.android.internal.R.layout.screen_simple;
    // System.out.println("Simple!");
    }
    mDecor.startChanging();
    View in = mLayoutInflater.inflate(layoutResource, null);
    decor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    ViewGroup contentParent = (ViewGroup) findViewById(ID_ANDROID_CONTENT);
    if (contentParent == null) {
        throw new RuntimeException("Window couldn't find content container view");
    }
    if ((features & (1 << FEATURE_INDETERMINATE_PROGRESS)) != 0) {
        ProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }
    // to top-level windows.
    if (getContainer() == null) {
        Drawable drawable = mBackgroundDrawable;
        if (mBackgroundResource != 0) {
            drawable = getContext().getResources().getDrawable(mBackgroundResource);
        }
        mDecor.setWindowBackground(drawable);
        drawable = null;
        if (mFrameResource != 0) {
            drawable = getContext().getResources().getDrawable(mFrameResource);
        }
        mDecor.setWindowFrame(drawable);
        if (mTitleColor == 0) {
            mTitleColor = mTextColor;
        }
        if (mTitle != null) {
            setTitle(mTitle);
        }
        setTitleColor(mTitleColor);
    }
    mDecor.finishChanging();
    return contentParent;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) Drawable(android.graphics.drawable.Drawable) MenuView(com.android.internal.view.menu.MenuView) ImageView(android.widget.ImageView) View(android.view.View) ActionBarView(com.android.internal.widget.ActionBarView) TextView(android.widget.TextView) ActionBarContextView(com.android.internal.widget.ActionBarContextView) WindowManager(android.view.WindowManager) IWindowManager(android.view.IWindowManager) AndroidRuntimeException(android.util.AndroidRuntimeException) TypedArray(android.content.res.TypedArray) LayoutParams(android.view.WindowManager.LayoutParams) ProgressBar(android.widget.ProgressBar) TypedValue(android.util.TypedValue)

Example 5 with ProgressBar

use of android.widget.ProgressBar in project Anki-Android by Ramblurr.

the class Feedback method refreshInterface.

private void refreshInterface() {
    if (mAllowFeedback) {
        Resources res = getResources();
        Button btnSend = (Button) findViewById(R.id.btnFeedbackSend);
        Button btnKeepLatest = (Button) findViewById(R.id.btnFeedbackKeepLatest);
        Button btnClearAll = (Button) findViewById(R.id.btnFeedbackClearAll);
        ProgressBar pbSpinner = (ProgressBar) findViewById(R.id.pbFeedbackSpinner);
        int numErrors = mErrorReports.size();
        if (numErrors == 0 || mErrorsSent) {
            if (!mErrorsSent) {
                mLvErrorList.setVisibility(View.GONE);
            }
            btnKeepLatest.setVisibility(View.GONE);
            btnClearAll.setVisibility(View.GONE);
            btnSend.setText(res.getString(R.string.feedback_send_feedback));
        } else {
            mLvErrorList.setVisibility(View.VISIBLE);
            btnKeepLatest.setVisibility(View.VISIBLE);
            btnClearAll.setVisibility(View.VISIBLE);
            btnSend.setText(res.getString(R.string.feedback_send_feedback_and_errors));
            refreshErrorListView();
            if (numErrors == 1) {
                btnKeepLatest.setEnabled(false);
            } else {
                btnKeepLatest.setEnabled(true);
            }
        }
        if (mPostingFeedback) {
            int buttonHeight = btnSend.getHeight();
            btnSend.setVisibility(View.GONE);
            pbSpinner.setVisibility(View.VISIBLE);
            LinearLayout topLine = (LinearLayout) findViewById(R.id.llFeedbackTopLine);
            topLine.setMinimumHeight(buttonHeight);
            mEtFeedbackText.setEnabled(false);
            mImm.hideSoftInputFromWindow(mEtFeedbackText.getWindowToken(), 0);
        } else {
            btnSend.setVisibility(View.VISIBLE);
            pbSpinner.setVisibility(View.GONE);
            mEtFeedbackText.setEnabled(true);
        }
    }
}
Also used : Button(android.widget.Button) Resources(android.content.res.Resources) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Aggregations

ProgressBar (android.widget.ProgressBar)184 TextView (android.widget.TextView)63 View (android.view.View)60 ImageView (android.widget.ImageView)40 LinearLayout (android.widget.LinearLayout)27 Context (android.content.Context)18 ViewGroup (android.view.ViewGroup)14 WindowManager (android.view.WindowManager)14 FrameLayout (android.widget.FrameLayout)14 Dialog (android.app.Dialog)12 Drawable (android.graphics.drawable.Drawable)12 RelativeLayout (android.widget.RelativeLayout)12 LayoutInflater (android.view.LayoutInflater)11 Button (android.widget.Button)11 LayoutParams (android.widget.LinearLayout.LayoutParams)9 Intent (android.content.Intent)8 LayoutParams (android.view.ViewGroup.LayoutParams)8 AlertDialog (android.app.AlertDialog)7 TypedArray (android.content.res.TypedArray)7 AdapterView (android.widget.AdapterView)7