Java Code Examples for org.chromium.base.ApiCompatibilityUtils#setPaddingRelative()
The following examples show how to use
org.chromium.base.ApiCompatibilityUtils#setPaddingRelative() .
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 File: BottomToolbarPhone.java From 365browser with Apache License 2.0 | 6 votes |
/** * Sets the height and title text appearance of the provided toolbar so that its style is * consistent with BottomToolbarPhone. * @param otherToolbar The other {@link Toolbar} to style. */ public void setOtherToolbarStyle(Toolbar otherToolbar) { // Android's Toolbar class typically changes its height based on device orientation. // BottomToolbarPhone has a fixed height. Update |toolbar| to match. otherToolbar.getLayoutParams().height = getHeight(); // Android Toolbar action buttons are aligned based on the minimum height. int extraTopMargin = getExtraTopMargin(); otherToolbar.setMinimumHeight(getHeight() - extraTopMargin); otherToolbar.setTitleTextAppearance( otherToolbar.getContext(), R.style.BottomSheetContentTitle); ApiCompatibilityUtils.setPaddingRelative(otherToolbar, ApiCompatibilityUtils.getPaddingStart(otherToolbar), otherToolbar.getPaddingTop() + extraTopMargin, ApiCompatibilityUtils.getPaddingEnd(otherToolbar), otherToolbar.getPaddingBottom()); otherToolbar.requestLayout(); }
Example 2
Source File: BookmarkPromoHeader.java From 365browser with Apache License 2.0 | 6 votes |
/** * @return Signin promo header {@link ViewHolder} instance that can be used with * {@link RecyclerView}. */ ViewHolder createHolder(ViewGroup parent) { SigninAndSyncView.Listener listener = new SigninAndSyncView.Listener() { @Override public void onViewDismissed() { setSigninPromoDeclined(); updateShouldShow(true); } }; SigninAndSyncView view = SigninAndSyncView.create(parent, listener, SigninAccessPoint.BOOKMARK_MANAGER); // A MarginResizer is used to apply margins in regular and wide display modes. Remove the // view's lateral padding so that margins can be used instead. ApiCompatibilityUtils.setPaddingRelative( view, 0, view.getPaddingTop(), 0, view.getPaddingBottom()); return new ViewHolder(view) {}; }
Example 3
Source File: HistoryItemView.java From 365browser with Apache License 2.0 | 5 votes |
private void updateRemoveButtonVisibility() { int removeButtonVisibility = !PrefServiceBridge.getInstance().canDeleteBrowsingHistory() ? View.GONE : mRemoveButtonVisible ? View.VISIBLE : View.INVISIBLE; mRemoveButton.setVisibility(removeButtonVisibility); int endPadding = removeButtonVisibility == View.GONE ? mEndPadding : 0; ApiCompatibilityUtils.setPaddingRelative(mContentView, ApiCompatibilityUtils.getPaddingStart(mContentView), mContentView.getPaddingTop(), endPadding, mContentView.getPaddingBottom()); }
Example 4
Source File: ToolbarTablet.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Sets the toolbar start padding based on whether the buttons are visible. * @param buttonsVisible Whether the toolbar buttons are visible. */ private void setStartPaddingBasedOnButtonVisibility(boolean buttonsVisible) { buttonsVisible = buttonsVisible || mHomeButton.getVisibility() == View.VISIBLE; ApiCompatibilityUtils.setPaddingRelative(this, buttonsVisible ? mStartPaddingWithButtons : mStartPaddingWithoutButtons, getPaddingTop(), ApiCompatibilityUtils.getPaddingEnd(this), getPaddingBottom()); }
Example 5
Source File: ToolbarTablet.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onFinishInflate() { super.onFinishInflate(); mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar); mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mBackButton = (TintedImageButton) findViewById(R.id.back_button); mForwardButton = (TintedImageButton) findViewById(R.id.forward_button); mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button); mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext()) || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true); mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button); mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable); updateSwitcherButtonVisibility(mShowTabStack); mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button); mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); mMenuButtonWrapper.setVisibility(View.VISIBLE); if (mAccessibilitySwitcherButton.getVisibility() == View.GONE && mMenuButtonWrapper.getVisibility() == View.GONE) { ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0, getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0); } mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button); // Initialize values needed for showing/hiding toolbar buttons when the activity size // changes. mShouldAnimateButtonVisibilityChange = false; mToolbarButtonsVisible = true; mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton}; }
Example 6
Source File: TextMessageWithLinkAndIconPreference.java From 365browser with Apache License 2.0 | 5 votes |
@Override public View onCreateView(ViewGroup parent) { View view = super.onCreateView(parent); if (mNoBottomSpacing) { ApiCompatibilityUtils.setPaddingRelative( view, ApiCompatibilityUtils.getPaddingStart(view), view.getPaddingTop(), ApiCompatibilityUtils.getPaddingEnd(view), 0); } ((TextView) view.findViewById(android.R.id.summary)).setMovementMethod( LinkMovementMethod.getInstance()); // The icon is aligned to the top of the text view, which can be higher than the // ascender line of the text, and makes it look aligned improperly. TextView textView = (TextView) view.findViewById( getTitle() != null ? android.R.id.title : android.R.id.summary); FontMetrics metrics = textView.getPaint().getFontMetrics(); ImageView icon = (ImageView) view.findViewById(android.R.id.icon); ApiCompatibilityUtils.setPaddingRelative( icon, 0, (int) java.lang.Math.ceil(metrics.ascent - metrics.top), 0, 0); return view; }
Example 7
Source File: ToolbarTablet.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onFinishInflate() { super.onFinishInflate(); mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar); mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mBackButton = (TintedImageButton) findViewById(R.id.back_button); mForwardButton = (TintedImageButton) findViewById(R.id.forward_button); mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button); mSecurityButton = (TintedImageButton) findViewById(R.id.security_button); mShowTabStack = AccessibilityUtil.isAccessibilityEnabled(); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true); mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button); mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable); updateSwitcherButtonVisibility(mShowTabStack); mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button); mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); mMenuButtonWrapper.setVisibility(View.VISIBLE); if (mAccessibilitySwitcherButton.getVisibility() == View.GONE && mMenuButtonWrapper.getVisibility() == View.GONE) { ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0, getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0); } mSaveOfflineButton = (TintedImageButton) findViewById(R.id.save_offline_button); // Initialize values needed for showing/hiding toolbar buttons when the activity size // changes. mShouldAnimateButtonVisibilityChange = false; mToolbarButtonsVisible = true; mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton}; }
Example 8
Source File: PaymentRequestUI.java From 365browser with Apache License 2.0 | 5 votes |
private void addCardAndAddressOptionsSettingsView(LinearLayout parent) { String message; if (!mShowDataSource) { message = mContext.getString(R.string.payments_card_and_address_settings); } else if (ChromeSigninController.get().isSignedIn()) { message = mContext.getString(R.string.payments_card_and_address_settings_signed_in, ChromeSigninController.get().getSignedInAccountName()); } else { message = mContext.getString(R.string.payments_card_and_address_settings_signed_out); } NoUnderlineClickableSpan settingsSpan = new NoUnderlineClickableSpan() { @Override public void onClick(View widget) { mClient.onCardAndAddressSettingsClicked(); } }; SpannableString spannableMessage = SpanApplier.applySpans( message, new SpanInfo("BEGIN_LINK", "END_LINK", settingsSpan)); TextView view = new TextViewWithClickableSpans(mContext); view.setText(spannableMessage); view.setMovementMethod(LinkMovementMethod.getInstance()); ApiCompatibilityUtils.setTextAppearance(view, R.style.PaymentsUiSectionDescriptiveText); // Add paddings instead of margin to let getMeasuredHeight return correct value for section // resize animation. int paddingSize = mContext.getResources().getDimensionPixelSize( R.dimen.payments_section_large_spacing); ApiCompatibilityUtils.setPaddingRelative( view, paddingSize, paddingSize, paddingSize, paddingSize); parent.addView(view); }
Example 9
Source File: LocationBarLayout.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Constructs a new list designed for containing omnibox suggestions. * @param context Context used for contained views. */ public OmniboxSuggestionsList(Context context) { super(context, null, android.R.attr.dropDownListViewStyle); setDivider(null); setFocusable(true); setFocusableInTouchMode(true); mSuggestionHeight = context.getResources().getDimensionPixelOffset( R.dimen.omnibox_suggestion_height); mSuggestionAnswerHeight = context.getResources().getDimensionPixelOffset( R.dimen.omnibox_suggestion_answer_height); int paddingTop = context.getResources().getDimensionPixelOffset( R.dimen.omnibox_suggestion_list_padding_top); int paddingBottom = context.getResources().getDimensionPixelOffset( R.dimen.omnibox_suggestion_list_padding_bottom); ApiCompatibilityUtils.setPaddingRelative(this, 0, paddingTop, 0, paddingBottom); Drawable background = getSuggestionPopupBackground(); setBackground(background); background.getPadding(mTempRect); mBackgroundVerticalPadding = mTempRect.top + mTempRect.bottom + getPaddingTop() + getPaddingBottom(); mAnchorView = LocationBarLayout.this.getRootView().findViewById(R.id.toolbar); }
Example 10
Source File: ToolbarTablet.java From 365browser with Apache License 2.0 | 5 votes |
/** * Sets the toolbar start padding based on whether the buttons are visible. * @param buttonsVisible Whether the toolbar buttons are visible. */ private void setStartPaddingBasedOnButtonVisibility(boolean buttonsVisible) { buttonsVisible = buttonsVisible || mHomeButton.getVisibility() == View.VISIBLE; ApiCompatibilityUtils.setPaddingRelative(this, buttonsVisible ? mStartPaddingWithButtons : mStartPaddingWithoutButtons, getPaddingTop(), ApiCompatibilityUtils.getPaddingEnd(this), getPaddingBottom()); }
Example 11
Source File: SelectableListToolbar.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onDisplayStyleChanged(UiConfig.DisplayStyle newDisplayStyle) { int padding = SelectableListLayout.getPaddingForDisplayStyle(newDisplayStyle, getResources()); int paddingStartOffset = 0; int paddingEndOffset = 0; int contentInsetStart = mOriginalContentInsetStart; int contentInsetStartWithNavigation = mOriginalContentInsetStartWithNavigation; int contentInsetEnd = mOriginalContentInsetEnd; int contentInsetEndWithActions = mOriginalContentInsetEndWithActions; if (newDisplayStyle.horizontal == HorizontalDisplayStyle.WIDE) { paddingStartOffset = mWideDisplayLateralOffsetPx; // The title and nav buttons are inset in the normal display style. In the wide display // style they should be aligned with the starting edge of the list elements. if (mIsSearching || mIsSelectionEnabled || mNavigationButton != NAVIGATION_BUTTON_NONE) { paddingStartOffset += mWideDisplayNavButtonOffsetPx; } else { paddingStartOffset -= mDefaultTitleMarginStartPx; } // The end button is also inset in the normal display. In the wide display it should be // aligned with the ending edge of the list elements. paddingEndOffset = mWideDisplayLateralOffsetPx + mWideDisplayEndOffsetPx; contentInsetStart = 0; contentInsetStartWithNavigation = 0; contentInsetEnd = 0; contentInsetEndWithActions = 0; } ApiCompatibilityUtils.setPaddingRelative(this, padding + paddingStartOffset, this.getPaddingTop(), padding + paddingEndOffset, this.getPaddingBottom()); setContentInsetsRelative(contentInsetStart, contentInsetEnd); setContentInsetStartWithNavigation(contentInsetStartWithNavigation); setContentInsetEndWithActions(contentInsetEndWithActions); }
Example 12
Source File: ToolbarTablet.java From delion with Apache License 2.0 | 5 votes |
@Override public void onFinishInflate() { super.onFinishInflate(); mLocationBar = (LocationBarTablet) findViewById(R.id.location_bar); mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mBackButton = (TintedImageButton) findViewById(R.id.back_button); mForwardButton = (TintedImageButton) findViewById(R.id.forward_button); mReloadButton = (TintedImageButton) findViewById(R.id.refresh_button); mShowTabStack = DeviceClassManager.isAccessibilityModeEnabled(getContext()) || CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_TABLET_TAB_STACK); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(getResources(), true); mAccessibilitySwitcherButton = (ImageButton) findViewById(R.id.tab_switcher_button); mAccessibilitySwitcherButton.setImageDrawable(mTabSwitcherButtonDrawable); updateSwitcherButtonVisibility(mShowTabStack); mBookmarkButton = (TintedImageButton) findViewById(R.id.bookmark_button); mMenuButton = (TintedImageButton) findViewById(R.id.menu_button); mMenuButtonWrapper.setVisibility( shouldShowMenuButton() ? View.VISIBLE : View.GONE); if (mAccessibilitySwitcherButton.getVisibility() == View.GONE && mMenuButtonWrapper.getVisibility() == View.GONE) { ApiCompatibilityUtils.setPaddingRelative((View) mMenuButtonWrapper.getParent(), 0, 0, getResources().getDimensionPixelSize(R.dimen.tablet_toolbar_end_padding), 0); } // Initialize values needed for showing/hiding toolbar buttons when the activity size // changes. mShouldAnimateButtonVisibilityChange = false; mToolbarButtonsVisible = true; mToolbarButtons = new TintedImageButton[] {mBackButton, mForwardButton, mReloadButton}; }
Example 13
Source File: LocationBarTablet.java From 365browser with Apache License 2.0 | 5 votes |
/** * @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not * focused. */ public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) { mShouldShowButtonsWhenUnfocused = shouldShowButtons; updateButtonVisibility(); ApiCompatibilityUtils.setPaddingRelative(mUrlBar, ApiCompatibilityUtils.getPaddingStart(mUrlBar), mUrlBar.getPaddingTop(), mShouldShowButtonsWhenUnfocused ? mUrlBarEndPaddingWithButtons : mUrlBarEndPaddingWithoutButtons, mUrlBar.getPaddingBottom()); }
Example 14
Source File: SelectableListLayout.java From 365browser with Apache License 2.0 | 5 votes |
private void setEmptyOrLoadingViewStyle(View view) { if (!FeatureUtilities.isChromeHomeEnabled()) return; ((FrameLayout.LayoutParams) view.getLayoutParams()).gravity = Gravity.CENTER_HORIZONTAL; ApiCompatibilityUtils.setPaddingRelative(view, ApiCompatibilityUtils.getPaddingStart(view), view.getPaddingTop() + mChromeHomeEmptyAndLoadingViewTopPadding, ApiCompatibilityUtils.getPaddingEnd(view), view.getPaddingBottom()); }
Example 15
Source File: AccountSigninView.java From delion with Apache License 2.0 | 5 votes |
@Override protected void onFinishInflate() { super.onFinishInflate(); mSigninChooseView = (AccountSigninChooseView) findViewById(R.id.account_signin_choose_view); mSigninChooseView.setAddNewAccountObserver(new AccountSigninChooseView.Observer() { @Override public void onAddNewAccount() { mListener.onNewAccount(); RecordUserAction.record("Signin_AddAccountToDevice"); } }); mPositiveButton = (ButtonCompat) findViewById(R.id.positive_button); mNegativeButton = (Button) findViewById(R.id.negative_button); // A workaround for Android support library ignoring padding set in XML. b/20307607 int padding = getResources().getDimensionPixelSize(R.dimen.fre_button_padding); ApiCompatibilityUtils.setPaddingRelative(mPositiveButton, padding, 0, padding, 0); ApiCompatibilityUtils.setPaddingRelative(mNegativeButton, padding, 0, padding, 0); // TODO(peconn): Ensure this is changed to R.string.cancel when used in Settings > Sign In. mCancelButtonTextId = R.string.no_thanks; mSigninConfirmationView = (AccountSigninConfirmationView) findViewById(R.id.signin_confirmation_view); mSigninConfirmationView.setScrolledToBottomObserver( new AccountSigninConfirmationView.Observer() { @Override public void onScrolledToBottom() { setPositiveButtonEnabled(); } }); mSigninAccountImage = (ImageView) findViewById(R.id.signin_account_image); mSigninAccountName = (TextView) findViewById(R.id.signin_account_name); mSigninAccountEmail = (TextView) findViewById(R.id.signin_account_email); mSigninSettingsControl = (TextView) findViewById(R.id.signin_settings_control); // For the spans to be clickable. mSigninSettingsControl.setMovementMethod(LinkMovementMethod.getInstance()); }
Example 16
Source File: LocationBarPhone.java From delion with Apache License 2.0 | 5 votes |
private void updateIncognitoBadgePadding() { // This can be triggered in the super.onFinishInflate, so we need to null check in this // place only. if (mIncognitoBadge == null) return; if (findViewById(R.id.location_bar_icon).getVisibility() == GONE) { ApiCompatibilityUtils.setPaddingRelative( mIncognitoBadge, 0, 0, mIncognitoBadgePadding, 0); } else { ApiCompatibilityUtils.setPaddingRelative(mIncognitoBadge, 0, 0, 0, 0); } }
Example 17
Source File: SiteSettingsPreference.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void onBindView(View view) { super.onBindView(view); int padding = getContext().getResources().getDimensionPixelSize(R.dimen.pref_icon_padding); ImageView icon = (ImageView) view.findViewById(android.R.id.icon); ApiCompatibilityUtils.setPaddingRelative( icon, padding, icon.getPaddingTop(), 0, icon.getPaddingBottom()); }
Example 18
Source File: LocationBarTablet.java From delion with Apache License 2.0 | 5 votes |
/** * @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not * focused. */ public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) { mShouldShowButtonsWhenUnfocused = shouldShowButtons; updateButtonVisibility(); ApiCompatibilityUtils.setPaddingRelative(mUrlBar, ApiCompatibilityUtils.getPaddingStart(mUrlBar), mUrlBar.getPaddingTop(), mShouldShowButtonsWhenUnfocused ? mUrlBarEndPaddingWithButtons : mUrlBarEndPaddingWithoutButtons, mUrlBar.getPaddingBottom()); }
Example 19
Source File: BookmarkFolderSelectActivity.java From delion with Apache License 2.0 | 5 votes |
/** * Sets up padding for the entry */ private void setUpPadding(FolderListEntry entry, TextView textView) { int paddingStart = mBasePadding + Math.min(entry.mDepth, MAX_FOLDER_DEPTH) * mPaddingIncrement; ApiCompatibilityUtils.setPaddingRelative(textView, paddingStart, 0, mBasePadding, 0); }
Example 20
Source File: CertificateViewer.java From delion with Apache License 2.0 | 4 votes |
private void showCertificateChain(byte[][] derData) { for (int i = 0; i < derData.length; i++) { addCertificate(derData[i]); } ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, mTitles) { @Override public View getView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); // Add extra padding on the end side to avoid overlapping the dropdown arrow. ApiCompatibilityUtils.setPaddingRelative(view, mPadding, mPadding, mPadding * 2, mPadding); return view; } }; arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); LinearLayout dialogContainer = new LinearLayout(mContext); dialogContainer.setOrientation(LinearLayout.VERTICAL); TextView title = new TextView(mContext); title.setText(R.string.certtitle); ApiCompatibilityUtils.setTextAlignment(title, View.TEXT_ALIGNMENT_VIEW_START); ApiCompatibilityUtils.setTextAppearance(title, android.R.style.TextAppearance_Large); title.setTypeface(title.getTypeface(), Typeface.BOLD); title.setPadding(mPadding, mPadding, mPadding, mPadding / 2); dialogContainer.addView(title); Spinner spinner = new Spinner(mContext); ApiCompatibilityUtils.setTextAlignment(spinner, View.TEXT_ALIGNMENT_VIEW_START); spinner.setAdapter(arrayAdapter); spinner.setOnItemSelectedListener(this); spinner.setDropDownWidth(ViewGroup.LayoutParams.MATCH_PARENT); // Remove padding so that dropdown has same width as the spinner. spinner.setPadding(0, 0, 0, 0); dialogContainer.addView(spinner); LinearLayout certContainer = new LinearLayout(mContext); certContainer.setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < mViews.size(); ++i) { LinearLayout certificateView = mViews.get(i); if (i != 0) { certificateView.setVisibility(LinearLayout.GONE); } certContainer.addView(certificateView); } ScrollView scrollView = new ScrollView(mContext); scrollView.addView(certContainer); dialogContainer.addView(scrollView); showDialogForView(dialogContainer); }