下面列出了android.widget.TextView#setMaxWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void updateNamePosition(@NonNull CoordinatorLayout parent, float factor) {
TextView child = (TextView) groupNameRef.require(parent);
View target = groupNameTargetRef.require(parent);
targetRect.set(target.getLeft(), target.getTop(), target.getRight(), target.getBottom());
childRect.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
if (child.getMaxWidth() != targetRect.width()) {
child.setMaxWidth(targetRect.width());
}
float deltaTop = targetRect.top - childRect.top;
float deltaStart = getStart(parent, targetRect) - getStart(parent, childRect);
float yTranslation = deltaTop * factor;
float xTranslation = deltaStart * factor;
child.setTranslationY(yTranslation);
child.setTranslationX(xTranslation);
}
@NonNull
private TextView newFieldTextView(String text, int textAppearance) {
Context context = binding.getRoot().getContext();
Resources resources = context.getResources();
TextView v = new TextView(context);
v.setTextAppearance(context, textAppearance);
// NOTE: These attributes don't work when applying text appearance programmatically, so we set
// them here individually instead.
v.setPadding(
0, 0, resources.getDimensionPixelSize(R.dimen.observation_summary_text_padding_right), 0);
v.setMaxWidth(resources.getDimensionPixelSize(R.dimen.observation_summary_text_max_width));
v.setMaxLines(1);
v.setSingleLine();
v.setEllipsize(TextUtils.TruncateAt.END);
v.setText(text);
return v;
}
public void initModule(float density, int densityDpi) {
mReturnButton = (ImageButton) findViewById(R.id.jmui_return_btn);
mGroupNumTv = (TextView) findViewById(R.id.jmui_group_num_tv);
mRightBtn = (ImageButton) findViewById(R.id.jmui_right_btn);
mChatTitle = (TextView) findViewById(R.id.jmui_title);
mAtMeBtn = (Button) findViewById(R.id.jmui_at_me_btn);
if (densityDpi <= 160) {
mChatTitle.setMaxWidth((int)(180 * density + 0.5f));
}else if (densityDpi <= 240) {
mChatTitle.setMaxWidth((int)(190 * density + 0.5f));
}else {
mChatTitle.setMaxWidth((int)(200 * density + 0.5f));
}
mChatListView = (DropDownListView) findViewById(R.id.lv_chat);
}
/**
* @param index of tab where badge should be added
* @param text the text of the badge (null to hide the badge)
*/
public void setBadgeText(int index, @Nullable String text) {
TabLayout.Tab tab = getTabAt(index);
if (tab == null || tab.getCustomView() == null) {
Log.e("BadgedTabLayout", "Tab is null. Not setting custom view");
return;
}
TextView badge = tab.getCustomView().findViewById(R.id.textview_tab_badge);
TextView tabText = tab.getCustomView().findViewById(R.id.textview_tab_title);
if (text == null) {
badge.setVisibility(View.GONE);
tabText.setMaxWidth(Integer.MAX_VALUE);
} else {
int maxWidth = getResources().getDimensionPixelSize(R.dimen.tab_text_max_width);
badge.setText(text);
tabText.setMaxWidth(maxWidth);
badge.setVisibility(View.VISIBLE);
}
TransitionManager.beginDelayedTransition((ViewGroup) tab.getCustomView());
}
private TextView createTextView(String text) {
TextView textView = new TextView(getContext());
if (getWidth() > 0) {
textView.setMaxWidth(getWidth() - 50);
}
textView.setText(text);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTagsTextSize);
textView.setTextColor(mTagsTextColor);
textView.setPadding(mTagsPaddingLeft, mTagsPaddingTop, mTagsPaddingRight, mTagsPaddingBottom);
// check Android version for set background
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
textView.setBackground(mTagsBackground);
} else {
textView.setBackgroundDrawable(mTagsBackground);
}
textView.setCompoundDrawablesWithIntrinsicBounds(mLeftDrawable, null, mRightDrawable, null);
textView.setCompoundDrawablePadding(mDrawablePadding);
return textView;
}
public DialogXRandomInfo(Context context, boolean guide, boolean auto) {
super(context);
setContentView(R.layout.dialog_xrandom_info);
findViewById(R.id.btn_ok).setOnClickListener(this);
TextView tv = (TextView) findViewById(R.id.tv);
if (guide) {
tv.setText(context.getString(R.string.xrandom_info_detail) + context.getString(R
.string.xrandom_info_guide));
} else {
tv.setText(context.getString(R.string.xrandom_info_detail));
}
tv.setMaxWidth(UIUtil.getScreenWidth() - UIUtil.dip2pix(80));
cbxAutoShowNegative = (CheckedTextView) findViewById(R.id.cbx_auto_show_negative);
if (auto) {
cbxAutoShowNegative.setVisibility(View.VISIBLE);
cbxAutoShowNegative.setOnClickListener(this);
} else {
cbxAutoShowNegative.setVisibility(View.GONE);
}
}
private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) {
TextView textView = new TextView(activity);
textView.setTextSize(textSize);
textView.setMaxWidth(maxWidth);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setText(text + " ");
layout.addView(textView);
}
/**
* @param tab for which custom title is created
* @param view custom view, manually inflated from badged_tab.xml
*/
private void makeCustomTitle(Tab tab, View view) {
TextView title = view.findViewById(R.id.textview_tab_title);
title.setTextColor(getTabTextColors());
if (tabTextSize != 0)
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
if (tabTruncateAt != null)
title.setEllipsize(tabTruncateAt);
if (tabFont != null)
title.setTypeface(tabFont);
if (isSpanText) {
title.setSingleLine(false);
title.setMarqueeRepeatLimit(-1);
title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
}
if (maxWidthText != -1)
title.setMaxWidth(maxWidthText);
if (!TextUtils.isEmpty(tab.getText()))
title.setText(tab.getText());
else
title.setVisibility(GONE);
}
/**
* Create a default view to be used for tabs.
*/
protected View createDefaultTabView(Context context, TabItemSpec tabItem) {
float density = getResources().getDisplayMetrics().density;
int padding = (int) (TAB_VIEW_PADDING_DIPS * density);
LinearLayout ll = new LinearLayout(context);
ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
ll.setGravity(Gravity.CENTER);
ll.setOrientation(LinearLayout.VERTICAL);
TypedValue outValue = new TypedValue();
getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
ll.setBackgroundResource(outValue.resourceId);
ImageView imgView = new ImageView(context);
imgView.setScaleType(ScaleType.FIT_CENTER);
LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
imgLP.gravity = Gravity.CENTER;
imgView.setLayoutParams(imgLP);
TextView textView = new TextView(context);
textView.setGravity(Gravity.CENTER);
textView.setMaxWidth((int) (TEXT_MAX_WIDTH * density));
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
textView.setTypeface(Typeface.DEFAULT_BOLD);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setAllCaps(true);
textView.setMaxLines(2);
textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
textView.setPadding(padding, 0, padding, 0);
this.setupItem(ll, textView, imgView, tabItem);
ll.addView(imgView);
ll.addView(textView);
return ll;
}
private void decorateItemTextView(TextView textView) {
textView.setTextColor(itemTextColorStateList);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, itemTextSize);
textView.setCompoundDrawablePadding(itemDrawablePadding);
textView.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, 0, rightDrawable, 0);
textView.setEllipsize(ellipsizeList.get(itemTextEllipsize));
if (maxItemWidth > 0) textView.setMaxWidth(maxItemWidth);
if (typeface != null) textView.setTypeface(typeface);
textView.setLayoutParams(itemFrameParams);
textView.measure(0, 0);
}
private LinearLayout createTGAView(String name) {
ImageView image = createTGAImageView("images/"+name);
if(image != null) {
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(image);
TextView label = new TextView(this);
label.setText(name);
label.setMaxWidth(128);
label.setPadding(8, 8, 0, 0);
layout.addView(label);
return layout;
}
return null;
}
private void showDebugAlert() {
if(VoIPService.getSharedInstance()==null)
return;
VoIPService.getSharedInstance().forceRating();
final LinearLayout debugOverlay=new LinearLayout(this);
debugOverlay.setOrientation(LinearLayout.VERTICAL);
debugOverlay.setBackgroundColor(0xCC000000);
int pad=AndroidUtilities.dp(16);
debugOverlay.setPadding(pad, pad*2, pad, pad*2);
TextView title=new TextView(this);
title.setTextColor(0xFFFFFFFF);
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
title.setTypeface(Typeface.DEFAULT_BOLD);
title.setGravity(Gravity.CENTER);
title.setText("libtgvoip v"+VoIPController.getVersion());
debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));
ScrollView scroll=new ScrollView(this);
final TextView debugText=new TextView(this);
debugText.setTypeface(Typeface.MONOSPACE);
debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
debugText.setMaxWidth(AndroidUtilities.dp(350));
debugText.setTextColor(0xFFFFFFFF);
debugText.setText(getFormattedDebugString());
scroll.addView(debugText);
debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));
TextView closeBtn=new TextView(this);
closeBtn.setBackgroundColor(0xFFFFFFFF);
closeBtn.setTextColor(0xFF000000);
closeBtn.setPadding(pad, pad, pad, pad);
closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
closeBtn.setText(LocaleController.getString("Close", R.string.Close));
debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));
final WindowManager wm=(WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));
closeBtn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
wm.removeView(debugOverlay);
}
});
final Runnable r = new Runnable() {
@Override
public void run() {
if (isFinishing() || VoIPService.getSharedInstance() == null) {
return;
}
debugText.setText(getFormattedDebugString());
debugOverlay.postDelayed(this, 500);
}
};
debugOverlay.postDelayed(r, 500);
}
private void showDebugAlert() {
if (VoIPService.getSharedInstance() == null)
return;
VoIPService.getSharedInstance().forceRating();
final LinearLayout debugOverlay = new LinearLayout(this);
debugOverlay.setOrientation(LinearLayout.VERTICAL);
debugOverlay.setBackgroundColor(0xCC000000);
int pad = AndroidUtilities.dp(16);
debugOverlay.setPadding(pad, pad * 2, pad, pad * 2);
TextView title = new TextView(this);
title.setTextColor(0xFFFFFFFF);
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
title.setTypeface(Typeface.DEFAULT_BOLD);
title.setGravity(Gravity.CENTER);
title.setText(getDebugTitle());
debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));
ScrollView scroll = new ScrollView(this);
final TextView debugText = new TextView(this);
debugText.setTypeface(Typeface.MONOSPACE);
debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
debugText.setMaxWidth(AndroidUtilities.dp(350));
debugText.setTextColor(0xFFFFFFFF);
debugText.setText(getFormattedDebugString());
scroll.addView(debugText);
debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));
TextView closeBtn = new TextView(this);
closeBtn.setBackgroundColor(0xFFFFFFFF);
closeBtn.setTextColor(0xFF000000);
closeBtn.setPadding(pad, pad, pad, pad);
closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
closeBtn.setText(LocaleController.getString("Close", R.string.Close));
debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));
final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));
closeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wm.removeView(debugOverlay);
}
});
final Runnable r = new Runnable() {
@Override
public void run() {
if (isFinishing() || VoIPService.getSharedInstance() == null) {
return;
}
title.setText(getDebugTitle());
debugText.setText(getFormattedDebugString());
debugOverlay.postDelayed(this, 500);
}
};
debugOverlay.postDelayed(r, 500);
}
static View getViewForward() {
LinearLayout cslr_ll_forward = new LinearLayout(context);
cslr_ll_forward.setId(R.id.cslr_ll_forward);
cslr_ll_forward.setClickable(true);
cslr_ll_forward.setOrientation(HORIZONTAL);
cslr_ll_forward.setPadding(i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding), i_Dp(R.dimen.messageContainerPaddingLeftRight), i_Dp(messageContainerPadding));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
cslr_ll_forward.setTextDirection(View.TEXT_DIRECTION_LOCALE);
}
setLayoutDirection(cslr_ll_forward, View.LAYOUT_DIRECTION_LOCALE);
LinearLayout.LayoutParams layout_687 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
cslr_ll_forward.setLayoutParams(layout_687);
View View_997 = new View(context);
View_997.setBackgroundColor(Color.parseColor(G.textBubble));
LinearLayout.LayoutParams layout_547 = new LinearLayout.LayoutParams(dpToPixel(2), ViewGroup.LayoutParams.MATCH_PARENT);
layout_547.rightMargin = dpToPixel(3);
View_997.setLayoutParams(layout_547);
cslr_ll_forward.addView(View_997);
TextView cslr_txt_prefix_forward = new TextView(context);
cslr_txt_prefix_forward.setId(R.id.cslr_txt_prefix_forward);
cslr_txt_prefix_forward.setText(context.getResources().getString(R.string.forwarded_from));
cslr_txt_prefix_forward.setTextColor(Color.parseColor(G.textBubble));
setTextSize(cslr_txt_prefix_forward, R.dimen.dp12);
cslr_txt_prefix_forward.setSingleLine(true);
cslr_txt_prefix_forward.setTypeface(G.typeface_IRANSansMobile_Bold);
LinearLayout.LayoutParams layout_992 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layout_992.rightMargin = i_Dp(dp4);
layout_992.leftMargin = i_Dp(R.dimen.dp6);
cslr_txt_prefix_forward.setLayoutParams(layout_992);
cslr_ll_forward.addView(cslr_txt_prefix_forward);
TextView cslr_txt_forward_from = new TextView(context);
cslr_txt_forward_from.setId(R.id.cslr_txt_forward_from);
cslr_txt_forward_from.setMinimumWidth(i_Dp(R.dimen.dp100));
cslr_txt_forward_from.setMaxWidth(i_Dp(R.dimen.dp140));
cslr_txt_forward_from.setTextColor(Color.parseColor(G.textBubble));
setTextSize(cslr_txt_forward_from, R.dimen.dp12);
cslr_txt_forward_from.setSingleLine(true);
cslr_txt_forward_from.setTypeface(G.typeface_IRANSansMobile_Bold);
LinearLayout.LayoutParams layout_119 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
cslr_txt_forward_from.setLayoutParams(layout_119);
cslr_ll_forward.addView(cslr_txt_forward_from);
return cslr_ll_forward;
}
static View getFileItem() {
LinearLayout mainContainer = new LinearLayout(G.context);
mainContainer.setId(R.id.mainContainer);
mainContainer.setOrientation(HORIZONTAL);
LinearLayout.LayoutParams layout_106 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
mainContainer.setLayoutParams(layout_106);
LinearLayout linearLayout_768 = new LinearLayout(G.context);
linearLayout_768.setOrientation(VERTICAL);
LinearLayout.LayoutParams layout_577 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
linearLayout_768.setLayoutParams(layout_577);
LinearLayout contentContainer = new LinearLayout(G.context);
LinearLayout.LayoutParams layoutParamsContentContainer = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
contentContainer.setId(R.id.contentContainer);
contentContainer.setLayoutParams(layoutParamsContentContainer);
contentContainer.setPadding(i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4), i_Dp(R.dimen.dp4));
contentContainer.setLayoutParams(layoutParamsContentContainer);
LinearLayout m_container = new LinearLayout(G.context);
m_container.setId(R.id.m_container);
m_container.setOrientation(VERTICAL);
LinearLayout.LayoutParams layout_346 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
m_container.setLayoutParams(layout_346);
LinearLayout linearLayout_784 = new LinearLayout(G.context);
linearLayout_784.setGravity(Gravity.CENTER_VERTICAL);
setLayoutDirection(linearLayout_784, View.LAYOUT_DIRECTION_LTR);
linearLayout_784.setOrientation(HORIZONTAL);
linearLayout_784.setPadding(0, 0, (int) G.context.getResources().getDimension(R.dimen.messageContainerPadding), 0);
LinearLayout.LayoutParams layout_419 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout_419.gravity = CENTER;
linearLayout_784.setLayoutParams(layout_419);
FrameLayout frameLayout = new FrameLayout(G.context);
FrameLayout.LayoutParams layoutParamsFrameLayout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParamsFrameLayout.gravity = CENTER;
frameLayout.setPadding(10, 10, 10, 10);
frameLayout.setLayoutParams(layoutParamsFrameLayout);
ImageView imgThumbnail = new ImageView(G.context);
imgThumbnail.setId(R.id.thumbnail);
LinearLayout.LayoutParams thumbnailParams = new LinearLayout.LayoutParams((int) G.context.getResources().getDimension(R.dimen.dp48), (int) G.context.getResources().getDimension(R.dimen.dp48));
thumbnailParams.gravity = CENTER;
imgThumbnail.setBackgroundColor(Color.TRANSPARENT);
imgThumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER);
AppUtils.setImageDrawable(imgThumbnail, R.drawable.file_icon);
imgThumbnail.setLayoutParams(thumbnailParams);
LinearLayout linearLayout_780 = new LinearLayout(G.context);
linearLayout_780.setOrientation(VERTICAL);
LinearLayout.LayoutParams layout_752 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout_752.gravity = CENTER;
linearLayout_780.setLayoutParams(layout_752);
TextView songArtist = new TextView(G.context);
songArtist.setId(R.id.songArtist);
songArtist.setEllipsize(TextUtils.TruncateAt.MIDDLE);
songArtist.setSingleLine(true);
songArtist.setMaxWidth((int) G.context.getResources().getDimension(R.dimen.dp180));
songArtist.setText("file_name.ext");
songArtist.setTextColor(Color.parseColor(G.textBubble));
setTextSize(songArtist, R.dimen.dp14);
songArtist.setTypeface(G.typeface_IRANSansMobile_Bold, BOLD);
LinearLayout.LayoutParams layout_1000 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
songArtist.setLayoutParams(layout_1000);
linearLayout_780.addView(songArtist);
TextView fileSize = new TextView(G.context);
fileSize.setId(R.id.fileSize);
fileSize.setSingleLine(true);
fileSize.setText("3.2 mb");
fileSize.setAllCaps(TRUE);
fileSize.setTextColor(Color.parseColor(G.textBubble));
setTextSize(fileSize, R.dimen.dp10);
setTypeFace(fileSize);
LinearLayout.LayoutParams layout_958 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout_958.topMargin = 3;
fileSize.setLayoutParams(layout_958);
linearLayout_780.addView(fileSize);
linearLayout_784.addView(frameLayout);
linearLayout_784.addView(linearLayout_780);
m_container.addView(linearLayout_784);
LinearLayout csliwt_layout_container_message = new LinearLayout(G.context);
csliwt_layout_container_message.setId(R.id.csliwt_layout_container_message);
csliwt_layout_container_message.setOrientation(HORIZONTAL);
LinearLayout.LayoutParams layout_312 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
csliwt_layout_container_message.setLayoutParams(layout_312);
m_container.addView(csliwt_layout_container_message);
contentContainer.addView(m_container);
linearLayout_768.addView(contentContainer);
frameLayout.addView(imgThumbnail);
frameLayout.addView(getProgressBar(R.dimen.dp52));
mainContainer.addView(linearLayout_768);
return mainContainer;
}
static View makeTextViewMessage(int maxsize, boolean hasEmoji, boolean hasLink) {
if (hasEmoji) {
EmojiTextViewE emojiTextViewE = new EmojiTextViewE(context);
emojiTextViewE.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// if (G.isDarkTheme) {
emojiTextViewE.setTextColor(Color.parseColor(G.textBubble));
// } else {
// emojiTextViewE.setTextColor(Color.parseColor("#333333"));
// }
emojiTextViewE.setId(R.id.messageSenderTextMessage);
emojiTextViewE.setPadding(10, 4, 10, 4);
emojiTextViewE.setTypeface(G.typeface_IRANSansMobile);
setTextSizeDirect(emojiTextViewE, G.userTextSize);
emojiTextViewE.setEmojiSize(i_Dp(R.dimen.dp18));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
emojiTextViewE.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG);
}
setLayoutDirection(emojiTextViewE, View.LAYOUT_DIRECTION_LOCALE);
if (hasLink) {
emojiTextViewE.setMovementMethod(LinkMovementMethod.getInstance());
}
if (maxsize > 0) {
emojiTextViewE.setMaxWidth(maxsize);
}
return emojiTextViewE;
} else {
TextView textView = new TextView(context);
textView.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// if (G.isDarkTheme) {
textView.setTextColor(Color.parseColor(G.textBubble));
// } else {
// textView.setTextColor(Color.parseColor("#333333"));
// }
textView.setId(R.id.messageSenderTextMessage);
textView.setPadding(10, 0, 10, 0);
textView.setTypeface(G.typeface_IRANSansMobile);
setTextSizeDirect(textView, G.userTextSize);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
textView.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG);
}
setLayoutDirection(textView, View.LAYOUT_DIRECTION_LOCALE);
if (hasLink) {
textView.setMovementMethod(LinkMovementMethod.getInstance());
}
if (maxsize > 0) {
textView.setMaxWidth(maxsize);
}
return textView;
}
}
/**
* Updates the total and how it's broken down.
*
* @param cart The shopping cart contents and the total.
*/
public void update(ShoppingCart cart) {
Context context = mBreakdownLayout.getContext();
CharSequence totalPrice = createValueString(
cart.getTotal().getCurrency(), cart.getTotal().getPrice(), true);
// Show the updated text view if the total changed.
showUpdateIfTextChanged(totalPrice);
// Update the summary to display information about the total.
setSummaryText(cart.getTotal().getLabel(), totalPrice);
mBreakdownLayout.removeAllViews();
if (cart.getContents() == null) return;
int maximumDescriptionWidthPx =
((View) mBreakdownLayout.getParent()).getWidth() * 2 / 3;
// Update the breakdown, using one row per {@link LineItem}.
int numItems = cart.getContents().size();
mBreakdownLayout.setRowCount(numItems);
for (int i = 0; i < numItems; i++) {
LineItem item = cart.getContents().get(i);
TextView description = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(description, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
description.setText(item.getLabel());
description.setEllipsize(TruncateAt.END);
description.setMaxLines(2);
if (maximumDescriptionWidthPx > 0) {
description.setMaxWidth(maximumDescriptionWidthPx);
}
TextView amount = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(amount, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
amount.setText(createValueString(item.getCurrency(), item.getPrice(), false));
// Each item is represented by a row in the GridLayout.
GridLayout.LayoutParams descriptionParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(0, 1, GridLayout.END));
GridLayout.LayoutParams amountParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(1, 1, GridLayout.END));
ApiCompatibilityUtils.setMarginStart(amountParams,
context.getResources().getDimensionPixelSize(
R.dimen.payments_section_descriptive_item_spacing));
mBreakdownLayout.addView(description, descriptionParams);
mBreakdownLayout.addView(amount, amountParams);
}
}
private void showDebugAlert() {
if (VoIPService.getSharedInstance() == null)
return;
VoIPService.getSharedInstance().forceRating();
final LinearLayout debugOverlay = new LinearLayout(this);
debugOverlay.setOrientation(LinearLayout.VERTICAL);
debugOverlay.setBackgroundColor(0xCC000000);
int pad = AndroidUtilities.dp(16);
debugOverlay.setPadding(pad, pad * 2, pad, pad * 2);
TextView title = new TextView(this);
title.setTextColor(0xFFFFFFFF);
title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
title.setTypeface(Typeface.DEFAULT_BOLD);
title.setGravity(Gravity.CENTER);
title.setText(getDebugTitle());
debugOverlay.addView(title, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 16));
ScrollView scroll = new ScrollView(this);
final TextView debugText = new TextView(this);
debugText.setTypeface(Typeface.MONOSPACE);
debugText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
debugText.setMaxWidth(AndroidUtilities.dp(350));
debugText.setTextColor(0xFFFFFFFF);
debugText.setText(getFormattedDebugString());
scroll.addView(debugText);
debugOverlay.addView(scroll, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1f));
TextView closeBtn = new TextView(this);
closeBtn.setBackgroundColor(0xFFFFFFFF);
closeBtn.setTextColor(0xFF000000);
closeBtn.setPadding(pad, pad, pad, pad);
closeBtn.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
closeBtn.setText(LocaleController.getString("Close", R.string.Close));
debugOverlay.addView(closeBtn, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));
final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
wm.addView(debugOverlay, new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION_PANEL, 0, PixelFormat.TRANSLUCENT));
closeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wm.removeView(debugOverlay);
}
});
final Runnable r = new Runnable() {
@Override
public void run() {
if (isFinishing() || VoIPService.getSharedInstance() == null) {
return;
}
title.setText(getDebugTitle());
debugText.setText(getFormattedDebugString());
debugOverlay.postDelayed(this, 500);
}
};
debugOverlay.postDelayed(r, 500);
}
public void initModule(float density, int densityDpi) {
mChatTitle = (TextView) findViewById(IdHelper.getViewID(mContext, "jmui_title"));
if (densityDpi <= 160) {
mChatTitle.setMaxWidth((int)(180 * density + 0.5f));
}else if (densityDpi <= 240) {
mChatTitle.setMaxWidth((int)(190 * density + 0.5f));
}else {
mChatTitle.setMaxWidth((int)(200 * density + 0.5f));
}
mReturnBtn = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_return_btn"));
mChatListView = (DropDownListView) findViewById(IdHelper.getViewID(mContext, "jmui_chat_list"));
mVoiceBtn = (RecordVoiceButton) findViewById(IdHelper.getViewID(mContext, "jmui_voice_btn"));
mChatInputEt = (EditText) findViewById(IdHelper.getViewID(mContext, "jmui_chat_input_et"));
mSwitchIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_switch_voice_ib"));
mAddFileIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_add_file_btn"));
mTakePhotoIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_pick_from_camera_btn"));
mPickPictureIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_pick_from_local_btn"));
mSendMsgBtn = (Button) findViewById(IdHelper.getViewID(mContext, "jmui_send_msg_btn"));
mBackground = (LinearLayout) findViewById(IdHelper.getViewID(mContext, "jmui_chat_background"));
mMoreMenuTl = (TableLayout) findViewById(IdHelper.getViewID(mContext, "jmui_more_menu_tl"));
mRightBtn = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_right_btn"));
mGroupNumTv = (TextView) findViewById(IdHelper.getViewID(mContext, "jmui_group_num_tv"));
mExpressionIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_expression_btn"));
mLocationIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_send_location_btn"));
mSendVideoIb = (ImageButton) findViewById(IdHelper.getViewID(mContext, "jmui_send_video_btn"));
mBackground.requestFocus();
mChatInputEt.addTextChangedListener(watcher);
mChatInputEt.setOnFocusChangeListener(listener);
mChatInputEt.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
mChatInputEt.setSingleLine(false);
mChatInputEt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
dismissMoreMenu();
Log.i("ChatView", "dismissMoreMenu()----------");
}
return false;
}
});
mChatInputEt.setMaxLines(4);
setMoreMenuHeight();
}
/**
* Updates the total and how it's broken down.
*
* @param cart The shopping cart contents and the total.
*/
public void update(ShoppingCart cart) {
Context context = mBreakdownLayout.getContext();
CharSequence totalPrice = createValueString(
cart.getTotal().getCurrency(), cart.getTotal().getPrice(), true);
// Show the updated text view if the total changed.
showUpdateIfTextChanged(totalPrice);
// Update the summary to display information about the total.
setSummaryText(cart.getTotal().getLabel(), totalPrice);
mBreakdownLayout.removeAllViews();
if (cart.getContents() == null) return;
int maximumDescriptionWidthPx =
((View) mBreakdownLayout.getParent()).getWidth() * 2 / 3;
// Update the breakdown, using one row per {@link LineItem}.
int numItems = cart.getContents().size();
mBreakdownLayout.setRowCount(numItems);
for (int i = 0; i < numItems; i++) {
LineItem item = cart.getContents().get(i);
TextView description = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(description, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
description.setText(item.getLabel());
description.setEllipsize(TruncateAt.END);
description.setMaxLines(2);
if (maximumDescriptionWidthPx > 0) {
description.setMaxWidth(maximumDescriptionWidthPx);
}
TextView amount = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(amount, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
amount.setText(createValueString(item.getCurrency(), item.getPrice(), false));
// Each item is represented by a row in the GridLayout.
GridLayout.LayoutParams descriptionParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(0, 1, GridLayout.END));
GridLayout.LayoutParams amountParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(1, 1, GridLayout.END));
ApiCompatibilityUtils.setMarginStart(amountParams,
context.getResources().getDimensionPixelSize(
R.dimen.payments_section_descriptive_item_spacing));
mBreakdownLayout.addView(description, descriptionParams);
mBreakdownLayout.addView(amount, amountParams);
}
}