Example usage for android.text Html fromHtml

List of usage examples for android.text Html fromHtml

Introduction

In this page you can find the example usage for android.text Html fromHtml.

Prototype

@Deprecated
public static Spanned fromHtml(String source) 

Source Link

Document

Returns displayable styled text from the provided HTML string with the legacy flags #FROM_HTML_MODE_LEGACY .

Usage

From source file:org.thomnichols.android.gmarks.WebViewLoginActivity.java

protected void showAuthenticatorMissingDialog() {
    new AlertDialog.Builder(this).setTitle(R.string.two_factor_auth_dlg_title)
            .setMessage(Html.fromHtml(getString(R.string.two_factor_not_installed_dlg_msg)))
            .setCancelable(false).setPositiveButton(R.string.btn_download, new OnClickListener() {
                public void onClick(DialogInterface dialog, int _) {
                    final Intent marketActivity = new Intent(Intent.ACTION_VIEW, MARKET_URI);
                    if (getPackageManager().resolveActivity(marketActivity, 0) == null)
                        marketActivity.setData(MARKET_WEB_URI);
                    try {
                        startActivity(marketActivity);
                    } catch (Exception ex) {
                        Log.w(TAG, "Couldn't open Android Market for Authenticator app!!");
                    }/*from  w  w  w .  j  av a2  s  . c om*/
                }
            }).setNegativeButton(getString(R.string.btn_cancel), new OnClickListener() {
                public void onClick(DialogInterface dlg, int _) {
                    dlg.dismiss();
                }
            }).show();
}

From source file:com.liato.bankdroid.banking.banks.Osuuspankki.java

@Override
public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException {
    super.updateTransactions(account, urlopen);

    Matcher matcher;/*w  w w.  j a  v a 2 s  .  c  o m*/
    try {
        response = urlopen.open(String.format("https://www.op.fi/?id=%s&tilinro=%s&ecb=1&srcpl=4",
                (account.getType() == Account.OTHER ? "12701" : "12401"), account.getId()));
        matcher = reTransactions.matcher(response);
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                    EXAMPLE DATA
             * 1: Book. date            21.01
             * 2: Trans. date           20.01
             * 3: Description           ITUNES-EURO LUXEMBOURG
             * 4: Transaction type      BANKKORTSBET.
             * 5: Amount in EUR         -3,99 
             * 
             */
            String[] date = Html.fromHtml(matcher.group(2)).toString().trim().split(".");
            Transaction transaction = new Transaction(Helpers.getTransactionDate(date[1], date[0]),
                    Html.fromHtml(matcher.group(3)).toString().trim(), Helpers.parseBalance(matcher.group(5)));
            transaction.setCurrency(account.getCurrency());
            transactions.add(transaction);
        }
        account.setTransactions(transactions);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.liato.bankdroid.banking.banks.BrummerKF.java

@Override
public void update() throws BankException, LoginException, BankChoiceException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }//from   ww  w  . j a v a2  s. c  o m

    urlopen = login();
    Matcher matcher;
    try {
        response = urlopen.open("https://www.brummer.se/sv/online/privat/");
        matcher = reAccounts.matcher(response);

        while (matcher.find()) {
            /*
             * 1: Kontonamn
             * 2: Kontonummer
             * 3: Avkastning under ret
             * 4: Genomsnittlig rlig avkastning sedan start
             * 5: Avkastning sedan start
             * 6: Marknadsvrde (kronor)
             */

            accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim(),
                    Helpers.parseBalance(matcher.group(6).trim()), matcher.group(2)));

            balance = balance.add(Helpers.parseBalance(matcher.group(6)));
        }
        if (accounts.isEmpty()) {
            throw new BankException(res.getText(R.string.no_accounts_found).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
}

From source file:com.liato.bankdroid.banking.banks.IkanoBank.java

@Override
public void update() throws BankException, LoginException, BankChoiceException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }/*from   www .j a va2s.  com*/

    urlopen = login();
    Matcher matcher = reAccounts.matcher(response);
    while (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                    EXAMPLE DATA
         * 1: ID                    ctl07_rptAccountList_ctl00_RowLink
         * 2: Name                  Kontonamn1
         * 3: Account number        123456
         * 4: Balance               316 000,39
         * 
         */
        accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                Helpers.parseBalance(matcher.group(4).trim()), matcher.group(1).trim()));
        balance = balance.add(Helpers.parseBalance(matcher.group(4)));
    }

    if (accounts.isEmpty()) {
        throw new BankException(res.getText(R.string.no_accounts_found).toString());
    }
    super.updateComplete();
}

From source file:com.liato.bankdroid.banking.banks.Lansforsakringar.java

public Urllib login() throws LoginException, BankException {
    try {/*from  w  w w .ja va 2  s  .c  o  m*/
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("Felaktig inloggning")) {
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }

        Matcher matcher = reToken.matcher(response);
        if (!matcher.find()) {
            throw new BankException(res.getText(R.string.unable_to_find).toString() + " token.");
        }
        mRequestToken = matcher.group(1);

        matcher = reUrl.matcher(response);
        if (!matcher.find()) {
            throw new BankException(res.getText(R.string.unable_to_find).toString() + " accounts url.");
        }

        host = urlopen.getCurrentURI().split("/")[2];
        accountsUrl = Html.fromHtml(matcher.group(1)).toString() + "&_token=" + mRequestToken;
        if (!accountsUrl.contains("https://")) {
            accountsUrl = "https://" + host + accountsUrl;
        }

    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:net.olejon.mdapp.DiseasesAndTreatmentsSearchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Connected?
    if (!mTools.isDeviceConnected()) {
        mTools.showToast(getString(R.string.device_not_connected), 1);

        finish();//from w w  w . j  a v a 2 s.c om

        return;
    }

    // Intent
    final Intent intent = getIntent();

    mSearchLanguage = intent.getStringExtra("language");

    final String searchString = intent.getStringExtra("string");

    // Layout
    setContentView(R.layout.activity_diseases_and_treatments_search);

    // Toolbar
    mToolbar = (Toolbar) findViewById(R.id.diseases_and_treatments_search_toolbar);
    mToolbar.setTitle(getString(R.string.diseases_and_treatments_search_search) + ": \"" + searchString + "\"");

    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Progress bar
    mProgressBar = (ProgressBar) findViewById(R.id.diseases_and_treatments_search_toolbar_progressbar);
    mProgressBar.setVisibility(View.VISIBLE);

    // Spinner
    mSpinner = (Spinner) findViewById(R.id.diseases_and_treatments_search_spinner);

    ArrayAdapter<CharSequence> arrayAdapter;

    if (mSearchLanguage.equals("")) {
        arrayAdapter = ArrayAdapter.createFromResource(mContext,
                R.array.diseases_and_treatments_search_spinner_items_english,
                R.layout.activity_diseases_and_treatments_search_spinner_header);
    } else {
        arrayAdapter = ArrayAdapter.createFromResource(mContext,
                R.array.diseases_and_treatments_search_spinner_items_norwegian,
                R.layout.activity_diseases_and_treatments_search_spinner_header);
    }

    arrayAdapter.setDropDownViewResource(R.layout.activity_diseases_and_treatments_search_spinner_item);

    mSpinner.setAdapter(arrayAdapter);
    mSpinner.setOnItemSelectedListener(this);

    // Refresh
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(
            R.id.diseases_and_treatments_search_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.accent_blue, R.color.accent_green,
            R.color.accent_purple, R.color.accent_orange);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            search(mSearchLanguage, searchString, false);
        }
    });

    // Recycler view
    mRecyclerView = (RecyclerView) findViewById(R.id.diseases_and_treatments_search_cards);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setAdapter(new DiseasesAndTreatmentsSearchAdapter(mContext, new JSONArray(), ""));
    mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));

    // Search
    search(mSearchLanguage, searchString, true);

    // Correct
    RequestQueue requestQueue = Volley.newRequestQueue(mContext);

    try {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
                getString(R.string.project_website_uri) + "api/1/correct/?search="
                        + URLEncoder.encode(searchString, "utf-8"),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        try {
                            final String correctSearchString = response.getString("correct");

                            if (!correctSearchString.equals("")) {
                                new MaterialDialog.Builder(mContext)
                                        .title(getString(R.string.correct_dialog_title))
                                        .content(Html.fromHtml(getString(R.string.correct_dialog_message)
                                                + ":<br><br><b>" + correctSearchString + "</b>"))
                                        .positiveText(getString(R.string.correct_dialog_positive_button))
                                        .negativeText(getString(R.string.correct_dialog_negative_button))
                                        .callback(new MaterialDialog.ButtonCallback() {
                                            @Override
                                            public void onPositive(MaterialDialog dialog) {
                                                ContentValues contentValues = new ContentValues();
                                                contentValues.put(
                                                        DiseasesAndTreatmentsSQLiteHelper.COLUMN_STRING,
                                                        correctSearchString);

                                                SQLiteDatabase sqLiteDatabase = new DiseasesAndTreatmentsSQLiteHelper(
                                                        mContext).getWritableDatabase();

                                                sqLiteDatabase.delete(DiseasesAndTreatmentsSQLiteHelper.TABLE,
                                                        DiseasesAndTreatmentsSQLiteHelper.COLUMN_STRING + " = "
                                                                + mTools.sqe(searchString) + " COLLATE NOCASE",
                                                        null);
                                                sqLiteDatabase.insert(DiseasesAndTreatmentsSQLiteHelper.TABLE,
                                                        null, contentValues);

                                                sqLiteDatabase.close();

                                                mToolbar.setTitle(getString(
                                                        R.string.diseases_and_treatments_search_search) + ": \""
                                                        + correctSearchString + "\"");

                                                mProgressBar.setVisibility(View.VISIBLE);

                                                search(mSearchLanguage, correctSearchString, true);
                                            }
                                        }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue)
                                        .negativeColorRes(R.color.black).show();
                            }
                        } catch (Exception e) {
                            Log.e("DiseasesAndTreatments", Log.getStackTraceString(e));
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.e("DiseasesAndTreatments", error.toString());
                    }
                });

        jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        requestQueue.add(jsonObjectRequest);
    } catch (Exception e) {
        Log.e("DiseasesAndTreatments", Log.getStackTraceString(e));
    }
}

From source file:com.blogspot.marioboehmer.thingibrowse.fragments.ThingDetailsFragment.java

private void showDescription(String description) {
    if (TextUtils.isEmpty(description)) {
        thingDescription.setVisibility(View.GONE);
        thingDescriptionLabel.setVisibility(View.GONE);
    } else {//w w  w. j  a  va2 s  .  c om
        thingDescription.setText(Html.fromHtml(description.replaceAll("\n", "<br />")));
        thingDescription.setVisibility(View.VISIBLE);
        thingDescriptionLabel.setVisibility(View.VISIBLE);
    }
}

From source file:com.liato.bankdroid.banking.banks.Handelsbanken.java

public void updateTransactions(Account account, Urllib urlopen) throws LoginException, BankException {
    super.updateTransactions(account, urlopen);
    Matcher matcher;//from  ww w  . j av  a  2 s  .c  om
    try {
        String accountWebId = accountIds.get(Integer.parseInt(account.getId()));
        response = urlopen.open("https://m.handelsbanken.se/primary/_-" + accountWebId);
        matcher = reTransactions.matcher(response);
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        while (matcher.find()) {
            transactions.add(new Transaction(matcher.group(1).trim(),
                    Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3))));
        }

        // Sort transactions by date
        Collections.sort(transactions, new Comparator<Transaction>() {
            public int compare(Transaction t1, Transaction t2) {
                return t2.compareTo(t1);
            }
        });

        account.setTransactions(transactions);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.activiti.android.app.fragments.integration.alfresco.AlfrescoIntegrationFragment.java

private void updateUI() {
    hide(R.id.validation_panel);/*from   www . ja  v  a 2  s  .com*/

    // The idea is to get Integration Information and compare them to
    // alfresco account.
    if (checkActivity()) {
        return;
    }

    // Retrieve information from activiti Account
    if (getArguments() != null) {
        accountId = BundleUtils.getLong(getArguments(), ARGUMENT_ACCOUNT_ID);
        activitiAccount = ActivitiAccountManager.getInstance(getActivity()).getByAccountId(accountId);
    }

    // We have alfresco account integration
    // Is Alfresco APP Present ?
    // Is Alfresco Version recent ?
    PackageInfo info = getAlfrescoInfo(getActivity());
    boolean outdated = (info != null && info.versionCode < 40);
    if (info == null || outdated) {
        // Alfresco APP is not present...
        // We request the installation from the play store
        titleTv.setText(
                getString(outdated ? R.string.settings_alfresco_update : R.string.settings_alfresco_install));

        summaryTv.setText(Html.fromHtml(getString(outdated ? R.string.settings_alfresco_update_summary
                : R.string.settings_alfresco_install_summary)));

        actionButton.setText(getString(outdated ? R.string.settings_alfresco_update_action
                : R.string.settings_alfresco_install_action));
        actionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startPlayStore();
            }
        });

        hide(R.id.validation_panel);

        return;
    }

    // Alfresco APP is present
    actionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            selectedAccount = null;
            launchAccountSelect();
        }
    });

    // Retrieve Alfresco Account
    Account[] accounts = AccountManager.get(getActivity())
            .getAccountsByType(AlfrescoIntegrator.ALFRESCO_ACCOUNT_TYPE);
    if (accounts.length == 0 && selectedAccount == null) {
        // Need to create an alfresco account!
        titleTv.setText(getString(R.string.settings_alfresco_not_found));
        summaryTv.setText(Html.fromHtml(getString(R.string.settings_alfresco_not_found_summary)));
        actionButton.setText(getString(R.string.settings_alfresco_not_found_action));
        /*
         * actionButton.setOnClickListener(new View.OnClickListener() {
         * @Override public void onClick(View v) { selectedAccount = null;
         * Intent i = AlfrescoIntegrator.createAccount(getActivity(),
         * selectedIntegration.getRepositoryUrl(),
         * activitiAccount.getUsername()); startActivityForResult(i, 10); }
         * });
         */

        return;
    }

    // An activitiAccount match if username == username
    for (int i = 0; i < accounts.length; i++) {
        String username = AccountManager.get(getActivity()).getUserData(accounts[i],
                BuildConfig.ALFRESCO_ACCOUNT_ID.concat(".username"));

        if (activitiAccount.getUsername().equals(username)) {
            // Lets compare hostname
            String alfUrl = AccountManager.get(getActivity()).getUserData(accounts[i],
                    BuildConfig.ALFRESCO_ACCOUNT_ID.concat(".url"));
            Uri alfUri = Uri.parse(alfUrl);
            Uri activitiUri = Uri.parse(selectedIntegration.getRepositoryUrl());

            if (alfUri != null && activitiUri != null && alfUri.getHost().equals(activitiUri.getHost())) {
                // We found one !
                selectedAccount = accounts[i];
                break;
            }
        }
    }

    // Have found ?
    if (selectedAccount != null) {
        alfrescoId = AccountManager.get(getActivity()).getUserData(selectedAccount,
                BuildConfig.ALFRESCO_ACCOUNT_ID.concat(".id"));
        alfrescoUsername = AccountManager.get(getActivity()).getUserData(selectedAccount,
                BuildConfig.ALFRESCO_ACCOUNT_ID.concat(".username"));
        alfrescoAccountName = AccountManager.get(getActivity()).getUserData(selectedAccount,
                BuildConfig.ALFRESCO_ACCOUNT_ID.concat(".name"));

        titleTv.setText(getString(R.string.settings_alfresco_account_found));

        summaryTv.setText(
                Html.fromHtml(String.format(getString(R.string.settings_alfresco_account_found_summary),
                        alfrescoAccountName, alfrescoUsername)));

        actionButton.setText(getString(R.string.settings_alfresco_account_found_action));

        show(R.id.validation_panel);
        Button validate = UIUtils.initValidation(getRootView(), R.string.general_action_confirm);
        validate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                saveIntegration();
            }
        });
        Button cancel = UIUtils.initCancel(getRootView(), R.string.general_action_cancel);
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().onBackPressed();
            }
        });
    } else {
        titleTv.setText(getString(R.string.settings_alfresco_account_found));
        summaryTv.setText(Html.fromHtml(getString(R.string.settings_alfresco_not_found_summary)));
        actionButton.setText(getString(R.string.settings_alfresco_not_found_action));

        hide(R.id.validation_panel);
    }
}

From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountPreferences.java

/**
 * Called when the button "Set Facebook privacy" is clicked. Opens an AlertDialog where the user selects a privacy setting.
 * @param view/*w  ww .j  a v  a 2  s  .c o  m*/
 */
public void btnFacebookClicked(View view) {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Set Privacy");
    builder.setSingleChoiceItems(R.array.privacy_setting, selectedPrivacy,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    selectedPrivacy = item;
                }
            });
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            switch (selectedPrivacy) {
            case 0:
                privacyPreference = Visibility.FRIENDS;
                facebookPrivacy = "Friends";
                break;
            case 1:
                privacyPreference = Visibility.FRIENDS_OF_FRIENDS;
                facebookPrivacy = "Friends of friends";
                break;
            case 2:
                privacyPreference = Visibility.PUBLIC;
                facebookPrivacy = "Public";
                break;
            default:
                break;
            }
            // Setting button text
            btnFacebook.setText(Html.fromHtml("<b align = left><big>" + "Set Facebook privacy" + "</big></b>"
                    + "<br />" + facebookPrivacy + "<br />"));

            // Writing data to SharedPreferences
            getApp().getSettings().setFacebookPrivacy(privacyPreference);
        }
    });
    builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();

}