List of usage examples for android.text SpannableStringBuilder append
public SpannableStringBuilder append(char text)
From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView vKeyId = (TextView) view.findViewById(R.id.subkey_item_key_id); TextView vKeyDetails = (TextView) view.findViewById(R.id.subkey_item_details); TextView vKeyExpiry = (TextView) view.findViewById(R.id.subkey_item_expiry); ImageView vCertifyIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_certify); ImageView vSignIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_sign); ImageView vEncryptIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_encrypt); ImageView vAuthenticateIcon = (ImageView) view.findViewById(R.id.subkey_item_ic_authenticate); ImageView vEditImage = (ImageView) view.findViewById(R.id.subkey_item_edit_image); ImageView vStatus = (ImageView) view.findViewById(R.id.subkey_item_status); // not used://w w w. ja v a 2 s . c o m ImageView deleteImage = (ImageView) view.findViewById(R.id.subkey_item_delete_button); deleteImage.setVisibility(View.GONE); long keyId = cursor.getLong(INDEX_KEY_ID); vKeyId.setText(KeyFormattingUtils.beautifyKeyId(keyId)); // may be set with additional "stripped" later on SpannableStringBuilder algorithmStr = new SpannableStringBuilder(); algorithmStr.append(KeyFormattingUtils.getAlgorithmInfo(context, cursor.getInt(INDEX_ALGORITHM), cursor.getInt(INDEX_KEY_SIZE), cursor.getString(INDEX_KEY_CURVE_OID))); SubkeyChange change = mSaveKeyringParcel != null ? mSaveKeyringParcel.getSubkeyChange(keyId) : null; if (change != null && (change.mDummyStrip || change.mMoveKeyToSecurityToken)) { if (change.mDummyStrip) { algorithmStr.append(", "); final SpannableString boldStripped = new SpannableString(context.getString(R.string.key_stripped)); boldStripped.setSpan(new StyleSpan(Typeface.BOLD), 0, boldStripped.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); algorithmStr.append(boldStripped); } if (change.mMoveKeyToSecurityToken) { algorithmStr.append(", "); final SpannableString boldDivert = new SpannableString(context.getString(R.string.key_divert)); boldDivert.setSpan(new StyleSpan(Typeface.BOLD), 0, boldDivert.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); algorithmStr.append(boldDivert); } } else { switch (SecretKeyType.fromNum(cursor.getInt(INDEX_HAS_SECRET))) { case GNU_DUMMY: algorithmStr.append(", "); algorithmStr.append(context.getString(R.string.key_stripped)); break; case DIVERT_TO_CARD: algorithmStr.append(", "); algorithmStr.append(context.getString(R.string.key_divert)); break; case PASSPHRASE_EMPTY: algorithmStr.append(", "); algorithmStr.append(context.getString(R.string.key_no_passphrase)); break; case UNAVAILABLE: // don't show this on pub keys //algorithmStr += ", " + context.getString(R.string.key_unavailable); break; } } vKeyDetails.setText(algorithmStr, TextView.BufferType.SPANNABLE); boolean isMasterKey = cursor.getInt(INDEX_RANK) == 0; if (isMasterKey) { vKeyId.setTypeface(null, Typeface.BOLD); } else { vKeyId.setTypeface(null, Typeface.NORMAL); } // Set icons according to properties vCertifyIcon.setVisibility(cursor.getInt(INDEX_CAN_CERTIFY) != 0 ? View.VISIBLE : View.GONE); vEncryptIcon.setVisibility(cursor.getInt(INDEX_CAN_ENCRYPT) != 0 ? View.VISIBLE : View.GONE); vSignIcon.setVisibility(cursor.getInt(INDEX_CAN_SIGN) != 0 ? View.VISIBLE : View.GONE); vAuthenticateIcon.setVisibility(cursor.getInt(INDEX_CAN_AUTHENTICATE) != 0 ? View.VISIBLE : View.GONE); boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; Date expiryDate = null; if (!cursor.isNull(INDEX_EXPIRY)) { expiryDate = new Date(cursor.getLong(INDEX_EXPIRY) * 1000); } // for edit key if (mSaveKeyringParcel != null) { boolean revokeThisSubkey = (mSaveKeyringParcel.mRevokeSubKeys.contains(keyId)); if (revokeThisSubkey) { if (!isRevoked) { isRevoked = true; } } SaveKeyringParcel.SubkeyChange subkeyChange = mSaveKeyringParcel.getSubkeyChange(keyId); if (subkeyChange != null) { if (subkeyChange.mExpiry == null || subkeyChange.mExpiry == 0L) { expiryDate = null; } else { expiryDate = new Date(subkeyChange.mExpiry * 1000); } } vEditImage.setVisibility(View.VISIBLE); } else { vEditImage.setVisibility(View.GONE); } boolean isExpired; if (expiryDate != null) { isExpired = expiryDate.before(new Date()); Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiryCal.setTime(expiryDate); // convert from UTC to time zone of device expiryCal.setTimeZone(TimeZone.getDefault()); vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + DateFormat.getDateFormat(context).format(expiryCal.getTime())); } else { isExpired = false; vKeyExpiry.setText(context.getString(R.string.label_expiry) + ": " + context.getString(R.string.none)); } // if key is expired or revoked... boolean isInvalid = isRevoked || isExpired; if (isInvalid) { vStatus.setVisibility(View.VISIBLE); vCertifyIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); vSignIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); vEncryptIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); vAuthenticateIcon.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); if (isRevoked) { vStatus.setImageResource(R.drawable.status_signature_revoked_cutout_24dp); vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); } else if (isExpired) { vStatus.setImageResource(R.drawable.status_signature_expired_cutout_24dp); vStatus.setColorFilter(mContext.getResources().getColor(R.color.key_flag_gray), PorterDuff.Mode.SRC_IN); } } else { vStatus.setVisibility(View.GONE); vKeyId.setTextColor(mDefaultTextColor); vKeyDetails.setTextColor(mDefaultTextColor); vKeyExpiry.setTextColor(mDefaultTextColor); vCertifyIcon.clearColorFilter(); vSignIcon.clearColorFilter(); vEncryptIcon.clearColorFilter(); vAuthenticateIcon.clearColorFilter(); } vKeyId.setEnabled(!isInvalid); vKeyDetails.setEnabled(!isInvalid); vKeyExpiry.setEnabled(!isInvalid); }
From source file:nya.miku.wishmaster.ui.settings.AutohideActivity.java
@SuppressLint("InflateParams") @Override//from ww w .j ava 2 s . co m protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Object item = l.getItemAtPosition(position); final int changeId; if (item instanceof AutohideRule) { changeId = position - 1; } else { changeId = -1; //-1 - ? } Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ? new ContextThemeWrapper(this, R.style.Neutron_Medium) : this; View dialogView = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_autohide_rule, null); final EditText regexEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_regex); final Spinner chanSpinner = (Spinner) dialogView.findViewById(R.id.dialog_autohide_chan_spinner); final EditText boardEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_boardname); final EditText threadEditText = (EditText) dialogView.findViewById(R.id.dialog_autohide_threadnum); final CheckBox inCommentCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_comment); final CheckBox inSubjectCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_subject); final CheckBox inNameCheckBox = (CheckBox) dialogView.findViewById(R.id.dialog_autohide_in_name); chanSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, chans)); if (changeId != -1) { AutohideRule rule = (AutohideRule) item; regexEditText.setText(rule.regex); int chanPosition = chans.indexOf(rule.chanName); chanSpinner.setSelection(chanPosition != -1 ? chanPosition : 0); boardEditText.setText(rule.boardName); threadEditText.setText(rule.threadNumber); inCommentCheckBox.setChecked(rule.inComment); inSubjectCheckBox.setChecked(rule.inSubject); inNameCheckBox.setChecked(rule.inName); } else { chanSpinner.setSelection(0); } DialogInterface.OnClickListener save = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String regex = regexEditText.getText().toString(); if (regex.length() == 0) { Toast.makeText(AutohideActivity.this, R.string.autohide_error_empty_regex, Toast.LENGTH_LONG) .show(); return; } try { Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.DOTALL); } catch (Exception e) { CharSequence message = null; if (e instanceof PatternSyntaxException) { String eMessage = e.getMessage(); if (!TextUtils.isEmpty(eMessage)) { SpannableStringBuilder a = new SpannableStringBuilder( getString(R.string.autohide_error_incorrect_regex)); a.append('\n'); int startlen = a.length(); a.append(eMessage); a.setSpan(new TypefaceSpan("monospace"), startlen, a.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); message = a; } } if (message == null) message = getString(R.string.error_unknown); Toast.makeText(AutohideActivity.this, message, Toast.LENGTH_LONG).show(); return; } AutohideRule rule = new AutohideRule(); int spinnerSelectedPosition = chanSpinner.getSelectedItemPosition(); rule.regex = regex; rule.chanName = spinnerSelectedPosition > 0 ? chans.get(spinnerSelectedPosition) : ""; // 0 ? = ? rule.boardName = boardEditText.getText().toString(); rule.threadNumber = threadEditText.getText().toString(); rule.inComment = inCommentCheckBox.isChecked(); rule.inSubject = inSubjectCheckBox.isChecked(); rule.inName = inNameCheckBox.isChecked(); if (!rule.inComment && !rule.inSubject && !rule.inName) { Toast.makeText(AutohideActivity.this, R.string.autohide_error_no_condition, Toast.LENGTH_LONG) .show(); return; } if (changeId == -1) { rulesJson.put(rule.toJson()); } else { rulesJson.put(changeId, rule.toJson()); } rulesChanged(); } }; AlertDialog dialog = new AlertDialog.Builder(this).setView(dialogView) .setTitle(changeId == -1 ? R.string.autohide_add_rule_title : R.string.autohide_edit_rule_title) .setPositiveButton(R.string.autohide_save_button, save) .setNegativeButton(android.R.string.cancel, null).create(); dialog.setCanceledOnTouchOutside(false); dialog.show(); }
From source file:com.bushstar.htmlcoin_android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;/*w w w. jav a 2 s.c o m*/ final String htmlcoinRequest = determineHTMLcoinRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "Htmlcoin:-" + Qr.encodeBinary(paymentRequest); else qrContent = htmlcoinRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.bushstar.kobocoin_android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;//from ww w. j a v a 2s.c o m final String kobocoinRequest = determineKobocoinRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = Qr.encodeBinary(paymentRequest); else qrContent = kobocoinRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.hivewallet.androidclient.wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;/*from w ww . ja v a 2 s . co m*/ final String bitcoinRequest = determineBitcoinRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "BITCOIN:-" + Qr.encodeBinary(paymentRequest); else qrContent = bitcoinRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.matthewmitchell.nubits_android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;/*from w w w.j a v a2 s .c o m*/ final String nubitsRequest = determineNubitsRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "Nu:-" + Qr.encodeBinary(paymentRequest); else qrContent = nubitsRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;//from w ww .j av a 2 s.c o m final String peercoinRequest = determinePeercoinRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "Peercoin:-" + Qr.encodeBinary(paymentRequest); else qrContent = peercoinRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.mybitcoin.wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;/*ww w . java 2 s. com*/ final String bitcoinRequest = determineBitcoinRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "BITCOIN:-" + Qr.encodeBinary(paymentRequest); else qrContent = bitcoinRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest, false); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.rimbit.android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;/*from ww w .ja va2 s . co m*/ final String rimbitRequest = determineRimbitRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "Rimbit:-" + Qr.encodeBinary(paymentRequest); else qrContent = rimbitRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }
From source file:com.woollysammoth.nubit_android_wallet.ui.RequestCoinsFragment.java
private void updateView() { if (!isResumed()) return;//from www. j a va 2 s . c o m final String nubitRequest = determineNubitRequestStr(true); final byte[] paymentRequest = determinePaymentRequest(true); // update qr-code final int size = (int) (256 * getResources().getDisplayMetrics().density); final String qrContent; if (config.getQrPaymentRequestEnabled()) qrContent = "Nubit:-" + Qr.encodeBinary(paymentRequest); else qrContent = nubitRequest; qrCodeBitmap = Qr.bitmap(qrContent, size); qrView.setImageBitmap(qrCodeBitmap); // update nfc ndef message final boolean nfcSuccess = Nfc.publishMimeObject(nfcManager, activity, PaymentProtocol.MIMETYPE_PAYMENTREQUEST, paymentRequest); // update initiate request message final SpannableStringBuilder initiateText = new SpannableStringBuilder( getString(R.string.request_coins_fragment_initiate_request_qr)); if (nfcSuccess) initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc)); initiateRequestView.setText(initiateText); // focus linking final int activeAmountViewId = amountCalculatorLink.activeTextView().getId(); acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId); }