use of android.widget.TextView in project OverlayMenu by sephiroth74.
the class OverMenuLayout method setEntries.
public void setEntries(CharSequence[] entries) {
if (entries == mEntries) {
return;
}
mCurrentPosition = -1;
mCurrentSelectedTextView = null;
if (null != selectedTextView) {
removeView(selectedTextView);
selectedTextView = null;
}
initializeTextSwitcher(getContext());
menuLayout.removeAllViews();
mEntries = entries;
if (null == mEntries) {
return;
}
LayoutParams params;
for (CharSequence string : entries) {
TextView textView = (TextView) makeView();
textView.setTextAppearance(getContext(), mMenuTextAppearance);
textView.setText(string);
params = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
textView.setLayoutParams(params);
menuLayout.addView(textView);
}
menuLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
menuLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
mHeight = menuLayout.getHeight();
mTop = menuLayout.getTop();
mBottom = menuLayout.getBottom();
mTextHeight = selectedTextView.getHeight();
int padding = menuLayout.getPaddingBottom() + menuLayout.getPaddingTop();
mMaxScroll = (mHeight / 2) - (padding + mItemsGap * 2);
mMinScroll = -mMaxScroll;
mCenter = new Point(menuLayout.getWidth() / 2, mHeight / 2);
if (OverMenuView.DEBUG) {
Log.v(TAG, "padding: " + padding);
Log.v(TAG, "top: " + mTop);
Log.v(TAG, "bottom: " + mBottom);
Log.v(TAG, "textHeight: " + mTextHeight);
Log.v(TAG, "maxScroll: " + mMaxScroll);
Log.v(TAG, "minScroll: " + mMinScroll);
Log.v(TAG, "center: " + mCenter);
Log.v(TAG, "defaultPosition: " + mDefaultPosition);
Log.v(TAG, "currentPosition: " + mCurrentPosition);
}
ViewGroup.LayoutParams params1 = selectedTextView.getLayoutParams();
params1.width = menuLayout.getWidth() - (menuLayout.getPaddingLeft() + menuLayout.getPaddingRight());
selectedTextView.setLayoutParams(params1);
int selectedPosition = mDefaultPosition;
if (selectedPosition < 0 || selectedPosition > mEntries.length - 1) {
selectedPosition = mEntries.length / 2;
}
setSelectedPosition(selectedPosition);
}
});
}
use of android.widget.TextView in project OverlayMenu by sephiroth74.
the class OverMenuLayout method onPostScroll.
private void onPostScroll(final float current) {
if (null == mEntries) {
return;
}
for (int i = 0; i < menuLayout.getChildCount(); i++) {
View item = menuLayout.getChildAt(i);
tempRect.set(item.getLeft(), (int) (item.getTop() + current), item.getRight(), (int) (item.getBottom() + current));
if (tempRect.contains(mCenter.x, mCenter.y)) {
updateSelected(i, (TextView) item);
break;
}
}
}
use of android.widget.TextView in project OverlayMenu by sephiroth74.
the class OverMenuLayout method makeView.
@Override
public View makeView() {
TextView textView = new TextView(getContext());
textView.setTextAppearance(getContext(), mSelectedTextAppearance);
textView.setGravity(mMenuTextGravity);
textView.setPadding(mMenuTextPadding, mItemsGap, mMenuTextPadding, mItemsGap);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
return textView;
}
use of android.widget.TextView in project Conversations by siacs.
the class StartConversationActivity method displayVerificationWarningDialog.
private void displayVerificationWarningDialog(final Contact contact, final Invite invite) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.verify_omemo_keys);
View view = getLayoutInflater().inflate(R.layout.dialog_verify_fingerprints, null);
final CheckBox isTrustedSource = (CheckBox) view.findViewById(R.id.trusted_source);
TextView warning = (TextView) view.findViewById(R.id.warning);
String jid = contact.getJid().toBareJid().toString();
SpannableString spannable = new SpannableString(getString(R.string.verifying_omemo_keys_trusted_source, jid, contact.getDisplayName()));
int start = spannable.toString().indexOf(jid);
if (start >= 0) {
spannable.setSpan(new TypefaceSpan("monospace"), start, start + jid.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
warning.setText(spannable);
builder.setView(view);
builder.setPositiveButton(R.string.confirm, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (isTrustedSource.isChecked() && invite.hasFingerprints()) {
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
}
switchToConversation(contact, invite.getBody());
}
});
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
StartConversationActivity.this.finish();
}
});
AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
StartConversationActivity.this.finish();
}
});
dialog.show();
}
use of android.widget.TextView in project Conversations by siacs.
the class BlockContactDialog method show.
public static void show(final XmppActivity xmppActivity, final Blockable blockable) {
final AlertDialog.Builder builder = new AlertDialog.Builder(xmppActivity);
final boolean isBlocked = blockable.isBlocked();
builder.setNegativeButton(R.string.cancel, null);
LayoutInflater inflater = (LayoutInflater) xmppActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_block_contact, null);
TextView message = (TextView) view.findViewById(R.id.text);
final CheckBox report = (CheckBox) view.findViewById(R.id.report_spam);
final boolean reporting = blockable.getAccount().getXmppConnection().getFeatures().spamReporting();
report.setVisibility(!isBlocked && reporting ? View.VISIBLE : View.GONE);
builder.setView(view);
String value;
SpannableString spannable;
if (blockable.getJid().isDomainJid() || blockable.getAccount().isBlocked(blockable.getJid().toDomainJid())) {
builder.setTitle(isBlocked ? R.string.action_unblock_domain : R.string.action_block_domain);
value = blockable.getJid().toDomainJid().toString();
spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_domain_text : R.string.block_domain_text, value));
} else {
builder.setTitle(isBlocked ? R.string.action_unblock_contact : R.string.action_block_contact);
value = blockable.getJid().toBareJid().toString();
spannable = new SpannableString(xmppActivity.getString(isBlocked ? R.string.unblock_contact_text : R.string.block_contact_text, value));
}
int start = spannable.toString().indexOf(value);
if (start >= 0) {
spannable.setSpan(new TypefaceSpan("monospace"), start, start + value.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
message.setText(spannable);
builder.setPositiveButton(isBlocked ? R.string.unblock : R.string.block, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
if (isBlocked) {
xmppActivity.xmppConnectionService.sendUnblockRequest(blockable);
} else {
boolean toastShown = false;
if (xmppActivity.xmppConnectionService.sendBlockRequest(blockable, report.isChecked())) {
Toast.makeText(xmppActivity, R.string.corresponding_conversations_closed, Toast.LENGTH_SHORT).show();
toastShown = true;
}
if (xmppActivity instanceof ContactDetailsActivity) {
if (!toastShown) {
Toast.makeText(xmppActivity, R.string.contact_blocked_past_tense, Toast.LENGTH_SHORT).show();
}
xmppActivity.finish();
}
}
}
});
builder.create().show();
}
Aggregations