Example usage for android.text TextUtils equals

List of usage examples for android.text TextUtils equals

Introduction

In this page you can find the example usage for android.text TextUtils equals.

Prototype

public static boolean equals(CharSequence a, CharSequence b) 

Source Link

Document

Returns true if a and b are equal, including if they are both null.

Usage

From source file:im.neon.fragments.VectorMessageListFragment.java

/**
 * the user taps on the e2e icon/*from  ww  w.  j  ava  2 s.c om*/
 *
 * @param event      the event
 * @param deviceInfo the deviceinfo
 */
public void onE2eIconClick(final Event event, final MXDeviceInfo deviceInfo) {
    android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
            getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    EncryptedEventContent encryptedEventContent = JsonUtils
            .toEncryptedEventContent(event.getWireContent().getAsJsonObject());

    View layout = inflater.inflate(R.layout.encrypted_event_info, null);

    TextView textView;

    textView = (TextView) layout.findViewById(R.id.encrypted_info_user_id);
    textView.setText(event.getSender());

    textView = (TextView) layout.findViewById(R.id.encrypted_info_curve25519_identity_key);
    if (null != deviceInfo) {
        textView.setText(encryptedEventContent.sender_key);
    } else {
        textView.setText(getActivity().getString(R.string.encryption_information_none));
    }

    textView = (TextView) layout.findViewById(R.id.encrypted_info_claimed_ed25519_fingerprint_key);
    if (null != deviceInfo) {
        textView.setText(deviceInfo.fingerprint());
    } else {
        textView.setText(getActivity().getString(R.string.encryption_information_none));
    }

    textView = (TextView) layout.findViewById(R.id.encrypted_info_algorithm);
    textView.setText(encryptedEventContent.algorithm);

    textView = (TextView) layout.findViewById(R.id.encrypted_info_session_id);
    textView.setText(encryptedEventContent.session_id);

    View decryptionErrorLabelTextView = layout.findViewById(R.id.encrypted_info_decryption_error_label);
    textView = (TextView) layout.findViewById(R.id.encrypted_info_decryption_error);

    if (null != event.getCryptoError()) {
        decryptionErrorLabelTextView.setVisibility(View.VISIBLE);
        textView.setVisibility(View.VISIBLE);
        textView.setText("**" + event.getCryptoError().getLocalizedMessage() + "**");
    } else {
        decryptionErrorLabelTextView.setVisibility(View.GONE);
        textView.setVisibility(View.GONE);
    }

    View noDeviceInfoLayout = layout.findViewById(R.id.encrypted_info_no_device_information_layout);
    View deviceInfoLayout = layout.findViewById(R.id.encrypted_info_sender_device_information_layout);

    if (null != deviceInfo) {
        noDeviceInfoLayout.setVisibility(View.GONE);
        deviceInfoLayout.setVisibility(View.VISIBLE);

        textView = (TextView) layout.findViewById(R.id.encrypted_info_name);
        textView.setText(deviceInfo.displayName());

        textView = (TextView) layout.findViewById(R.id.encrypted_info_device_id);
        textView.setText(deviceInfo.deviceId);

        textView = (TextView) layout.findViewById(R.id.encrypted_info_verification);

        if (deviceInfo.isUnknown() || deviceInfo.isUnverified()) {
            textView.setText(getActivity().getString(R.string.encryption_information_not_verified));
        } else if (deviceInfo.isVerified()) {
            textView.setText(getActivity().getString(R.string.encryption_information_verified));
        } else {
            textView.setText(getActivity().getString(R.string.encryption_information_blocked));
        }

        textView = (TextView) layout.findViewById(R.id.encrypted_ed25519_fingerprint);
        textView.setText(deviceInfo.fingerprint());
    } else {
        noDeviceInfoLayout.setVisibility(View.VISIBLE);
        deviceInfoLayout.setVisibility(View.GONE);
    }

    builder.setView(layout);
    builder.setTitle(R.string.encryption_information_title);

    builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // nothing to do
        }
    });

    // the current id cannot be blocked, verified...
    if (!TextUtils.equals(encryptedEventContent.device_id, mSession.getCredentials().deviceId)) {
        if ((null == event.getCryptoError()) && (null != deviceInfo)) {
            if (deviceInfo.isUnverified() || deviceInfo.isUnknown()) {
                builder.setNegativeButton(R.string.encryption_information_verify,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                CommonActivityUtils.displayDeviceVerificationDialog(deviceInfo,
                                        event.getSender(), mSession, getActivity(),
                                        mDeviceVerificationCallback);
                            }
                        });

                builder.setPositiveButton(R.string.encryption_information_block,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                mSession.getCrypto().setDeviceVerification(
                                        MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED, deviceInfo.deviceId,
                                        event.getSender(), mDeviceVerificationCallback);
                            }
                        });
            } else if (deviceInfo.isVerified()) {
                builder.setNegativeButton(R.string.encryption_information_unverify,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                mSession.getCrypto().setDeviceVerification(
                                        MXDeviceInfo.DEVICE_VERIFICATION_UNVERIFIED, deviceInfo.deviceId,
                                        event.getSender(), mDeviceVerificationCallback);
                            }
                        });

                builder.setPositiveButton(R.string.encryption_information_block,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                mSession.getCrypto().setDeviceVerification(
                                        MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED, deviceInfo.deviceId,
                                        event.getSender(), mDeviceVerificationCallback);
                            }
                        });
            } else { // BLOCKED
                builder.setNegativeButton(R.string.encryption_information_verify,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                CommonActivityUtils.displayDeviceVerificationDialog(deviceInfo,
                                        event.getSender(), mSession, getActivity(),
                                        mDeviceVerificationCallback);
                            }
                        });

                builder.setPositiveButton(R.string.encryption_information_unblock,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                mSession.getCrypto().setDeviceVerification(
                                        MXDeviceInfo.DEVICE_VERIFICATION_UNVERIFIED, deviceInfo.deviceId,
                                        event.getSender(), mDeviceVerificationCallback);
                            }
                        });
            }
        }
    }

    final android.support.v7.app.AlertDialog dialog = builder.create();
    dialog.show();

    if (null == deviceInfo) {
        mSession.getCrypto().getDeviceList().downloadKeys(Arrays.asList(event.getSender()), true,
                new ApiCallback<MXUsersDevicesMap<MXDeviceInfo>>() {
                    @Override
                    public void onSuccess(MXUsersDevicesMap<MXDeviceInfo> info) {
                        if (dialog.isShowing()) {
                            EncryptedEventContent encryptedEventContent = JsonUtils
                                    .toEncryptedEventContent(event.getWireContent().getAsJsonObject());

                            MXDeviceInfo deviceInfo = mSession.getCrypto().deviceWithIdentityKey(
                                    encryptedEventContent.sender_key, event.getSender(),
                                    encryptedEventContent.algorithm);

                            if (null != deviceInfo) {
                                dialog.cancel();
                                onE2eIconClick(event, deviceInfo);
                            }
                        }
                    }

                    @Override
                    public void onNetworkError(Exception e) {
                    }

                    @Override
                    public void onMatrixError(MatrixError e) {
                    }

                    @Override
                    public void onUnexpectedError(Exception e) {
                    }
                });
    }
}

From source file:com.jrummyapps.android.safetynet.SafetyNetHelper.java

private SafetyNetVerification verify(SafetyNetResponse response) {
    Boolean isValidSignature = null;
    if (!TextUtils.isEmpty(apiKey)) {
        try {//from   w  w w  .j  a v a  2 s . c om
            isValidSignature = validate(response.jws, apiKey);
        } catch (SafetyNetError e) {
            Log.d(TAG, "An error occurred while using the Android Device Verification API", e);
        }
    }

    String nonce = Base64.encodeToString(this.nonce, Base64.DEFAULT).trim();
    boolean isValidNonce = TextUtils.equals(nonce, response.nonce);

    long durationOfReq = response.timestampMs - requestTimestamp;
    boolean isValidResponseTime = durationOfReq < MAX_TIMESTAMP_DURATION;

    boolean isValidApkSignature = true;
    if (response.apkCertificateDigestSha256 != null && response.apkCertificateDigestSha256.length > 0) {
        isValidApkSignature = Arrays.equals(getApkCertificateDigests().toArray(),
                response.apkCertificateDigestSha256);
    }

    boolean isValidApkDigest = true;
    if (!TextUtils.isEmpty(response.apkDigestSha256)) {
        isValidApkDigest = TextUtils.equals(getApkDigestSha256(), response.apkDigestSha256);
    }

    return new SafetyNetVerification(isValidSignature, isValidNonce, isValidResponseTime, isValidApkSignature,
            isValidApkDigest);
}

From source file:im.vector.activity.VectorUnifiedSearchActivity.java

@Override
public void onTabSelected(android.support.v7.app.ActionBar.Tab tab,
        android.support.v4.app.FragmentTransaction ft) {
    Log.d(LOG_TAG, "## onTabSelected() FragTag=" + tab.getTag());

    // clear any displayed windows
    resetUi(true);//from   w w w .j a va  2  s.  co  m

    // attach / replace a fragment by tag
    String tabTag = (String) tab.getTag();
    Fragment fragment = null;
    boolean replace = false;

    // search a room by name
    if (TextUtils.equals(tabTag, TAG_FRAGMENT_SEARCH_IN_ROOM_NAMES)) {
        if (null == mSearchInRoomNamesFragment) {
            replace = true;
            mSearchInRoomNamesFragment = VectorSearchRoomsListFragment.newInstance(mSession.getMyUserId(),
                    R.layout.fragment_vector_recents_list);
        }
        fragment = mSearchInRoomNamesFragment;
        mCurrentTabIndex = mSearchInRoomNamesTabIndex;

    }
    // search a message by its body
    else if (TextUtils.equals((String) tab.getTag(), TAG_FRAGMENT_SEARCH_IN_MESSAGE)) {
        if (null == mSearchInMessagesFragment) {
            replace = true;
            mSearchInMessagesFragment = VectorSearchMessagesListFragment.newInstance(mSession.getMyUserId(),
                    null, org.matrix.androidsdk.R.layout.fragment_matrix_message_list_fragment);
        }
        fragment = mSearchInMessagesFragment;
        mCurrentTabIndex = mSearchInMessagesTabIndex;
    }
    // search a file by name
    else if (TextUtils.equals((String) tab.getTag(), TAG_FRAGMENT_SEARCH_IN_FILES)) {
        if (null == mSearchInFilesFragment) {
            replace = true;
            mSearchInFilesFragment = VectorSearchRoomsFilesListFragment.newInstance(mSession.getMyUserId(),
                    null, org.matrix.androidsdk.R.layout.fragment_matrix_message_list_fragment);
        }
        fragment = mSearchInFilesFragment;
        mCurrentTabIndex = mSearchInFilesTabIndex;
    }
    // search an user by name
    else if (TextUtils.equals((String) tab.getTag(), TAG_FRAGMENT_SEARCH_PEOPLE)) {
        if (null == mSearchInPeopleFragment) {
            replace = true;
            mSearchInPeopleFragment = VectorSearchPeopleListFragment.newInstance(mSession.getMyUserId(),
                    R.layout.fragment_vector_search_people_list);
        }
        fragment = mSearchInPeopleFragment;
        mCurrentTabIndex = mSearchInPeopleTabIndex;

        // Check permission to access contacts
        CommonActivityUtils.checkPermissions(CommonActivityUtils.REQUEST_CODE_PERMISSION_MEMBERS_SEARCH, this);
    }

    if (replace) {
        ft.replace(R.id.search_fragment_container, fragment, tabTag);
    } else {
        ft.attach(fragment);
    }

    /*if (-1 != mCurrentTabIndex) {
    searchAccordingToTabHandler();
    }*/

    resetUi(true);
}

From source file:com.android.screenspeak.controller.CursorControllerApp.java

private boolean isLogicalScrollableWidget(AccessibilityNodeInfoCompat node) {
    if (node == null) {
        return false;
    }//w w  w.j  a va 2 s  .  c  om

    CharSequence className = node.getClassName();
    return !(TextUtils.equals(className, DatePicker.class.getName())
            || TextUtils.equals(className, NumberPicker.class.getName()));
}

From source file:net.eledge.android.europeana.gui.activity.SearchActivity.java

private void handleIntent(Intent intent) {
    String query = null;/*from   www.  ja  v  a 2 s .c om*/
    String[] qf = null;
    if (intent != null) {

        if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
            query = intent.getStringExtra(SearchManager.QUERY);
            qf = splitFacets(intent.getStringExtra(SearchManager.USER_QUERY));
        } else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
            Parcelable[] parcelables = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            NdefMessage msg = (NdefMessage) parcelables[0];
            Uri uri = Uri.parse(new String(msg.getRecords()[0].getPayload()));
            query = uri.getQueryParameter("query");
            qf = StringArrayUtils.toArray(uri.getQueryParameters("qf"));
        } else if (Intent.ACTION_VIEW.equals(intent.getAction())) {
            query = intent.getDataString();
            if (!TextUtils.isEmpty(query)) {
                if (StringUtils.contains(query, "europeana.eu/")) {
                    Uri uri = Uri.parse(query);
                    query = uri.getQueryParameter("query");
                    qf = StringArrayUtils.toArray(uri.getQueryParameters("qf"));
                }
            }
        } else {
            // no search action recognized? end this activity...
            closeSearchActivity();
        }
        if (!TextUtils.isEmpty(query) && !TextUtils.equals(runningSearch, query)) {
            runningSearch = query;
            if (StringArrayUtils.isNotBlank(qf)) {
                searchController.newSearch(this, query, qf);
            } else {
                searchController.newSearch(this, query);
            }
            getSupportActionBar().setTitle(searchController.getSearchTitle(this));
        }
    }
}

From source file:com.alibaba.weex.IndexActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
        getMenuInflater().inflate(R.menu.main_scan, menu);
    } else {//  ww  w.  java2 s. c  om
        getMenuInflater().inflate(R.menu.main, menu);
    }
    return true;
}

From source file:com.com2us.module.inapp.DefaultBilling.java

protected void showPreviousProgressInfoDialog(Activity activity, Runnable runnable) {
    String message;// w w  w .ja v a2s. co m
    String okay;
    String language = this.moduleData.getLanguage();
    String country = this.moduleData.getCountry();
    if (TextUtils.equals("ko", language)) {
        message = "\uc9c0\uae09\ub418\uc9c0 \uc54a\uc740 \uc0c1\ud488\uc774 \uc788\uc2b5\ub2c8\ub2e4. \n\uc7ac \uc9c0\uae09\uc744 \uc2dc\ub3c4\ud569\ub2c8\ub2e4.";
        okay = "\ud655\uc778";
    } else if (TextUtils.equals("fr", language)) {
        message = "Echec de lattribution de certains objets. \nLe processus va recommencer.";
        okay = "OK";
    } else if (TextUtils.equals("de", language)) {
        message = "Nicht erhaltene Items vorhanden. \nVorgang wird wiederholt.";
        okay = "OK";
    } else if (TextUtils.equals("ja", language)) {
        message = "\u652f\u7d66\u3055\u308c\u3066\u306a\u3044\u30a2\u30a4\u30c6\u30e0\u304c\u3042\u308a\u307e\u3059\u3002 \n\u518d\u652f\u7d66\u3044\u305f\u3057\u307e\u3059\u3002";
        okay = "OK";
    } else if (TextUtils.equals("ru", language)) {
        message = "\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b. \n\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0449\u0435 \u0440\u0430\u0437.";
        okay = "OK";
    } else if (TextUtils.equals("tw", country)) {
        message = "\u5546\u54c1\u672a\u6210\u529f\u7d66\u4ed8\uff0c \n\u5c07\u5617\u8a66\u91cd\u65b0\u9818\u53d6\u3002";
        okay = "\u78ba\u8a8d";
    } else if (TextUtils.equals("cn", country)) {
        message = "\u5b58\u5728\u672a\u80fd\u652f\u4ed8\u7684\u5546\u54c1\u3002 \n\u5c06\u5c1d\u8bd5\u91cd\u65b0\u652f\u4ed8\u3002";
        okay = "\u786e\u8ba4";
    } else {
        message = "Failed to grant some items. \nThe process will restart.";
        okay = "OK";
    }
    final Activity activity2 = activity;
    final Runnable runnable2 = runnable;
    activity.runOnUiThread(new Runnable() {
        public void run() {
            AlertDialog dialog = new Builder(activity2).setIcon(17301659).setMessage(message)
                    .setPositiveButton(okay, new OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                        }
                    }).create();
            final Activity activity = activity2;
            final Runnable runnable = runnable2;
            dialog.setOnDismissListener(new OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    activity.runOnUiThread(runnable);
                }
            });
            dialog.show();
        }
    });
}

From source file:com.alibaba.weex.IndexActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_refresh:
        if (!TextUtils.equals(sCurrentIp, DEFAULT_IP)) {
            createWeexInstance();//from  w w  w . j a v  a  2 s  .  c  o  m
            renderPageByURL(getIndexUrl());
            mProgressBar.setVisibility(View.VISIBLE);
        }
        break;
    case R.id.action_scan:
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {
                Toast.makeText(this, "please give me the permission", Toast.LENGTH_SHORT).show();
            } else {
                ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA },
                        CAMERA_PERMISSION_REQUEST_CODE);
            }
        } else {
            startActivity(new Intent(this, CaptureActivity.class));
        }
        break;
    default:
        break;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.citrus.sdk.TransactionResponse.java

public static TransactionResponse parseLoadMoneyResponse(String response) {
    Logger.d("parseLoadMoneyResponse :: " + response);

    TransactionResponse transactionResponse;
    if (response.contains("#")) {
        String token[] = response.split("#");
        if (token != null && token.length == 2) {
            String decodeResp[] = token[1].split(":");

            String transactionId;
            String balanceValue;//from w  w w . j ava 2  s.c  om
            String balanceCurrency;

            String dateTime;
            String transactionValue;
            String transactionCurrency;

            if (decodeResp.length > 1) {
                transactionId = decodeResp[1];
                balanceValue = decodeResp[2];
                balanceCurrency = decodeResp[3];

                dateTime = decodeResp[4];
                transactionValue = decodeResp[5];
                transactionCurrency = decodeResp[6];

                if (TextUtils.equals(decodeResp[0], "SUCCESSFUL")) {
                    transactionResponse = new TransactionResponse(TransactionStatus.SUCCESSFUL,
                            ResponseMessages.SUCCESS_MESSAGE_LOAD_MONEY, transactionId);
                } else {
                    transactionResponse = new TransactionResponse(TransactionStatus.FAILED,
                            ResponseMessages.ERROR_MESSAGE_LOAD_MONEY, transactionId);
                }

                transactionResponse.transactionAmount = new Amount(transactionValue, transactionCurrency);
                transactionResponse.balanceAmount = new Amount(balanceValue, balanceCurrency);
                transactionResponse.transactionDetails.transactionDateTime = dateTime;
            } else {
                transactionResponse = new TransactionResponse(TransactionStatus.FAILED,
                        ResponseMessages.ERROR_MESSAGE_LOAD_MONEY, null);
            }
        } else {
            transactionResponse = new TransactionResponse(TransactionStatus.FAILED,
                    ResponseMessages.ERROR_MESSAGE_LOAD_MONEY, null);
        }
    } else {
        transactionResponse = new TransactionResponse(TransactionStatus.FAILED,
                ResponseMessages.ERROR_MESSAGE_LOAD_MONEY, null);
    }

    return transactionResponse;
}

From source file:com.dellingertech.andevcon.mocklocationprovider.SendMockLocationService.java

@Override
public int onStartCommand(Intent startIntent, int flags, int startId) {
    // Get the type of test to run
    mTestRequest = startIntent.getAction();

    /*//from   w  ww.j  av a2 s  .c o  m
     * If the incoming Intent was a request to run a one-time or continuous test
     */
    if ((TextUtils.equals(mTestRequest, LocationUtils.ACTION_START_ONCE))
            || (TextUtils.equals(mTestRequest, LocationUtils.ACTION_START_CONTINUOUS))) {

        // Get the pause interval and injection interval
        mPauseInterval = startIntent.getIntExtra(LocationUtils.EXTRA_PAUSE_VALUE, 2);
        mInjectionInterval = startIntent.getIntExtra(LocationUtils.EXTRA_SEND_INTERVAL, 1);

        // Post a notification in the notification bar that a test is starting
        postNotification(getString(R.string.notification_content_test_start));

        // Create a location client
        mLocationClient = new LocationClient(this, this, this);

        // Start connecting to Location Services
        mLocationClient.connect();

    } else if (TextUtils.equals(mTestRequest, LocationUtils.ACTION_STOP_TEST)) {

        // Remove any existing notifications
        removeNotification();

        // Send a message back to the main activity that the test is stopping
        sendBroadcastMessage(LocationUtils.CODE_TEST_STOPPED, 0);

        // Stop this Service
        stopSelf();
    }

    /*
     * Tell the system to keep the Service alive, but to discard the Intent that
     * started the Service
     */
    return Service.START_STICKY;
}