Search in sources :

Example 36 with TextView

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);
        }
    });
}
Also used : TextView(android.widget.TextView) Point(android.graphics.Point) ViewTreeObserver(android.view.ViewTreeObserver)

Example 37 with TextView

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;
        }
    }
}
Also used : TextView(android.widget.TextView) View(android.view.View) Point(android.graphics.Point)

Example 38 with TextView

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;
}
Also used : TextView(android.widget.TextView)

Example 39 with 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();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) SpannableString(android.text.SpannableString) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SuppressLint(android.annotation.SuppressLint) SpannableString(android.text.SpannableString) CheckBox(android.widget.CheckBox) OnClickListener(android.content.DialogInterface.OnClickListener) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TypefaceSpan(android.text.style.TypefaceSpan)

Example 40 with TextView

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();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) SpannableString(android.text.SpannableString) SpannableString(android.text.SpannableString) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) TypefaceSpan(android.text.style.TypefaceSpan)

Aggregations

TextView (android.widget.TextView)4994 View (android.view.View)2680 ImageView (android.widget.ImageView)1137 Button (android.widget.Button)442 LinearLayout (android.widget.LinearLayout)439 LayoutInflater (android.view.LayoutInflater)425 Intent (android.content.Intent)397 ListView (android.widget.ListView)389 AdapterView (android.widget.AdapterView)372 ViewGroup (android.view.ViewGroup)322 OnClickListener (android.view.View.OnClickListener)304 RecyclerView (android.support.v7.widget.RecyclerView)197 Test (org.junit.Test)197 ScrollView (android.widget.ScrollView)166 DialogInterface (android.content.DialogInterface)162 Context (android.content.Context)156 Drawable (android.graphics.drawable.Drawable)155 EditText (android.widget.EditText)149 AlertDialog (android.app.AlertDialog)144 Bundle (android.os.Bundle)144