Android Open Source - saldo Saldo Http Client






From Project

Back to project page saldo.

License

The source code is released under:

GNU General Public License

If you think the Android project saldo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.adrup.saldo;
//from  www.ja v  a 2  s .c  o m
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;

import android.content.Context;
import android.os.Build;

import java.util.Locale;

public class SaldoHttpClient extends DefaultHttpClient {
  private Context mContext;
  private static String mUserAgent;
  private static Locale sLocale;
  private static Object sLockForLocaleSettings;

  public SaldoHttpClient(Context context) {
    this(context, null, null);
  }

  public SaldoHttpClient(Context context, HttpParams params) {
    this(context, null, params);
  }

  public SaldoHttpClient(Context context, ClientConnectionManager conman, HttpParams params) {
    super(conman, params);
    mContext = context;
    if (sLockForLocaleSettings == null) {
      sLockForLocaleSettings = new Object();
      sLocale = Locale.getDefault();
    }
    mUserAgent = getCurrentUserAgent();
    getParams().setParameter(HttpProtocolParams.USER_AGENT, mUserAgent);
  }

  /**
   * Looks at sLocale and mContext and returns current UserAgent String.
   * 
   * @return Current UserAgent String.
   */
  private synchronized String getCurrentUserAgent() {
    Locale locale;
    synchronized (sLockForLocaleSettings) {
      locale = sLocale;
    }
    StringBuffer buffer = new StringBuffer();
    // Add version
    final String version = Build.VERSION.RELEASE;
    if (version.length() > 0) {
      buffer.append(version);
    } else {
      // default to "1.0"
      buffer.append("1.0");
    }
    buffer.append("; ");
    final String language = locale.getLanguage();
    if (language != null) {
      buffer.append(language.toLowerCase());
      final String country = locale.getCountry();
      if (country != null) {
        buffer.append("-");
        buffer.append(country.toLowerCase());
      }
    } else {
      // default to "en"
      buffer.append("en");
    }

    final String model = Build.MODEL;
    if (model.length() > 0) {
      buffer.append("; ");
      buffer.append(model);
    }
    final String id = Build.ID;
    if (id.length() > 0) {
      buffer.append(" Build/");
      buffer.append(id);
    }
    final String base = mContext.getResources().getText(R.string.web_user_agent).toString();
    return String.format(base, Saldo.getVersionName(mContext), buffer);
  }

}




Java Source Code List

com.adrup.http.EasySSLSocketFactory.java
com.adrup.http.EasyX509TrustManager.java
com.adrup.http.HttpException.java
com.adrup.http.HttpHelper.java
com.adrup.saldo.AccountsViewBinder.java
com.adrup.saldo.AutoUpdateReceiver.java
com.adrup.saldo.AutoUpdateService.java
com.adrup.saldo.BankListActivity.java
com.adrup.saldo.BankLoginEditActivity.java
com.adrup.saldo.Constants.java
com.adrup.saldo.DatabaseAdapter.java
com.adrup.saldo.SaldoHttpClient.java
com.adrup.saldo.Saldo.java
com.adrup.saldo.SettingsActivity.java
com.adrup.saldo.Util.java
com.adrup.saldo.bank.AccountHashKey.java
com.adrup.saldo.bank.Account.java
com.adrup.saldo.bank.AuthenticationException.java
com.adrup.saldo.bank.BankException.java
com.adrup.saldo.bank.BankLogin.java
com.adrup.saldo.bank.BankManagerFactory.java
com.adrup.saldo.bank.BankManager.java
com.adrup.saldo.bank.RemoteAccount.java
com.adrup.saldo.bank.coop.CoopException.java
com.adrup.saldo.bank.coop.CoopManager.java
com.adrup.saldo.bank.firstcard.FirstcardException.java
com.adrup.saldo.bank.firstcard.FirstcardManager.java
com.adrup.saldo.bank.ica.IcaException.java
com.adrup.saldo.bank.ica.IcaManager.java
com.adrup.saldo.bank.icabanken.IcabankenException.java
com.adrup.saldo.bank.icabanken.IcabankenManager.java
com.adrup.saldo.bank.lf.LfBankException.java
com.adrup.saldo.bank.lf.LfBankManager.java
com.adrup.saldo.bank.nordea.NordeaException.java
com.adrup.saldo.bank.nordea.NordeaManager.java
com.adrup.saldo.bank.preem.PreemException.java
com.adrup.saldo.bank.preem.PreemManager.java
com.adrup.saldo.bank.statoil.StatoilException.java
com.adrup.saldo.bank.statoil.StatoilManager.java
com.adrup.saldo.bank.swedbank.SwedbankException.java
com.adrup.saldo.bank.swedbank.SwedbankManager.java
com.adrup.saldo.widget.SaldoWidgetProvider.java
com.adrup.saldo.widget.WidgetConfigurationActivity.java
com.adrup.saldo.widget.WidgetService.java
com.adrup.util.HashCodeUtil.java
com.adrup.util.NumberUtil.java
com.adrup.util.SectionedAdapter.java