Search in sources :

Example 31 with ProgressBar

use of android.widget.ProgressBar in project phonegap-facebook-plugin by Wizcorp.

the class CordovaChromeClient method getVideoLoadingProgressView.

@Override
public /**
     * Ask the host application for a custom progress view to show while
     * a <video> is loading.
     * @return View The progress view.
     */
View getVideoLoadingProgressView() {
    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.
        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);
        mVideoProgressView = layout;
    }
    return mVideoProgressView;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Example 32 with ProgressBar

use of android.widget.ProgressBar in project remusic by aa112901.

the class AppCompatProgressBarHelper method getTintTarget.

@Nullable
private Drawable getTintTarget(int layerId, boolean shouldFallback) {
    Drawable layer = null;
    final Drawable d = ((ProgressBar) mView).getProgressDrawable();
    if (d != null) {
        ((ProgressBar) mView).setProgressDrawable(d.mutate());
        if (d instanceof LayerDrawable) {
            layer = ((LayerDrawable) d).findDrawableByLayerId(layerId);
        }
        if (shouldFallback && layer == null) {
            layer = d;
        }
    }
    return layer;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 33 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 34 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 35 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)193 TextView (android.widget.TextView)66 View (android.view.View)63 ImageView (android.widget.ImageView)41 LinearLayout (android.widget.LinearLayout)30 Context (android.content.Context)18 ViewGroup (android.view.ViewGroup)16 WindowManager (android.view.WindowManager)14 FrameLayout (android.widget.FrameLayout)14 Drawable (android.graphics.drawable.Drawable)13 Dialog (android.app.Dialog)12 Button (android.widget.Button)12 RelativeLayout (android.widget.RelativeLayout)12 LayoutInflater (android.view.LayoutInflater)11 SuppressLint (android.annotation.SuppressLint)10 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