Example usage for android.text SpannableString length

List of usage examples for android.text SpannableString length

Introduction

In this page you can find the example usage for android.text SpannableString length.

Prototype

int length();

Source Link

Document

Returns the length of this character sequence.

Usage

From source file:com.playground.notification.app.fragments.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Get app version
    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String versionName;/*  w w w .j  ava  2 s.  c  om*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        versionName = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        versionName = VERSION_UNAVAILABLE;
    }

    // About.
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(
            Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName)));

    // Licenses.
    SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses));
    licensesLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showOpenSourceLicenses(getActivity());
        }
    }, 0, licensesLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(licensesLink);

    // End User License Agreement.
    SpannableString eulaLink = new SpannableString(getString(R.string.about_eula));
    eulaLink.setSpan(new ClickableSpan() {
        @Override
        public void onClick(View view) {
            showEula(getActivity());
        }
    }, 0, eulaLink.length(), 0);
    aboutBody.append("\n\n");
    aboutBody.append(eulaLink);

    // Show "About" dialog.
    LayoutInflater layoutInflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null);
    ;
    TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv);
    aboutBodyView.setText(aboutBody);
    aboutBodyView.setMovementMethod(new LinkMovementMethod());

    dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_spielplatz_radar));
        }
    });

    dialogV.findViewById(R.id.weather_by_ll).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_openweathermap));
        }
    });

    return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV)
            .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).create();
}

From source file:com.avapira.bobroreader.hanabira.HanabiraParser.java

@SuppressWarnings("ConstantConditions")
private void replaceAll(String begin, String end, SpanObjectFactory factory, int flag) {
    int removedFormatCharsDelta = 0;
    Pattern pattern = Pattern.compile(String.format("(%s)(.+?)(%s)", begin, end), Pattern.MULTILINE | flag);
    String beginRestore = restoreBreaks(begin);
    String endRestore = restoreBreaks(end);
    Matcher matcher = pattern.matcher(builder);
    String inlinedString;//from ww w .  j  a  v  a 2 s.  c o  m

    boolean code = begin.contains("`");
    while (matcher.find()) {
        int start = matcher.start(2);
        int finish = matcher.end(2);

        // don't reformat in code blocks
        if (!code) {
            CodeBlockSpan[] spans = builder.getSpans(start, finish, CodeBlockSpan.class);
            if (spans != null && spans.length != 0) {
                continue;
            }
        }

        // don't reformat double borders while searchin for sinlges
        // e.g.: searching for "*abc*", found "**"
        inlinedString = matcher.group(2);
        if (inlinedString == null || "".equals(inlinedString)) {
            System.out.println(matcher.group());
            continue;
        }

        int lengthPrefix = matcher.group(1).length();
        builder.replace(matcher.start(1) - removedFormatCharsDelta, matcher.end(1) - removedFormatCharsDelta,
                beginRestore);

        builder.replace(matcher.start(3) - lengthPrefix - removedFormatCharsDelta + beginRestore.length(),
                matcher.end(3) - lengthPrefix - removedFormatCharsDelta + beginRestore.length(), endRestore);

        SpannableString rep = new SpannableString(matcher.group(2));
        rep.setSpan(factory.getSpan(), 0, rep.length(), 0);
        if (!code) {
            Linkify.addLinks(rep, Linkify.WEB_URLS);
            // fixme twice used Linkify? try remove and just setSpan to builder
        }
        builder.replace(matcher.start() - removedFormatCharsDelta + beginRestore.length(),
                matcher.start() + rep.length() - removedFormatCharsDelta + endRestore.length(), rep);

        // store deletions
        removedFormatCharsDelta += matcher.group(1).length() - beginRestore.length();
        removedFormatCharsDelta += matcher.group(3).length() - endRestore.length();
    }
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringAboutMe(int stringRes, int stringResMulti, ParcelableUser[] sources) {
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final boolean nameFirst = adapter.isNameFirst();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final SpannableString firstDisplayName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstDisplayName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondDisplayName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondDisplayName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, secondDisplayName);
    } else {//from   w w  w  . j  a  va  2s . c o m
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, nOthers);
    }
}

From source file:net.net76.lifeiq.TaskiQ.RegisterActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    inputFirstname = (EditText) findViewById(R.id.firstname);
    inputSurname = (EditText) findViewById(R.id.surname);
    inputUserID = (EditText) findViewById(R.id.userID);
    inputEmail = (EditText) findViewById(R.id.email);
    //1 inputPassword = (EditText) findViewById(R.id.password);
    //1inputPassword2 = (EditText) findViewById(R.id.password2);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    EULA = (TextView) findViewById(R.id.EULA);

    SpannableString content = new SpannableString(EULA.getText().toString());
    content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
    EULA.setText(content);// w  ww.  j a  v  a  2s.  co  m
    EULA.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            PackageInfo versionInfo = getPackageInfo();
            // EULA title
            String title = RegisterActivity.this.getString(R.string.app_name) + " v " + versionInfo.versionName;

            // EULA text
            String message = RegisterActivity.this.getString(R.string.eula_string);

            android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this)
                    .setTitle(title).setMessage(message).setCancelable(false)
                    .setPositiveButton(R.string.accept, new Dialog.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {

                            EULAAccept = true;
                            // Close dialog
                            dialogInterface.dismiss();

                        }
                    }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            EULAAccept = false;

                        }

                    });
            builder.create().show();
        }

    });

    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.Country_array,
            android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);

    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Log.v("item", (String) parent.getItemAtPosition(position));
            countryString = (String) parent.getItemAtPosition(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // TODO Auto-generated method stub
        }
    });

    btnRegister = (Button) findViewById(R.id.btnRegister);
    btnLinkToLogin = (Button) findViewById(R.id.btnLinkToLoginScreen);

    // Progress dialog
    pDialog = new ProgressDialog(this);
    //pDialog.setCancelable(false);
    pDialog.setCanceledOnTouchOutside(false);

    // Session manager
    session = new SessionManager(getApplicationContext());

    // SQLite database handler
    db = new SQLiteHandler(getApplicationContext());

    // Check if user is already logged in or not
    if (session.isLoggedIn()) {
        // User is already logged in. Take him to main activity
        Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
        startActivity(intent);
        finish();
    }

    // Register Button Click event
    btnRegister.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            String Firstname = inputFirstname.getText().toString();
            String Surname = inputSurname.getText().toString();
            String UserID = inputUserID.getText().toString();
            String email = inputEmail.getText().toString();
            //1    String password = inputPassword.getText().toString();
            //1   String password2 = inputPassword2.getText().toString();

            if (!Firstname.isEmpty() && !Surname.isEmpty() && !email.isEmpty() && !UserID.isEmpty()) {

                if (isEmailValid(email)) {

                    if (!UserID.contains(" ")) {

                        if (!countryString.equals("Select country of residence")) {
                            if (EULAAccept.equals(true)) {

                                if (isNetworkAvaliable(getApplicationContext())) {
                                    registerUser(Firstname, Surname, UserID, email, countryString);
                                } else {
                                    Toast.makeText(getApplicationContext(),
                                            "Currently there is no network. Please try later.",
                                            Toast.LENGTH_SHORT).show();
                                }
                            } else {
                                Toast.makeText(getApplicationContext(),
                                        "Please read and accept End User License Agreement.",
                                        Toast.LENGTH_SHORT).show();
                            }
                        } else {
                            Toast.makeText(getApplicationContext(), "Please select a country of residence.",
                                    Toast.LENGTH_SHORT).show();
                        }

                    } else {
                        Toast.makeText(getApplicationContext(), "In the User ID no spaces are allowed.",
                                Toast.LENGTH_SHORT).show();
                    }

                } else {
                    Toast.makeText(getApplicationContext(), "Please enter a valid email address!",
                            Toast.LENGTH_SHORT).show();
                }

            } else {
                Toast.makeText(getApplicationContext(), "Please enter your details!", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    });

    // Link to Login Screen
    btnLinkToLogin.setOnClickListener(new View.OnClickListener() {

        public void onClick(View view) {
            Intent i = new Intent(getApplicationContext(), LoginActivity.class);
            startActivity(i);
            finish();
        }
    });

}

From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java

public SpannableStringBuilder formatPerPlayer(String fixed, playstat query) {
    SpannableStringBuilder sps = SpannableStringBuilder.valueOf(fixed);

    for (Player p : gameManager.getCurrGameState().getPlayers()) {
        if (p.getPlayerId() == 0)
            continue;
        SpannableString s = new SpannableString(String.valueOf(query.call(p)) + " ");
        s.setSpan(new ForegroundColorSpan(p.getColor()), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sps.append(s);/*from  ww w  .j  a v  a  2  s.c o m*/
    }
    return sps;
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringByFriends(int stringRes, int stringResMulti, ParcelableUser[] sources,
        Object[] targets) {/*w ww . ja v a2s .c o  m*/
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final boolean nameFirst = adapter.isNameFirst();
    final SpannableString firstSourceName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstSourceName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    final String displayName;
    final Object target = targets[0];
    if (target instanceof ParcelableUser) {
        displayName = manager.getDisplayName((ParcelableUser) target, nameFirst, false);
    } else if (target instanceof ParcelableStatus) {
        displayName = manager.getDisplayName((ParcelableStatus) target, nameFirst, false);
    } else {
        throw new IllegalArgumentException();
    }
    final SpannableString firstTargetName = new SpannableString(displayName);
    firstTargetName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstTargetName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, firstTargetName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondSourceName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondSourceName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, secondSourceName,
                firstTargetName);
    } else {
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, nOthers, firstTargetName);
    }
}

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:/*from 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:com.directsiding.android.WebActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_web);

    // Le ponemos la font Signika al titulo del Action Bar
    SpannableString s = new SpannableString(getString(R.string.app_name));
    s.setSpan(new TypefaceSpan(this, LoginActivity.PATH_SIGNIKA_FONT), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Agregamos lo necesario al Action Bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(s);// ww w  .j  a v  a 2s  .  com
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // Obtenemos la url a la que el usuario va a ingresar
    String url = getIntent().getExtras().getString(LoginActivity.EXTRA_URL);

    // Obtenemos la cookie y la agregamos al webview
    Cookie sessionCookie = LoginOpActivity.cookie;
    CookieSyncManager.createInstance(this);
    CookieManager cookieManager = CookieManager.getInstance();
    if (sessionCookie != null) {
        //cookieManager.removeSessionCookie();
        String cookieString = sessionCookie.getName() + "=" + sessionCookie.getValue() + "; domain="
                + sessionCookie.getDomain();
        cookieManager.setCookie(LoginActivity.POST_URL, cookieString);
        CookieSyncManager.getInstance().sync();
    }

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar_webView);
    webView = (WebView) findViewById(R.id.webView_ing);

    webViewConfig();
    webView.loadUrl(url);
    //webView.loadUrl("http://www.google.com");

    // guardamos el tiempo en el que se creo la actividad
    lastTimeStamp = SystemClock.elapsedRealtime();

}

From source file:com.jwetherell.quick_response_code.EncoderActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.btnshare:
        OnClickShare(null);/*from www  .  ja  v a  2s.  co  m*/
        return true;
    case android.R.id.home:
        onBackPressed();
        return true;
    case R.id.empty:
        Statistics.getInstance(EncoderActivity.this).click();
        View menuItemView = findViewById(R.id.empty);
        PopupMenu popupMenu = new PopupMenu(this, menuItemView);
        popupMenu.inflate(R.menu.menu_contextual_wps);
        for (int i = 0; i < popupMenu.getMenu().size(); i++) {
            MenuItem itemMenu = popupMenu.getMenu().getItem(i);
            SpannableString spanString = new SpannableString(
                    popupMenu.getMenu().getItem(i).getTitle().toString());
            spanString.setSpan(new ForegroundColorSpan(Color.BLACK), 0, spanString.length(), 0);
            itemMenu.setTitle(spanString);
        }
        popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                Statistics.getInstance(EncoderActivity.this).click();
                // TODO Auto-generated method stub
                switch (item.getItemId()) {
                case R.id.wps:
                    Statistics.getInstance(EncoderActivity.this).sendStatistics(TAGS.TAG_31);
                    Intent mIntent = new Intent(EncoderActivity.this, AVActivateWpsActivity.class);
                    mIntent.putExtra("is_5ghz", getIntent().getBooleanExtra("is_5ghz", false));
                    startActivity(mIntent);
                    break;

                default:
                    break;
                }

                return false;
            }
        });
        popupMenu.show();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.pax.pay.trans.action.activity.InputTransData2Activity.java

private void setEditText_date(EditText editText) {
    SpannableString ss = new SpannableString(getString(R.string.prompt_date_default2));
    AbsoluteSizeSpan ass = new AbsoluteSizeSpan(getResources().getDimensionPixelOffset(R.dimen.font_size_large),
            false);/*from w w  w .  j a va  2 s  . c  o  m*/
    ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    editText.setHint(new SpannedString(ss)); // ??,?
    editText.setHintTextColor(getResources().getColor(R.color.textEdit_hint));
    editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) });
}