Java Code Examples for org.chromium.base.ApiCompatibilityUtils

The following examples show how to use org.chromium.base.ApiCompatibilityUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AndroidChromium   Source File: ToolbarPhone.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a ToolbarPhone object.
 * @param context The Context in which this View object is created.
 * @param attrs The AttributeSet that was specified with this View.
 */
public ToolbarPhone(Context context, AttributeSet attrs) {
    super(context, attrs);
    mToolbarSidePadding = getResources().getDimensionPixelOffset(
            R.dimen.toolbar_edge_padding);
    mLocationBarVerticalMargin =
            getResources().getDimensionPixelOffset(R.dimen.location_bar_vertical_margin);
    mLocationBarBackgroundCornerRadius =
            getResources().getDimensionPixelOffset(R.dimen.location_bar_corner_radius);
    mProgressBackBackgroundColorWhite = ApiCompatibilityUtils.getColor(getResources(),
            R.color.progress_bar_background_white);
    mLightModeDefaultColor =
            ApiCompatibilityUtils.getColor(getResources(), R.color.light_mode_tint);
    mDarkModeDefaultColor =
            ApiCompatibilityUtils.getColor(getResources(), R.color.dark_mode_tint);
}
 
Example 2
Source Project: AndroidChromium   Source File: IncognitoNewTabPageView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mScrollView = (NewTabPageScrollView) findViewById(R.id.ntp_scrollview);
    mScrollView.setBackgroundColor(
            ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_bg_incognito));

    // FOCUS_BEFORE_DESCENDANTS is needed to support keyboard shortcuts. Otherwise, pressing
    // any shortcut causes the UrlBar to be focused. See ViewRootImpl.leaveTouchMode().
    mScrollView.setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS);

    View learnMore = findViewById(R.id.learn_more);
    learnMore.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mManager.loadIncognitoLearnMore();
        }
    });
}
 
Example 3
Source Project: 365browser   Source File: VisibleNetworks.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Compares the specified object with this VisibleCell for equality.  Returns
 * {@code true} if the given object is a VisibleWifi and has identical values for
 * all of its fields except timestampMs.
 */
@Override
public boolean equals(Object object) {
    if (!(object instanceof VisibleCell)) {
        return false;
    }
    VisibleCell that = (VisibleCell) object;
    return ApiCompatibilityUtils.objectEquals(mRadioType, that.radioType())
            && ApiCompatibilityUtils.objectEquals(mCellId, that.cellId())
            && ApiCompatibilityUtils.objectEquals(
                       mLocationAreaCode, that.locationAreaCode())
            && ApiCompatibilityUtils.objectEquals(
                       mMobileCountryCode, that.mobileCountryCode())
            && ApiCompatibilityUtils.objectEquals(
                       mMobileNetworkCode, that.mobileNetworkCode())
            && ApiCompatibilityUtils.objectEquals(
                       mPrimaryScramblingCode, that.primaryScramblingCode())
            && ApiCompatibilityUtils.objectEquals(mPhysicalCellId, that.physicalCellId())
            && ApiCompatibilityUtils.objectEquals(
                       mTrackingAreaCode, that.trackingAreaCode());
}
 
Example 4
Source Project: AndroidChromium   Source File: FindToolbarPhone.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void updateVisualsForTabModel(boolean isIncognito) {
    int queryTextColorId;
    if (isIncognito) {
        setBackgroundResource(R.color.incognito_primary_color);
        ColorStateList white = ApiCompatibilityUtils.getColorStateList(getResources(),
                R.color.light_mode_tint);
        mFindNextButton.setTint(white);
        mFindPrevButton.setTint(white);
        mCloseFindButton.setTint(white);
        queryTextColorId = R.color.find_in_page_query_white_color;
    } else {
        setBackgroundColor(Color.WHITE);
        ColorStateList dark = ApiCompatibilityUtils.getColorStateList(getResources(),
                R.color.dark_mode_tint);
        mFindNextButton.setTint(dark);
        mFindPrevButton.setTint(dark);
        mCloseFindButton.setTint(dark);
        queryTextColorId = R.color.find_in_page_query_color;
    }
    mFindQuery.setTextColor(
            ApiCompatibilityUtils.getColor(getContext().getResources(), queryTextColorId));
}
 
Example 5
Source Project: delion   Source File: PaymentRequestSection.java    License: Apache License 2.0 6 votes vote down vote up
private View createIcon(GridLayout parent, int rowIndex) {
    // The icon has a pre-defined width.
    ImageView icon = new ImageView(parent.getContext());
    icon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    icon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
    icon.setImageResource(mOption.getDrawableIconId());
    icon.setMaxWidth(mIconMaxWidth);

    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
            GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(2, 1));
    iconParams.topMargin = mVerticalMargin;
    ApiCompatibilityUtils.setMarginStart(iconParams, mLargeSpacing);
    parent.addView(icon, iconParams);

    icon.setOnClickListener(OptionSection.this);
    return icon;
}
 
Example 6
Source Project: AndroidChromium   Source File: RecentTabsGroupView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onFinishInflate() {
    super.onFinishInflate();
    mDeviceIcon = (ImageView) findViewById(R.id.device_icon);
    mTimeLabel = (TextView) findViewById(R.id.time_label);
    mDeviceLabel = (TextView) findViewById(R.id.device_label);
    mExpandCollapseIcon = (ImageView) findViewById(R.id.expand_collapse_icon);

    // Create drawable for expand/collapse arrow.
    LevelListDrawable collapseIcon = new LevelListDrawable();
    collapseIcon.addLevel(DRAWABLE_LEVEL_COLLAPSED, DRAWABLE_LEVEL_COLLAPSED,
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_expanded));
    TintedDrawable collapse =
            TintedDrawable.constructTintedDrawable(getResources(), R.drawable.ic_collapsed);
    collapse.setTint(
            ApiCompatibilityUtils.getColorStateList(getResources(), R.color.blue_mode_tint));
    collapseIcon.addLevel(DRAWABLE_LEVEL_EXPANDED, DRAWABLE_LEVEL_EXPANDED, collapse);
    mExpandCollapseIcon.setImageDrawable(collapseIcon);
}
 
Example 7
Source Project: 365browser   Source File: WebappActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initializeWebappData() {
    if (mWebappInfo.displayMode() == WebDisplayMode.FULLSCREEN) {
        enterImmersiveMode();
    }

    final int backgroundColor = ColorUtils.getOpaqueColor(mWebappInfo.backgroundColor(
            ApiCompatibilityUtils.getColor(getResources(), R.color.webapp_default_bg)));

    mSplashScreen = new FrameLayout(this);
    mSplashScreen.setBackgroundColor(backgroundColor);

    ViewGroup contentView = (ViewGroup) findViewById(android.R.id.content);
    contentView.addView(mSplashScreen);

    mWebappUma.splashscreenVisible();
    mWebappUma.recordSplashscreenBackgroundColor(mWebappInfo.hasValidBackgroundColor()
            ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM
            : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT);
    mWebappUma.recordSplashscreenThemeColor(mWebappInfo.hasValidThemeColor()
            ? WebappUma.SPLASHSCREEN_COLOR_STATUS_CUSTOM
            : WebappUma.SPLASHSCREEN_COLOR_STATUS_DEFAULT);

    initializeSplashScreenWidgets(backgroundColor);
}
 
Example 8
Source Project: AndroidChromium   Source File: CustomNotificationBuilder.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Shows the work profile badge if it is needed.
 */
private void addWorkProfileBadge(RemoteViews view) {
    Resources resources = mContext.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    int size = dpToPx(WORK_PROFILE_BADGE_SIZE_DP, metrics);
    int[] colors = new int[size * size];

    // Create an immutable bitmap, so that it can not be reused for painting a badge into it.
    Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888);

    Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
    Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity(
            mContext, inputDrawable, null /* badgeLocation */, metrics.densityDpi);

    // The input bitmap is immutable, so the output drawable will be a different instance from
    // the input drawable if the work profile badge was applied.
    if (inputDrawable != outputDrawable && outputDrawable instanceof BitmapDrawable) {
        view.setImageViewBitmap(
                R.id.work_profile_badge, ((BitmapDrawable) outputDrawable).getBitmap());
        view.setViewVisibility(R.id.work_profile_badge, View.VISIBLE);
    }
}
 
Example 9
Source Project: 365browser   Source File: UiUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Gets the set of locales supported by the current enabled Input Methods.
 * @param context A {@link Context} instance.
 * @return A possibly-empty {@link Set} of locale strings.
 */
public static Set<String> getIMELocales(Context context) {
    LinkedHashSet<String> locales = new LinkedHashSet<String>();
    InputMethodManager imManager =
            (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    List<InputMethodInfo> enabledMethods = imManager.getEnabledInputMethodList();
    for (int i = 0; i < enabledMethods.size(); i++) {
        List<InputMethodSubtype> subtypes =
                imManager.getEnabledInputMethodSubtypeList(enabledMethods.get(i), true);
        if (subtypes == null) continue;
        for (int j = 0; j < subtypes.size(); j++) {
            String locale = ApiCompatibilityUtils.getLocale(subtypes.get(j));
            if (!TextUtils.isEmpty(locale)) locales.add(locale);
        }
    }
    return locales;
}
 
Example 10
Source Project: AndroidChromium   Source File: ToolbarTablet.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void updateBookmarkButton(boolean isBookmarked, boolean editingAllowed) {
    if (isBookmarked) {
        mBookmarkButton.setImageResource(R.drawable.btn_star_filled);
        // Non-incognito mode shows a blue filled star.
        mBookmarkButton.setTint(isIncognito()
                ? mLightModeTint
                : ApiCompatibilityUtils.getColorStateList(
                        getResources(), R.color.blue_mode_tint));
        mBookmarkButton.setContentDescription(getContext().getString(
                R.string.edit_bookmark));
    } else {
        mBookmarkButton.setImageResource(R.drawable.btn_star);
        mBookmarkButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTint);
        mBookmarkButton.setContentDescription(getContext().getString(
                R.string.accessibility_menu_bookmark));
    }
    mBookmarkButton.setEnabled(editingAllowed);
}
 
Example 11
Source Project: 365browser   Source File: IncognitoNewTabPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an Incognito NewTabPage.
 * @param activity The activity used to create the new tab page's View.
 */
public IncognitoNewTabPage(Activity activity) {
    mActivity = activity;

    mTitle = activity.getResources().getString(R.string.button_new_tab);
    mBackgroundColor =
            ApiCompatibilityUtils.getColor(activity.getResources(), R.color.ntp_bg_incognito);
    mThemeColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.incognito_primary_color);

    LayoutInflater inflater = LayoutInflater.from(activity);
    mIncognitoNewTabPageView = (IncognitoNewTabPageView) inflater.inflate(useMDIncognitoNTP()
                    ? R.layout.new_tab_page_incognito_md
                    : R.layout.new_tab_page_incognito,
            null);
    mIncognitoNewTabPageView.initialize(mIncognitoNewTabPageManager);

    if (!useMDIncognitoNTP()) {
        TextView newTabIncognitoMessage = (TextView) mIncognitoNewTabPageView.findViewById(
                R.id.new_tab_incognito_message);
        newTabIncognitoMessage.setText(
                activity.getResources().getString(R.string.new_tab_incognito_message));
    }
}
 
Example 12
Source Project: delion   Source File: SnackbarView.java    License: Apache License 2.0 6 votes vote down vote up
void adjustViewPosition() {
    mParent.getWindowVisibleDisplayFrame(mCurrentVisibleRect);
    // Only update if the visible frame has changed, otherwise there will be a layout loop.
    if (!mCurrentVisibleRect.equals(mPreviousVisibleRect)) {
        mPreviousVisibleRect.set(mCurrentVisibleRect);

        int keyboardHeight = mParent.getHeight() - mCurrentVisibleRect.bottom
                + mCurrentVisibleRect.top;
        MarginLayoutParams lp = getLayoutParams();
        lp.bottomMargin = keyboardHeight;
        if (mIsTablet) {
            int margin = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_margin_tablet);
            ApiCompatibilityUtils.setMarginStart(lp, margin);
            lp.bottomMargin += margin;
            int width = mParent.getResources()
                    .getDimensionPixelSize(R.dimen.snackbar_width_tablet);
            lp.width = Math.min(width, mParent.getWidth() - 2 * margin);
        }
        mView.setLayoutParams(lp);
    }
}
 
Example 13
Source Project: 365browser   Source File: CustomTabTabPersistencePolicy.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Given a list of metadata files, determine which are applicable for deletion based on the
 * deletion strategy of Custom Tabs.
 *
 * @param currentTimeMillis The current time in milliseconds
 *                          ({@link System#currentTimeMillis()}.
 * @param allMetadataFiles The complete list of all metadata files to check.
 * @return The list of metadata files that are applicable for deletion.
 */
protected static List<File> getMetadataFilesForDeletion(
        long currentTimeMillis, List<File> allMetadataFiles) {
    Collections.sort(allMetadataFiles, new Comparator<File>() {
        @Override
        public int compare(File lhs, File rhs) {
            long lhsModifiedTime = lhs.lastModified();
            long rhsModifiedTime = rhs.lastModified();

            // Sort such that older files (those with an lower timestamp number) are at the
            // end of the sorted listed.
            return ApiCompatibilityUtils.compareLong(rhsModifiedTime, lhsModifiedTime);
        }
    });

    List<File> stateFilesApplicableForDeletion = new ArrayList<File>();
    for (int i = 0; i < allMetadataFiles.size(); i++) {
        File file = allMetadataFiles.get(i);
        long fileAge = currentTimeMillis - file.lastModified();
        if (i >= MAXIMUM_STATE_FILES || fileAge >= STATE_EXPIRY_THRESHOLD) {
            stateFilesApplicableForDeletion.add(file);
        }
    }
    return stateFilesApplicableForDeletion;
}
 
Example 14
Source Project: delion   Source File: DownloadManagerUi.java    License: Apache License 2.0 6 votes vote down vote up
SpaceDisplay(final ViewGroup parent) {
    mSpaceUsedTextView = (TextView) parent.findViewById(R.id.space_used_display);
    mSpaceTotalTextView = (TextView) parent.findViewById(R.id.space_total_display);
    mSpaceBar = (ProgressBar) parent.findViewById(R.id.space_bar);

    mFileSystemBytesTask = new AsyncTask<Void, Void, Long>() {
        @Override
        protected Long doInBackground(Void... params) {
            StatFs statFs = new StatFs(Environment.getExternalStoragePublicDirectory(
                    Environment.DIRECTORY_DOWNLOADS).getPath());
            long totalBlocks = ApiCompatibilityUtils.getBlockCount(statFs);
            long blockSize = ApiCompatibilityUtils.getBlockSize(statFs);
            long fileSystemBytes = totalBlocks * blockSize;
            return fileSystemBytes;
        }
    };
    mFileSystemBytesTask.execute();
}
 
Example 15
Source Project: delion   Source File: DownloadManagerUi.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the UI for the given Activity.
 *
 * @param activity Activity that is showing the UI.
 */
public void initialize(DownloadManagerUiDelegate delegate, Activity activity) {
    mDelegate = delegate;

    mActionBarDrawerToggle = new ActionBarDrawerToggle(activity,
            this, (Toolbar) findViewById(R.id.action_bar),
            R.string.accessibility_bookmark_drawer_toggle_btn_open,
            R.string.accessibility_bookmark_drawer_toggle_btn_close);
    addDrawerListener(mActionBarDrawerToggle);
    mActionBarDrawerToggle.syncState();

    FadingShadowView shadow = (FadingShadowView) findViewById(R.id.shadow);
    if (DeviceFormFactor.isLargeTablet(getContext())) {
        shadow.setVisibility(View.GONE);
    } else {
        shadow.init(ApiCompatibilityUtils.getColor(getResources(),
                R.color.toolbar_shadow_color), FadingShadow.POSITION_TOP);
    }

    mSpaceDisplay.update(0);

    ((Toolbar) findViewById(R.id.action_bar)).setTitle(R.string.menu_downloads);
}
 
Example 16
Source Project: 365browser   Source File: ToolbarTablet.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void updateBookmarkButton(boolean isBookmarked, boolean editingAllowed) {
    if (isBookmarked) {
        mBookmarkButton.setImageResource(R.drawable.btn_star_filled);
        // Non-incognito mode shows a blue filled star.
        mBookmarkButton.setTint(isIncognito()
                ? mLightModeTint
                : ApiCompatibilityUtils.getColorStateList(
                        getResources(), R.color.blue_mode_tint));
        mBookmarkButton.setContentDescription(getContext().getString(
                R.string.edit_bookmark));
    } else {
        mBookmarkButton.setImageResource(R.drawable.btn_star);
        mBookmarkButton.setTint(isIncognito() ? mLightModeTint : mDarkModeTint);
        mBookmarkButton.setContentDescription(getContext().getString(
                R.string.accessibility_menu_bookmark));
    }
    mBookmarkButton.setEnabled(editingAllowed);
}
 
Example 17
Source Project: delion   Source File: UrlBar.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
    mFocused = focused;
    if (!focused) mAutocompleteSpan.clearSpan();
    super.onFocusChanged(focused, direction, previouslyFocusedRect);

    if (focused && mFirstFocusTimeMs == 0) {
        mFirstFocusTimeMs = SystemClock.elapsedRealtime();
        if (mOmniboxLivenessListener != null) mOmniboxLivenessListener.onOmniboxFocused();
    }

    if (focused) StartupMetrics.getInstance().recordFocusedOmnibox();

    // When unfocused, force left-to-right rendering at the paragraph level (which is desired
    // for URLs). Right-to-left runs are still rendered RTL, but will not flip the whole URL
    // around. This is consistent with OmniboxViewViews on desktop. When focused, render text
    // normally (to allow users to make non-URL searches and to avoid showing Android's split
    // insertion point when an RTL user enters RTL text).
    if (focused) {
        ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT);
    } else {
        ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR);
    }
    // Always align to the same as the paragraph direction (LTR = left, RTL = right).
    ApiCompatibilityUtils.setTextAlignment(this, TEXT_ALIGNMENT_TEXT_START);
}
 
Example 18
Source Project: delion   Source File: SuggestionView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (getMeasuredWidth() == 0) return;

    if (mSuggestion.getType() != OmniboxSuggestionType.SEARCH_SUGGEST_TAIL) {
        mContentsView.resetTextWidths();
    }

    boolean refineVisible = mRefineView.getVisibility() == VISIBLE;
    boolean isRtl = ApiCompatibilityUtils.isLayoutRtl(this);
    int contentsViewOffsetX = isRtl && refineVisible ? mRefineWidth : 0;
    mContentsView.layout(
            contentsViewOffsetX,
            0,
            contentsViewOffsetX + mContentsView.getMeasuredWidth(),
            mContentsView.getMeasuredHeight());
    int refineViewOffsetX = isRtl ? 0 : getMeasuredWidth() - mRefineWidth;
    mRefineView.layout(
            refineViewOffsetX,
            0,
            refineViewOffsetX + mRefineWidth,
            mContentsView.getMeasuredHeight());
}
 
Example 19
Source Project: 365browser   Source File: SuggestionView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets a description line for the omnibox suggestion.
 *
 * @param str The description text.
 * @param isUrl Whether this text is a URL (as opposed to a normal string).
 */
private void showDescriptionLine(Spannable str, boolean isUrl) {
    TextView textLine = mContentsView.mTextLine2;
    if (textLine.getVisibility() != VISIBLE) {
        textLine.setVisibility(VISIBLE);
    }
    textLine.setText(str, BufferType.SPANNABLE);

    // Force left-to-right rendering for URLs. See UrlBar constructor for details.
    if (isUrl) {
        textLine.setTextColor(URL_COLOR);
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_LTR);
    } else {
        textLine.setTextColor(getStandardFontColor());
        ApiCompatibilityUtils.setTextDirection(textLine, TEXT_DIRECTION_INHERIT);
    }
}
 
Example 20
Source Project: AndroidChromium   Source File: LocationBarLayout.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Call to force the UI to update the state of various buttons based on whether or not the
 * current tab is incognito.
 */
@Override
public void updateVisualsForState() {
    if (updateUseDarkColors() || mIsEmphasizingHttpsScheme != shouldEmphasizeHttpsScheme()) {
        updateSecurityIcon(getSecurityLevel());
    }
    ColorStateList colorStateList = ApiCompatibilityUtils.getColorStateList(getResources(),
            mUseDarkColors ? R.color.dark_mode_tint : R.color.light_mode_tint);
    mMicButton.setTint(colorStateList);
    mDeleteButton.setTint(colorStateList);

    setNavigationButtonType(mNavigationButtonType);
    mUrlBar.setUseDarkTextColors(mUseDarkColors);

    if (mSuggestionList != null) {
        mSuggestionList.setBackground(getSuggestionPopupBackground());
    }
    mSuggestionListAdapter.setUseDarkColors(mUseDarkColors);
}
 
Example 21
Source Project: AndroidChromium   Source File: PaymentRequestSection.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    mExtraTextViews = new TextView[3];
    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i] = new TextView(context);
        ApiCompatibilityUtils.setTextAppearance(
                mExtraTextViews[i], R.style.PaymentsUiSectionDefaultText);
        mainSectionLayout.addView(
                mExtraTextViews[i], new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    }
}
 
Example 22
Source Project: AndroidChromium   Source File: SuggestionView.java    License: Apache License 2.0 5 votes vote down vote up
private int getUrlBarLeftOffset() {
    if (DeviceFormFactor.isTablet(getContext())) {
        mUrlBar.getLocationInWindow(mViewPositionHolder);
        return mViewPositionHolder[0];
    } else {
        return ApiCompatibilityUtils.isLayoutRtl(this) ? mPhoneUrlBarLeftOffsetRtlPx
                : mPhoneUrlBarLeftOffsetPx;
    }
}
 
Example 23
Source Project: 365browser   Source File: BottomSheetContentController.java    License: Apache License 2.0 5 votes vote down vote up
private void updateVisuals(boolean isIncognitoTabModelSelected) {
    setBackgroundResource(isIncognitoTabModelSelected ? R.color.incognito_primary_color
                                                      : R.color.default_primary_color);

    ColorStateList tint = ApiCompatibilityUtils.getColorStateList(getResources(),
            isIncognitoTabModelSelected ? R.color.bottom_nav_tint_incognito
                                        : R.color.bottom_nav_tint);
    setItemIconTintList(tint);
    setItemTextColor(tint);
}
 
Example 24
Source Project: AndroidChromium   Source File: ContextualSearchPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param context The current Android {@link Context}.
 * @param updateHost The {@link LayoutUpdateHost} used to request updates in the Layout.
 * @param eventHost The {@link EventFilterHost} for propagating events.
 * @param panelManager The object managing the how different panels are shown.
 */
public ContextualSearchPanel(Context context, LayoutUpdateHost updateHost,
            EventFilterHost eventHost, OverlayPanelManager panelManager) {
    super(context, updateHost, eventHost, panelManager);
    mSceneLayer = createNewContextualSearchSceneLayer();
    mPanelMetrics = new ContextualSearchPanelMetrics();

    mBarShadowHeightPx = ApiCompatibilityUtils.getDrawable(mContext.getResources(),
            R.drawable.contextual_search_bar_shadow).getIntrinsicHeight();
    mEndButtonWidthDp = mPxToDp * (float) mContext.getResources().getDimensionPixelSize(
            R.dimen.contextual_search_end_button_width);
}
 
Example 25
Source Project: 365browser   Source File: PromoDialog.java    License: Apache License 2.0 5 votes vote down vote up
protected PromoDialog(Context context) {
    super(context, R.style.PromoDialog);

    mScrimView = new FrameLayout(context);
    mScrimView.setBackgroundColor(ApiCompatibilityUtils.getColor(
            context.getResources(), R.color.modal_dialog_scrim_color));
    LayoutInflater.from(context).inflate(R.layout.promo_dialog_layout, mScrimView, true);

    mDialogLayout = (PromoDialogLayout) mScrimView.findViewById(R.id.promo_dialog_layout);
    mDialogLayout.initialize(getDialogParams());
}
 
Example 26
Source Project: 365browser   Source File: ContentSettingsResources.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the Drawable object of the icon for a content type with a disabled tint.
 */
public static Drawable getDisabledIcon(int contentType, Resources resources) {
    Drawable icon = ApiCompatibilityUtils.getDrawable(resources, getIcon(contentType));
    icon.mutate();
    int disabledColor = ApiCompatibilityUtils.getColor(resources,
            R.color.primary_text_disabled_material_light);
    icon.setColorFilter(disabledColor, PorterDuff.Mode.SRC_IN);
    return icon;
}
 
Example 27
Source Project: 365browser   Source File: AppMenuIconRowFooter.java    License: Apache License 2.0 5 votes vote down vote up
private void updateBookmarkMenuItem(BookmarkBridge bookmarkBridge, Tab currentTab) {
    mBookmarkButton.setEnabled(bookmarkBridge.isEditBookmarksEnabled());

    if (currentTab.getBookmarkId() != Tab.INVALID_BOOKMARK_ID) {
        mBookmarkButton.setImageResource(R.drawable.btn_star_filled);
        mBookmarkButton.setContentDescription(mActivity.getString(R.string.edit_bookmark));
        mBookmarkButton.setTint(ApiCompatibilityUtils.getColorStateList(
                getResources(), R.color.blue_mode_tint));
    } else {
        mBookmarkButton.setImageResource(R.drawable.btn_star);
        mBookmarkButton.setContentDescription(
                mActivity.getString(R.string.accessibility_menu_bookmark));
    }
}
 
Example 28
Source Project: delion   Source File: CertificateViewer.java    License: Apache License 2.0 5 votes vote down vote up
private TextView addLabel(LinearLayout certificateView, String label) {
    TextView t = new TextView(mContext);
    ApiCompatibilityUtils.setTextAlignment(t, View.TEXT_ALIGNMENT_VIEW_START);
    t.setPadding(mPadding, mPadding / 2, mPadding, 0);
    t.setText(label);
    t.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(),
            R.color.connection_info_popup_text));
    certificateView.addView(t);
    return t;
}
 
Example 29
Source Project: delion   Source File: CertificateViewer.java    License: Apache License 2.0 5 votes vote down vote up
private void addValue(LinearLayout certificateView, String value) {
    TextView t = new TextView(mContext);
    ApiCompatibilityUtils.setTextAlignment(t, View.TEXT_ALIGNMENT_VIEW_START);
    t.setText(value);
    t.setPadding(mPadding, 0, mPadding, mPadding / 2);
    t.setTextColor(ApiCompatibilityUtils.getColor(mContext.getResources(),
            R.color.connection_info_popup_text));
    certificateView.addView(t);
}
 
Example 30
Source Project: AndroidChromium   Source File: UrlBar.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Sets the {@link UrlBar}'s text direction based on focus and contents.
 *
 * Should be called whenever focus or text contents change.
 */
private void fixupTextDirection() {
    // When unfocused, force left-to-right rendering at the paragraph level (which is desired
    // for URLs). Right-to-left runs are still rendered RTL, but will not flip the whole URL
    // around. This is consistent with OmniboxViewViews on desktop. When focused, render text
    // normally (to allow users to make non-URL searches and to avoid showing Android's split
    // insertion point when an RTL user enters RTL text). Also render text normally when the
    // text field is empty (because then it displays an instruction that is not a URL).
    if (mFocused || length() == 0) {
        ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT);
    } else {
        ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR);
    }
}