Java Code Examples for org.chromium.base.ApiCompatibilityUtils#setMarginEnd()
The following examples show how to use
org.chromium.base.ApiCompatibilityUtils#setMarginEnd() .
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: PaymentRequestUiErrorView.java From delion with Apache License 2.0 | 6 votes |
/** * Initializes the view with the correct strings. * * @param title Title of the webpage. * @param origin Origin of the webpage. */ public void initialize(String title, String origin) { ((TextView) findViewById(R.id.page_title)).setText(title); ((TextView) findViewById(R.id.hostname)).setText(origin); // Remove the close button, then expand the page information to take up the space formerly // occupied by the X. View toRemove = findViewById(R.id.close_button); ((ViewGroup) toRemove.getParent()).removeView(toRemove); int titleEndMargin = getContext().getResources().getDimensionPixelSize( R.dimen.payments_section_large_spacing); View pageInfoGroup = findViewById(R.id.page_info); ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMargin); }
Example 2
Source File: LocationBarTablet.java From delion with Apache License 2.0 | 6 votes |
@Override protected void updateLayoutParams() { // Calculate the bookmark/delete button margins. final MarginLayoutParams micLayoutParams = (MarginLayoutParams) mMicButton.getLayoutParams(); int micSpace = ApiCompatibilityUtils.getMarginEnd(micLayoutParams); if (mMicButton.getVisibility() != View.GONE) micSpace += mMicButton.getWidth(); final MarginLayoutParams deleteLayoutParams = (MarginLayoutParams) mDeleteButton.getLayoutParams(); final MarginLayoutParams bookmarkLayoutParams = (MarginLayoutParams) mBookmarkButton.getLayoutParams(); ApiCompatibilityUtils.setMarginEnd(deleteLayoutParams, micSpace); ApiCompatibilityUtils.setMarginEnd(bookmarkLayoutParams, micSpace); mDeleteButton.setLayoutParams(deleteLayoutParams); mBookmarkButton.setLayoutParams(bookmarkLayoutParams); super.updateLayoutParams(); }
Example 3
Source File: PaymentRequestUiErrorView.java From 365browser with Apache License 2.0 | 6 votes |
/** * Initializes the view with the correct strings. * * @param title Title of the webpage. * @param origin Origin of the webpage. * @param securityLevel The security level of the page that invoked PaymentRequest. */ public void initialize(String title, String origin, int securityLevel) { ((PaymentRequestHeader) findViewById(R.id.header)) .setTitleAndOrigin(title, origin, securityLevel); // Remove the close button, then expand the page information to take up the space formerly // occupied by the X. View toRemove = findViewById(R.id.close_button); ((ViewGroup) toRemove.getParent()).removeView(toRemove); int titleEndMargin = getContext().getResources().getDimensionPixelSize( R.dimen.payments_section_large_spacing); View pageInfoGroup = findViewById(R.id.page_info); ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMargin); }
Example 4
Source File: PaymentRequestUiErrorView.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Initializes the view with the correct strings. * * @param title Title of the webpage. * @param origin Origin of the webpage. */ public void initialize(String title, String origin) { ((TextView) findViewById(R.id.page_title)).setText(title); ((TextView) findViewById(R.id.hostname)).setText(origin); // Remove the close button, then expand the page information to take up the space formerly // occupied by the X. View toRemove = findViewById(R.id.close_button); ((ViewGroup) toRemove.getParent()).removeView(toRemove); int titleEndMargin = getContext().getResources().getDimensionPixelSize( R.dimen.payments_section_large_spacing); View pageInfoGroup = findViewById(R.id.page_info); ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) pageInfoGroup.getLayoutParams(), titleEndMargin); }
Example 5
Source File: LocationBarTablet.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void updateLayoutParams() { // Calculate the bookmark/delete button margins. int lastButtonSpace; if (mSaveOfflineButton.getVisibility() == View.VISIBLE) { MarginLayoutParams saveOfflineLayoutParams = (MarginLayoutParams) mSaveOfflineButton.getLayoutParams(); lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(saveOfflineLayoutParams); } else { MarginLayoutParams micLayoutParams = (MarginLayoutParams) mMicButton.getLayoutParams(); lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(micLayoutParams); } if (mMicButton.getVisibility() == View.VISIBLE || mSaveOfflineButton.getVisibility() == View.VISIBLE) { lastButtonSpace += mMicButtonWidth; } final MarginLayoutParams deleteLayoutParams = (MarginLayoutParams) mDeleteButton.getLayoutParams(); final MarginLayoutParams bookmarkLayoutParams = (MarginLayoutParams) mBookmarkButton.getLayoutParams(); ApiCompatibilityUtils.setMarginEnd(deleteLayoutParams, lastButtonSpace); ApiCompatibilityUtils.setMarginEnd(bookmarkLayoutParams, lastButtonSpace); mDeleteButton.setLayoutParams(deleteLayoutParams); mBookmarkButton.setLayoutParams(bookmarkLayoutParams); super.updateLayoutParams(); }
Example 6
Source File: PaymentRequestSection.java From delion with Apache License 2.0 | 5 votes |
/** Creates the View and adds it to the parent at the given index. */ public SectionSeparator(ViewGroup parent, int index) { super(parent.getContext()); Resources resources = parent.getContext().getResources(); setBackgroundColor(ApiCompatibilityUtils.getColor( resources, R.color.payments_section_separator)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, resources.getDimensionPixelSize(R.dimen.payments_section_separator_height)); int margin = resources.getDimensionPixelSize(R.dimen.payments_section_large_spacing); ApiCompatibilityUtils.setMarginStart(params, margin); ApiCompatibilityUtils.setMarginEnd(params, margin); parent.addView(this, index, params); }
Example 7
Source File: PaymentRequestSection.java From 365browser with Apache License 2.0 | 5 votes |
/** Creates the View and adds it to the parent at the given index. */ public SectionSeparator(ViewGroup parent, int index) { super(parent.getContext()); Resources resources = parent.getContext().getResources(); setBackgroundColor(ApiCompatibilityUtils.getColor( resources, R.color.payments_section_separator)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, resources.getDimensionPixelSize(R.dimen.separator_height)); int margin = resources.getDimensionPixelSize(R.dimen.payments_section_large_spacing); ApiCompatibilityUtils.setMarginStart(params, margin); ApiCompatibilityUtils.setMarginEnd(params, margin); parent.addView(this, index, params); }
Example 8
Source File: ToolbarPhone.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void inflateTabSwitchingResources() { mToggleTabStackButton = (ImageView) findViewById(R.id.tab_switcher_button); mNewTabButton = (NewTabButton) findViewById(R.id.new_tab_button); mToggleTabStackButton.setClickable(false); Resources resources = getResources(); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(resources, false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(resources, true); mToggleTabStackButton.setImageDrawable(mTabSwitcherButtonDrawable); mTabSwitcherModeViews.add(mNewTabButton); // Ensure that the new tab button will not draw over the toolbar buttons if the // translated string is long. Set a margin to the size of the toolbar button container // for the new tab button. WindowManager wm = (WindowManager) getContext().getSystemService( Context.WINDOW_SERVICE); Point screenSize = new Point(); wm.getDefaultDisplay().getSize(screenSize); mToolbarButtonsContainer.measure( MeasureSpec.makeMeasureSpec(screenSize.x, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(screenSize.y, MeasureSpec.AT_MOST)); ApiCompatibilityUtils.setMarginEnd(getFrameLayoutParams(mNewTabButton), mToolbarButtonsContainer.getMeasuredWidth()); }
Example 9
Source File: LocationBarTablet.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override protected void updateLayoutParams() { // Calculate the bookmark/delete button margins. int lastButtonSpace; if (mSaveOfflineButton.getVisibility() == View.VISIBLE) { MarginLayoutParams saveOfflineLayoutParams = (MarginLayoutParams) mSaveOfflineButton.getLayoutParams(); lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(saveOfflineLayoutParams); } else { MarginLayoutParams micLayoutParams = (MarginLayoutParams) mMicButton.getLayoutParams(); lastButtonSpace = ApiCompatibilityUtils.getMarginEnd(micLayoutParams); } if (mMicButton.getVisibility() == View.VISIBLE || mSaveOfflineButton.getVisibility() == View.VISIBLE) { lastButtonSpace += mMicButtonWidth; } final MarginLayoutParams deleteLayoutParams = (MarginLayoutParams) mDeleteButton.getLayoutParams(); final MarginLayoutParams bookmarkLayoutParams = (MarginLayoutParams) mBookmarkButton.getLayoutParams(); ApiCompatibilityUtils.setMarginEnd(deleteLayoutParams, lastButtonSpace); ApiCompatibilityUtils.setMarginEnd(bookmarkLayoutParams, lastButtonSpace); mDeleteButton.setLayoutParams(deleteLayoutParams); mBookmarkButton.setLayoutParams(bookmarkLayoutParams); super.updateLayoutParams(); }
Example 10
Source File: ToolbarPhone.java From 365browser with Apache License 2.0 | 5 votes |
private void inflateTabSwitchingResources() { mToggleTabStackButton = (ImageView) findViewById(R.id.tab_switcher_button); mNewTabButton = (NewTabButton) findViewById(R.id.new_tab_button); mToggleTabStackButton.setClickable(false); Resources resources = getResources(); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(resources, false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(resources, true); mToggleTabStackButton.setImageDrawable(mTabSwitcherButtonDrawable); mTabSwitcherModeViews.add(mNewTabButton); // Ensure that the new tab button will not draw over the toolbar buttons if the // translated string is long. Set a margin to the size of the toolbar button container // for the new tab button. WindowManager wm = (WindowManager) getContext().getSystemService( Context.WINDOW_SERVICE); Point screenSize = new Point(); wm.getDefaultDisplay().getSize(screenSize); mToolbarButtonsContainer.measure( MeasureSpec.makeMeasureSpec(screenSize.x, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(screenSize.y, MeasureSpec.AT_MOST)); ApiCompatibilityUtils.setMarginEnd(getFrameLayoutParams(mNewTabButton), mToolbarButtonsContainer.getMeasuredWidth()); }
Example 11
Source File: ToolbarPhone.java From delion with Apache License 2.0 | 5 votes |
private void inflateTabSwitchingResources() { mToggleTabStackButton = (ImageView) findViewById(R.id.tab_switcher_button); mNewTabButton = (NewTabButton) findViewById(R.id.new_tab_button); mToggleTabStackButton.setClickable(false); Resources resources = getResources(); mTabSwitcherButtonDrawable = TabSwitcherDrawable.createTabSwitcherDrawable(resources, false); mTabSwitcherButtonDrawableLight = TabSwitcherDrawable.createTabSwitcherDrawable(resources, true); mToggleTabStackButton.setImageDrawable(mTabSwitcherButtonDrawable); mTabSwitcherModeViews.add(mNewTabButton); // Ensure that the new tab button will not draw over the toolbar buttons if the // translated string is long. Set a margin to the size of the toolbar button container // for the new tab button. WindowManager wm = (WindowManager) getContext().getSystemService( Context.WINDOW_SERVICE); Point screenSize = new Point(); wm.getDefaultDisplay().getSize(screenSize); mToolbarButtonsContainer.measure( MeasureSpec.makeMeasureSpec(screenSize.x, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(screenSize.y, MeasureSpec.AT_MOST)); ApiCompatibilityUtils.setMarginEnd(getFrameLayoutParams(mNewTabButton), mToolbarButtonsContainer.getMeasuredWidth()); }
Example 12
Source File: SnippetArticleViewHolder.java From 365browser with Apache License 2.0 | 5 votes |
/** * Updates the layout taking into account screen dimensions and the type of snippet displayed. */ private void updateLayout() { final int horizontalStyle = mUiConfig.getCurrentDisplayStyle().horizontal; final int verticalStyle = mUiConfig.getCurrentDisplayStyle().vertical; final int layout = mCategoryInfo.getCardLayout(); boolean showHeadline = shouldShowHeadline(); boolean showDescription = shouldShowDescription(horizontalStyle, verticalStyle, layout); boolean showThumbnail = shouldShowThumbnail(horizontalStyle, verticalStyle, layout); mHeadlineTextView.setVisibility(showHeadline ? View.VISIBLE : View.GONE); mArticleSnippetTextView.setVisibility(showDescription ? View.VISIBLE : View.GONE); mThumbnailView.setVisibility(showThumbnail ? View.VISIBLE : View.GONE); ViewGroup.MarginLayoutParams publisherBarParams = (ViewGroup.MarginLayoutParams) mPublisherBar.getLayoutParams(); if (showDescription) { publisherBarParams.topMargin = mPublisherBar.getResources().getDimensionPixelSize( R.dimen.snippets_publisher_margin_top_with_article_snippet); } else if (showHeadline) { // When we show a headline and not a description, we reduce the top margin of the // publisher bar. publisherBarParams.topMargin = mPublisherBar.getResources().getDimensionPixelSize( R.dimen.snippets_publisher_margin_top_without_article_snippet); } else { // When there is no headline and no description, we remove the top margin of the // publisher bar. publisherBarParams.topMargin = 0; } ApiCompatibilityUtils.setMarginEnd( publisherBarParams, showThumbnail ? mThumbnailFootprintPx : 0); mPublisherBar.setLayoutParams(publisherBarParams); }
Example 13
Source File: EditorView.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Create the visual representation of the EditorModel. * * This would be more optimal as a RelativeLayout, but because it's dynamically generated, it's * much more human-parsable with inefficient LinearLayouts for half-width controls sharing rows. */ private void prepareEditor() { // Ensure the layout is empty. removeTextChangedListenersAndInputFilters(); mDataView = (ViewGroup) mLayout.findViewById(R.id.contents); mDataView.removeAllViews(); mFieldViews.clear(); mEditableTextFields.clear(); mDropdownFields.clear(); // Add Views for each of the {@link EditorFields}. for (int i = 0; i < mEditorModel.getFields().size(); i++) { EditorFieldModel fieldModel = mEditorModel.getFields().get(i); EditorFieldModel nextFieldModel = null; boolean isLastField = i == mEditorModel.getFields().size() - 1; boolean useFullLine = fieldModel.isFullLine(); if (!isLastField && !useFullLine) { // If the next field isn't full, stretch it out. nextFieldModel = mEditorModel.getFields().get(i + 1); if (nextFieldModel.isFullLine()) useFullLine = true; } if (useFullLine) { addFieldViewToEditor(mDataView, fieldModel); } else { // Create a LinearLayout to put it and the next view side by side. LinearLayout rowLayout = new LinearLayout(mContext); mDataView.addView(rowLayout); View firstView = addFieldViewToEditor(rowLayout, fieldModel); View lastView = addFieldViewToEditor(rowLayout, nextFieldModel); LinearLayout.LayoutParams firstParams = (LinearLayout.LayoutParams) firstView.getLayoutParams(); LinearLayout.LayoutParams lastParams = (LinearLayout.LayoutParams) lastView.getLayoutParams(); firstParams.width = 0; firstParams.weight = 1; ApiCompatibilityUtils.setMarginEnd(firstParams, mHalfRowMargin); lastParams.width = 0; lastParams.weight = 1; i = i + 1; } } // Add the footer. mDataView.addView(mFooter); }
Example 14
Source File: PaymentRequestSection.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** Expand the separator to be the full width of the dialog. */ public void expand() { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) getLayoutParams(); ApiCompatibilityUtils.setMarginStart(params, 0); ApiCompatibilityUtils.setMarginEnd(params, 0); }
Example 15
Source File: PaymentRequestSection.java From AndroidChromium with Apache License 2.0 | 4 votes |
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists, boolean editIconExists, boolean isEnabled) { Context context = parent.getContext(); Resources resources = context.getResources(); // By default, the label appears to the right of the "button" in the second column. // + If there is no button, no option and edit icon, the label spans the whole row. // + If there is no option and edit icon, the label spans three columns. // + If there is no edit icon or option icon, the label spans two columns. // + Otherwise, the label occupies only its own column. int columnStart = 1; int columnSpan = 1; if (!optionIconExists) columnSpan++; if (!editIconExists) columnSpan++; TextView labelView = new TextView(context); if (mRowType == OPTION_ROW_TYPE_OPTION) { // Show the string representing the PaymentOption. ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled ? R.style.PaymentsUiSectionDefaultText : R.style.PaymentsUiSectionDisabledText); labelView.setText(convertOptionToString( mOption, mDelegate.isBoldLabelNeeded(OptionSection.this))); labelView.setEnabled(isEnabled); } else if (mRowType == OPTION_ROW_TYPE_ADD) { // Shows string saying that the user can add a new option, e.g. credit card no. String typeface = resources.getString(R.string.roboto_medium_typeface); int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle); int buttonHeight = resources.getDimensionPixelSize( R.dimen.payments_section_add_button_height); ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionAddButtonLabel); labelView.setMinimumHeight(buttonHeight); labelView.setGravity(Gravity.CENTER_VERTICAL); labelView.setTypeface(Typeface.create(typeface, textStyle)); } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) { // The description spans all the columns. columnStart = 0; columnSpan = 4; ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionDescriptiveText); } else if (mRowType == OPTION_ROW_TYPE_WARNING) { // Warnings use three columns. columnSpan = 3; ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionWarningText); } // The label spans two columns if no option or edit icon, or spans three columns if // no option and edit icons. Setting the view width to 0 forces it to stretch. GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams( GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(columnStart, columnSpan, GridLayout.FILL)); labelParams.topMargin = mVerticalMargin; labelParams.width = 0; if (optionIconExists) { // Margin at the end of the label instead of the start of the option icon to // allow option icon in the the next row align with the end of label (include // end margin) when edit icon exits in that row, like below: // ---Label---------------------[label margin]|---option icon---| // ---Label---[label margin]|---option icon---|----edit icon----| ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing); } parent.addView(labelView, labelParams); labelView.setOnClickListener(OptionSection.this); return labelView; }
Example 16
Source File: PaymentRequestSection.java From 365browser with Apache License 2.0 | 4 votes |
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists, boolean editIconExists, boolean isEnabled) { Context context = parent.getContext(); Resources resources = context.getResources(); // By default, the label appears to the right of the "button" in the second column. // + If there is no button, no option and edit icon, the label spans the whole row. // + If there is no option and edit icon, the label spans three columns. // + If there is no edit icon or option icon, the label spans two columns. // + Otherwise, the label occupies only its own column. int columnStart = 1; int columnSpan = 1; if (!optionIconExists) columnSpan++; if (!editIconExists) columnSpan++; TextView labelView = new TextView(context); if (mRowType == OPTION_ROW_TYPE_OPTION) { // Show the string representing the PaymentOption. ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled ? R.style.PaymentsUiSectionDefaultText : R.style.PaymentsUiSectionDisabledText); labelView.setText(convertOptionToString(mOption, mDelegate.isBoldLabelNeeded(OptionSection.this), false /* singleLine */)); labelView.setEnabled(isEnabled); } else if (mRowType == OPTION_ROW_TYPE_ADD) { // Shows string saying that the user can add a new option, e.g. credit card no. String typeface = resources.getString(R.string.roboto_medium_typeface); int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle); int buttonHeight = resources.getDimensionPixelSize( R.dimen.payments_section_add_button_height); ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionAddButtonLabel); labelView.setMinimumHeight(buttonHeight); labelView.setGravity(Gravity.CENTER_VERTICAL); labelView.setTypeface(Typeface.create(typeface, textStyle)); } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) { // The description spans all the columns. columnStart = 0; columnSpan = 4; ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionDescriptiveText); } else if (mRowType == OPTION_ROW_TYPE_WARNING) { // Warnings use three columns. columnSpan = 3; ApiCompatibilityUtils.setTextAppearance( labelView, R.style.PaymentsUiSectionWarningText); } // The label spans two columns if no option or edit icon, or spans three columns if // no option and edit icons. Setting the view width to 0 forces it to stretch. GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(columnStart, columnSpan, GridLayout.FILL, 1f)); labelParams.topMargin = mVerticalMargin; labelParams.width = 0; if (optionIconExists) { // Margin at the end of the label instead of the start of the option icon to // allow option icon in the the next row align with the end of label (include // end margin) when edit icon exits in that row, like below: // ---Label---------------------[label margin]|---option icon---| // ---Label---[label margin]|---option icon---|----edit icon----| ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing); } parent.addView(labelView, labelParams); labelView.setOnClickListener(OptionSection.this); return labelView; }
Example 17
Source File: PaymentRequestSection.java From 365browser with Apache License 2.0 | 4 votes |
/** Expand the separator to be the full width of the dialog. */ public void expand() { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) getLayoutParams(); ApiCompatibilityUtils.setMarginStart(params, 0); ApiCompatibilityUtils.setMarginEnd(params, 0); }
Example 18
Source File: EditorDialog.java From 365browser with Apache License 2.0 | 4 votes |
/** * Create the visual representation of the EditorModel. * * This would be more optimal as a RelativeLayout, but because it's dynamically generated, it's * much more human-parsable with inefficient LinearLayouts for half-width controls sharing rows. */ private void prepareEditor() { // Ensure the layout is empty. removeTextChangedListenersAndInputFilters(); mDataView = (ViewGroup) mLayout.findViewById(R.id.contents); mDataView.removeAllViews(); mFieldViews.clear(); mEditableTextFields.clear(); mDropdownFields.clear(); // Add Views for each of the {@link EditorFields}. for (int i = 0; i < mEditorModel.getFields().size(); i++) { EditorFieldModel fieldModel = mEditorModel.getFields().get(i); EditorFieldModel nextFieldModel = null; boolean isLastField = i == mEditorModel.getFields().size() - 1; boolean useFullLine = fieldModel.isFullLine(); if (!isLastField && !useFullLine) { // If the next field isn't full, stretch it out. nextFieldModel = mEditorModel.getFields().get(i + 1); if (nextFieldModel.isFullLine()) useFullLine = true; } if (useFullLine || isLastField) { addFieldViewToEditor(mDataView, fieldModel); } else { // Create a LinearLayout to put it and the next view side by side. LinearLayout rowLayout = new LinearLayout(mContext); mDataView.addView(rowLayout); View firstView = addFieldViewToEditor(rowLayout, fieldModel); View lastView = addFieldViewToEditor(rowLayout, nextFieldModel); LinearLayout.LayoutParams firstParams = (LinearLayout.LayoutParams) firstView.getLayoutParams(); LinearLayout.LayoutParams lastParams = (LinearLayout.LayoutParams) lastView.getLayoutParams(); firstParams.width = 0; firstParams.weight = 1; ApiCompatibilityUtils.setMarginEnd(firstParams, mHalfRowMargin); lastParams.width = 0; lastParams.weight = 1; // Align the text field and the dropdown field. if ((fieldModel.isTextField() && nextFieldModel.isDropdownField()) || (nextFieldModel.isTextField() && fieldModel.isDropdownField())) { LinearLayout.LayoutParams dropdownParams = fieldModel.isDropdownField() ? firstParams : lastParams; dropdownParams.topMargin = mDropdownTopPadding; dropdownParams.bottomMargin = 0; } i = i + 1; } } // Add the footer. mDataView.addView(mFooter); }
Example 19
Source File: ToolbarPhone.java From delion with Apache License 2.0 | 4 votes |
@Override public void onFinishInflate() { super.onFinishInflate(); mPhoneLocationBar = (LocationBarPhone) findViewById(R.id.location_bar); mToolbarButtonsContainer = (ViewGroup) findViewById(R.id.toolbar_buttons); mReturnButton = (TintedImageButton) findViewById(R.id.return_button); mHomeButton = (TintedImageButton) findViewById(R.id.home_button); mUrlBar = (TextView) findViewById(R.id.url_bar); mUrlActionsContainer = findViewById(R.id.url_action_container); mBrowsingModeViews.add(mPhoneLocationBar); mToolbarBackground = new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL)); mTabSwitcherAnimationBgOverlay = new ColorDrawable(getToolbarColorForVisualState(VisualState.NORMAL)); mLocationBarBackground = ApiCompatibilityUtils.getDrawable(getResources(), R.drawable.inset_textbox); mLocationBarBackground.getPadding(mUrlBackgroundPadding); mPhoneLocationBar.setPadding( mUrlBackgroundPadding.left, mUrlBackgroundPadding.top, mUrlBackgroundPadding.right, mUrlBackgroundPadding.bottom); setLayoutTransition(null); mMenuButtonWrapper.setVisibility(shouldShowMenuButton() ? View.VISIBLE : View.GONE); if (FeatureUtilities.isDocumentMode(getContext())) { ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) mMenuButtonWrapper.getLayoutParams(), getResources().getDimensionPixelSize(R.dimen.document_toolbar_menu_offset)); } if (FeatureUtilities.isTabSwitchingEnabled(getContext())) { inflateTabSwitchingResources(); } else { hideTabSwitchingResources(); } setWillNotDraw(false); }
Example 20
Source File: DownloadItemView.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initialize the DownloadItemView. Must be called before the item can respond to click events. * * @param provider The BackendProvider that allows interacting with the data backends. * @param item The item represented by this DownloadItemView. */ public void displayItem(BackendProvider provider, DownloadHistoryItemWrapper item) { mItem = item; setItem(item); // Cancel any previous thumbnail request for the previously displayed item. ThumbnailProvider thumbnailProvider = provider.getThumbnailProvider(); thumbnailProvider.cancelRetrieval(this); // Asynchronously grab a thumbnail for the file if it might have one. int fileType = item.getFilterType(); mThumbnailBitmap = null; if (fileType == DownloadFilter.FILTER_IMAGE && item.isComplete()) { Bitmap cached_thumbnail = thumbnailProvider.getThumbnail(this); if (cached_thumbnail != null && !cached_thumbnail.isRecycled()) { mThumbnailBitmap = cached_thumbnail; } } else { // TODO(dfalcantara): Get thumbnails for audio and video files when possible. } // Pick what icon to display for the item. mIconResId = DownloadUtils.getIconResId(fileType, DownloadUtils.ICON_SIZE_24_DP); updateIconView(); Context context = mFilesizeView.getContext(); mFilenameCompletedView.setText(item.getDisplayFileName()); mFilenameInProgressView.setText(item.getDisplayFileName()); mHostnameView.setText(item.getDisplayHostname()); mFilesizeView.setText( Formatter.formatFileSize(context, item.getFileSize())); if (item.isComplete()) { showLayout(mLayoutCompleted); } else { showLayout(mLayoutInProgress); mDownloadStatusView.setText(item.getStatusString()); Progress progress = item.getDownloadProgress(); if (item.isPaused()) { mPauseResumeButton.setImageResource(R.drawable.ic_play_arrow_white_24dp); mPauseResumeButton.setContentDescription( getContext().getString(R.string.download_notification_resume_button)); mProgressView.setIndeterminate(false); } else { mPauseResumeButton.setImageResource(R.drawable.ic_pause_white_24dp); mPauseResumeButton.setContentDescription( getContext().getString(R.string.download_notification_pause_button)); mProgressView.setIndeterminate(progress.isIndeterminate()); } if (!progress.isIndeterminate()) { mProgressView.setProgress(progress.getPercentage()); } // Display the percentage downloaded in text form. // To avoid problems with RelativeLayout not knowing how to place views relative to // removed views in the hierarchy, this code instead makes the percentage View's width // to 0 by removing its text and eliminating the margin. if (progress.isIndeterminate()) { mDownloadPercentageView.setText(null); ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) mDownloadPercentageView.getLayoutParams(), 0); } else { mDownloadPercentageView.setText( DownloadUtils.getPercentageString(progress.getPercentage())); ApiCompatibilityUtils.setMarginEnd( (MarginLayoutParams) mDownloadPercentageView.getLayoutParams(), mMargin); } } setBackgroundResourceForGroupPosition( getItem().isFirstInGroup(), getItem().isLastInGroup()); }