Search in sources :

Example 76 with SuppressLint

use of android.annotation.SuppressLint in project AndroidChromium by JackyAndroid.

the class SnippetArticleViewHolder method fetchFaviconFromService.

// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
private void fetchFaviconFromService(final URI snippetUri) {
    // Show the default favicon immediately.
    setDefaultFaviconOnView();
    if (!mUseFaviconService)
        return;
    int sizePx = getFaviconServiceSupportedSize();
    if (sizePx == 0)
        return;
    // Replace the default icon by another one from the service when it is fetched.
    mNewTabPageManager.ensureIconIsAvailable(// Store to the cache for the whole domain.
    getSnippetDomain(snippetUri), String.format(FAVICON_SERVICE_FORMAT, snippetUri.getHost(), sizePx), /*useLargeIcon=*/
    false, /*isTemporary=*/
    true, new IconAvailabilityCallback() {

        @Override
        public void onIconAvailabilityChecked(boolean newlyAvailable) {
            if (!newlyAvailable)
                return;
            // The download succeeded, the favicon is in the cache; fetch it.
            fetchFaviconFromLocalCache(snippetUri, /*fallbackToService=*/
            false);
        }
    });
}
Also used : IconAvailabilityCallback(org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallback) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 77 with SuppressLint

use of android.annotation.SuppressLint in project AndroidChromium by JackyAndroid.

the class UiConfig method computeDisplayStyleForCurrentConfig.

@DisplayStyle
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
private int computeDisplayStyleForCurrentConfig() {
    int widthDp = mContext.getResources().getConfiguration().screenWidthDp;
    String debugString;
    @DisplayStyle int newDisplayStyle;
    if (widthDp < REGULAR_CARD_MIN_WIDTH_DP) {
        newDisplayStyle = DISPLAY_STYLE_NARROW;
        if (DEBUG)
            debugString = String.format("DISPLAY_STYLE_NARROW (w=%ddp)", widthDp);
    } else if (widthDp >= WIDE_CARD_MIN_WIDTH_DP) {
        newDisplayStyle = DISPLAY_STYLE_WIDE;
        if (DEBUG)
            debugString = String.format("DISPLAY_STYLE_WIDE (w=%ddp)", widthDp);
    } else {
        newDisplayStyle = DISPLAY_STYLE_REGULAR;
        if (DEBUG)
            debugString = String.format("DISPLAY_STYLE_REGULAR (w=%ddp)", widthDp);
    }
    if (DEBUG) {
        Log.d(TAG, debugString);
        Toast.makeText(mContext, debugString, Toast.LENGTH_SHORT).show();
    }
    return newDisplayStyle;
}
Also used : SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 78 with SuppressLint

use of android.annotation.SuppressLint in project AndroidChromium by JackyAndroid.

the class FindResultBar method onTouchEvent.

@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouchEvent(MotionEvent event) {
    if (!mDismissing && mTickmarks.size() > 0 && mTickmarks.size() == mMatches.length && !mWaitingForActivateAck && event.getAction() != MotionEvent.ACTION_CANCEL) {
        // We decided it's more important to get the keyboard out of the
        // way asap; the user can compensate if their next MotionEvent
        // scrolls somewhere unintended.
        UiUtils.hideKeyboard(this);
        // Identify which drawn tickmark is closest to the user's finger.
        int closest = Collections.binarySearch(mTickmarks, new Tickmark(event.getY(), event.getY()));
        if (closest < 0) {
            // No exact match, so must determine nearest.
            int insertionPoint = -1 - closest;
            if (insertionPoint == 0) {
                closest = 0;
            } else if (insertionPoint == mTickmarks.size()) {
                closest = mTickmarks.size() - 1;
            } else {
                float distanceA = Math.abs(event.getY() - mTickmarks.get(insertionPoint - 1).centerY());
                float distanceB = Math.abs(event.getY() - mTickmarks.get(insertionPoint).centerY());
                closest = insertionPoint - (distanceA <= distanceB ? 1 : 0);
            }
        }
        // Now activate the find match corresponding to that tickmark.
        // Since mTickmarks may be outdated, we can't just pass the index.
        // Instead we send the renderer the coordinates of the center of the
        // find match's rect (as originally received in setMatchRects), and
        // it will activate whatever find result is currently closest to
        // that point (which will usually be the same one).
        mWaitingForActivateAck = true;
        mFindInPageBridge.activateNearestFindResult(mMatches[closest].centerX(), mMatches[closest].centerY());
    }
    // Consume the event, whether or not we acted upon it.
    return true;
}
Also used : SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 79 with SuppressLint

use of android.annotation.SuppressLint in project AndroidChromium by JackyAndroid.

the class ToolbarPhone method layoutLocationBar.

@SuppressLint("RtlHardcoded")
private boolean layoutLocationBar(int containerWidth) {
    // Note that Toolbar's direction depends on system layout direction while
    // LocationBar's direction depends on its text inside.
    FrameLayout.LayoutParams locationBarLayoutParams = getFrameLayoutParams(getLocationBar().getContainerView());
    // Chrome prevents layout_gravity="left" from being defined in XML, but it simplifies
    // the logic, so it is manually specified here.
    locationBarLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    int width = 0;
    int leftMargin = 0;
    // Always update the unfocused layout params regardless of whether we are using
    // those in this current layout pass as they are needed for animations.
    updateUnfocusedLocationBarLayoutParams();
    if (mLayoutLocationBarInFocusedMode || mVisualState == VisualState.NEW_TAB_NORMAL) {
        int priorVisibleWidth = 0;
        for (int i = 0; i < mLocationBar.getChildCount(); i++) {
            View child = mLocationBar.getChildAt(i);
            if (child == mLocationBar.getFirstViewVisibleWhenFocused())
                break;
            if (child.getVisibility() == GONE)
                continue;
            priorVisibleWidth += child.getMeasuredWidth();
        }
        width = containerWidth - (2 * mToolbarSidePadding) + priorVisibleWidth;
        if (ApiCompatibilityUtils.isLayoutRtl(mLocationBar)) {
            leftMargin = mToolbarSidePadding;
        } else {
            leftMargin = -priorVisibleWidth + mToolbarSidePadding;
        }
    } else {
        width = mUnfocusedLocationBarLayoutWidth;
        leftMargin = mUnfocusedLocationBarLayoutLeft;
    }
    boolean changed = false;
    changed |= (width != locationBarLayoutParams.width);
    locationBarLayoutParams.width = width;
    changed |= (leftMargin != locationBarLayoutParams.leftMargin);
    locationBarLayoutParams.leftMargin = leftMargin;
    return changed;
}
Also used : FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint)

Example 80 with SuppressLint

use of android.annotation.SuppressLint in project AndroidDevelop by 7449.

the class GifView method setViewAttributes.

@SuppressLint("NewApi")
private void setViewAttributes(Context context, AttributeSet attrs, int defStyle) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
    // 从描述文件中读出gif的值,创建出Movie实例  
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.GifView, defStyle, R.style.Widget_GifView);
    mMovieResourceId = array.getResourceId(R.styleable.GifView_gif, -1);
    mPaused = array.getBoolean(R.styleable.GifView_paused, false);
    array.recycle();
    if (mMovieResourceId != -1) {
        mMovie = Movie.decodeStream(getResources().openRawResource(mMovieResourceId));
    }
}
Also used : TypedArray(android.content.res.TypedArray) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1773 View (android.view.View)369 TextView (android.widget.TextView)243 Intent (android.content.Intent)232 ImageView (android.widget.ImageView)112 Paint (android.graphics.Paint)109 File (java.io.File)102 IOException (java.io.IOException)96 ArrayList (java.util.ArrayList)93 Context (android.content.Context)91 LayoutInflater (android.view.LayoutInflater)89 Uri (android.net.Uri)84 Bundle (android.os.Bundle)83 SharedPreferences (android.content.SharedPreferences)78 Bitmap (android.graphics.Bitmap)78 WebView (android.webkit.WebView)76 PendingIntent (android.app.PendingIntent)72 Method (java.lang.reflect.Method)72 SimpleDateFormat (java.text.SimpleDateFormat)69 ViewGroup (android.view.ViewGroup)66