List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:com.tct.mail.ui.ConversationViewFragment.java
private boolean processInPlaceUpdates(MessageCursor newCursor, MessageCursor oldCursor) { final Set<String> idsOfChangedBodies = Sets.newHashSet(); final List<Integer> changedOverlayPositions = Lists.newArrayList(); boolean changed = false; int pos = 0;// ww w. ja v a2 s . com while (true) { if (!newCursor.moveToPosition(pos) || !oldCursor.moveToPosition(pos)) { break; } final ConversationMessage newMsg = newCursor.getMessage(); final ConversationMessage oldMsg = oldCursor.getMessage(); // We are going to update the data in the adapter whenever any input fields change. // This ensures that the Message object that ComposeActivity uses will be correctly // aligned with the most up-to-date data. if (!newMsg.isEqual(oldMsg)) { mAdapter.updateItemsForMessage(newMsg, changedOverlayPositions); LogUtils.i(LOG_TAG, "msg #%d (%d): detected field(s) change. sendingState=%s", pos, newMsg.id, newMsg.sendingState); } // update changed message bodies in-place if (!TextUtils.equals(newMsg.bodyHtml, oldMsg.bodyHtml) || !TextUtils.equals(newMsg.bodyText, oldMsg.bodyText)) { // maybe just set a flag to notify JS to re-request changed bodies idsOfChangedBodies.add('"' + mTemplates.getMessageDomId(newMsg) + '"'); LogUtils.i(LOG_TAG, "msg #%d (%d): detected body change", pos, newMsg.id); } pos++; } if (!changedOverlayPositions.isEmpty()) { // notify once after the entire adapter is updated mConversationContainer.onOverlayModelUpdate(changedOverlayPositions); changed = true; } final ConversationFooterItem footerItem = mAdapter.getFooterItem(); if (footerItem != null) { footerItem.invalidateMeasurement(); } if (!idsOfChangedBodies.isEmpty()) { mWebView.loadUrl(String.format("javascript:replaceMessageBodies([%s]);", TextUtils.join(",", idsOfChangedBodies))); changed = true; } // TS: Gantao 2015-06-02 EMAIL BUGFIX-998526 ADD_S if (mMessageHeaderView != null) { mMessageHeaderView.updateHeight(); } // TS: Gantao 2015-06-02 EMAIL BUGFIX-998526 ADD_E return changed; }
From source file:im.neon.activity.VectorRoomActivity.java
/** * Manage the room preview buttons area//from w ww . jav a 2 s . c o m */ private void manageRoomPreview() { if (null != sRoomPreviewData) { mRoomPreviewLayout.setVisibility(View.VISIBLE); TextView invitationTextView = (TextView) findViewById(R.id.room_preview_invitation_textview); TextView subInvitationTextView = (TextView) findViewById(R.id.room_preview_subinvitation_textview); Button joinButton = (Button) findViewById(R.id.button_join_room); Button declineButton = (Button) findViewById(R.id.button_decline); final RoomEmailInvitation roomEmailInvitation = sRoomPreviewData.getRoomEmailInvitation(); String roomName = sRoomPreviewData.getRoomName(); if (TextUtils.isEmpty(roomName)) { roomName = " "; } Log.d(LOG_TAG, "Preview the room " + sRoomPreviewData.getRoomId()); // if the room already exists if (null != mRoom) { Log.d(LOG_TAG, "manageRoomPreview : The room is known"); String inviter = ""; if (null != roomEmailInvitation) { inviter = roomEmailInvitation.inviterName; } if (TextUtils.isEmpty(inviter)) { Collection<RoomMember> members = mRoom.getActiveMembers(); for (RoomMember member : members) { if (TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_JOIN)) { inviter = TextUtils.isEmpty(member.displayname) ? member.getUserId() : member.displayname; } } } invitationTextView .setText(getResources().getString(R.string.room_preview_invitation_format, inviter)); declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(LOG_TAG, "The user clicked on decline."); setProgressVisibility(View.VISIBLE); mRoom.leave(new ApiCallback<Void>() { @Override public void onSuccess(Void info) { Log.d(LOG_TAG, "The invitation is rejected"); onDeclined(); } private void onError(String errorMessage) { Log.d(LOG_TAG, "The invitation rejection failed " + errorMessage); CommonActivityUtils.displayToast(VectorRoomActivity.this, errorMessage); setProgressVisibility(View.GONE); } @Override public void onNetworkError(Exception e) { onError(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onError(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onError(e.getLocalizedMessage()); } }); } }); } else { if ((null != roomEmailInvitation) && !TextUtils.isEmpty(roomEmailInvitation.email)) { invitationTextView.setText(getResources().getString(R.string.room_preview_invitation_format, roomEmailInvitation.inviterName)); subInvitationTextView.setText(getResources() .getString(R.string.room_preview_unlinked_email_warning, roomEmailInvitation.email)); } else { invitationTextView .setText(getResources().getString(R.string.room_preview_try_join_an_unknown_room, TextUtils.isEmpty(sRoomPreviewData.getRoomName()) ? getResources().getString( R.string.room_preview_try_join_an_unknown_room_default) : roomName)); // the room preview has some messages if ((null != sRoomPreviewData.getRoomResponse()) && (null != sRoomPreviewData.getRoomResponse().messages)) { subInvitationTextView.setText( getResources().getString(R.string.room_preview_room_interactions_disabled)); } } declineButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(LOG_TAG, "The invitation is declined (unknown room)"); sRoomPreviewData = null; VectorRoomActivity.this.finish(); } }); } joinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(LOG_TAG, "The user clicked on Join."); Room room = sRoomPreviewData.getSession().getDataHandler() .getRoom(sRoomPreviewData.getRoomId()); String signUrl = null; if (null != roomEmailInvitation) { signUrl = roomEmailInvitation.signUrl; } setProgressVisibility(View.VISIBLE); room.joinWithThirdPartySigned(sRoomPreviewData.getRoomIdOrAlias(), signUrl, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { onJoined(); } private void onError(String errorMessage) { CommonActivityUtils.displayToast(VectorRoomActivity.this, errorMessage); setProgressVisibility(View.GONE); } @Override public void onNetworkError(Exception e) { onError(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onError(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onError(e.getLocalizedMessage()); } }); } }); enableActionBarHeader(SHOW_ACTION_BAR_HEADER); } else { mRoomPreviewLayout.setVisibility(View.GONE); } }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
private void onPhonebookCountryUpdate(final Intent data) { if (data != null && data.hasExtra(CountryPickerActivity.EXTRA_OUT_COUNTRY_NAME) && data.hasExtra(CountryPickerActivity.EXTRA_OUT_COUNTRY_CODE)) { final String countryCode = data.getStringExtra(CountryPickerActivity.EXTRA_OUT_COUNTRY_CODE); if (!TextUtils.equals(countryCode, PhoneNumberUtils.getCountryCode(getActivity()))) { PhoneNumberUtils.setCountryCode(getActivity(), countryCode); mContactPhonebookCountryPreference .setSummary(data.getStringExtra(CountryPickerActivity.EXTRA_OUT_COUNTRY_NAME)); }//from w w w . ja v a 2 s. co m } }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
private void displayTextSizeSelection(final Activity activity) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); LayoutInflater inflater = activity.getLayoutInflater(); View layout = inflater.inflate(R.layout.text_size_selection, null); builder.setTitle(R.string.font_size); builder.setView(layout);/* w ww.ja v a2s. c o m*/ builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); final AlertDialog dialog = builder.create(); dialog.show(); LinearLayout linearLayout = layout.findViewById(R.id.text_selection_group_view); int childCount = linearLayout.getChildCount(); String scaleText = VectorApp.getFontScale(); for (int i = 0; i < childCount; i++) { View v = linearLayout.getChildAt(i); if (v instanceof CheckedTextView) { final CheckedTextView checkedTextView = (CheckedTextView) v; checkedTextView.setChecked(TextUtils.equals(checkedTextView.getText(), scaleText)); checkedTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); VectorApp.updateFontScale(checkedTextView.getText().toString()); activity.startActivity(activity.getIntent()); activity.finish(); } }); } } }
From source file:com.tct.mail.compose.ComposeActivity.java
private ReplyFromAccount getReplyFromAccountFromDraft(final Account account, final Message msg) { final Address[] draftFroms = Address.parse(msg.getFrom()); final String sender = draftFroms.length > 0 ? draftFroms[0].getAddress() : ""; ReplyFromAccount replyFromAccount = null; List<ReplyFromAccount> replyFromAccounts = mFromSpinner.getReplyFromAccounts(); if (TextUtils.equals(account.getEmailAddress(), sender)) { replyFromAccount = getDefaultReplyFromAccount(account); } else {/*from w w w . jav a2 s . c o m*/ for (ReplyFromAccount fromAccount : replyFromAccounts) { if (TextUtils.equals(fromAccount.address, sender)) { replyFromAccount = fromAccount; break; } } } return replyFromAccount; }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Display a dialog containing the device ID, the device name and the "last seen" information.<> * This dialog allow to delete the corresponding device (see {@link #displayDeviceDeletionDialog(DeviceInfo)}) * * @param aDeviceInfo the device information *///from ww w. j av a 2s . c o m private void displayDeviceDetailsDialog(DeviceInfo aDeviceInfo) { android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View layout = inflater.inflate(R.layout.devices_details_settings, null); if (null != aDeviceInfo) { //device ID TextView textView = layout.findViewById(R.id.device_id); textView.setText(aDeviceInfo.device_id); // device name textView = layout.findViewById(R.id.device_name); String displayName = (TextUtils.isEmpty(aDeviceInfo.display_name)) ? LABEL_UNAVAILABLE_DATA : aDeviceInfo.display_name; textView.setText(displayName); // last seen info textView = layout.findViewById(R.id.device_last_seen); if (!TextUtils.isEmpty(aDeviceInfo.last_seen_ip)) { String lastSeenIp = aDeviceInfo.last_seen_ip; String lastSeenTime = LABEL_UNAVAILABLE_DATA; if (null != getActivity()) { SimpleDateFormat dateFormatTime = new SimpleDateFormat( getString(R.string.devices_details_time_format)); String time = dateFormatTime.format(new Date(aDeviceInfo.last_seen_ts)); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); lastSeenTime = dateFormat.format(new Date(aDeviceInfo.last_seen_ts)) + ", " + time; } String lastSeenInfo = this.getString(R.string.devices_details_last_seen_format, lastSeenIp, lastSeenTime); textView.setText(lastSeenInfo); } else { // hide last time seen section layout.findViewById(R.id.device_last_seen_title).setVisibility(View.GONE); textView.setVisibility(View.GONE); } // title & icon builder.setTitle(R.string.devices_details_dialog_title); builder.setIcon(android.R.drawable.ic_dialog_info); builder.setView(layout); final DeviceInfo fDeviceInfo = aDeviceInfo; builder.setPositiveButton(R.string.rename, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { displayDeviceRenameDialog(fDeviceInfo); } }); // disable the deletion for our own device if (!TextUtils.equals(mSession.getCrypto().getMyDevice().deviceId, fDeviceInfo.device_id)) { builder.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { displayDeviceDeletionDialog(fDeviceInfo); } }); } builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { dialog.cancel(); return true; } return false; } }); builder.create().show(); } else { Log.e(LOG_TAG, "## displayDeviceDetailsDialog(): sanity check failure"); if (null != getActivity()) CommonActivityUtils.displayToast(getActivity().getApplicationContext(), "DeviceDetailsDialog cannot be displayed.\nBad input parameters."); } }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Display an alert dialog to rename a device * * @param aDeviceInfoToRename device info */// ww w . j a v a 2 s .com private void displayDeviceRenameDialog(final DeviceInfo aDeviceInfoToRename) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.devices_details_device_name); final EditText input = new EditText(getActivity()); input.setText(aDeviceInfoToRename.display_name); builder.setView(input); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { displayLoadingView(); mSession.setDeviceName(aDeviceInfoToRename.device_id, input.getText().toString(), new ApiCallback<Void>() { @Override public void onSuccess(Void info) { // search which preference is updated int count = mDevicesListSettingsCategory.getPreferenceCount(); for (int i = 0; i < count; i++) { VectorCustomActionEditTextPreference pref = (VectorCustomActionEditTextPreference) mDevicesListSettingsCategory .getPreference(i); if (TextUtils.equals(aDeviceInfoToRename.device_id, pref.getTitle())) { pref.setSummary(input.getText()); } } // detect if the updated device is the current account one Preference pref = findPreference( PreferencesManager.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY); if (TextUtils.equals(pref.getSummary(), aDeviceInfoToRename.device_id)) { findPreference( PreferencesManager.SETTINGS_ENCRYPTION_INFORMATION_DEVICE_ID_PREFERENCE_KEY) .setSummary(input.getText()); } hideLoadingView(); } @Override public void onNetworkError(Exception e) { onCommonDone(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onCommonDone(e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onCommonDone(e.getLocalizedMessage()); } }); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Manage the e2e keys export./*w w w. j a v a 2s.c om*/ */ private void exportKeys() { View dialogLayout = getActivity().getLayoutInflater().inflate(R.layout.dialog_export_e2e_keys, null); AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.encryption_export_room_keys); dialog.setView(dialogLayout); final TextInputEditText passPhrase1EditText = dialogLayout .findViewById(R.id.dialog_e2e_keys_passphrase_edit_text); final TextInputEditText passPhrase2EditText = dialogLayout .findViewById(R.id.dialog_e2e_keys_confirm_passphrase_edit_text); final Button exportButton = dialogLayout.findViewById(R.id.dialog_e2e_keys_export_button); final TextWatcher textWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { exportButton.setEnabled(!TextUtils.isEmpty(passPhrase1EditText.getText()) && TextUtils.equals(passPhrase1EditText.getText(), passPhrase2EditText.getText())); } @Override public void afterTextChanged(Editable s) { } }; passPhrase1EditText.addTextChangedListener(textWatcher); passPhrase2EditText.addTextChangedListener(textWatcher); exportButton.setEnabled(false); final AlertDialog exportDialog = dialog.show(); exportButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { displayLoadingView(); CommonActivityUtils.exportKeys(mSession, passPhrase1EditText.getText().toString(), new ApiCallback<String>() { @Override public void onSuccess(String filename) { Toast.makeText(VectorApp.getInstance().getApplicationContext(), filename, Toast.LENGTH_SHORT).show(); hideLoadingView(); } @Override public void onNetworkError(Exception e) { hideLoadingView(); } @Override public void onMatrixError(MatrixError e) { hideLoadingView(); } @Override public void onUnexpectedError(Exception e) { hideLoadingView(); } }); exportDialog.dismiss(); } }); }
From source file:com.android.mail.compose.ComposeActivity.java
private void appendSignature() { final String newSignature = mCachedSettings != null ? mCachedSettings.signature : null; final int signaturePos = getSignatureStartPosition(mSignature, mBodyView.getText().toString()); if (!TextUtils.equals(newSignature, mSignature) || signaturePos < 0) { mSignature = newSignature;/*ww w . j ava 2s .c o m*/ if (!TextUtils.isEmpty(mSignature)) { // Appending a signature does not count as changing text. mBodyView.removeTextChangedListener(this); mBodyView.append(convertToPrintableSignature(mSignature)); mBodyView.addTextChangedListener(this); } resetBodySelection(); } }