Java Code Examples for android.widget.TextView#setTextColor()

The following examples show how to use android.widget.TextView#setTextColor() . 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: OneClickFragment.java    From AndroidDigIn with Apache License 2.0 6 votes vote down vote up
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        TextView inflate = (TextView) inflater.inflate(R.layout.one_click_frag, container, false);
        inflate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mClickListener != null) {
                    mClickListener.onClickInOneClick(v, mWhich);
                }
            }
        });
        inflate.setBackgroundColor(mBgColor);
//        inflate.setTextColor(Utils.getComplimentColor(mBgColor));
        //the better
        inflate.setTextColor(Utils.getContrastColor(mBgColor));
        return inflate;
    }
 
Example 2
Source File: VideoCropActivity.java    From TikTok with Apache License 2.0 6 votes vote down vote up
private void notifyRecordTime(){
    TextView textView15 = (TextView) findViewById(R.id.tidal_pat_video_crop_time_selector_15_txt);
    TextView textView120 = (TextView) findViewById(R.id.tidal_pat_video_crop_time_selector_120_txt);
    switch (mRecordTimeType){
        case RECORD_TIME_15:
            textView15.setTextColor(getResources().getColor(R.color.few_transparency));
            textView15.setBackgroundResource(R.drawable.bg_personal_show_video_speed_level_left);
            textView120.setTextColor(getResources().getColor(R.color.white));
            textView120.setBackgroundColor(getResources().getColor(R.color.transparency));
            break;
        case RECORD_TIME_120:
            textView15.setTextColor(getResources().getColor(R.color.white));
            textView15.setBackgroundColor(getResources().getColor(R.color.transparency));
            textView120.setTextColor(getResources().getColor(R.color.few_transparency));
            textView120.setBackgroundResource(R.drawable.bg_personal_show_video_speed_level_right);
            break;
    }

}
 
Example 3
Source File: RadioColorCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public RadioColorCell(Context context) {
    super(context);

    radioButton = new RadioButton(context);
    radioButton.setSize(AndroidUtilities.dp(20));
    radioButton.setColor(Theme.getColor(Theme.key_dialogRadioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
    addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 18), 14, (LocaleController.isRTL ? 18 : 0), 0));

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 51), 13, (LocaleController.isRTL ? 51 : 21), 0));
}
 
Example 4
Source File: JkChatActivity.java    From HttpRequest with Apache License 2.0 6 votes vote down vote up
/**
 * 删除或重发窗体显示
 * @author leibing
 * @createTime 2017/5/5
 * @lastModify 2017/5/5
 * @param v 位置参照物
 * @param action 操作名称
 * @param onClick 点击事件
 * @return
 */
private void showPopUp(View v,String action, View.OnClickListener onClick){
    LinearLayout layout = new LinearLayout(this);
    layout.setBackground(getResources().getDrawable(R.drawable.jk_chat_long_press_the_trigger));
    layout.setGravity(Gravity.CENTER);
    TextView tv = new TextView(this);
    tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    tv.setText(action);
    tv.setPadding(0, 0, 0, 16);
    tv.setTextColor(Color.WHITE);
    tv.setOnClickListener(onClick);
    layout.addView(tv);
    popupWindow = new PopupWindow(layout, 120, 100);
    popupWindow.setFocusable(true);
    popupWindow.setOutsideTouchable(true);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    int[] location = new int[2];
    v.getLocationOnScreen(location);
    popupWindow.showAtLocation(v, Gravity.NO_GRAVITY, location[0] + v.getMeasuredWidth() / 3,
            location[1]-popupWindow.getHeight());
}
 
Example 5
Source File: ColorPreference.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override protected void onBindView(View view) {
    super.onBindView(view);
    if (mMaterial) {
        TextView textTitle = (TextView) view.findViewById(android.R.id.title);
        TextView textSummary = (TextView) view.findViewById(android.R.id.summary);

        textTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        textSummary.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
        textTitle.setTextColor(getColor(android.R.attr.textColorPrimary));
        textSummary.setTextColor(getColor(android.R.attr.textColorSecondary));

        View parent = (View) textSummary.getParent().getParent();
        parent.setPadding((int) dpToPx(16), 0, (int) dpToPx(16), 0);
    }
}
 
Example 6
Source File: GeocodingResultCell.java    From mobile-android-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public GeocodingResultCell(Context context) {
    super(context);

    label = new TextView(context);
    label.setGravity(Gravity.CENTER_VERTICAL);
    label.setTextColor(Color.WHITE);
    addView(label);

    type = new TextView(context);
    type.setGravity(Gravity.CENTER_VERTICAL);
    type.setTextColor(Color.LTGRAY);
    addView(type);
}
 
Example 7
Source File: DrawerActionCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public DrawerActionCell(Context context) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    textView.setCompoundDrawablePadding(AndroidUtilities.dp(29));
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 19, 0, 16, 0));
}
 
Example 8
Source File: CalendarFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
protected void highlightCalendarGridCell(TextView text, Calendar calendarDate, Calendar currentDate) {
    if (calendarDate.equals(currentDate)) {
        text.setTextColor(getResources().getColor(R.color.white));
        text.setBackgroundColor(getResources().getColor(R.color.cc_attention_positive_color));
    }
    else if (calendarDate.get(Calendar.MONTH) != currentDate.get(Calendar.MONTH)) {
        text.setTextColor(getResources().getColor(R.color.grey_dark));
        text.setBackgroundColor(getResources().getColor(R.color.grey_lighter));
    }
    else {
        text.setTextColor(getResources().getColor(R.color.black));
        text.setBackgroundColor(getResources().getColor(R.color.transparent));
    }
}
 
Example 9
Source File: IntroActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    TextView headerTextView = new TextView(container.getContext());
    TextView messageTextView = new TextView(container.getContext());

    FrameLayout frameLayout = new FrameLayout(container.getContext()) {
        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            int oneFourth = (bottom - top) / 4;
            int y = (oneFourth * 3 - AndroidUtilities.dp(275)) / 2;
            y += AndroidUtilities.dp(166);
            int x = AndroidUtilities.dp(18);
            headerTextView.layout(x, y, x + headerTextView.getMeasuredWidth(), y + headerTextView.getMeasuredHeight());

            y += AndroidUtilities.dp(42);
            x = AndroidUtilities.dp(16);
            messageTextView.layout(x, y, x + messageTextView.getMeasuredWidth(), y + messageTextView.getMeasuredHeight());
        }
    };

    headerTextView.setTextColor(0xff212121);
    headerTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 26);
    headerTextView.setGravity(Gravity.CENTER);
    frameLayout.addView(headerTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 18, 244, 18, 0));

    messageTextView.setTextColor(0xff808080);
    messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    messageTextView.setGravity(Gravity.CENTER);
    frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 16, 286, 16, 0));

    container.addView(frameLayout, 0);

    headerTextView.setText(titles[position]);
    messageTextView.setText(AndroidUtilities.replaceTags(messages[position]));

    return frameLayout;
}
 
Example 10
Source File: UIViewController.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
private void updateTabStyles() {

		for (int i = 0; i < tabCount; i++) {

			View v = tabsContainer.getChildAt(i);
			
			v.setBackgroundResource(tabBackgroundResId);

			if (v instanceof TextView) {

				TextView tab = (TextView) v;
				tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
				tab.setTypeface(tabTypeface, tabTypefaceStyle);
				tab.setTextColor(tabTextColor);

				if (textAllCaps) {
					if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
						tab.setAllCaps(true);
					} else {
						tab.setText(tab.getText().toString().toUpperCase(locale));
					}
				}
				if (i == selectedPosition) {
					tab.setTextColor(selectedTabTextColor);
				}
			}
		}

	}
 
Example 11
Source File: FixedTabIndicator.java    From DropDownMenu with Apache License 2.0 5 votes vote down vote up
private void switchTab(int pos) {
    TextView tv = getChildAtCurPos(pos);

    Drawable drawable = tv.getCompoundDrawables()[2];
    int level = drawable.getLevel();

    if (mOnItemClickListener != null) {
        mOnItemClickListener.onItemClick(tv, pos, level == 1);
    }

    if (mLastIndicatorPosition == pos) {
        // 点击同一个条目时
        tv.setTextColor(level == 0 ? mTabSelectedColor : mTabDefaultColor);
        drawable.setLevel(1 - level);

        return;
    }

    mCurrentIndicatorPosition = pos;
    resetPos(mLastIndicatorPosition);

    //highLightPos(pos);
    tv.setTextColor(mTabSelectedColor);
    tv.getCompoundDrawables()[2].setLevel(1);

    mLastIndicatorPosition = pos;
}
 
Example 12
Source File: SkinMaterialTextInputLayout.java    From Android-skin-support with MIT License 5 votes vote down vote up
private void applyCounterTextColorResource() {
        mCounterTextColorResId = SkinCompatHelper.checkResourceId(mCounterTextColorResId);
        if (mCounterTextColorResId != INVALID_ID) {
            TextView counterView = getCounterView();
            if (counterView != null) {
//                SkinLog.e(TAG, "mCounterTextColor = " +Integer.toHexString(SkinCompatResources.getInstance().getColor(mCounterTextColorResId)));
                counterView.setTextColor(SkinCompatResources.getColor(getContext(), mCounterTextColorResId));
                updateEditTextBackgroundInternal();
            }
        }
    }
 
Example 13
Source File: TabFragment.java    From bubble-icon-tabbar-android with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    TextView textView = getView().findViewById(R.id.tab_title);
    textView.setText(title);
    textView.setTextColor(ContextCompat.getColor(getContext(), colorId));
}
 
Example 14
Source File: DingAdapterActivity.java    From NCalendar with Apache License 2.0 5 votes vote down vote up
private void setLunar(View view, LocalDate localDate, List<LocalDate> selectedDateList) {

            TextView tv_lunar = view.findViewById(R.id.tv_lunar);
            CalendarDate calendarDate = CalendarUtil.getCalendarDate(localDate);
            tv_lunar.setText(calendarDate.lunar.lunarOnDrawStr);
            if (selectedDateList.contains(localDate)) {
                tv_lunar.setTextColor(Color.WHITE);
            } else {
                tv_lunar.setTextColor(Color.GRAY);
            }
        }
 
Example 15
Source File: Utils.java    From financisto with GNU General Public License v2.0 4 votes vote down vote up
public void setTransferTextColor(TextView textView) {
    textView.setTextColor(transferColor);
}
 
Example 16
Source File: AppCompatTimePickerDelegate.java    From AppCompat-Extension-Library with Apache License 2.0 4 votes vote down vote up
public AppCompatTimePickerDelegate(AppCompatTimePicker delegator, Context context, AttributeSet attrs,
                                   int defStyleAttr, int defStyleRes) {
    super(delegator, context);

    // process style attributes
    final TypedArray a = mContext.obtainStyledAttributes(attrs,
            R.styleable.TimePickerDialog, defStyleAttr, defStyleRes);
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    final Resources res = mContext.getResources();

    mSelectHours = res.getString(R.string.select_hours);
    mSelectMinutes = res.getString(R.string.select_minutes);

    String[] amPmStrings = getAmPmStrings(context);
    mAmText = amPmStrings[0];
    mPmText = amPmStrings[1];

    final View mainView = inflater.inflate(R.layout.time_picker_material, delegator);

    mHeaderView = mainView.findViewById(R.id.time_header);

    // Set up hour/minute labels.
    mHourView = (TextView) mainView.findViewById(R.id.hours);
    mHourView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mHourView,
            new ClickActionDelegate(context, R.string.select_hours));
    mSeparatorView = (TextView) mainView.findViewById(R.id.separator);
    mMinuteView = (TextView) mainView.findViewById(R.id.minutes);
    mMinuteView.setOnClickListener(mClickListener);
    ViewCompat.setAccessibilityDelegate(mMinuteView,
            new ClickActionDelegate(context, R.string.select_minutes));

    // Now that we have text appearances out of the way, make sure the hour
    // and minute views are correctly sized.
    mHourView.setMinWidth(computeStableWidth(mHourView, 24));
    mMinuteView.setMinWidth(computeStableWidth(mMinuteView, 60));

    // Set up AM/PM labels.
    mAmPmLayout = mainView.findViewById(R.id.ampm_layout);
    mAmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.am_label);
    mAmLabel.setText(obtainVerbatim(amPmStrings[0]));
    mAmLabel.setOnClickListener(mClickListener);
    mPmLabel = (CheckedTextView) mAmPmLayout.findViewById(R.id.pm_label);
    mPmLabel.setText(obtainVerbatim(amPmStrings[1]));
    mPmLabel.setOnClickListener(mClickListener);


    // Set up header text color, if available.
    ColorStateList headerTextColor;
    if (a.hasValue(R.styleable.TimePickerDialog_headerTextColor)) {
        headerTextColor = a.getColorStateList(R.styleable.DatePickerDialog_headerTextColor);
    } else {
        headerTextColor = PickerThemeUtils.getHeaderTextColorStateList(mContext);
    }
    mHourView.setTextColor(headerTextColor);
    mSeparatorView.setTextColor(headerTextColor);
    mMinuteView.setTextColor(headerTextColor);
    mAmLabel.setTextColor(headerTextColor);
    mPmLabel.setTextColor(headerTextColor);

    // Set up header background, if available.
    ViewCompatUtils.setBackground(mHeaderView, PickerThemeUtils.getHeaderBackground(mContext,
            a.getColor(R.styleable.DatePickerDialog_headerBackground,
                    ThemeUtils.getThemeAttrColor(mContext, R.attr.colorAccent))));

    a.recycle();

    mRadialTimePickerView = (RadialTimePickerView) mainView.findViewById(
            R.id.radial_picker);

    setupListeners();

    mAllowAutoAdvance = true;

    // Set up for keyboard mode.
    mDoublePlaceholderText = res.getString(R.string.time_placeholder);
    mDeletedKeyFormat = res.getString(R.string.deleted_key);
    mPlaceholderText = mDoublePlaceholderText.charAt(0);
    mAmKeyCode = mPmKeyCode = -1;
    generateLegalTimesTree();

    // Initialize with current time
    final Calendar calendar = Calendar.getInstance(mCurrentLocale);
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);
    initialize(currentHour, currentMinute, false /* 12h */, HOUR_INDEX);
}
 
Example 17
Source File: FilterCreateActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void showRemoveAlert(int position, CharSequence name, Object object, boolean include) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    if (include) {
        builder.setTitle(LocaleController.getString("FilterRemoveInclusionTitle", R.string.FilterRemoveInclusionTitle));
        if (object instanceof String) {
            builder.setMessage(LocaleController.formatString("FilterRemoveInclusionText", R.string.FilterRemoveInclusionText, name));
        } else if (object instanceof TLRPC.User) {
            builder.setMessage(LocaleController.formatString("FilterRemoveInclusionUserText", R.string.FilterRemoveInclusionUserText, name));
        } else {
            builder.setMessage(LocaleController.formatString("FilterRemoveInclusionChatText", R.string.FilterRemoveInclusionChatText, name));
        }
    } else {
        builder.setTitle(LocaleController.getString("FilterRemoveExclusionTitle", R.string.FilterRemoveExclusionTitle));
        if (object instanceof String) {
            builder.setMessage(LocaleController.formatString("FilterRemoveExclusionText", R.string.FilterRemoveExclusionText, name));
        } else if (object instanceof TLRPC.User) {
            builder.setMessage(LocaleController.formatString("FilterRemoveExclusionUserText", R.string.FilterRemoveExclusionUserText, name));
        } else {
            builder.setMessage(LocaleController.formatString("FilterRemoveExclusionChatText", R.string.FilterRemoveExclusionChatText, name));
        }
    }
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    builder.setPositiveButton(LocaleController.getString("StickersRemove", R.string.StickersRemove), (dialogInterface, i) -> {
        if (position == includeContactsRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
        } else if (position == includeNonContactsRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
        } else if (position == includeGroupsRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_GROUPS;
        } else if (position == includeChannelsRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
        } else if (position == includeBotsRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_BOTS;
        } else if (position == excludeArchivedRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
        } else if (position == excludeMutedRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
        } else if (position == excludeReadRow) {
            newFilterFlags &=~ MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
        } else {
            if (include) {
                newAlwaysShow.remove(position - includeStartRow);
            } else {
                newNeverShow.remove(position - excludeStartRow);
            }
        }
        fillFilterName();
        updateRows();
        checkDoneButton(true);
    });
    AlertDialog alertDialog = builder.create();
    showDialog(alertDialog);
    TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (button != null) {
        button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
    }
}
 
Example 18
Source File: FragmentCharacteristicDetail.java    From EFRConnect-android with Apache License 2.0 4 votes vote down vote up
private void initPropertiesForEditableFieldsDialog(LinearLayout propertiesContainer) {
    propertiesContainer.removeAllViews();
    String propertiesString = Common.getProperties(getActivity(), mBluetoothCharact.getProperties());
    String[] propsExploded = propertiesString.split(",");
    for (String propertyValue : propsExploded) {
        TextView propertyView = new TextView(context);
        String propertyValueTrimmed = propertyValue.trim();
        // length 13 is used to cut off property string at length "Write no resp"
        propertyValueTrimmed = propertyValue.length() > 13 ? propertyValue.substring(0, 13) : propertyValueTrimmed;
        propertyValueTrimmed.toUpperCase();
        propertyView.setText(propertyValueTrimmed);
        propertyView.append("  ");
        propertyView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.characteristic_property_text_size));
        propertyView.setTextColor(ContextCompat.getColor(context, R.color.silabs_blue));
        propertyView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);

        LinearLayout propertyContainer = new LinearLayout(context);
        propertyContainer.setOrientation(LinearLayout.HORIZONTAL);

        ImageView propertyIcon = new ImageView(context);
        int iconId;
        if (propertyValue.trim().toUpperCase().equals("BROADCAST")) {
            iconId = R.drawable.debug_prop_broadcast;
        } else if (propertyValue.trim().toUpperCase().equals("READ")) {
            iconId = R.drawable.ic_icon_read_on;
        } else if (propertyValue.trim().toUpperCase().equals("WRITE NO RESPONSE")) {
            iconId = R.drawable.debug_prop_write_no_resp;
        } else if (propertyValue.trim().toUpperCase().equals("WRITE")) {
            iconId = R.drawable.ic_icon_edit_on;
        } else if (propertyValue.trim().toUpperCase().equals("NOTIFY")) {
            iconId = R.drawable.ic_icon_notify_on;
        } else if (propertyValue.trim().toUpperCase().equals("INDICATE")) {
            iconId = R.drawable.ic_icon_indicate_on;
        } else if (propertyValue.trim().toUpperCase().equals("SIGNED WRITE")) {
            iconId = R.drawable.debug_prop_signed_write;
        } else if (propertyValue.trim().toUpperCase().equals("EXTENDED PROPS")) {
            iconId = R.drawable.debug_prop_ext;
        } else {
            iconId = R.drawable.debug_prop_ext;
        }
        propertyIcon.setBackgroundResource(iconId);

        LinearLayout.LayoutParams paramsText = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        paramsText.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;

        LinearLayout.LayoutParams paramsIcon = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        paramsIcon.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;

        if (propertyValue.trim().toUpperCase().equals("WRITE NO RESPONSE")) {
            float d = getResources().getDisplayMetrics().density;
            paramsIcon = new LinearLayout.LayoutParams((int) (24 * d), ((int) (24 * d)));
            paramsIcon.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        }

        propertyContainer.addView(propertyView, paramsText);
        propertyContainer.addView(propertyIcon, paramsIcon);

        LinearLayout.LayoutParams paramsTextAndIconContainer = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        paramsTextAndIconContainer.gravity = Gravity.RIGHT;
        propertiesContainer.addView(propertyContainer, paramsTextAndIconContainer);
    }
}
 
Example 19
Source File: PickerBottomLayout.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
public PickerBottomLayout(Context context, boolean darkTheme) {
    super(context);
    isDarkTheme = darkTheme;

    setBackgroundColor(isDarkTheme ? 0xff1a1a1a : 0xffffffff);

    cancelButton = new TextView(context);
    cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    cancelButton.setTextColor(isDarkTheme ? 0xffffffff : 0xff007aff);
    cancelButton.setGravity(Gravity.CENTER);
    cancelButton.setBackgroundDrawable(
            Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR
                    : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    cancelButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    cancelButton.setText(R.string.Preview);
    // cancelButton.getPaint().setFakeBoldText(true);
    addView(cancelButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(
            Theme.createBarSelectorDrawable(isDarkTheme ? Theme.ACTION_BAR_PICKER_SELECTOR_COLOR
                    : Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    doneButton.setPadding(AndroidUtilities.dp(29), 0, AndroidUtilities.dp(29), 0);
    addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));

    doneButtonBadgeTextView = new TextView(context);
    // doneButtonBadgeTextView.getPaint().setFakeBoldText(true);
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
    doneButtonBadgeTextView.setTextColor(0xffffffff);
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    doneButtonBadgeTextView.setBackgroundResource(
            isDarkTheme ? R.drawable.photobadge_new : R.drawable.photobadge_new);
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8),
            AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView,
            LayoutHelper.createLinear(26, 26, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
    doneButtonTextView.setTextColor(isDarkTheme ? 0xffffffff : 0xff007aff);
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setText(R.string.Send);
    // doneButtonTextView.getPaint().setFakeBoldText(true);
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
}
 
Example 20
Source File: FeaturedStickerSetInfoCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public FeaturedStickerSetInfoCell(Context context, int left) {
    super(context);

    delDrawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_delButton), Theme.getColor(Theme.key_featuredStickers_delButtonPressed));
    addDrawable = Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed));

    botProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    botProgressPaint.setColor(Theme.getColor(Theme.key_featuredStickers_buttonProgress));
    botProgressPaint.setStrokeCap(Paint.Cap.ROUND);
    botProgressPaint.setStyle(Paint.Style.STROKE);
    botProgressPaint.setStrokeWidth(AndroidUtilities.dp(2));

    nameTextView = new TextView(context);
    nameTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelTrendingTitle));
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
    nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    nameTextView.setSingleLine(true);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, left, 8, 100, 0));

    infoTextView = new TextView(context);
    infoTextView.setTextColor(Theme.getColor(Theme.key_chat_emojiPanelTrendingDescription));
    infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    infoTextView.setEllipsize(TextUtils.TruncateAt.END);
    infoTextView.setSingleLine(true);
    addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, left, 30, 100, 0));

    addButton = new TextView(context) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (drawProgress || !drawProgress && progressAlpha != 0) {
                botProgressPaint.setAlpha(Math.min(255, (int) (progressAlpha * 255)));
                int x = getMeasuredWidth() - AndroidUtilities.dp(11);
                rect.set(x, AndroidUtilities.dp(3), x + AndroidUtilities.dp(8), AndroidUtilities.dp(8 + 3));
                canvas.drawArc(rect, angle, 220, false, botProgressPaint);
                invalidate((int) rect.left - AndroidUtilities.dp(2), (int) rect.top - AndroidUtilities.dp(2), (int) rect.right + AndroidUtilities.dp(2), (int) rect.bottom + AndroidUtilities.dp(2));
                long newTime = System.currentTimeMillis();
                if (Math.abs(lastUpdateTime - System.currentTimeMillis()) < 1000) {
                    long delta = (newTime - lastUpdateTime);
                    float dt = 360 * delta / 2000.0f;
                    angle += dt;
                    angle -= 360 * (angle / 360);
                    if (drawProgress) {
                        if (progressAlpha < 1.0f) {
                            progressAlpha += delta / 200.0f;
                            if (progressAlpha > 1.0f) {
                                progressAlpha = 1.0f;
                            }
                        }
                    } else {
                        if (progressAlpha > 0.0f) {
                            progressAlpha -= delta / 200.0f;
                            if (progressAlpha < 0.0f) {
                                progressAlpha = 0.0f;
                            }
                        }
                    }
                }
                lastUpdateTime = newTime;
                invalidate();
            }
        }
    };
    addButton.setGravity(Gravity.CENTER);
    addButton.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    addButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    addButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    addView(addButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | Gravity.RIGHT, 0, 16, 14, 0));
}