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:com.liato.bankdroid.banking.banks.BrummerKF.java

public Urllib login() throws LoginException, BankException {
    try {/*from  w  ww  . j a  va  2s  . c  o  m*/
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());

        Matcher matcher = reError.matcher(response);
        if (matcher.find()) {
            String errormsg = Html.fromHtml(matcher.group(1).trim()).toString();
            if (errormsg.contains("Personnummer")) {
                throw new LoginException(errormsg);
            } else {
                throw new BankException(errormsg);
            }
        }
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

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

public Urllib login() throws LoginException, BankException {
    try {//www  .  j a va2s .  c  o m
        LoginPackage lp = preLogin();
        String response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        Matcher matcher = reError.matcher(response);
        if (matcher.find()) {
            String errormsg = Html.fromHtml(matcher.group(1).trim()).toString();
            if (errormsg.contains("ord eller personnummer") || errormsg.contains("et alternativ")
                    || errormsg.contains("fyra siffror")) {
                throw new LoginException(errormsg);
            } else {
                throw new BankException(errormsg);
            }
        }
    } catch (ClientProtocolException e) {
        Log.e(TAG, "ClientProtocolException: " + e.getMessage());
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "IOException: " + e.getMessage());
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:de.geeksfactory.opacclient.frontend.ResultsAdapter.java

@Override
public View getView(int position, View contentView, ViewGroup viewGroup) {
    View view;// w  w w.  ja  v a2 s.c o  m

    // position always 0-7
    if (objects.get(position) == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
        return view;
    }

    SearchResult item = objects.get(position);

    if (contentView == null) {
        LayoutInflater layoutInflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = layoutInflater.inflate(R.layout.listitem_searchresult, viewGroup, false);
    } else {
        view = contentView;
    }

    TextView tv = (TextView) view.findViewById(R.id.tvResult);
    tv.setText(Html.fromHtml(item.getInnerhtml()));

    ImageView ivType = (ImageView) view.findViewById(R.id.ivType);

    PreferenceDataSource pds = new PreferenceDataSource(getContext());
    ConnectivityManager connMgr = (ConnectivityManager) getContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    if (item.getCoverBitmap() != null) {
        ivType.setImageBitmap(BitmapUtils.bitmapFromBytes(item.getCoverBitmap()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if ((pds.isLoadCoversOnDataPreferenceSet()
            || !ConnectivityManagerCompat.isActiveNetworkMetered(connMgr)) && item.getCover() != null) {
        LoadCoverTask lct = new LoadCoverTask(ivType, item);
        lct.execute();
        ivType.setImageResource(R.drawable.ic_loading);
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(0, 0, 0, 0);
    } else if (item.getType() != null && item.getType() != MediaType.NONE) {
        ivType.setImageResource(getResourceByMediaType(item.getType()));
        ivType.setVisibility(View.VISIBLE);
        ivType.setPadding(padding8dp, padding8dp, padding8dp, padding8dp);
    } else {
        ivType.setVisibility(View.INVISIBLE);
    }
    ImageView ivStatus = (ImageView) view.findViewById(R.id.ivStatus);

    if (item.getStatus() != null) {
        ivStatus.setVisibility(View.VISIBLE);
        switch (item.getStatus()) {
        case GREEN:
            ivStatus.setImageResource(R.drawable.status_light_green_check);
            break;
        case RED:
            ivStatus.setImageResource(R.drawable.status_light_red_cross);
            break;
        case YELLOW:
            ivStatus.setImageResource(R.drawable.status_light_yellow_alert);
            break;
        case UNKNOWN:
            ivStatus.setVisibility(View.INVISIBLE);
            break;
        }
    } else {
        ivStatus.setVisibility(View.GONE);
    }

    return view;
}

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

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

    //No transaction history for loans, funds and credit cards.
    int accType = account.getType();
    if (accType == Account.LOANS || accType == Account.FUNDS || accType == Account.CCARD)
        return;//w w  w.  j  a v  a  2  s  .  c o  m

    String response = null;
    Matcher matcher;
    try {
        response = urlopen.open(
                "http://www.nullbyte.eu/bankdroid/tests/testbank/transactions_" + account.getId() + ".htm");
        matcher = reTransactions.matcher(response);
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        while (matcher.find()) {
            transactions.add(new Transaction(Html.fromHtml(matcher.group(1)).toString().trim(),
                    Html.fromHtml(matcher.group(2)).toString().trim(), Helpers.parseBalance(matcher.group(3))));
        }
        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.MobilbankenBase.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());
    }/*  w  w  w . jav a 2  s  .  co  m*/

    urlopen = login();
    Matcher matcher = reAccounts.matcher(response);
    while (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                EXAMPLE DATA
         * 1: ID                ?
         * 2: Name              Sparkonto
         * 3: Account number    9570 012.345.678-9 SEK
         * 4: ?                 xxxxxxxxxxx
         * 5: Amount            ?
         *   
         */
        accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                Helpers.parseBalance(matcher.group(5)), matcher.group(1).trim()));
        balance = balance.add(Helpers.parseBalance(matcher.group(5)));
    }

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

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

/**
 * Initializes the preferences from the {@link PreferenceResonse} retrieved from the database.
 * @param res//w ww . j  a v a 2  s  .co  m
 */
public void initPreferences(PreferenceResponse res) {
    setContentView(R.layout.my_account_preferences);

    // Get default privacy value from user preferences
    privacyPreference = getApp().getSettings().getFacebookPrivacy();
    if (privacyPreference == Visibility.FRIENDS) {
        selectedPrivacy = 0;
        facebookPrivacy = "Friends";
    }
    if (privacyPreference == Visibility.FRIENDS_OF_FRIENDS) {
        selectedPrivacy = 1;
        facebookPrivacy = "Friends of friends";
    }
    if (privacyPreference == Visibility.PUBLIC) {
        selectedPrivacy = 2;
        facebookPrivacy = "Public";
    }

    listPreferences = (ListView) findViewById(R.id.listPreferences);
    btnFacebook = (Button) findViewById(R.id.preferencesFacebookButton);

    /**Preferences fetched from the strigs.xml*/
    String[] preferences = getResources().getStringArray(R.array.preferences_array);
    prefAdap = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, preferences);
    listPreferences.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    listPreferences.setAdapter(prefAdap);
    prefAdap.notifyDataSetChanged();

    selectedItems = new ArrayList<String>();
    checked = listPreferences.getCheckedItemPositions();
    pref2 = res.getPreferences();

    /**Fetch preferences from the database and display them*/
    for (int i = 0; i < 5; i++) {
        switch (i) {
        case 0:
            if (pref2.getMusic()) {
                listPreferences.setItemChecked(i, true);
            }
            break;
        case 1:
            if (pref2.getAnimals()) {
                listPreferences.setItemChecked(i, true);
            }
            break;
        case 2:
            if (pref2.getBreaks()) {
                listPreferences.setItemChecked(i, true);
            }
            break;
        case 3:
            if (pref2.getTalking()) {
                listPreferences.setItemChecked(i, true);
            }
            break;
        case 4:
            if (pref2.getSmoking()) {
                listPreferences.setItemChecked(i, true);
            }
            break;
        }
    }
    prefAdap.notifyDataSetChanged();

    listPreferences.addFooterView(btnFacebook);
    // Setting the Facebook privacy button
    btnFacebook.setText(Html.fromHtml("<b>" + "Set Facebook privacy" + "</b>" + "<br />" + "<small>"
            + facebookPrivacy + "</small>" + "<br />"));

    // Indicating that the preferences are initialized
    isPrefInitialized = true;
}

From source file:app.hacked.ProjectDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.project_detail_fragment, container, false);

    ((TextView) rootView.findViewById(R.id.Title)).setText(Name);
    ((TextView) rootView.findViewById(R.id.Title))
            .setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));

    /*((TextView) rootView.findViewById(R.id.TeamMembers)).setText(TeamMembers);
    ((TextView) rootView.findViewById(R.id.TeamMembers)).setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));*/

    ((TextView) rootView.findViewById(R.id.Tech)).setText(Technologies);
    ((TextView) rootView.findViewById(R.id.Tech))
            .setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL));

    ((TextView) rootView.findViewById(R.id.Description)).setText(Html.fromHtml(Description));
    ((TextView) rootView.findViewById(R.id.Description))
            .setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));

    ((Button) rootView.findViewById(R.id.VoteUp)).setOnClickListener(new View.OnClickListener() {
        @Override//from   w ww.  j  a va 2  s . c o m
        public void onClick(View view) {
            doVote(true);
        }
    });

    ((Button) rootView.findViewById(R.id.VoteDown)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            doVote(false);
        }
    });

    ((Button) rootView.findViewById(R.id.EditProject)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://www.hackerleague.org/hackathons/hacked/hacks")));
        }
    });

    return rootView;
}

From source file:com.adrup.saldo.bank.ica.IcaManager.java

@Override
public Map<AccountHashKey, RemoteAccount> getAccounts(Map<AccountHashKey, RemoteAccount> accounts)
        throws BankException {
    Log.d(TAG, "getAccounts()");

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    // Android doesn't like ICA's cert, so we need a forgiving TrustManager
    schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
    HttpParams params = new BasicHttpParams();
    HttpClient httpClient = new SaldoHttpClient(mContext,
            new ThreadSafeClientConnManager(params, schemeRegistry), null);

    try {/*w  ww  .j  a v  a 2 s. c o m*/
        // get login page

        Log.d(TAG, "getting login page");

        String res = HttpHelper.get(httpClient, LOGIN_URL);

        Matcher matcher = Pattern.compile(VIEWSTATE_REGEX).matcher(res);
        if (!matcher.find()) {
            Log.e(TAG, "No viewstate match.");
            Log.d(TAG, res);
            throw new IcaException("No viewState match.");
        }
        String viewState = matcher.group(1);
        Log.d(TAG, "viewState= " + viewState);

        // do login post, should redirect us to the accounts page
        List<NameValuePair> parameters = new ArrayList<NameValuePair>(3);

        parameters.add(new BasicNameValuePair(VIEWSTATE_PARAM, viewState));
        parameters.add(new BasicNameValuePair(USER_PARAM, mBankLogin.getUsername()));
        parameters.add(new BasicNameValuePair(PASS_PARAM, mBankLogin.getPassword()));
        parameters.add(new BasicNameValuePair(BUTTON_PARAM, "Logga in"));

        res = HttpHelper.post(httpClient, LOGIN_URL, parameters);

        if (res.contains("login-error")) {
            Log.d(TAG, "auth fail");
            throw new AuthenticationException("auth fail");
        }

        // extract account info
        matcher = Pattern.compile(ACCOUNTS_REGEX).matcher(res);

        int remoteId = 1;
        int count = 0;
        while (matcher.find()) {
            count++;
            int groupCount = matcher.groupCount();
            for (int i = 1; i <= groupCount; i++) {
                Log.d(TAG, i + ":" + matcher.group(i));
            }
            if (groupCount < 2) {
                throw new BankException("Pattern match issue: groupCount < 2");
            }

            int ordinal = remoteId;
            String name = Html.fromHtml(matcher.group(1)).toString();
            long balance = Long.parseLong(matcher.group(2).replaceAll("\\,|\\.| ", "")) / 100;
            accounts.put(new AccountHashKey(String.valueOf(remoteId), mBankLogin.getId()),
                    new Account(String.valueOf(remoteId), mBankLogin.getId(), ordinal, name, balance));
            remoteId++;
        }
        if (count == 0) {
            Log.d(TAG, "no accounts added");
            Log.d(TAG, res);
        }
    } catch (IOException e) {
        Log.e(TAG, e.getMessage(), e);
        throw new IcaException(e.getMessage(), e);
    } catch (HttpException e) {
        Log.e(TAG, e.getMessage(), e);
        throw new IcaException(e.getMessage(), e);
    } finally {
        httpClient.getConnectionManager().shutdown();
    }

    return accounts;
}

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

@Override
public void update() throws BankException, LoginException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }/* w  w w  .  java2  s.com*/
    urlopen = login();
    Matcher matcher = reAccounts.matcher(response);
    Integer accountId = 0;
    while (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                     EXAMPLE DATA           NOTES
         * 1: account number         **** **** **** 1234
         * 2: id                     a1c2d3d4e5f6s7b8c9d0   Changes when session expires
         * 3: ofakturerat amount     &nbsp;2 988,96
         * 
         */

        // Create a separate account for "Ofakturerat".
        // Set the balance for the main account to 0 and update it later
        accounts.add(new Account(Html.fromHtml(matcher.group(1)).toString().trim(), new BigDecimal(0),
                accountId.toString()));
        accounts.add(new Account(" " + "Ofakturerat", Helpers.parseBalance(matcher.group(3)),
                "o:ofak:" + accountId.toString(), Account.OTHER));
        accountIds.add(matcher.group(2).trim());
        accountId += 1;
    }

    try {
        response = urlopen.open("https://e-saldo.eurocard.se/nis/ecse/getBillingUnits.do");
        matcher = reSaldo.matcher(response);
        int i = 0;
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                     EXAMPLE DATA
             * 1: balance                &nbsp;40 988,96
             * 
             */

            // Update the main account balance
            if (accounts.size() >= i * 2 + 1) {
                accounts.get(i * 2).setBalance(Helpers.parseBalance(matcher.group(1)));
            }
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

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

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

@Override
public void update() throws BankException, LoginException {
    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  w ww  .  j a va  2s  . c  o  m
    urlopen = login();
    String response = null;
    Matcher matcher;
    try {

        Log.d("BankNordea", "Opening: https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html");
        response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html");

        matcher = reAccounts.matcher(response);
        while (matcher.find()) {
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), matcher.group(1).trim()));
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        }

        Log.d("BankNordea",
                "Opening: https://mobil.nordea.se/banking-nordea/nordea-c3/funds/portfolio/funds.html");
        response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/funds/portfolio/funds.html");

        matcher = reFundsLoans.matcher(response);
        while (matcher.find()) {
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), "f:" + matcher.group(1).trim(), -1L,
                    Account.FUNDS));
        }

        Log.d("BankNordea", "Opening: https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html?type=lan");
        response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/accounts.html?type=lan");

        matcher = reFundsLoans.matcher(response);
        while (matcher.find()) {
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), "l:" + matcher.group(1).trim(), -1L,
                    Account.LOANS));
        }
        matcher = reCards.matcher(response);
        Log.d(TAG, "Opening: https://mobil.nordea.se/banking-nordea/nordea-c3/card/list.html");
        response = urlopen.open("https://mobil.nordea.se/banking-nordea/nordea-c3/card/list.html");
        while (matcher.find()) {
            accounts.add(new Account(Html.fromHtml(matcher.group(2)).toString().trim(),
                    Helpers.parseBalance(matcher.group(3)), "c:" + matcher.group(1).trim(), -1L,
                    Account.CCARD));
            balance = balance.add(Helpers.parseBalance(matcher.group(3)));
        }

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

        // Konungens konto
        //accounts.add(new Account("Personkonto", Helpers.parseBalance("568268.37"), "1"));
        //accounts.add(new Account("Kapitalkonto", Helpers.parseBalance("5789002.00"), "0"));
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    } finally {
        super.updateComplete();
    }
}