List of usage examples for android.text TextUtils equals
public static boolean equals(CharSequence a, CharSequence b)
From source file:im.neon.activity.LoginActivity.java
/** * @return the homeserver config. null if the url is not valid *//*from w w w . ja va 2 s. c om*/ private HomeserverConnectionConfig getHsConfig() { if (null == mHomeserverConnectionConfig) { String hsUrlString = getHomeServerUrl(); if (TextUtils.isEmpty(hsUrlString) || !hsUrlString.startsWith("http") || TextUtils.equals(hsUrlString, "http://") || TextUtils.equals(hsUrlString, "https://")) { Toast.makeText(this, getString(R.string.login_error_must_start_http), Toast.LENGTH_SHORT).show(); return null; } if (!hsUrlString.startsWith("http://") && !hsUrlString.startsWith("https://")) { hsUrlString = "https://" + hsUrlString; } String identityServerUrlString = getIdentityServerUrl(); if (TextUtils.isEmpty(identityServerUrlString) || !identityServerUrlString.startsWith("http") || TextUtils.equals(identityServerUrlString, "http://") || TextUtils.equals(identityServerUrlString, "https://")) { Toast.makeText(this, getString(R.string.login_error_must_start_http), Toast.LENGTH_SHORT).show(); return null; } if (!identityServerUrlString.startsWith("http://") && !identityServerUrlString.startsWith("https://")) { identityServerUrlString = "https://" + identityServerUrlString; } try { mHomeserverConnectionConfig = null; mHomeserverConnectionConfig = new HomeserverConnectionConfig(Uri.parse(hsUrlString), Uri.parse(identityServerUrlString), null, new ArrayList<Fingerprint>(), false); } catch (Exception e) { Log.e(LOG_TAG, "getHsConfig fails " + e.getLocalizedMessage()); } } RegistrationManager.getInstance().setHsConfig(mHomeserverConnectionConfig); return mHomeserverConnectionConfig; }
From source file:im.neon.activity.VectorRoomActivity.java
/** * Display the typing status in the notification area. *//*from w w w . j a v a2 s .c om*/ private void onRoomTypings() { mLatestTypingMessage = null; List<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.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Refresh the pushers list/* ww w.j a va 2 s. c o m*/ */ private void refreshPushersList() { final GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(getActivity()) .getSharedGCMRegistrationManager(); final List<Pusher> pushersList = new ArrayList<>(gcmRegistrationManager.mPushersList); if (pushersList.isEmpty()) { getPreferenceScreen().removePreference(mPushersSettingsCategory); getPreferenceScreen().removePreference(mPushersSettingsDivider); return; } // check first if there is an update boolean isNewList = true; if ((null != mDisplayedPushers) && (pushersList.size() == mDisplayedPushers.size())) { isNewList = !mDisplayedPushers.containsAll(pushersList); } if (isNewList) { // remove the displayed one mPushersSettingsCategory.removeAll(); // add new emails list mDisplayedPushers = pushersList; int index = 0; for (final Pusher pusher : mDisplayedPushers) { if (null != pusher.lang) { boolean isThisDeviceTarget = TextUtils .equals(gcmRegistrationManager.getCurrentRegistrationToken(), pusher.pushkey); VectorCustomActionEditTextPreference preference = new VectorCustomActionEditTextPreference( getActivity(), isThisDeviceTarget ? Typeface.BOLD : Typeface.NORMAL); preference.setTitle(pusher.deviceDisplayName); preference.setSummary(pusher.appDisplayName); preference.setKey(PUSHER_PREFERENCE_KEY_BASE + index); index++; mPushersSettingsCategory.addPreference(preference); // the user cannot remove the self device target if (!isThisDeviceTarget) { preference.setOnPreferenceLongClickListener( new VectorCustomActionEditTextPreference.OnPreferenceLongClickListener() { @Override public boolean onPreferenceLongClick(Preference preference) { final String dialogMessage = getString( R.string.settings_delete_notification_targets_confirmation); new AlertDialog.Builder(getActivity()) .setTitle(R.string.dialog_title_confirmation) .setMessage(dialogMessage).setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); displayLoadingView(); gcmRegistrationManager.unregister(mSession, pusher, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { refreshPushersList(); onCommonDone(null); } @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()); } }); } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) .create().show(); return true; } }); } } } } }
From source file:com.yeahka.android.lepos.Device.java
public ResultModel modifyMerchantBaseInfo(OADMerchantBaseInfo info) { String object = "Merchant_Base_Info"; String action = "Modify"; // ???? ?(0) Modify_Upgrade_Info boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(), "0"); boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance()) .getBoolean(Constants.FROM_PROMOTE, false); // MyLog.info("Merchant_Base_Info", "isFromPromote=" + isPromote); if (isPromote || isVerify) { action = "Modify_Upgrade_Info"; }/* ww w. ja v a 2 s .com*/ // MyLog.info("Merchant_Base_Info", action); String jsonStr = getOADJsonStr(info, object, action); byte[] data = getTLVPackaget(jsonStr, false); return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class); }
From source file:com.yeahka.android.lepos.Device.java
public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv) { String object = "Picture_Info"; String action = "Upload"; // ???? ?(0) Modify_Upgrade_Info boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(), "0"); boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance()) .getBoolean(Constants.FROM_PROMOTE, false); // MyLog.d("isFromPromote", "isFromPromote=" + isPromote); if (isPromote || isVerify) { action = "Upload_Upgrade_Pic"; }//from ww w . j a va 2s. co m String jsonStr = getOADJsonStr(info, object, action); byte[] data = getTLVPackaget(jsonStr, false, tlv); return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class); }
From source file:com.yeahka.android.lepos.Device.java
public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv1, TLVBytes tlv2) { String object = "Picture_Info"; String action = "Upload"; // ???? ?(0) Modify_Upgrade_Info boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(), "0"); boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance()) .getBoolean(Constants.FROM_PROMOTE, false); if (isPromote || isVerify) { action = "Upload_Upgrade_Pic"; }/*from w ww. ja v a2 s. co m*/ String jsonStr = getOADJsonStr(info, object, action); byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2); return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class); }
From source file:com.yeahka.android.lepos.Device.java
public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv1, TLVBytes tlv2, TLVBytes tlv3) { String object = "Picture_Info"; String action = "Upload"; // ???? ?(0) Modify_Upgrade_Info boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(), "0"); boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance()) .getBoolean(Constants.FROM_PROMOTE, false); if (isPromote || isVerify) { action = "Upload_Upgrade_Pic"; }/*www .j a v a 2 s.c o m*/ String jsonStr = getOADJsonStr(info, object, action); byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2, tlv3); return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class); }
From source file:im.neon.activity.VectorRoomActivity.java
/** * Display the active members count / members count in the expendable header. *///from w w w .jav a2 s . com private void updateRoomHeaderMembersStatus() { if (null != mActionBarHeaderActiveMembers) { // refresh only if the action bar is hidden if (mActionBarCustomTitle.getVisibility() == View.GONE) { if ((null != mRoom) || (null != sRoomPreviewData)) { // update the members status: "active members"/"members" int joinedMembersCount = 0; int activeMembersCount = 0; RoomState roomState = (null != sRoomPreviewData) ? sRoomPreviewData.getRoomState() : mRoom.getState(); if (null != roomState) { Collection<RoomMember> members = roomState.getDisplayableMembers(); for (RoomMember member : members) { if (TextUtils.equals(member.membership, RoomMember.MEMBERSHIP_JOIN)) { joinedMembersCount++; User user = mSession.getDataHandler().getStore().getUser(member.getUserId()); if ((null != user) && user.isActive()) { activeMembersCount++; } } } // in preview mode, the room state might be a publicRoom // so try to use the public room info. if ((roomState instanceof PublicRoom) && (0 == joinedMembersCount)) { activeMembersCount = joinedMembersCount = ((PublicRoom) roomState).numJoinedMembers; } boolean displayInvite = TextUtils.isEmpty(mEventId) && (null == sRoomPreviewData) && (1 == joinedMembersCount); if (displayInvite) { mActionBarHeaderActiveMembers.setVisibility(View.GONE); mActionBarHeaderInviteMemberView.setVisibility(View.VISIBLE); } else { mActionBarHeaderInviteMemberView.setVisibility(View.GONE); String text = null; if (null != sRoomPreviewData) { if (joinedMembersCount == 1) { text = getResources().getString(R.string.room_title_one_member); } else if (joinedMembersCount > 0) { text = getResources().getString(R.string.room_title_members, joinedMembersCount); } } else { text = getString(R.string.room_header_active_members, activeMembersCount, joinedMembersCount); } if (!TextUtils.isEmpty(text)) { mActionBarHeaderActiveMembers.setText(text); mActionBarHeaderActiveMembers.setVisibility(View.VISIBLE); } else { mActionBarHeaderActiveMembers.setVisibility(View.GONE); } } } else { mActionBarHeaderActiveMembers.setVisibility(View.GONE); mActionBarHeaderActiveMembers.setVisibility(View.GONE); } } } else { mActionBarHeaderActiveMembers.setVisibility(View.GONE); } } }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Attempt to add a new email to the account * * @param email the email to add./* w w w . j av a 2 s . co m*/ */ private void addEmail(String email) { // check first if the email syntax is valid if (TextUtils.isEmpty(email) || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) { Toast.makeText(getActivity(), getString(R.string.auth_invalid_email), Toast.LENGTH_SHORT).show(); return; } // check first if the email syntax is valid if (mDisplayedEmails.indexOf(email) >= 0) { Toast.makeText(getActivity(), getString(R.string.auth_email_already_defined), Toast.LENGTH_SHORT) .show(); return; } final ThreePid pid = new ThreePid(email, ThreePid.MEDIUM_EMAIL); displayLoadingView(); mSession.getMyUser().requestEmailValidationToken(pid, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { showEmailValidationDialog(pid); } }); } } @Override public void onNetworkError(Exception e) { onCommonDone(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { if (TextUtils.equals(MatrixError.THREEPID_IN_USE, e.errcode)) { onCommonDone(getString(R.string.account_email_already_used_error)); } else { onCommonDone(e.getLocalizedMessage()); } } @Override public void onUnexpectedError(Exception e) { onCommonDone(e.getLocalizedMessage()); } }); }
From source file:im.vector.fragments.VectorSettingsPreferencesFragment.java
/** * Show an email validation dialog to warn the user tho valid his email link. * * @param pid the used pid./*from w ww.j ava 2s. co m*/ */ private void showEmailValidationDialog(final ThreePid pid) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.account_email_validation_title); builder.setMessage(R.string.account_email_validation_message); builder.setPositiveButton(R.string._continue, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mSession.getMyUser().add3Pid(pid, true, new ApiCallback<Void>() { @Override public void onSuccess(Void info) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { hideLoadingView(); refreshEmailsList(); } }); } } @Override public void onNetworkError(Exception e) { onCommonDone(e.getLocalizedMessage()); } @Override public void onMatrixError(MatrixError e) { if (TextUtils.equals(e.errcode, MatrixError.THREEPID_AUTH_FAILED)) { if (null != getActivity()) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { hideLoadingView(); Toast.makeText(getActivity(), getString(R.string.account_email_validation_error), Toast.LENGTH_SHORT).show(); } }); } } else { 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.dismiss(); hideLoadingView(); } }); AlertDialog alert = builder.create(); alert.show(); }