List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Update the displayname.//from www.j a v a2 s. c o m */ private void onDisplayNameClick(final String value) { if (!TextUtils.equals(mSession.getMyUser().displayname, value)) { displayLoadingView(); mSession.getMyUser().updateDisplayName(value, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { // refresh the settings value SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences.Editor editor = preferences.edit(); editor.putString(PreferencesManager.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY, value); editor.commit(); onCommonDone(null); refreshDisplay(); } @Override public void onNetworkError(Exception e) { onCommonDone(e.getLocalizedMessage()); } @Override public void onMatrixError(final MatrixError e) { if (MatrixError.M_CONSENT_NOT_GIVEN.equals(e.errcode)) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { hideLoadingView(); ((RiotAppCompatActivity) getActivity()).getConsentNotGivenHelper() .displayDialog(e); } }); } } else { onCommonDone(e.getLocalizedMessage()); } } @Override public void onUnexpectedError(Exception e) { onCommonDone(e.getLocalizedMessage()); } }); } }
From source file:com.android.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;//from www.j a v a2 s .c o m 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; } return changed; }
From source file:github.why168.swipeback.view.SwipeBackLayout.java
/** * ??/*from w w w .ja v a2 s. c o m*/ * * @param activity * @return */ public boolean checkDeviceHasNavigationBar(Activity activity) { boolean hasNavigationBar = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (TextUtils.equals("Nexus 4".toLowerCase().trim(), Build.MODEL.toLowerCase().trim())) { hasNavigationBar = false; } else { hasNavigationBar = newCheckDeviceHasNavigationBar(activity); } } else { hasNavigationBar = oldCheckDeviceHasNavigationBar(activity); } return hasNavigationBar; }
From source file:com.tct.mail.compose.ComposeActivity.java
private void finishCreate() { final Bundle savedState = mInnerSavedState; findViews();// w ww . j av a 2 s .c o m // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_S updateFromRowByAccounts(); // TS: junwei-xu 2015-09-01 EMAIL BUGFIX-526192 ADD_E final Intent intent = getIntent(); final Message message; final ArrayList<AttachmentPreview> previews; mShowQuotedText = false; final CharSequence quotedText; int action; // Check for any of the possibly supplied accounts.; final Account account; if (hadSavedInstanceStateMessage(savedState)) { action = savedState.getInt(EXTRA_ACTION, COMPOSE); account = savedState.getParcelable(Utils.EXTRA_ACCOUNT); message = savedState.getParcelable(EXTRA_MESSAGE); previews = savedState.getParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = savedState.getParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE); quotedText = savedState.getCharSequence(EXTRA_QUOTED_TEXT); mExtraValues = savedState.getParcelable(EXTRA_VALUES); } else { account = obtainAccount(intent); action = intent.getIntExtra(EXTRA_ACTION, COMPOSE); // Initialize the message from the message in the intent message = intent.getParcelableExtra(ORIGINAL_DRAFT_MESSAGE); previews = intent.getParcelableArrayListExtra(EXTRA_ATTACHMENT_PREVIEWS); mRefMessage = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE); //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_S if (mRefMessage != null && "".equals(mRefMessage.bodyHtml)) { String htmlbody = Body.restoreBodyHtmlWithMessageId(this, mRefMessage.getId()); mRefMessage.bodyHtml = htmlbody; //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S } else if (message != null) { if ("".equals(message.bodyHtml)) { String htmlbody = Body.restoreBodyHtmlWithMessageId(this, message.getId()); message.bodyHtml = htmlbody; } if ("".equals(message.bodyText)) { String body = Body.restoreBodyTextWithMessageId(this, message.getId()); message.bodyText = body; } //TS: xujian 2015-06-23 EMAIL BUGFIX_1015657 MOD_S } //TS: wenggangjin 2015-01-06 EMAIL BUGFIX_882161 MOD_E mRefMessageUri = intent.getParcelableExtra(EXTRA_IN_REFERENCE_TO_MESSAGE_URI); quotedText = null; if (Analytics.isLoggable()) { if (intent.getBooleanExtra(Utils.EXTRA_FROM_NOTIFICATION, false)) { Analytics.getInstance().sendEvent("notification_action", "compose", getActionString(action), 0); } } } //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_S // mAttachmentsView.setAttachmentPreviews(previews); //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_E // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_S if (action == EDIT_DRAFT) { //mIsClickIcon = true;//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535 mEditDraft = true; } // TS: yanhua.chen 2015-9-19 EMAIL BUGFIX_569665 ADD_E setAccount(account); if (mAccount == null) { return; } // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S // initRecipients(); // TS: chenyanhua 2015-01-12 EMAIL BUGFIX-890424 MOD_S // Clear the notification and mark the conversation as seen, if necessary final Folder notificationFolder = intent.getParcelableExtra(EXTRA_NOTIFICATION_FOLDER); if (notificationFolder != null) { final Uri conversationUri = intent.getParcelableExtra(EXTRA_NOTIFICATION_CONVERSATION); Intent actionIntent; if (conversationUri != null) { actionIntent = new Intent(MailIntentService.ACTION_RESEND_NOTIFICATIONS_WEAR); actionIntent.putExtra(Utils.EXTRA_CONVERSATION, conversationUri); } else { actionIntent = new Intent(MailIntentService.ACTION_CLEAR_NEW_MAIL_NOTIFICATIONS); actionIntent.setData(Utils.appendVersionQueryParameter(this, notificationFolder.folderUri.fullUri)); } actionIntent.setPackage(getPackageName()); actionIntent.putExtra(Utils.EXTRA_ACCOUNT, account); actionIntent.putExtra(Utils.EXTRA_FOLDER, notificationFolder); startService(actionIntent); } if (intent.getBooleanExtra(EXTRA_FROM_EMAIL_TASK, false)) { mLaunchedFromEmail = true; } else if (Intent.ACTION_SEND.equals(intent.getAction())) { final Uri dataUri = intent.getData(); if (dataUri != null) { final String dataScheme = intent.getData().getScheme(); final String accountScheme = mAccount.composeIntentUri.getScheme(); mLaunchedFromEmail = TextUtils.equals(dataScheme, accountScheme); } } if (mRefMessageUri != null) { mShowQuotedText = true; mComposeMode = action; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); String wearReply = null; if (remoteInput != null) { LogUtils.d(LOG_TAG, "Got remote input from new api"); CharSequence input = remoteInput.getCharSequence(NotificationActionUtils.WEAR_REPLY_INPUT); if (input != null) { wearReply = input.toString(); } } else { // TODO: remove after legacy code has been removed. LogUtils.d(LOG_TAG, "No remote input from new api, falling back to compatibility mode"); ClipData clipData = intent.getClipData(); if (clipData != null && LEGACY_WEAR_EXTRA.equals(clipData.getDescription().getLabel())) { Bundle extras = clipData.getItemAt(0).getIntent().getExtras(); if (extras != null) { wearReply = extras.getString(NotificationActionUtils.WEAR_REPLY_INPUT); } } } if (!TextUtils.isEmpty(wearReply)) { createWearReplyTask(this, mRefMessageUri, UIProvider.MESSAGE_PROJECTION, mComposeMode, wearReply).execute(); finish(); return; } else { LogUtils.w(LOG_TAG, "remote input string is null"); } } getLoaderManager().initLoader(INIT_DRAFT_USING_REFERENCE_MESSAGE, null, this); return; } else if (message != null && action != EDIT_DRAFT) { initFromDraftMessage(message); initQuotedTextFromRefMessage(mRefMessage, action); mShowQuotedText = message.appendRefMessageContent; // if we should be showing quoted text but mRefMessage is null // and we have some quotedText, display that if (mShowQuotedText && mRefMessage == null) { if (quotedText != null) { initQuotedText(quotedText, false /* shouldQuoteText */); } else if (mExtraValues != null) { initExtraValues(mExtraValues); return; } } } else if (action == EDIT_DRAFT) { if (message == null) { throw new IllegalStateException("Message must not be null to edit draft"); } initFromDraftMessage(message); // Update the action to the draft type of the previous draft switch (message.draftType) { case UIProvider.DraftType.REPLY: action = REPLY; break; case UIProvider.DraftType.REPLY_ALL: action = REPLY_ALL; break; case UIProvider.DraftType.FORWARD: action = FORWARD; break; case UIProvider.DraftType.COMPOSE: default: action = COMPOSE; break; } LogUtils.d(LOG_TAG, "Previous draft had action type: %d", action); mShowQuotedText = message.appendRefMessageContent; //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_S //Terrible original design,refMessageUri did not save to db,the value is always 0 here. //but the body's sourceKey is saved ,it points to the refMessage's id,so we can get //the refMessage from the body's sourceKey. long sourceKey = Body.restoreBodySourceKey(this, message.id); if (sourceKey != 0) { // If we're editing an existing draft that was in reference to an existing message, // still need to load that original message since we might need to refer to the // original sender and recipients if user switches "reply <-> reply-all". mRefMessageUri = Uri.parse("content://" + EmailContent.AUTHORITY + "/uimessage/" + sourceKey); //TS: Gantao 2015-07-28 EMAIL BUGFIX_1053829 MOD_E mComposeMode = action; getLoaderManager().initLoader(REFERENCE_MESSAGE_LOADER, null, this); return; } } else if ((action == REPLY || action == REPLY_ALL || action == FORWARD)) { if (mRefMessage != null) { initFromRefMessage(action); mShowQuotedText = true; } } else { if (initFromExtras(intent)) { return; } } mComposeMode = action; finishSetup(action, intent, savedState); }
From source file:im.neon.activity.LoginActivity.java
/** * Make login request with given params/* w ww.ja va 2 s.c o m*/ * * @param hsConfig the HS config * @param hsUrlString the HS url * @param identityUrlString the Identity server URL * @param username the username * @param phoneNumber the phone number * @param phoneNumberCountry the phone number country code * @param password the user password */ private void login(final HomeserverConnectionConfig hsConfig, final String hsUrlString, final String identityUrlString, final String username, final String phoneNumber, final String phoneNumberCountry, final String password) { try { mLoginHandler.login(this, hsConfig, username, phoneNumber, phoneNumberCountry, password, new SimpleApiCallback<HomeserverConnectionConfig>(this) { @Override public void onSuccess(HomeserverConnectionConfig c) { enableLoadingScreen(false); goToSplash(); LoginActivity.this.finish(); } @Override public void onNetworkError(Exception e) { Log.e(LOG_TAG, "onLoginClick : Network Error: " + e.getMessage()); enableLoadingScreen(false); Toast.makeText(getApplicationContext(), getString(R.string.login_error_network_error), Toast.LENGTH_LONG).show(); } @Override public void onUnexpectedError(Exception e) { Log.e(LOG_TAG, "onLoginClick : onUnexpectedError" + e.getMessage()); enableLoadingScreen(false); String msg = getString(R.string.login_error_unable_login) + " : " + e.getMessage(); Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); } @Override public void onMatrixError(MatrixError e) { // if the registration is forbidden with matrix.org url // try with the vector.im HS if (TextUtils.equals(hsUrlString, getString(R.string.vector_im_server_url)) && TextUtils.equals(e.errcode, MatrixError.FORBIDDEN)) { Log.e(LOG_TAG, "onLoginClick : test with matrix.org as HS"); mHomeserverConnectionConfig = new HomeserverConnectionConfig( Uri.parse(getString(R.string.matrix_org_server_url)), Uri.parse(identityUrlString), null, new ArrayList<Fingerprint>(), false); login(mHomeserverConnectionConfig, getString(R.string.matrix_org_server_url), identityUrlString, username, phoneNumber, phoneNumberCountry, password); } else { Log.e(LOG_TAG, "onLoginClick : onMatrixError " + e.getLocalizedMessage()); enableLoadingScreen(false); onFailureDuringAuthRequest(e); } } }); } catch (Exception e) { Toast.makeText(this, getString(R.string.login_error_invalid_home_server), Toast.LENGTH_SHORT).show(); enableLoadingScreen(false); setActionButtonsEnabled(true); } }
From source file:im.neon.activity.LoginActivity.java
/** * Check the homeserver flows.// w w w . j av a2 s. co m * i.e checks if this login page is enough to perform a registration. * else switcth to a fallback page */ private void checkLoginFlows() { // check only login flows if (mMode != MODE_LOGIN) { return; } try { final HomeserverConnectionConfig hsConfig = getHsConfig(); // invalid URL if (null == hsConfig) { setActionButtonsEnabled(false); } else { enableLoadingScreen(true); mLoginHandler.getSupportedLoginFlows(LoginActivity.this, hsConfig, new SimpleApiCallback<List<LoginFlow>>() { @Override public void onSuccess(List<LoginFlow> flows) { // stop listening to network state removeNetworkStateNotificationListener(); if (mMode == MODE_LOGIN) { enableLoadingScreen(false); setActionButtonsEnabled(true); boolean isSupported = true; // supported only m.login.password by now for (LoginFlow flow : flows) { isSupported &= TextUtils.equals(LoginRestClient.LOGIN_FLOW_TYPE_PASSWORD, flow.type); } // if not supported, switch to the fallback login if (!isSupported) { Intent intent = new Intent(LoginActivity.this, FallbackLoginActivity.class); intent.putExtra(FallbackLoginActivity.EXTRA_HOME_SERVER_ID, hsConfig.getHomeserverUri().toString()); startActivityForResult(intent, FALLBACK_LOGIN_ACTIVITY_REQUEST_CODE); } else if (mIsPendingLogin) { onLoginClick(); } } } private void onError(String errorMessage) { if (mMode == MODE_LOGIN) { enableLoadingScreen(false); setActionButtonsEnabled(false); Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show(); } } @Override public void onNetworkError(Exception e) { Log.e(LOG_TAG, "Network Error: " + e.getMessage(), e); // listen to network state, to resume processing as soon as the network is back addNetworkStateNotificationListener(); onError(getString(R.string.login_error_unable_login) + " : " + e.getLocalizedMessage()); } @Override public void onUnexpectedError(Exception e) { onError(getString(R.string.login_error_unable_login) + " : " + e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { onFailureDuringAuthRequest(e); } }); } } catch (Exception e) { Toast.makeText(getApplicationContext(), getString(R.string.login_error_invalid_home_server), Toast.LENGTH_SHORT).show(); enableLoadingScreen(false); } }
From source file:com.android.calendar.event.EditEventView.java
/** * Checks if the start and end times for this event should be displayed in * the Calendar app's time zone as well and formats and displays them. *///from w w w.j a va2 s . c om private void updateHomeTime() { String tz = Utils.getTimeZone(mActivity, null); if (!mAllDayCheckBox.isChecked() && !TextUtils.equals(tz, mTimezone) && mModification != EditEventHelper.MODIFY_UNINITIALIZED) { int flags = DateUtils.FORMAT_SHOW_TIME; boolean is24Format = DateFormat.is24HourFormat(mActivity); if (is24Format) { flags |= DateUtils.FORMAT_24HOUR; } long millisStart = mStartTime.toMillis(false); long millisEnd = mEndTime.toMillis(false); boolean isDSTStart = mStartTime.isDst != 0; boolean isDSTEnd = mEndTime.isDst != 0; // First update the start date and times String tzDisplay = TimeZone.getTimeZone(tz).getDisplayName(isDSTStart, TimeZone.SHORT, Locale.getDefault()); StringBuilder time = new StringBuilder(); mSB.setLength(0); time.append(DateUtils.formatDateRange(mActivity, mF, millisStart, millisStart, flags, tz)).append(" ") .append(tzDisplay); mStartTimeHome.setText(time.toString()); flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY; mSB.setLength(0); mStartDateHome.setText( DateUtils.formatDateRange(mActivity, mF, millisStart, millisStart, flags, tz).toString()); // Make any adjustments needed for the end times if (isDSTEnd != isDSTStart) { tzDisplay = TimeZone.getTimeZone(tz).getDisplayName(isDSTEnd, TimeZone.SHORT, Locale.getDefault()); } flags = DateUtils.FORMAT_SHOW_TIME; if (is24Format) { flags |= DateUtils.FORMAT_24HOUR; } // Then update the end times time.setLength(0); mSB.setLength(0); time.append(DateUtils.formatDateRange(mActivity, mF, millisEnd, millisEnd, flags, tz)).append(" ") .append(tzDisplay); mEndTimeHome.setText(time.toString()); flags = DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_WEEKDAY; mSB.setLength(0); mEndDateHome .setText(DateUtils.formatDateRange(mActivity, mF, millisEnd, millisEnd, flags, tz).toString()); mStartHomeGroup.setVisibility(View.VISIBLE); mEndHomeGroup.setVisibility(View.VISIBLE); } else { mStartHomeGroup.setVisibility(View.GONE); mEndHomeGroup.setVisibility(View.GONE); } }
From source file:im.vector.activity.VectorRoomActivity.java
/** * Display the typing status in the notification area. *///from w ww .jav a 2s .c o m private void onRoomTypings() { mLatestTypingMessage = null; ArrayList<String> typingUsers = mRoom.getTypingUsers(); if ((null != typingUsers) && (typingUsers.size() > 0)) { String myUserId = mSession.getMyUserId(); // get the room member names ArrayList<String> names = new ArrayList<>(); for (int i = 0; i < typingUsers.size(); i++) { RoomMember member = mRoom.getMember(typingUsers.get(i)); // check if the user is known and not oneself if ((null != member) && !TextUtils.equals(myUserId, member.getUserId()) && (null != member.displayname)) { names.add(member.displayname); } } // nothing to display ? if (0 == names.size()) { mLatestTypingMessage = null; } else if (1 == names.size()) { mLatestTypingMessage = String.format(this.getString(R.string.room_one_user_is_typing), names.get(0)); } else if (2 == names.size()) { mLatestTypingMessage = String.format(this.getString(R.string.room_two_users_are_typing), names.get(0), names.get(1)); } else if (names.size() > 2) { mLatestTypingMessage = String.format(this.getString(R.string.room_many_users_are_typing), names.get(0), names.get(1)); } } refreshNotificationsArea(); }
From source file:im.neon.activity.VectorRoomActivity.java
/** * Insert an user displayname in the message editor. * * @param text the text to insert.//from www . j av a2 s . c o m */ public void insertUserDisplayNameInTextEditor(String text) { if (null != text) { if (TextUtils.equals(mSession.getMyUser().displayname, text)) { // current user if (TextUtils.isEmpty(mEditText.getText())) { mEditText.setText(String.format("%s ", SlashComandsParser.CMD_EMOTE)); mEditText.setSelection(mEditText.getText().length()); } } else { // another user if (TextUtils.isEmpty(mEditText.getText())) { mEditText.append(sanitizeDisplayname(text) + ": "); } else { mEditText.getText().insert(mEditText.getSelectionStart(), sanitizeDisplayname(text) + " "); } } } }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Refresh the known information about the account */// w w w. j a va 2 s.c om private void refreshPreferences() { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity()); SharedPreferences.Editor editor = preferences.edit(); editor.putString(PreferencesManager.SETTINGS_DISPLAY_NAME_PREFERENCE_KEY, mSession.getMyUser().displayname); editor.putString(PreferencesManager.SETTINGS_VERSION_PREFERENCE_KEY, VectorUtils.getApplicationVersion(getActivity())); BingRuleSet mBingRuleSet = mSession.getDataHandler().pushRules(); if (null != mBingRuleSet) { for (String resourceText : mPushesRuleByResourceId.keySet()) { Preference preference = findPreference(resourceText); if ((null != preference) && (preference instanceof CheckBoxPreference)) { String ruleId = mPushesRuleByResourceId.get(resourceText); BingRule rule = mBingRuleSet.findDefaultRule(ruleId); boolean isEnabled = ((null != rule) && rule.isEnabled); if (TextUtils.equals(ruleId, BingRule.RULE_ID_DISABLE_ALL) || TextUtils.equals(ruleId, BingRule.RULE_ID_SUPPRESS_BOTS_NOTIFICATIONS)) { isEnabled = !isEnabled; } // check if the rule is only defined by don't notify else if (isEnabled) { List<Object> actions = rule.actions; // no action -> noting will be done if ((null == actions) || actions.isEmpty()) { isEnabled = false; } else if (1 == actions.size()) { try { isEnabled = !TextUtils.equals((String) (actions.get(0)), BingRule.ACTION_DONT_NOTIFY); } catch (Exception e) { Log.e(LOG_TAG, "## refreshPreferences failed " + e.getMessage()); } } } editor.putBoolean(resourceText, isEnabled); } } } editor.commit(); }