Java Code Examples for android.widget.TextView#setTypeface()
The following examples show how to use
android.widget.TextView#setTypeface() .
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: FlyWoo File: SlidingTabLayout.java License: Apache License 2.0 | 6 votes |
/** * Create a default view to be used for tabs. This is called if a custom tab * view is not set via {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
Example 2
Source Project: Telegram File: HeaderCell.java License: GNU General Public License v2.0 | 6 votes |
public HeaderCell(Context context, String textColorKey, int padding, int topMargin, boolean text2) { super(context); textView = new TextView(getContext()); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); textView.setMinHeight(AndroidUtilities.dp(height - topMargin)); textView.setTextColor(Theme.getColor(textColorKey)); textView.setTag(textColorKey); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, topMargin, padding, 0)); if (text2) { textView2 = new SimpleTextView(getContext()); textView2.setTextSize(13); textView2.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP); addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, padding, 21, padding, 0)); } }
Example 3
Source Project: CompactCalendarView File: SlidingTabLayout.java License: MIT License | 6 votes |
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
Example 4
Source Project: photo-editor-android File: PhotoEditorSDK.java License: MIT License | 6 votes |
public void addEmoji(String emojiName, Typeface emojiFont) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View emojiRootView = inflater.inflate(R.layout.photo_editor_sdk_text_item_list, null); TextView emojiTextView = (TextView) emojiRootView.findViewById(R.id.photo_editor_sdk_text_tv); emojiTextView.setTypeface(emojiFont); emojiTextView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); emojiTextView.setText(convertEmoji(emojiName)); MultiTouchListener multiTouchListener = new MultiTouchListener(deleteView, parentView, this.imageView, onPhotoEditorSDKListener); multiTouchListener.setOnMultiTouchListener(this); emojiRootView.setOnTouchListener(multiTouchListener); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); parentView.addView(emojiRootView, params); addedViews.add(emojiRootView); if (onPhotoEditorSDKListener != null) onPhotoEditorSDKListener.onAddViewListener(ViewType.EMOJI, addedViews.size()); }
Example 5
Source Project: Interessant File: IndicatorTabLayout.java License: Apache License 2.0 | 5 votes |
private void renderTabText(int position) { for (int i = 0; i < tabViews.size(); i++) { TextView textView = (TextView) tabViews.get(i); if (i == position) { textView.setTextColor(indicatorColor); textView.setTypeface(null, Typeface.BOLD); } else { textView.setTextColor(modulateColorAlpha(indicatorColor, 0.8f)); textView.setTypeface(null, Typeface.NORMAL); } } }
Example 6
Source Project: MuslimMateAndroid File: AzkarAdapter.java License: GNU General Public License v3.0 | 5 votes |
public ViewHolder(View itemView) { super(itemView); Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/simple.otf"); title = (TextView) itemView.findViewById(R.id.textView14); title.setTypeface(tf); ID = (TextView) itemView.findViewById(R.id.hidden); counter = (TextView) itemView.findViewById(R.id.textView16); }
Example 7
Source Project: TelePlus-Android File: PhotoPickerSearchCell.java License: GNU General Public License v2.0 | 5 votes |
public SearchButton(Context context) { super(context); setBackgroundColor(0xff1a1a1a); selector = new View(context); selector.setBackgroundDrawable(Theme.getSelectorDrawable(false)); addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER); addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP)); textView1 = new TextView(context); textView1.setGravity(Gravity.CENTER_VERTICAL); textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView1.setTextColor(0xffffffff); textView1.setSingleLine(true); textView1.setEllipsize(TextUtils.TruncateAt.END); addView(textView1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 8, 4, 0)); textView2 = new TextView(context); textView2.setGravity(Gravity.CENTER_VERTICAL); textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10); textView2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView2.setTextColor(0xff666666); textView2.setSingleLine(true); textView2.setEllipsize(TextUtils.TruncateAt.END); addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 26, 4, 0)); }
Example 8
Source Project: candybar-library File: Popup.java License: Apache License 2.0 | 5 votes |
private int getMeasuredWidth(@NonNull Context context) { DisplayMetrics metrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics); int maxWidth = context.getResources().getDimensionPixelSize(R.dimen.popup_max_width); int minWidth = context.getResources().getDimensionPixelSize(R.dimen.popup_min_width); String longestText = ""; for (PopupItem item : mAdapter.getItems()) { if (item.getTitle().length() > longestText.length()) longestText = item.getTitle(); } int padding = context.getResources().getDimensionPixelSize(R.dimen.content_margin); int iconSize = context.getResources().getDimensionPixelSize(R.dimen.icon_size_small); TextView textView = new TextView(context); textView.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setTypeface(TypefaceHelper.getRegular(context)); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources() .getDimension(R.dimen.text_content_subtitle)); textView.setPadding(padding + iconSize + padding, 0, padding, 0); textView.setText(longestText); int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(metrics.widthPixels, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(widthMeasureSpec, heightMeasureSpec); int measuredWidth = textView.getMeasuredWidth() + padding; if (measuredWidth <= minWidth) { return minWidth; } if (measuredWidth >= minWidth && measuredWidth <= maxWidth) { return measuredWidth; } return maxWidth; }
Example 9
Source Project: android-tv-leanback File: SlidingTabLayout.java License: Apache License 2.0 | 5 votes |
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}. */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setTextColor(getResources().getColor(android.R.color.white)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); return textView; }
Example 10
Source Project: Telegram File: SharedMediaSectionCell.java License: GNU General Public License v2.0 | 5 votes |
public SharedMediaSectionCell(Context context) { super(context); textView = new TextView(getContext()); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 16, 0, 16, 0)); }
Example 11
Source Project: ShadowsocksRR File: Shadowsocks.java License: Apache License 2.0 | 5 votes |
/** * init toolbar */ private void initToolbar() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // non-translatable logo toolbar.setTitle("shadowsocks R"); toolbar.setTitleTextAppearance(toolbar.getContext(), R.style.Toolbar_Logo); try { Field field = Toolbar.class.getDeclaredField("mTitleTextView"); field.setAccessible(true); TextView title = (TextView) field.get(toolbar); title.setFocusable(true); title.setGravity(0x10); title.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(Shadowsocks.this, ProfileManagerActivity.class)); } }); TypedArray typedArray = obtainStyledAttributes(new int[]{R.attr.selectableItemBackgroundBorderless}); title.setBackgroundResource(typedArray.getResourceId(0, 0)); typedArray.recycle(); Typeface tf = Typefaces.get(this, "fonts/Iceland.ttf"); if (tf != null) { title.setTypeface(tf); } title.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); } catch (Exception e) { e.printStackTrace(); } }
Example 12
Source Project: ETSMobile-Android2 File: ExpandableListMoodleSectionAdapter.java License: Apache License 2.0 | 5 votes |
@Override public View getGroupView(int groupPosition, boolean isExpanded,View convertView, ViewGroup parent) { MoodleCourseDetailsFragment.HeaderText header = (MoodleCourseDetailsFragment.HeaderText) getGroup(groupPosition); if (convertView == null) { LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = infalInflater.inflate(R.layout.list_group, null); } TextView lblListHeader = (TextView) convertView.findViewById(R.id.lblListHeader); lblListHeader.setTypeface(null, Typeface.BOLD); lblListHeader.setText(header.getHeaderName()); return convertView; }
Example 13
Source Project: 920-text-editor-v2 File: PagerSlidingTabStrip.java License: Apache License 2.0 | 5 votes |
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if(tabBackgroundResId > 0) 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); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }
Example 14
Source Project: meiShi File: ButtonFlat.java License: Apache License 2.0 | 5 votes |
@Override protected void setAttributes(AttributeSet attrs) { // Set text button String text = null; int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1); if(textResource != -1){ text = getResources().getString(textResource); }else{ text = attrs.getAttributeValue(ANDROIDXML,"text"); } if(text != null){ textButton = new TextView(getContext()); textButton.setText(text.toUpperCase()); textButton.setTextColor(backgroundColor); textButton.setTypeface(null, Typeface.BOLD); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); textButton.setLayoutParams(params); addView(textButton); } int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1); if(bacgroundColor != -1){ setBackgroundColor(getResources().getColor(bacgroundColor)); }else{ // Color by hexadecimal // Color by hexadecimal background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1); if (background != -1) setBackgroundColor(background); } }
Example 15
Source Project: HeaderView File: ProfileChooserFragment.java License: MIT License | 4 votes |
@SuppressLint("RtlHardcoded") @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle bundle = getArguments(); SparseArray<Profile> profileSparseArray = bundle.getSparseParcelableArray("profileSparseArray"); List<Item> items = bundle.getParcelableArrayList("items"); int accent = bundle.getInt("accent"); boolean showAdd = bundle.getBoolean("showAdd"); String titleValue = bundle.getString("titleValue"); int icon = bundle.getInt("icon"); add.setImageResource(icon); title.setTextColor(Utils.getTextColorPrimary(getActivity())); title.setText(titleValue); title.setGravity(Gravity.CENTER_VERTICAL | (hvIsRTL ? Gravity.RIGHT : Gravity.LEFT)); if (typeface != null) title.setTypeface(typeface); add.setVisibility(showAdd ? View.VISIBLE : View.INVISIBLE); add.setColorFilter(Utils.getTextColorPrimary(getActivity())); add.setBackgroundResource(Utils.selectableItemBackgroundBorderless(getActivity())); add.setOnClickListener(v -> { if (callback != null) { if (callback.onAdd()) { dismiss(); } } }); if (profileSparseArray != null) { for (int i = 0; i < profileSparseArray.size(); i++) { Profile profile = profileSparseArray.valueAt(i); if (profile.getId() != 1) { RowProfileView profileView = new RowProfileView(getActivity()); profileView.setTypeface(typeface); profileView.setProfile(profile, i == 0); profileView.setAccent(accent); profileView.setOnClickListener(v -> { RowProfileView rowProfileView = (RowProfileView) v; if (callback != null) { if (callback.onSelect(rowProfileView.getProfile().getId(), rowProfileView.isActive())) { dismiss(); } } }); linearLayout.addView(profileView); } } } if (items != null) { int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.hv_item_padding); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); for (Item item : items) { TextView textView = new TextView(getActivity()); textView.setText(item.getTitle()); if (typeface != null) textView.setTypeface(typeface); textView.setTag(item.getId()); textView.setBackgroundResource(Utils.selectableItemBackground(getActivity())); textView.setPadding(padding, padding / 2, padding, padding / 2); textView.setTextColor(Utils.getTextColorSecondary(getActivity())); textView.setGravity(Gravity.CENTER_VERTICAL | (hvIsRTL ? Gravity.RIGHT : Gravity.LEFT)); textView.setOnClickListener(v -> { int id = (int) v.getTag(); if (callback != null) { if (callback.onItem(id)) { dismiss(); } } }); linearLayout1.addView(textView, layoutParams); } } }
Example 16
Source Project: storage-chooser File: TypefaceUtil.java License: Mozilla Public License 2.0 | 4 votes |
public static void setTypefaceRegular(Context context, TextView textView) { mNunitoTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/NunitoSans-Regular.ttf"); textView.setTypeface(mNunitoTypeFace); }
Example 17
Source Project: TelePlus-Android File: LoginActivity.java License: GNU General Public License v2.0 | 4 votes |
public LoginActivityResetWaitView(Context context) { super(context); setOrientation(VERTICAL); confirmTextView = new TextView(context); confirmTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6)); confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); confirmTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(confirmTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); resetAccountText = new TextView(context); resetAccountText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); resetAccountText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6)); resetAccountText.setText(LocaleController.getString("ResetAccountStatus", R.string.ResetAccountStatus)); resetAccountText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); resetAccountText.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(resetAccountText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 24, 0, 0)); resetAccountTime = new TextView(context); resetAccountTime.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); resetAccountTime.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6)); resetAccountTime.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); resetAccountTime.setLineSpacing(AndroidUtilities.dp(2), 1.0f); addView(resetAccountTime, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 2, 0, 0)); resetAccountButton = new TextView(context); resetAccountButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); resetAccountButton.setText(LocaleController.getString("ResetAccountButton", R.string.ResetAccountButton)); resetAccountButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); resetAccountButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); resetAccountButton.setLineSpacing(AndroidUtilities.dp(2), 1.0f); resetAccountButton.setPadding(0, AndroidUtilities.dp(14), 0, 0); addView(resetAccountButton, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 0, 7, 0, 0)); resetAccountButton.setOnClickListener(view -> { if (Math.abs(ConnectionsManager.getInstance(currentAccount).getCurrentTime() - startTime) < waitTime) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("ResetMyAccountWarningText", R.string.ResetMyAccountWarningText)); builder.setTitle(LocaleController.getString("ResetMyAccountWarning", R.string.ResetMyAccountWarning)); builder.setPositiveButton(LocaleController.getString("ResetMyAccountWarningReset", R.string.ResetMyAccountWarningReset), (dialogInterface, i) -> { needShowProgress(0); TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount(); req.reason = "Forgot password"; ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { needHideProgress(); if (error == null) { Bundle params = new Bundle(); params.putString("phoneFormated", requestPhone); params.putString("phoneHash", phoneHash); params.putString("code", phoneCode); setPage(5, true, params, false); } else { if (error.text.equals("2FA_RECENT_CONFIRM")) { needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ResetAccountCancelledAlert", R.string.ResetAccountCancelledAlert)); } else { needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text); } } }), ConnectionsManager.RequestFlagWithoutLogin | ConnectionsManager.RequestFlagFailOnServerErrors); }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); }); }
Example 18
Source Project: apigee-android-sdk File: MessageBoard.java License: Apache License 2.0 | 4 votes |
private void createPosts() { //get total number of posts from Posts.java int numPosts = ((Messagee) this.getApplication()).messController.getPosts().getNumPosts(); //clear all posts from llPosts llPosts.removeAllViews(); //create individual post layouts and add to llPosts for(int i=numPosts-1; i>=0; i--){ /*cell layout: |picture| |arrow| |Username| | | |image| |Post ............| | | | | |Post ............| | | | | |Post ............| */ //create layout for post cell LinearLayout llCell = new LinearLayout(this); llCell.setOrientation(LinearLayout.HORIZONTAL); //create layout to hold username and post message LinearLayout llUserAndPost = new LinearLayout(this); llUserAndPost.setOrientation(LinearLayout.VERTICAL); //Create image holder for user image ImageView postImage = new ImageView(this); postImage.setMaxWidth(dpToPix(50)); postImage.setBackgroundColor(getResources().getColor(R.color.black)); postImage.setPadding(dpToPix(1), dpToPix(1), dpToPix(1), dpToPix(1)); postImage.setMaxHeight(dpToPix(50)); postImage.setScaleType(ImageView.ScaleType.FIT_XY); postImage.setAdjustViewBounds(true); String imURL = ((Messagee) this.getApplication()).messController.getPosts().getPicURLByIndex(i); postImage.setImageDrawable(((Messagee) this.getApplication()).messController.getPostImages().getImage(imURL)); //draw arrow ImageView arrowImage = new ImageView(this); arrowImage.setMaxWidth(dpToPix(30)); arrowImage.setMaxHeight(dpToPix(30)); arrowImage.setScaleType(ImageView.ScaleType.FIT_XY); arrowImage.setAdjustViewBounds(true); arrowImage.setImageDrawable(getResources().getDrawable(R.drawable.arrow)); //text holder for username String username = ((Messagee) this.getApplication()).messController.getPosts().getPostNameByIndex(i); TextView usernameText = new TextView(this); usernameText.setPadding(0, 0, 0, dpToPix(4)); usernameText.setTextColor(getResources().getColor(R.color.black)); usernameText.setText(username); usernameText.setTypeface(null,1); usernameText.setTextSize(17); //text holder for message String postMessage = ((Messagee) this.getApplication()).messController.getPosts().getPostMessageByIndex(i); TextView postText = new TextView(this); postText.setTextColor(getResources().getColor(R.color.post_message_gray)); postText.setText(postMessage); postText.setTextSize(17); //add username and post text to a linear layout llUserAndPost.addView(usernameText); llUserAndPost.addView(postText); //set layout properties and add rounded rectangle border llUserAndPost.setBackgroundDrawable(getResources().getDrawable(R.drawable.rounded_corners_white)); llUserAndPost.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); llUserAndPost.setPadding(dpToPix(14), dpToPix(10), dpToPix(14), dpToPix(10)); //add images and text layout to create the post layout llCell.addView(postImage); llCell.addView(arrowImage); llCell.addView(llUserAndPost); llCell.setPadding(dpToPix(10f), dpToPix(18f), dpToPix(10f), 0); //add post layout to layout containing all posts llPosts.addView(llCell); } }
Example 19
Source Project: TelePlus-Android File: FeaturedStickerSetCell.java License: GNU General Public License v2.0 | 4 votes |
public FeaturedStickerSetCell(Context context) { super(context); progressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); progressPaint.setColor(Theme.getColor(Theme.key_featuredStickers_buttonProgress)); progressPaint.setStrokeCap(Paint.Cap.ROUND); progressPaint.setStyle(Paint.Style.STROKE); progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); textView = new TextView(context); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLines(1); textView.setMaxLines(1); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71, 10, LocaleController.isRTL ? 71 : 100, 0)); valueTextView = new TextView(context); valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2)); valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); valueTextView.setLines(1); valueTextView.setMaxLines(1); valueTextView.setSingleLine(true); valueTextView.setEllipsize(TextUtils.TruncateAt.END); valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, LocaleController.isRTL ? 100 : 71, 35, LocaleController.isRTL ? 71 : 100, 0)); imageView = new BackupImageView(context); imageView.setAspectFit(true); addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 12, 8, LocaleController.isRTL ? 12 : 0, 0)); addButton = new TextView(context) { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (drawProgress || !drawProgress && progressAlpha != 0) { progressPaint.setAlpha(Math.min(255, (int) (progressAlpha * 255))); int x = getMeasuredWidth() - AndroidUtilities.dp(11); progressRect.set(x, AndroidUtilities.dp(3), x + AndroidUtilities.dp(8), AndroidUtilities.dp(8 + 3)); canvas.drawArc(progressRect, angle, 220, false, progressPaint); invalidate((int) progressRect.left - AndroidUtilities.dp(2), (int) progressRect.top - AndroidUtilities.dp(2), (int) progressRect.right + AndroidUtilities.dp(2), (int) progressRect.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")); addButton.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed))); addButton.setText(LocaleController.getString("Add", R.string.Add).toUpperCase()); addButton.setPadding(AndroidUtilities.dp(17), 0, AndroidUtilities.dp(17), 0); addView(addButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 28, Gravity.TOP | (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT), LocaleController.isRTL ? 14 : 0, 18, LocaleController.isRTL ? 0 : 14, 0)); checkImage = new ImageView(context); checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY)); checkImage.setImageResource(R.drawable.sticker_added); addView(checkImage, LayoutHelper.createFrame(19, 14)); }
Example 20
Source Project: Rey-MusicPlayer File: ABRepeatDialog.java License: Apache License 2.0 | 2 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mApp = (Common) getActivity().getApplicationContext(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.a_b_repeat); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_ab_repeat, null); mSeekBar = view.findViewById(R.id.repeat_song_range_placeholder_seekbar); repeatSongATime = view.findViewById(R.id.repeat_song_range_A_time); repeatSongBTime = view.findViewById(R.id.repeat_song_range_B_time); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mSeekBar.getLayoutParams(); viewGroup = (ViewGroup) mSeekBar.getParent(); viewGroup.removeView(mSeekBar); repeatSongATime.setTypeface(TypefaceHelper.getTypeface(getActivity().getApplicationContext(), "Futura-Condensed-Font")); repeatSongBTime.setTypeface(TypefaceHelper.getTypeface(getActivity().getApplicationContext(), "Futura-Condensed-Font")); TextView textView = view.findViewById(R.id.repeat_song_range_instructions); textView.setTypeface(TypefaceHelper.getTypeface(getActivity().getApplicationContext(), "Futura-Condensed-Font")); currentSongDurationMillis = mApp.getService().getMediaPlayer().getDuration(); mRangeSeekBar = new RangeSeekBar<>(0, currentSongDurationMillis, getActivity().getApplicationContext()); mRangeSeekBar.setLayoutParams(params); viewGroup.addView(mRangeSeekBar); if (PreferencesHelper.getInstance().getInt(PreferencesHelper.Key.REPEAT_MODE, Constants.REPEAT_OFF) == Constants.A_B_REPEAT) { repeatSongATime.setText(MusicUtils.convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointA())); repeatSongBTime.setText(MusicUtils.convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointB())); repeatPointA = mApp.getService().getRepeatSongRangePointA(); repeatPointB = mApp.getService().getRepeatSongRangePointB(); mRangeSeekBar.setSelectedMinValue(repeatPointA); mRangeSeekBar.setSelectedMaxValue(repeatPointB); } else { repeatSongATime.setText("0:00"); repeatSongBTime.setText(MusicUtils.convertMillisToMinsSecs(currentSongDurationMillis)); repeatPointA = 0; repeatPointB = currentSongDurationMillis; } mRangeSeekBar.setOnRangeSeekBarChangeListener((bar, minValue, maxValue) -> { repeatPointA = minValue; repeatPointB = maxValue; repeatSongATime.setText(MusicUtils.convertMillisToMinsSecs(minValue)); repeatSongBTime.setText(MusicUtils.convertMillisToMinsSecs(maxValue)); }); repeatSongATime.setText(MusicUtils.convertMillisToMinsSecs(repeatPointA)); repeatSongBTime.setText(MusicUtils.convertMillisToMinsSecs(repeatPointB)); builder.setView(view); builder.setPositiveButton(R.string.repeat, (arg0, arg1) -> { PreferencesHelper.getInstance().put(PreferencesHelper.Key.REPEAT_MODE, Constants.A_B_REPEAT); mApp.getService().setRepeatSongRange(repeatPointA, repeatPointB); ((NowPlayingActivity) getActivity()).applyRepeatButton(); dismiss(); }); builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); return builder.create(); }